Applying VertexController causes the model to dark-out

Started by Darai, October 15, 2016, 11:50:10 AM

Previous topic - Next topic

Darai

Hi,

I have here a strange behaviour you surely know what to do with. It looks so obvious that it must be a mistake on my side. But I am still new in this so I am asking for your help.

I created a simple object and apply to it a vertex controller. (and put lamp and ambient lighting) In the moment I applied the controller, the object get's darker and stays that way. Like the sun does not apply for the object any more. Do you know why and how to fix it? How does it look can be seen in the attached screenshots.

Thank you,
Darai.

The renderer

public void onSurfaceChanged(GL10 gl, int w, int h) {
...
world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

sqr = new MiniMonster3D();

sqr.setTexture("Tex");
sqr.setScale(10f);
sqr.build();

world.addObject(sqr);
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(sqr.getTransformedCenter());

SimpleVector sv = new SimpleVector();
sv.set(sqr.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
MemoryHelper.compact();
...
}

public void onDrawFrame(GL10 gl) {
...
  if (System.currentTimeMillis() - time >= 100) {
    //Logger.log(fps/10 + "fps");
    fps = 0;
    time = System.currentTimeMillis();
    sqr.pulse();
  }
  fps++;
...
}


the Object

public class MiniMonster3D extends Object3D {

public MiniMonster3D(){
super(2);
SimpleVector LU = new SimpleVector(-0.5f, -0.5f, 0f);
SimpleVector LD = new SimpleVector(-0.5f, 0.5f, 0f);
SimpleVector RU = new SimpleVector(0.5f, -0.5f, 0f);
SimpleVector RD = new SimpleVector(0.5f, 0.5f, 0f);
this.addTriangle(LU,0,0,LD,0,1,RD,1,1);
this.addTriangle(LU,0,0,RD,1,1,RU,1,0);
this.getMesh().setVertexController(new MyVertexController(), false);
}

public void pulse(){
this.getMesh().applyVertexController();
this.touch();
}
}


the Controller

public class MyVertexController extends GenericVertexController {
...
@Override
public void apply() {
nextScale();
Log.i("VC", "pulse, scale = "+myscale);
SimpleVector[]out = getDestinationMesh();
SimpleVector[]in  = getSourceMesh();
SimpleVector tgt, src;
for(int i = 0;i<3;i++){
tgt = out[i];
src = in[i];
tgt.x = src.x*myscale;
tgt.y = src.y*myscale;
tgt.z = src.z*myscale;
}
}
...


AeroShark333

Looks fine to me...

Would it help to add this after this.touch() in the pulse method?

this.calcNormals();
this.calcTangentVectors();