Way to rotate loaded model permanently

Started by bLAZY, January 31, 2012, 11:26:00 PM

Previous topic - Next topic

bLAZY

Hi,

I load md2 model and it's rotated at start around Y-axis by 180 degrees. My game is taht object goes into the screen and should see its back but now I see front. Is here some way to rotate this object during loading?


EDIT:

I found solution a little bit too late.

object.rotateY((float) Math.PI);
object.rotateMesh();
object.clearRotation();


Sorry for cluttering.

EgonOlsen

You can do:


// Load your object here, then do...
obj.rotate?(<whatever>);
obj.rotateMesh();
obj.clearRotation();

bLAZY

Egon always first :) I wasted two hours to adjust my code and it doesn't worked until I saw that solution. jPCT has always what I need.
Thanks.

HammerNL

I'm doing (almost) the same thing, but somehow rotateMesh() does not make the rotation permanent in my case.

I'm loading a 3DS model using Loader.load3DS(). Like bLAZY I also need to permanently rotate the object. My object consists of more than 1 object, so I'm wrapping them in a dummyObject first, which then is rotated:

Object3D[] puppetParts  = Loader.load3DS(stream,.1f);
Object3D puppet = Object3D.createDummyObj();
for (Object3D part: puppetParts)
  puppet.addChild(part);
puppet.rotateZ(-PI/2); // make puppet face positive X axis
puppet.rotateMesh(); // should make rotation permanent
puppet.clearRotation(); // but this rotates my puppet back!?
world.addObjects(puppetParts);


What am I doing wrong?

Thanks!

EgonOlsen

It doesn't work that way. rotateMesh makes rotations permanent to the mesh of the object to which it is being applied. Applying it to a dummy mesh makes it permanent to that mesh, which makes no sense. You have to rotate each part and call rotateMesh on all of them.

HammerNL

You do react fast, fantastic!

I was afraid of that, but simply rotating the encapsulating dummyObject seems a lot easier. All sub-objects then rotate in one go around the same axis, which works nicely. So the sub-objects do get rotated.

I've also tried calling rotateMesh() on each of the sub-parts, but that has no effect.

I'm sure there is a good explanation, but I simply don't see it. In my head, all the objects are correctly presented on the view, and I simply want that view to be the default.

I will try rotating all the sub-objects one by one around the same axis, and I'm sure that will work. Wouldn't it make sense if my approach would also work?

Thanks