Velocity of a node relative to the 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
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Velocity of a node relative to the node.

Post by Browndog »

I have a node moving at a velocity, The problem is that velocity is in world coordinates I would like it relative to the ship as if the ship were at the origin(0,0,0) below is what I have tried to do but its not quite right yet:

Code: Select all

     vector3df getRelativeVel(IAnimatedMeshSceneNode myNode, vector3df worldVel)
         {       
         matrix4 m = new matrix4();
         m->setRotationDegrees(myNode.getRotation());
         worldVel+=myNode.getAbsolutePosition();
         m->inverseRotateVect(worldVel);
         return worldVel; 
         }

Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post by Browndog »

ahhh Ive fixe it :), didnt need this worldVel+=myNode.getAbsolutePosition();
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

position doesnt affect velocity, so "worldVel+=myNode.getAbsolutePosition();" needs removing. myNode->getAbsoluteTransformation().inverseRotateVect(worldVel) should work even if your node is a child of another rotated node, and is one less call to "new" :)

edit: bah too slow :P
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post by Browndog »

thanks thats going to save me a bit
Post Reply