rotating a node

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Gav
Posts: 23
Joined: Fri Jul 16, 2004 12:28 pm

rotating a node

Post by Gav »

:oops:

Code: Select all

case KEY_KEY_D:
{
core::vector3df v = node->getPosition();
v.rotateXYBy(10.0f, v);
node->setPosition(v);
return true;
}
basically i am wanting to rotate the node in a clockwise direction when i press D.... but when i press D. . . nothing happens! :( :roll:
im pretty sure it is something to do with me wrongly using rotateXYBy()

I tried reading the API i really did ...... :? but when you dont know what you're looking for it can be hard to find something.

sorry if this was already covered in one of the tutorials and i didnt realise..

*edit*

I will be more specific -
I think the problem is in the line

v.rotateXYBy(10.0f, v);

what should the 2nd parameter be?


oh and you're all slack hehehe as if none of you know how to perform a simple rotation - hurry up n answer :P :lol:
Gav
Posts: 23
Joined: Fri Jul 16, 2004 12:28 pm

Post by Gav »

...bump :cry: nobody likes me waaaaah :lol:
just_a_guest

rotating the position...

Post by just_a_guest »

Well, I guess that the key to solving the problem is to realize the difference between position and rotation (both are vectors). What you try to do is to rotate the positon of the node (doesn't sound wierd???), but the position is just a vector and indicates nothing but the x,y,z coords relative to the parent node. If there is no parent node these are absolute coords. But this has nothing to do with the rotation... To put it straight all you have to do is to get the rotation vector (by calling getRotation(...) method), alter it and set it as the current rot. of your node (using setRotation(...)). I'd be best to increment/decrement the Y field of the rot. vector (if I guess right) and that's all.
Oz (not logged in)

Post by Oz (not logged in) »

Does this work?

v.rotateXZBy(90, vector3d<f32>(0,0,0));

Should rotate v 90 degrees around (0,0,0)
Oz
Posts: 81
Joined: Tue Aug 31, 2004 3:34 pm

Post by Oz »

Oh sorry, the second parametre is what your rotating v around. By putting (0,0,0) or origin some call it its just rotating on the spot.
(Im pretty sure thats right but anyone feel free to correct me)
"When we looked at the relics of the precursors, we saw what heights civilization can attain.
When we looked at their ruins, we marked the danger of that height." -Keeper Annals
(Thief2: The Metal Age)
Guest

Post by Guest »

:oops: heh thanks
Post Reply