Animate character

Started by whis, March 06, 2007, 11:22:25 PM

Previous topic - Next topic

whis

Hello,

I have a problem with the animation in jPCT:

I loaded a file .3ds in an 3dObject (body) and I added it into the world.
Then i loaded 6 file .3ds in 6 3dObject (marche1, marche2,....): they are my 3d sprites.

I also created a new animation with the 3d sprites:

        theWorld.addObject(body);
animation = new Animation(6);
int marcheseq = animation.createSubSequence("marche");
body.build();
marche1.build();
marche2.build();
marche3.build();
marche4.build();
marche5.build();
marche6.build();
animation.addKeyFrame(marche1.getMesh());
animation.addKeyFrame(marche2.getMesh());
animation.addKeyFrame(marche3.getMesh());
animation.addKeyFrame(marche4.getMesh());
animation.addKeyFrame(marche5.getMesh());
animation.addKeyFrame(marche6.getMesh());

body.setAnimationSequence(animation);
 
Loader.setVertexOptimization(false);


To finish I run my animation:

while (!exit)
{

buffer.clear();
theWorld.renderScene(buffer);
theWorld.draw(buffer);
buffer.update();
buffer.display(frameGraphics);
body.animate(x, marcheseq);
if (x>6) {
anim=0;
}
else
{
anim+=1;
}
}
}


My character appears on the screen (body) but the animation don't start(I have no errors), why?
Someone can help me?

Thanks.

EgonOlsen

#1
There seems to be a mixture of "x" and "anim" in your code. Anyway, the animation's index is a float ranging from 0 to 1. In your code, you seem to increment it in steps of 1, which will lead to no animation at all. Try to increase it by 0.1f or something and see if that helps.
Btw: When creating animations out of 3ds files, it makes sense to set http://www.jpct.net/doc/com/threed/jpct/Loader.html#setVertexOptimization(boolean) to false before loading the model.

whis

I'm sorry for the mix of "anim" and "x".
T have try to set this variable at 0 then incremente it by 0.1.
I have also set "setVertexOptimization" to false before loading the 3ds files.

I doesn't work.

The 3d object that emcapsulate the animation have to be empty or not?

EgonOlsen

Quote from: whis on March 07, 2007, 11:16:03 AM
The 3d object that emcapsulate the animation have to be empty or not?
No. It has to be initialized with a mesh of the same kind. For example the first mesh in the series. If it isn't, you should get a warning about it in the console.

whis

Ok thanks, and when i create a keyframe does a message appears in the console (becaus i Have no messages fot it)?

EgonOlsen

Quote from: whis on March 07, 2007, 11:25:31 AM
...and when i create a keyframe does a message appears in the console (becaus i Have no messages fot it)?
No, it doesn't. That's an operation like any other...no extra message for this one.