Jump to content
  • Advertisement
Sign in to follow this  
kellyrawks

gluSphere Mapping

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

I know this maybe a simple fix but can anyone tell me why all of my spheres are being mapped sideways?
glPushMatrix(); 
		glEnable( GL_TEXTURE_2D );
		glBindTexture(GL_TEXTURE_2D, marsTex);
		glTranslatef(2, 0, 0);
		gluSphere(mars, 0.6f, 20, 20); 
		gluLookAt(0, 3, 6, 0, 0, 0, 0, 1, 0);
		glDisable( GL_TEXTURE_2D );
	glPopMatrix(); 



The angle for rotation is set to 0 the mars planet seems to be translated on its side. I know this because the latitudinal bars aren't horizontal. I changed the rotation axis several times and nothing.I just want my planets translated right side up. The angle for rotation is set to 0.

Share this post


Link to post
Share on other sites
Advertisement
You should probably allow for local transformations instead of invoking gluLookAt to modify the modelview matrix. Try something similar to:



<begin of rendering method>

gluLookAt(0, 3, 6, 0, 0, 0, 0, 1, 0);

<for each object begin>

glPushMatrix();
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, marsTex);
glTranslatef(2, 0, 0);
glRotate3f(90, 1, 0, 0); // rotate 90 degress around x-axis
gluSphere(mars, 0.6f, 20, 20);
glDisable( GL_TEXTURE_2D );
glPopMatrix();

<for each object end>




... or move into OpenGL 3 territory and store your own matrices and perform your own transformations.

Share this post


Link to post
Share on other sites
Thanks, It works(stands vertical) but if I wish it to rotate in place around the y axis it only seems to be spinning around the x axis



glPushMatrix(); // Push on a new matrix scope
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, marsTex);
glRotatef(MarsRot / 2, 0, 1.0, 0); // Rotate the sphere around the earth sphere
glTranslatef(2, 1, 0);
glRotatef(90, 1, 0 , 0); // rotate 90 degrees around x-axis
glRotatef(MarsRot, 0.0, 1.0, 0.0); // now rotate the sphere in place around the y axis
gluSphere(mars, 0.6f, 20, 20);



Any idea why? I even changed the axis and it still flips over instead of spinning vertically.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!