Page 1 of 1

Move in a direction...?

Posted: Wed Mar 15, 2006 6:11 am
by Lovehina
Im having a simple problem. Im rotating a scene node, and after rotation trying to move it in the direction its facing. But as I have discovered, when a scenenode is rotated its axis (x,y,z) are not.

So Im wondering if there is a way to rotate the axis of a scene node...?

And if that method doesnt exist in IRRLicht, what is then the simplest and least CPU intensive way to calculate direction...?

Posted: Wed Mar 15, 2006 8:00 am
by Heizi
I dont know whether this helps you, but you could save
the angle each time you rotate the scene node. In the beginning
I think the rotation is 0. So if you rotate the Scene Node
you can:
rotation+=(amount you rotate the node)

moving a node can work (for example) like this:
you just get the position of it, here it is point A.
Then you may want to move to point B and calculate
the vector between it:
(B-A).normalize()*speed*time
then just add it to A and set the new position.
you can can leave the time away, if you dont want to code it time based.

Re: Move in a direction...?

Posted: Wed Mar 15, 2006 12:39 pm
by Guest
Lovehina wrote:But as I have discovered, when a scenenode is rotated its axis (x,y,z) are not.
Have you looked at scenenode->getRotation()?

Posted: Wed Mar 15, 2006 9:59 pm
by Lovehina
Sorry, I didnt have time to respond. Heizi thank you for your answer but that doesnt help me much. In your case I would have to know the next point to which Im supose to move, but in my case that is pointless.
Have you looked at scenenode->getRotation()?
Please be more specific, I have no idea what you mean with this...

Posted: Thu Mar 16, 2006 12:20 am
by Acki
There is a magic file included to the sdk, called Irrlicht.chm !!! :roll:
Open it and search for getRotation...

Posted: Thu Mar 16, 2006 1:02 am
by Lovehina
I know that! But getRotation only gives me how much a node has rotated in one of its axis, it doesnt give me any direction...!

Posted: Thu Mar 16, 2006 2:51 am
by Lovehina

Posted: Thu Mar 16, 2006 10:29 am
by Guest
There's a great article written by nick_japan in the code snippets section.