hi,
I am experimenting Animation with the following code:
private class MyVertexController extends GenericVertexController{
/**
*
*/
private static final long serialVersionUID = 1L;
private float mOff = 0.0f;
public MyVertexController(float off){
mOff = off;
}
@Override
public void apply() {
// TODO Auto-generated method stub
SimpleVector[] src = this.getSourceMesh();
SimpleVector[] dst = this.getDestinationMesh();
Logger.log("src length: "+src.length+" dst length: "+dst.length);
for(int i=0; i<src.length && i<dst.length; i++){
dst[i].x = src[i].x + mOff;
}
}
}
private void setupAnimate(Object3D obj){
obj.build();
Mesh mesh = obj.getMesh();
Object3D obj1 = obj.cloneObject();
Object3D obj2 = obj.cloneObject();
//world.addObject(obj1);
//world.addObject(obj2);
Mesh mesh1 = mesh.cloneMesh(true);
obj1.setMesh(mesh1);
//obj1.rotateX(1.4f);
//obj1.rotateMesh();
obj1.build();
if(mesh1.setVertexController(new MyVertexController(0.0f), true))
Logger.log("vertex controller set for mesh1");
mesh1.applyVertexController();
Mesh mesh2 = mesh.cloneMesh(true);
obj2.setMesh(mesh2);
obj2.build();
if(mesh2.setVertexController(new MyVertexController(10.0f), true))
Logger.log("vertex controller set for mesh2");
mesh2.applyVertexController();
Animation ani = new Animation(2);
ani.createSubSequence("main");
ani.addKeyFrame(mesh1);
ani.addKeyFrame(mesh2);
ani.setInterpolationMethod(Animation.LINEAR);
obj.setAnimationSequence(ani);
obj.setMesh(mesh1.cloneMesh(true));
obj.build();
}
the setupAnimate() would setup animation for my object. in the rendering loop, I call obj.animation(index) to do animation, but the object stay still always. do I doing something wrong in the setup code ? thanks.