Animate Model

Started by bigfishcatcher, December 18, 2006, 01:02:42 PM

Previous topic - Next topic

bigfishcatcher

First a big thanks for helping me

I have added mouse movement to the FPS demo and have even added a bullet to the weapon -

I have read a couple of posts about animation of the models so my question is can I

load multiple files of a model say
man01.3ds
man02.3ds
man03.3ds

to animate

Thanks

EgonOlsen

Yes, that can be done. This thread has some info about it: http://www.jpct.net/forum/viewtopic.php?t=667

bigfishcatcher

I tried this code but I can't even find the method

loadDefault3ds

bigfishcatcher

or the method


loadObjectFromFolder

Mizuki Takase

I have no idea if this compiles or work, but that code pretty much holds the idea of what you will need to do to load multiple files and make an animation from it.


//simply merges all of the meshes together
public static Object3D meshMerge(Object3D[] arrayObject3D){
 Object3D resultingObject3D = new Object3D(0);
 
 for(int i=0; i<arrayObject3D.length; i++){
   Object3D tempObject3D = arrayObject3D[i];
   resultingObject3D = Object3D.mergeObjects(resultingObject3D, tempObject3D);
 }
 return resultingObject3D;
}

public void initAnimation(){
 this.animation = new Animation(3);
 this.animation.addKeyFrame(meshMerge(Loader.load3DS("man01.3ds", 1)).getMesh());
 this.animation.addKeyFrame(meshMerge(Loader.load3DS("man02.3ds", 1)).getMesh());
 this.animation.addKeyFrame(meshMerge(Loader.load3DS("man03.3ds", 1)).getMesh());
}


Don't forget to create the main object, set the animation to this.animation, and then play the animation. Here are the following functions to do so:


    new Object3D(Object3D obj)
    Object3D.setAnimationSequence(Animation anim)
    Object3D.animate(float index, int seq)

The loadObjectFromFolder will most likely contain an instance of File so that you can have an idea of what files are inside a particular directory. From there, the function will be loading each Object3D and making that a big animation.