Sign in to follow this  

3D Rotations

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

Hi, I am working on a small 3D app. I am using OpenGL and C++. I am trying to rotate a block. I would like it to spin in a diagonal direction. I know that I want it to rotate .2 of a degree around its local coordinates x-axis and .2 of a degree around its local coordinates y-axis between every frame. I am trying something like the following:
/* .. some code .. */

// this is called between frames
void Cube::update(){
	// for now update this cubes rotation
	rotX += .2;
	rotZ += .2;
}

/* .. more code .. */

void Cube::draw( Fl_Gl_Window *gl ){
	// preform the needed rotate
	glRotated( rotX, 1, 0, 0 );
	glRotated( rotY, 0, 1, 0 );

	/* .. code here to draw the cube as a group of quads .. */
}


When I preform the above code the cube seems to rotate in the correct direction and then change directions. I understand why this is, when I do the xRotation I am moving where the y-axis points and thus rotating around it will not give the desired result. I am curious if there is a way to compute one matrix to preform the rotation? If there is could somone please enlighten me, I am really drawing a blank on this one. Thanks in advance :) -sevans :EOF

Share this post


Link to post
Share on other sites
I don't really have the matrix perspective on this, but if you want to see some manual rotations here's my SDL code for a rotating toroid:

Donuts, the tastiest of nuts.

Read the text help file for controls, and there's code in QB if you want (though I don't know why you would)

Not that this is particularly helpful if you want to use opengl to do so (which is advisable)

[Edited by - M2tM on October 20, 2006 2:54:46 AM]

Share this post


Link to post
Share on other sites

This topic is 4074 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.

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