Archived

This topic is now archived and is closed to further replies.

Kwizatz

Problem with rotation function on the glbook

Recommended Posts

Ok, I am writting a MD2 loading and displaying class bassed on the OpenGL programming book, everything works fine, but MD2 models are huge and use an "UP" vector of 0,0,1, which is not the one OpenGL uses (0,1,0), so I am scaling and rotating at load time so I dont have to do it per frame, scaling works great, but then rotation does not. I am doing it on a per Point basis. I am trying to use the rotation function on Page 77:
void CVector3::Rotate(float rx,float ry, float rz)
{
  x=x*(cos(rz)*cos(ry)) +
    y*((cos(rz)*sin(ry)*sin(rx)) - (sin(rz)*cos(rx))) +
    z*((cos(rz)*sin(ry)*sin(rx)) - (sin(rz)*cos(rx)));
  
  y=x*(sin(rz)*cos(ry)) +
    y*((sin(rz)*sin(ry)*sin(rx)) - (cos(rz)*cos(rx))) +
    z*((sin(rz)*sin(ry)*cos(rx)) - (cos(rz)*sin(rx)));
  
  z= -x*sin(rz)+z*(cos(ry)*sin(rx));
};
 
Where rx,ry,rz are rotation angles for each coordinate, I think that if I have 0,1,0 and I use rotate(90,0,0), I should end with 0,0,1, but this is not the case, I get instead 0,0.45,0. So, any idea what is wrong? am I getting the right result, but not undertsnading what the function really does? or am I missing some parentesis? Thanks

Share this post


Link to post
Share on other sites