Author Topic: A question about keyFrame animation  (Read 1813 times)

Offline Simdanfeg

  • byte
  • *
  • Posts: 41
    • View Profile
A question about keyFrame animation
« 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);
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A question about keyFrame animation
« Reply #1 on: April 13, 2011, 12:13:15 pm »
What's the value for "an"?

Offline Simdanfeg

  • byte
  • *
  • Posts: 41
    • View Profile
Re: A question about keyFrame animation
« Reply #2 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

Offline Simdanfeg

  • byte
  • *
  • Posts: 41
    • View Profile
Re: A question about keyFrame animation
« Reply #3 on: April 13, 2011, 06:27:32 pm »
Can be displayed with JPCT, why not display it in the android, which is perplexing problem. ???

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: A question about keyFrame animation
« Reply #4 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();
« Last Edit: April 14, 2011, 08:02:59 am by EgonOlsen »

Offline Simdanfeg

  • byte
  • *
  • Posts: 41
    • View Profile
Re: A question about keyFrame animation
« Reply #5 on: April 14, 2011, 07:06:41 am »
EgonOlsen,Very, very grateful to you, it is moving up, how exciting, ;D