After helping someone get the inward vector from a matrix ive realised it is ordered different to some other ones. So, hes the code for getting the Left (fixed), Up and In vectors from a matrix.
NOTE: Im using a camera as an example, any scenenode should do:/*
0 1 2 3 // right(0,1,2) (-right for left)
4 5 6 7 // up(4,5,6)
8 9 10 11 // in(8,9,10)
12 13 14 15
*/
In:
Code: Select all
matrix4 cameramatrix = camera->getRelativeTransformation();
vector3df in( cameramatrix.M[8],
cameramatrix.M[9],
cameramatrix.M[10]);
vector3df pos = camera->getPosition();
pos += in;
camera->setPosition(pos);
Code: Select all
matrix4 cameramatrix = camera->getRelativeTransformation();
vector3df up( cameramatrix.M[4],
cameramatrix.M[5],
cameramatrix.M[6]);
vector3df pos = camera->getPosition();
pos += up;
camera->setPosition(pos);
Code: Select all
matrix4 cameramatrix = camera->getRelativeTransformation();
vector3df left( -cameramatrix.M[0],
-cameramatrix.M[1],
-cameramatrix.M[2]);
vector3df pos = camera->getPosition();
pos += left;
camera->setPosition(pos);
EDIT: Oh yeah, -Up is Down, -In is Back (duh!)
pos+=in*scale;
Is how you alter the speed. (its 1 unit normally)
So:
pos+=in*5;
makes your camera (or whatever scenenode) whiz forward fast!
See: (where this madness began)
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3705