Author Topic: Rotating blade...  (Read 2808 times)

Offline guiloic

  • byte
  • *
  • Posts: 24
    • View Profile
Rotating blade...
« on: April 17, 2006, 02:20:01 pm »
I've a problem ;( I try to rotate the blade of my helicopter... but it's difficult...

I have tried to use Animation, but I've this error :

Quote
ERROR: The sizes of the Animation's Meshes (68) and the object's Mesh (1445) don't match!


I can't understand where is the problem.

Code: [Select]
public Helicopter(float coordX, float coordY, float coordZ) {
super(coordX, coordY, coordZ);
Object3D objs[] = Loader.load3DS("models" + File.separatorChar
+ "helicopter.3ds", 7f);
this.model = objs[0];

for (int i = 1; i < objs.length; i++)
this.model = Object3D.mergeObjects(this.model, objs[i]);

Texture tex = new Texture("models" + File.separatorChar + "gunmap.png");
TextureManager.getInstance().addTexture("gunmap", tex);

this.model.setTexture("gunmap");

this.model.build();
this.model.getMesh().compress();
this.model.translate((float)(coordX*pbm), -1 * (float)(coordY*pbm), (float)(coordZ*pbm));

Object3D[] animArray = new Object3D[8];
for(int i=0;i<animArray.length;i++) {
objs[0].rotateY((float)Math.PI / animArray.length);
Object3D obj = objs[0].cloneObject();
obj.rotateMesh();
animArray[i] = obj;
}

Animation anim=new Animation(animArray.length);
anim.createSubSequence("rotating blade");
for (int i=0; i<animArray.length; i++) {
  animArray[i].build();
  anim.addKeyFrame(animArray[i].getMesh());
}
this.model.setAnimationSequence(anim);

}


I'm sorry....
ww.devcat.org

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12258
    • View Profile
    • http://www.jpct.net
Rotating blade...
« Reply #1 on: April 17, 2006, 05:31:20 pm »
The animation's size (i.e. the mesh size) has to be the same as the one of the object you are assigning it to. In your example, you need another clone of your blade and assign the animation to that one.

Offline guiloic

  • byte
  • *
  • Posts: 24
    • View Profile
Rotating blade...
« Reply #2 on: April 17, 2006, 07:03:46 pm »
Thank you very much. But now I didn't use Animation, I prefer use child and rotate it directly... it's easier !
ww.devcat.org