Jump to content
  • Advertisement
Sign in to follow this  
antiderivative

Rotating Selected Objects Only

This topic is 3556 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
Advertisement
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
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!