A question about keyFrame animation

Started by Simdanfeg, April 13, 2011, 05:17:34 AM

Previous topic - Next topic

Simdanfeg

Thank you for your help, now I have a new question to ask your advice. I had five balls of different sizes with 3dMax, when I use the frame of animation only shows the first frame, I do not know why, I also searched the forum-related information, but still failed to resolve, the following I Show me the code to stick in here, I hope you can help me.


thing = loadModel("s0.3DS", scale);
Animation anim = new Animation(5);

anim.createSubSequence("default");
anim.addKeyFrame(thing.getMesh());

anim.createSubSequence("change");
anim.addKeyFrame(loadModel("s2.3DS", scale).getMesh());
anim.addKeyFrame(loadModel("s3.3DS", scale).getMesh());
anim.addKeyFrame(loadModel("s4.3DS", scale).getMesh());
anim.addKeyFrame(loadModel("s1.3DS", scale).getMesh());
thing.setAnimationSequence(anim);

thing.build();
world.addObject(thing);




private Object3D loadModel(String fileName, float scale) {
Loader.setVertexOptimization(false);
Object3D[] model = Loader.load3DS(LoadFile.loadf(fileName), scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;

for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float) (Math.PI / 2));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.build();
}
return o3d;
}



public void doAnim() {
{
ind += 0.02f;
if (ind > 1f) {
ind -= 1f;
}
}
thing.animate(ind, an);
}

EgonOlsen


Simdanfeg

'an'  is a variable I declaration, its value is 2,I wrote my program According to The following page http://www.jpct.net/wiki/index.php/Loading_3ds_Keyframes_from_Blender

Simdanfeg

Can be displayed with JPCT, why not display it in the android, which is perplexing problem. ???

EgonOlsen

#4
That's because you are doing this call in loadModel:


o3d.build();


Because at this stage, jPCT-AE can't detect the animation (it's not present yet) and prepares the object to be compiled statically. Try to replace it with:


o3d.calcNormals();

Simdanfeg

EgonOlsen,Very, very grateful to you, it is moving up, how exciting, ;D