Jump to content
  • Advertisement
Sign in to follow this  
movEAX_444

Texture mapping. Why are the sides of the cube mapped like that in lesson 6

This topic is 4821 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 don't understand why NeHe texture maps the cube the way he does in lesson 6. Shouldn't every side of the cube have the texture facing the right way? Why is it that if the cube spins on the Y axis, not all the textures on each side face right side up. Here's an example. He does this:
// Front Face
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		// Back Face
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
Why doesn't he do the back face bottom right, and then bottom left? Why does it always start at a different point? I thought the back face was just the front face but it's drawn in relation to us seeing the "back" of it because we drawing from the front.

Share this post


Link to post
Share on other sites
Advertisement
IT is like this because in order to flip it in the correct orientation you have to reverse the winding order of the vertics(from 1234 to in this case 1432), the textures allso need fliping.

So if you take the front face, switch possition on line 2 and 4, change the z coordinate to -1 on all of them, and finaly flip the u coordinate(1 becomes 0 and 0 becomes 1), then you will see that it fits just perfectly.

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!