Jump to content
  • Advertisement
Sign in to follow this  
teslaa66

rotating matrix

This topic is 3567 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

Is there a way i can make a matrix
float newMatrix[16];
apply a rotation of 10 degrees on the X axis and 60 degrees on the Z axis but simulataneously so it doesnt rotate an already rotated matrix? then load the matrix before a model in my scene
glLoadMatrixf(newMatrix);
So now i can perform two rotations without one rotation rotating an already rotated scene? If this is all possible how do i apply a rotation of 10 degrees on the X axis and 60 degrees on the Z axis of a matrix please?

Share this post


Link to post
Share on other sites
Advertisement
See this page. About half way down, there's an explanation of how to create a 4x4 matrix representing compound rotations.

However, unless you really need this matrix for some reason, I'd suggest using glLoadIdentity and glRotatef to build the matrix on-the-fly. It will produce the same result as calling glLoadMatrix but will make your code a little easier to read.

Also, if you want to transform already positioned objects, try using glMultMatrix or omitting glLoadIdentity.

Share this post


Link to post
Share on other sites
probably be easier if i show u my display


glLoadMatrixf(carMatrix); //Loads Car Matrix

glTranslatef(0,0,9.03+carHeight); //Translates the car to the correct height
glScalef(0.035,0.025,0.023); //Scales the car to the right side

glBindTexture(GL_TEXTURE_2D, texture[5]); //Textures the car

glRotatef(carRoll, 1, 0, 0); //Rolls the car

glRotatef(carPitch, 0, 1, 0); //Effects the pitch of the car

rendermd2(car); //Renders the car




Here if i effect the roll of the car then applying the pitch doesnt pitch the car it pitches the already rolled car.

If i apply a glLoadIdentity after the first rotate then the car loses the scale and translate as well as the first rotate. Any ideas?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!