Jump to content
• Advertisement

#### Archived

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

# Billboarding Problem

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

##### 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

##### 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

##### Share on other sites
Aww... but I want a sun...

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

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5
• Advertisement

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×

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