Billboarding with gluLookAt?

Started by
0 comments, last by Deathscythe 18 years, 10 months ago
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]
Advertisement
Try this algorithm:

Matrix billboard = Camera->GetViewMatrix();
billboard = TransposeMatrix(billboard)
billboard.SetUpperLeft3x3ToIdentity();
glPushMatix()
glMultMatrix(billboard)
RenderSprites()
glPopMatrix();
President: Video Game Development Club of UCIhttp://spirit.dos.uci.edu/vgdc

This topic is closed to new replies.

Advertisement