Rotating and moving
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany
Rotating and moving
Hey,
sorry for asking this beginner question, but I could not find out on my own : I have a 3D models which can be rotated and moved. My problem is that the movement is axis-aligned and NOT linked with the rotation.
Let's say the rotation is 0 and the models moves "left". Everythings fine here. But if the rotation is 180 degrees and the model moves "left", it should move to the right ( seen through world coordinates ). See my problem ?
All I can think of is a dummy scene-node which holds the rotation and the model being a child to that taking the movement. Sounds crappy to me though..
Can anyone please help me ?
... thanks ! [/list]
sorry for asking this beginner question, but I could not find out on my own : I have a 3D models which can be rotated and moved. My problem is that the movement is axis-aligned and NOT linked with the rotation.
Let's say the rotation is 0 and the models moves "left". Everythings fine here. But if the rotation is 180 degrees and the model moves "left", it should move to the right ( seen through world coordinates ). See my problem ?
All I can think of is a dummy scene-node which holds the rotation and the model being a child to that taking the movement. Sounds crappy to me though..
Can anyone please help me ?
... thanks ! [/list]
Yep, that's right. The sceneNode is the holder for the model and should be used to handle position and rotation information. It also controls the bounding box.
This allows you to load a model, set the model upside down, load another model to the same node and be able to turn both using the same sceneNode rotator.
Sounds crappy? Nope, it's the common way to perform rotates and transforms.
This allows you to load a model, set the model upside down, load another model to the same node and be able to turn both using the same sceneNode rotator.
Sounds crappy? Nope, it's the common way to perform rotates and transforms.
Crud, how do I do this again?
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany
If you say so ...
So let's summarize : First I create a dummy scene node, that is a IDummyTransformationSceneNode. Then I load the model into a scenenode and make the dummy scene node the parent. The rotation goes into the dummy-scene-node-parent and the movement into the child-scenenode which contains the model.
Is that correct ??
So let's summarize : First I create a dummy scene node, that is a IDummyTransformationSceneNode. Then I load the model into a scenenode and make the dummy scene node the parent. The rotation goes into the dummy-scene-node-parent and the movement into the child-scenenode which contains the model.
Is that correct ??
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
Code: Select all
ISceneNode* shipDummy = 0;
Dummy = scenemgr->addDummyTransformationSceneNode(0,1);
RealNode->setParent(Dummy);
Eh? ... (i'm still a newb myself, and was just about to ask this same question Isometric God)
That did compile with no errors
I was wondering this to Can you just use a normal scene node so you can use the setRotation/ getRotation, or do you have to use the dummy and rotate manually with the matrix? (because in the docs of IDummyTransformationSceneNode it says that set/getRotation does nothing...) btw. Im new to the forums
-
- Posts: 81
- Joined: Fri Aug 22, 2003 12:06 pm
- Location: Germany
- Contact:
I had the problem myself. There is no scenenode yet that simply represents a node in the scenegraph, without any mesh/light/... attached. I used a temporary solution and created a light scenenode with light color/radius 0. I'm sure Niko will add an adequate scenenode in 0.5.
Cheers.
Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany
I used it when attaching scene nodes to bones of skeletal animated models. From the API docs:
This scene node does not render itself, and does not respond to set/getPosition, set/getRotation and set/getScale. Its just a simple scene node that takes a matrix as relative transformation, making it possible to insert any transformation anywhere into the scene graph. This scene node is for example used by the IAnimatedMeshSceneNode for emulating joint scene nodes when playing skeletal animations.
This scene node does not render itself, and does not respond to set/getPosition, set/getRotation and set/getScale. Its just a simple scene node that takes a matrix as relative transformation, making it possible to insert any transformation anywhere into the scene graph. This scene node is for example used by the IAnimatedMeshSceneNode for emulating joint scene nodes when playing skeletal animations.
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany
I found a quick & easy solution to my problem. For those who are fighting the same problem :
Hope this helps
Code: Select all
core::vector3df delta_v = m_Vel * m_TimeFactor;
delta_v.rotateXZBy(m_Rotation.Y, core::vector3df(0, 0, 0));
m_Pos += delta_v;
*smacks head on desk*
And here I was performing long and involved geometry to do the same effect with cosines and sines and argggghhh.....
I should have taken my own advice and realized that Irrlicht makes hard things simple and started my search for an answer by looking for the simplest answer.
Thanks Isometric God, you just saved me 17 lines of code.
And here I was performing long and involved geometry to do the same effect with cosines and sines and argggghhh.....
I should have taken my own advice and realized that Irrlicht makes hard things simple and started my search for an answer by looking for the simplest answer.
Thanks Isometric God, you just saved me 17 lines of code.
Crud, how do I do this again?
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
- Posts: 81
- Joined: Fri Aug 22, 2003 12:06 pm
- Location: Germany
- Contact:
I did because I trusted the API docs. If Nikos dummy scenenode does respond to setPosition/Rotation, it might work as well.Isometric God wrote:And why does hearsedriver create his own dummy scenenode then ?
Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
Hello,
yesterday I've started working with the Irrlicht-Engine and I've got the same problem.
I tried to solf it like that but it doesn't work:
First i tried to calculate the rotation myself with sin() and cos() functions, but it was exactly the same problem:
With 0° and 180° rotation -> everything is fine
With 90° and 270° rotation -> direction reversed
Between these rotations -> X and Z axis are swaped
@Isometric God
You say, your code works. Could you please comment it? I don't understand it, because I don't know what delta_v, m_Vel and m_TimeFactor are.
Thank you...
BTW: Is there a german forum, too?
yesterday I've started working with the Irrlicht-Engine and I've got the same problem.
I tried to solf it like that but it doesn't work:
I don't use a FPS-Camera because I want a 3d-person camera.//v1, v2 and Rotation: vector3d
//Keyboardinput W or S:
v = model_node->getPosition();
v2 = v;
v.X += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
v.rotateXZBy(Rotation.Y,v2);
model_node->setPosition(v);
// [...]
//Keyboardinput A or D
v = model_node->getPosition();
v2 = v;
v.rotateXZBy(Rotation.Y,v2);
model_node->setPosition(v);
// [...]
//Mousemove
Rotation = core::vector3df(0, event.MouseInput.X * 720 / ResX, 0);
model_node->setRotation(Rotation);
First i tried to calculate the rotation myself with sin() and cos() functions, but it was exactly the same problem:
With 0° and 180° rotation -> everything is fine
With 90° and 270° rotation -> direction reversed
Between these rotations -> X and Z axis are swaped
@Isometric God
You say, your code works. Could you please comment it? I don't understand it, because I don't know what delta_v, m_Vel and m_TimeFactor are.
Thank you...
BTW: Is there a german forum, too?