Billboarding Problem

Started by
2 comments, last by Lithic 20 years, 2 months ago
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();
Advertisement
Try this...

glBegin(GL_QUADS); // Draw sunglColor4f(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();
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]
Aww... but I want a sun...



"Remember: Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler

Globals are not evil. Singletons are evil.

This topic is closed to new replies.

Advertisement