Move in a direction...?

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
Lovehina

Move in a direction...?

Post 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...?
Heizi
Posts: 30
Joined: Mon Oct 10, 2005 11:23 am
Location: Steinach/Baden

Post 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.
Guest

Re: Move in a direction...?

Post 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()?
Lovehina

Post 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...
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

There is a magic file included to the sdk, called Irrlicht.chm !!! :roll:
Open it and search for getRotation...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Lovehina

Post 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...!
Lovehina

Post by Lovehina »

Guest

Post by Guest »

There's a great article written by nick_japan in the code snippets section.
Post Reply