Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lithic

Billboarding Problem

This topic is 5337 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''ve just put the finishing touches on my sky and but one small problem remains. I''ve looked at several billboarding posts and implemented a billboard for my sun. However, when rendered, the sun does ugly things when the view direction changes. How can I correct this, code is below: float matrix[16]; glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)matrix); // get modelview matrix glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[4]); // Set sun texture sunCoord[0] *= 5.0f; // multiply sun position to make it further away sunCoord[1] *= 5.0f; sunCoord[2] *= 5.0f; glBegin(GL_QUADS); // Draw sun glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(sunCoord[0] - matrix[0] - matrix[4], sunCoord[1] - matrix[1] - matrix[5], sunCoord[2] - matrix[2] - matrix[6]); glTexCoord2f(1.0f, 0.0f); glVertex3f(sunCoord[0] + matrix[0] - matrix[4], sunCoord[1] + matrix[1] - matrix[5], sunCoord[2] + matrix[2] - matrix[6]); glTexCoord2f(1.0f, 1.0f); glVertex3f(sunCoord[0] + matrix[0] + matrix[4], sunCoord[1] + matrix[1] + matrix[5], sunCoord[2] + matrix[2] + matrix[6]); glTexCoord2f(0.0f, 1.0f); glVertex3f(sunCoord[0] - matrix[0] + matrix[4], sunCoord[1] - matrix[1] + matrix[5], sunCoord[2] - matrix[2] + matrix[6]); glEnd();

Share this post


Link to post
Share on other sites
Advertisement
Try this...



glBegin(GL_QUADS); // Draw sun

glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(sunCoord[0] - matrix[0] - matrix[1], sunCoord[1] - matrix[4] - matrix[5], sunCoord[2] - matrix[8] - matrix[9]);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(sunCoord[0] + matrix[0] - matrix[1], sunCoord[1] + matrix[4] - matrix[5], sunCoord[2] + matrix[8] - matrix[9]);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(sunCoord[0] + matrix[0] + matrix[1], sunCoord[1] + matrix[4] + matrix[5], sunCoord[2] + matrix[8] + matrix[9]);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(sunCoord[0] - matrix[0] + matrix[1], sunCoord[1] - matrix[4] + matrix[5], sunCoord[2] - matrix[8] + matrix[9]);
glEnd();


Share this post


Link to post
Share on other sites
Works great now thanks! Heres a sky screenshot (no sun sorry, didn't want to take another pic).



EDIT: fixed link

--===LITHIC===--
--===WWW.Decimation.TK===--

[edited by - Lithic on February 9, 2004 12:27:34 AM]

Share this post


Link to post
Share on other sites

  • 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!