Author Topic: Animate Model  (Read 2859 times)

Offline bigfishcatcher

  • byte
  • *
  • Posts: 17
    • View Profile
Animate Model
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Animate Model
« Reply #1 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

Offline bigfishcatcher

  • byte
  • *
  • Posts: 17
    • View Profile
animation
« Reply #2 on: December 20, 2006, 01:21:54 pm »
I tried this code but I can't even find the method

loadDefault3ds

Offline bigfishcatcher

  • byte
  • *
  • Posts: 17
    • View Profile
animation
« Reply #3 on: December 20, 2006, 01:25:28 pm »
or the method


loadObjectFromFolder

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
Animate Model
« Reply #4 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:

    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.