www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: bigfishcatcher on December 18, 2006, 01:02:42 pm

Title: Animate Model
Post by: bigfishcatcher on December 18, 2006, 01:02:42 pm
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
Title: Animate Model
Post by: EgonOlsen on December 20, 2006, 12:40:16 am
Yes, that can be done. This thread has some info about it: http://www.jpct.net/forum/viewtopic.php?t=667
Title: animation
Post by: bigfishcatcher on December 20, 2006, 01:21:54 pm
I tried this code but I can't even find the method

loadDefault3ds
Title: animation
Post by: bigfishcatcher on December 20, 2006, 01:25:28 pm
or the method


loadObjectFromFolder
Title: Animate Model
Post by: Mizuki Takase on December 20, 2006, 03:14:13 pm
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.

Code: [Select]

//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:



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.