this is from a private message, i'm posting it here hoping it may be handy
i originally store each key frame on a seperate 3ds file and each animation sequence in a different folder.
say you have 2 animations: walk and jump. create them in a 3d editor like 3d max, and store necessary keyframes in seperate 3ds files. decide how many keyframes you will use and select them. remember all jpct can do is to interpolate between keyframes. so for walk you need at least these key frames: stand, right foot up, right down and left up, left down and right up, stand again. the file structure will be like:
character/default.3ds
character/walk/frame0.3ds
character/walk/frame1.3ds
character/walk/frame2.3ds
..
character/jump/frame0.3ds
..
then your code to load this animation will be like:
Object3D character = loadDefault3ds();
Animation animation = new Animation(<total number of frames>);
int walkSeq = animation.createSubSequence("walk");
for frames in walk folder {
Object3D o = loadObjectFromFolder(..);
animation.addKeyFrame(o.getMesh());
}
// do same for jump
character.setAnimationSequence(animation);
for this to work vertex optimization should be disabled or else jpct will weld close vertices into a single one and which in turn will break animation sequence: all meshes in an animation sequence should have same number of vertices
Loader.setVertexOptimization(false);
after these you can walk your character around by moving it and animate it at the same time by using
character.translate(Vector)
character.animate(index, walkSeq)
you should calculate index so that walk animation should look continuos.
-- o --
for cloting and weapons as i said before there are 2 distinct methods, texture based and mesh based.
for texture based, simply change texture of your character. i dynamically create cloth texture combinations in karga but that is only an addition. you can just use a couple of textures which were prepared offline
for mesh based, say your character has a weapon in his hand. you should put it into hand of your character in 3dmax and animate it with your character and save
exactly same key frames. so you will have a directory structure like:
weapon/default.3ds
weapon/walk/frame0.3ds
weapon/walk/frame1.3ds
..
weapon/jump/frame0.3ds
..
load it the same way as your character and add it as a child:
character.addChild(weapon);
then, when you animate your character you should animate weapon too. old code now becomes:
character.translate(Vector);
character.animate(index, walkSeq);
weapon.animate(index, walkSeq);
an important point is, you
shouldnt move your weapon as it will move with your character since it's a child of it. when you dont need a weapon just set it unvisible. that will succesfully do the trick
hope this helps
r a f t