vector math question

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
the_cX
Halfling
Posts: 77
Joined: Fri Mar 25, 2005 7:13 pm

vector math question

Post by the_cX »

Code: Select all

 // moves mesh forward
 mTranslationVector = mCharacterNode->getOrientation( )* Vector3::UNIT_X;
 mCharacterNode->translate( mTranslationVector * 100 * mFrameEvent.timeSinceLastFrame);

 // moves mesh to the right
 mTranslationVector = mCharacterNode->getOrientation( )* Vector3::UNIT_Z;
 mCharacterNode->translate( mTranslationVector * 100 * mFrameEvent.timeSinceLastFrame);

alright, so im writing some code to move my mesh around the world. the first part moves it relative forward and the second part moves it relative to the right. the question is, i want to do this by manipulating the mTranslationVector in some way and using only one all to mCharacterNode->translate() at the very end. eventually i wont just be moving the mesh forward and to the right, itll be moving in call 4 directions and i just want to make one call to mCharacterNode->translate(). i know theres a way to do it, but i just dont know how. can one of you vector gurus help me out?

any help is appreciated, thanks! :D
User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia

Post by monster »

Code: Select all

mTranslationVector = Vector3::ZERO;
mTranslationVector += mCharacterNode->getOrientation( )* Vector3::UNIT_X;
mTranslationVector += mCharacterNode->getOrientation( )* Vector3::UNIT_Z;
mCharacterNode->translate( mTranslationVector * 100 * mFrameEvent.timeSinceLastFrame);
:?:
User avatar
the_cX
Halfling
Posts: 77
Joined: Fri Mar 25, 2005 7:13 pm

Post by the_cX »

wow, that was perfect.

thanks monster, your wonderful.

not only does it work, but i get it now. :)