Page 1 of 1

A question about rotating a scene node

Posted: Sat Oct 24, 2009 6:36 pm
by TaviO!
I've created an AnimatedMeshSceneNode, using the sydney md2 from the tutorials. By running some tests, I found that the model has an initial rotation that makes it look in the direction of the X axis.

What I want to do is position the camera so that it looks like it is inside the model's head. The first step was to make it so the initial look at for the camera points in the same direction the model is facing initially.

However, I am feeling a little uneasy about this initial rotation. Who sets this initial rotation for the model? The engine? The model itself? How can I change it, if possible?

Thanks!

Posted: Sat Oct 24, 2009 6:46 pm
by Abraxas)
The answer to this is in the first tutorial

Posted: Sat Oct 24, 2009 7:00 pm
by TaviO!
I am sorry, but I read the first tutorial again (HelloWorld) and I could not find any references to what the initial rotation of the model is and wheter that depends on the md2 file or the engine.

Posted: Sat Oct 24, 2009 7:14 pm
by Abraxas)
In the future, look at the public member functions of classes.

once your node is defined as a scene node, it has ->setRotation().

remember to use the proper argument format.

Posted: Sat Oct 24, 2009 7:24 pm
by TaviO!
Using that method gives me no guarantee of where the model will be looking at after the rotation. To know that, I must know where the model is looking at initially. And that's what I'm asking: where do I find this information?

Posted: Sat Oct 24, 2009 7:41 pm
by hybrid
You just load the model and check where it looks at. This simply depends on the model, nothing else. You can use a 3d editong tool to change the rotation before laoding into Irrlicht (or the meshconverter tool, which is part of the SDK).

Posted: Sat Oct 24, 2009 7:42 pm
by TaviO!
Ok, I will try that!

Thanks for the answer!

Posted: Sun Oct 25, 2009 12:17 pm
by Psan
Or you can use mesh manipulator to set the initial rotation, which is as good as rotating it in a 3D editor program.

Code: Select all

   core::matrix4 m;
   m.setRotationDegrees(core::vector3df(90,0,0));  //or anything
   smgr->getMeshManipulator()->transform(mesh, m);
   scene::ISceneNode *node = smgr->addMeshSceneNode(mesh);
Edited by hybrid for proper usage of transform instead of transformMesh :-)

Posted: Sun Oct 25, 2009 3:21 pm
by hybrid
The transformMesh method is deprecated - we all know that when we pass an IMesh to a method it will work on the mesh, and when passing a buffer it will work on that buffer. That's why the method was renamed in 1.5