algo for moving in the direction of object facing
ok! i managed to get the object rotates abt itself... now
i am figuring out how to make it move in the direction it is facing...
any ideas to share?
thx!
edwin
The following members in your world matrix form a vector that points in the direction the object is facing:
_13, _23, _33
Assuming there are no scales or skews in your matrix (if it''s just rotation and translation, there won''t be), then that vector is also normalised (it''s length == 1).
So all you have to do is multiply that vector by the distance to move and add it to the translation part of the world matrix:
vec3 direction;
direction.x = worldmatrix._13;
direction.y = worldmatrix._23;
direction.z = worldmatrix._33;
worldmatrix._41 += direction.x * DISTANCE_TO_MOVE;
worldmatrix._42 += direction.y * DISTANCE_TO_MOVE;
worldmatrix._43 += direction.z * DISTANCE_TO_MOVE;
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement