Page 1 of 1

Velocity of a node relative to the node.

Posted: Sun May 28, 2006 11:48 pm
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; 
         }


Posted: Mon May 29, 2006 12:10 am
by Browndog
ahhh Ive fixe it :), didnt need this worldVel+=myNode.getAbsolutePosition();

Posted: Mon May 29, 2006 12:16 am
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

Posted: Mon May 29, 2006 3:17 am
by Browndog
thanks thats going to save me a bit