www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Simdanfeg on April 13, 2011, 05:17:34 am

Title: A question about keyFrame animation
Post by: Simdanfeg on April 13, 2011, 05:17:34 am
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.

Code: [Select]
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);


Code: [Select]
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;
}

Code: [Select]
public void doAnim() {
{
ind += 0.02f;
if (ind > 1f) {
ind -= 1f;
}
}
thing.animate(ind, an);
}
Title: Re: A question about keyFrame animation
Post by: EgonOlsen on April 13, 2011, 12:13:15 pm
What's the value for "an"?
Title: Re: A question about keyFrame animation
Post by: Simdanfeg on April 13, 2011, 04:08:51 pm
'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 (http://www.jpct.net/wiki/index.php/Loading_3ds_Keyframes_from_Blender)
Title: Re: A question about keyFrame animation
Post by: Simdanfeg on April 13, 2011, 06:27:32 pm
Can be displayed with JPCT, why not display it in the android, which is perplexing problem. ???
Title: Re: A question about keyFrame animation
Post by: EgonOlsen on April 13, 2011, 10:44:59 pm
That's because you are doing this call in loadModel:

Code: [Select]
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:

Code: [Select]
o3d.calcNormals();
Title: Re: A question about keyFrame animation
Post by: Simdanfeg on April 14, 2011, 07:06:41 am
EgonOlsen,Very, very grateful to you, it is moving up, how exciting, ;D