Matrix Rotations

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Chev
Posts: 37
Joined: Wed Nov 19, 2003 6:15 am

Matrix Rotations

Post by Chev »

I've been reading up on how to use matrices because they appear to be easiest way to transform your nodes once you figure them out (especially when needing to do a series of transformations). I plan on doing a lot of rotation around various axis (not just x,y,z). So I'm thinking matrix is the way to go. However, I was not getting the results I liked so I tried a very simple operation and found that either they are broke or I'm not doing something right. Here is some example code.

Code: Select all

//create matrix and sample vector
matrix4 mat;
vector3df rot=vector3df(0,1,0);  //rotated 1 degree on y-axis

//set the rotation transformation
mat.setRotationDegrees(vector3df(0,90,0)); 

//Apply the transformation
mat.transformVect(rot);     

//update player rotation
player->setRotation(rot);    //should equal (0,91,0) right?
Well the result of this is (0,1,0) i.e. it does nothing. I tried doing mat.makeIdentity() first and that had no effect. I also tried the setRotationRadians() version and that had no effect. Has anyone else tried using the irrlicht matrix functions?
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

vector3df(0,1,0) means that you create a vector with the coordinates (0, 1, 0). It has nothing to do with rotation. Rotating this vector around the y-axis won't do anything, because the vector is the same as the y-direction vector.

I don't want to insult you, but I would strongly recommend reading a book on matrices before starting to work with them. It will help you a lot !
Chev
Posts: 37
Joined: Wed Nov 19, 2003 6:15 am

Post by Chev »

Thanks! I have been reading alot about them and will continue to do so. btw it was the way that vectors are used that I was messing up on. The problem was that I thought I knew what I was doing with the vectors LOL :oops: . Back to the drawing board.
Post Reply