# rotating matrix

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

## 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 on other sites
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 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?

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632960
• Total Posts
3009478
• ### Who's Online (See full list)

There are no registered users currently online

×