Sign in to follow this  

Rotating Selected Objects Only

This topic is 3342 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'm learning how to use lighting and materials on platonic solids. All of that is working fine for me. However, I'm having difficulty understanding how I can stop the rotation of my text while still allowing my object to rotate. Any help will be appreciated. Jill
void display()
{	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		
	
	// rotates about an angle on the y axis
	glRotatef(theta, 0.0, 1.0, 0.0);

	// set wireframe or solid mode
	glPolygonMode(GL_FRONT_AND_BACK, wireframeMode);
	
	switch( currentPlatonicSolid )
	{
		case 1:		
			setMaterial(jade);
			glPushMatrix();
			glRotatef(45,1,0,0);
			glutSolidCube(1);
			glPopMatrix();
			displayString(0, -3, "Jade Cube");
			break;
		case 2:
			// pewter material tetrahedron
			displayString(0, -3, "Pewter Tetrahedron");
			setMaterial(pewter);
			glutSolidTetrahedron();
			break;
       .....

Share this post


Link to post
Share on other sites
The way you are doing it, rotation is applied to the whole scene. To rotate just one object, just use glRotate inside a glPushMatrix()/glPopMatrix() pair. Usually, drawing a scene looks something like this:

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

SetupCameraMatrix();
SetupLightPositions();

glPushMatrix();
DoSomeMatrixStuff();//rotate,translate,etc..
DrawObject1();
glPopMatrix();

glPushMatrix();
DoOtherMatrixStuff();
DrawObject2();
glPopMatrix();

Share this post


Link to post
Share on other sites

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