Sign in to follow this  
RuneLancer

Billboarding with gluLookAt?

Recommended Posts

RuneLancer    253
My game engine features a 3D environment with 2D billboarded sprites. I've gotten most of the basic code up and running quite well, and keep my camera centered on my main character with gluLookAt(). My camera system works exactly as I want it to, allowing me to do fly-bys, rotations around all axises, and to focus on different parts of the scene for cinematic events. Problem is, I can't seem to get billboarding to work with my sprites... Now, the mechanics behind 3D maths is one thing I rather suck at. Hunting around for tutorials or explanations of how to achieve billboarding and attempting to implement it has failed, as they all feature custom camera systems with glTranslatef()/glRotatef() and, from what I've observed, it seems that whatever gluLookAt() does is far different than what glTranslatef()/glRotatef() does. I've attempted to build my own camera system, but I can't seem to build something that works like I want it to. Googling for this has turned up articles that, quite frankly, went way over my head; most of them skipping the math or dumping complicated expressions without explaining the how and why. I'd LOVE to keep gluLookAt() as my camera system is entirely built on top of this. It's just getting sprites to face the camera that doesn't work out too well for me. :x Many thanks in advance. Edit: Hehe, nevermind. Took me a bit of mucking about and experimenting, but I finally got it to work! Yay! :D [Edited by - RuneLancer on June 11, 2005 12:53:51 AM]

Share this post


Link to post
Share on other sites
Deathscythe    139
Try this algorithm:

Matrix billboard = Camera->GetViewMatrix();
billboard = TransposeMatrix(billboard)
billboard.SetUpperLeft3x3ToIdentity();
glPushMatix()
glMultMatrix(billboard)
RenderSprites()
glPopMatrix();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this