Jump to content
  • Advertisement

Archived

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

Kwizatz

Problem with rotation function on the glbook

This topic is 5539 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
It just hit me, I might have to convert the cos/sin results from radians to degrees newbie mistake, I guess I am a bit rusty.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!