Advertisement

Newbie rotation question...

Started by May 17, 2002 07:27 PM
-1 comments, last by Zab 22 years, 9 months ago
Hi, I was wondering if somebody could give me a hand here... I''m drawing a few triangles ( I guess you could call them a model ) using a basic GL_TRIANGLES setup, with the "front" of the model pointing along the x axis. Now, what I want to do is rotate the (modelview?) matrix so that when the model is drawn on the screen, the "front" is pointing along a certain vector ( a normalized velocity in this case ), without any roll. I''ve got something going, but I''m getting strange results. At the moment it looks like this: double pitch = -atan(m_velocity.y / sqrt(m_velocity.z * m_velocity.z+ m_velocity.x*m_velocity.x)); double yaw = atan2( m_velocity.x, m_velocity.z); glRotatef( pitch / PI * 180 , 0,0,1 ); glRotatef( yaw / PI * 180, 0,1,0 ); I kind of took the above code from somewhere, and don''t really understand it so it may not make too much sense. Any help would be much appreciated!

This topic is closed to new replies.

Advertisement