Sign in to follow this  
teslaa66

rotating matrix

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this