Rotating blade...

Started by guiloic, April 17, 2006, 02:20:01 PM

Previous topic - Next topic

guiloic

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 :

QuoteERROR: 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.

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....

EgonOlsen

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.

guiloic

Thank you very much. But now I didn't use Animation, I prefer use child and rotate it directly... it's easier !