problems with vectors

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
masfworld
Posts: 9
Joined: Thu Sep 30, 2004 10:29 pm

problems with vectors

Post by masfworld »

if i have a vector with rotation (0,0,0) in x,y,z, if i want to move forward, i change the z coordenate. this isn't so easy when i have rotation. for example. if i want to go in the direction of a vector that it have, and the vector is rotated. how can i to change the coordenates for moving in the direction of vector?????.
thanks
Phenix
Posts: 51
Joined: Sat Nov 15, 2003 3:15 pm
Location: Earth
Contact:

Post by Phenix »

if your direction vector is directionVector and the vector that stores the rotation of directionVector is rotationVector try this:

core::vector3df zeroVect=core::vector3df(0.0,0.0,0.0);
directionVector.rotateYZby(rotationVector.X,zeroVect);
directionVector.rotateXZby(rotationVector.Y,zeroVect);
directionVector.rotateXYby(rotationVector.Z,zeroVect);

this code rotate the direction by rotationVector.
Anyway if the rotationVector is the rotation of the camera,this code doesn't seem to work.
For example if your directionVector is (0,0,1),the rotationVector is camera->getRotation() and you want to walk forward,you have to change the third line with directionVector.rotateXZby(-rotationVector.Y,zeroVect);
Post Reply