Facing the Screen

Started by
4 comments, last by PhiberOptic 21 years, 4 months ago
This is pretty embarasing to ask, but I have never thought of the problem before. I have some quads "flying" around the screen. How can I make them always face my vector camera. (Like sprites in old 3d games, such as Duke Nukem or Doom) ?? [edited by - PhiberOptic on December 3, 2002 3:52:42 PM]
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"
Advertisement
Use billboarding.
You can read up on it in The Red Book or in any OpenGL programming book or reference.
Unfortunetely, I do not have a link to give you.

Hope this helps,


TommyB
g7tommyB
There are many possible approaches. If your "vector camera" has up and right vectors, then an easy approach is to just draw your quads using these (unit length) vectors, e.g., define each quad with a single, central point (corresponding nicely to particle in a particle system) and generate the four vertices using this point and then up and right vectors, appropriately scaled.
or just have all your quads (particles) share a common normal vector of 0,0,1 or something. then each frame do a single rotational interpolation between that normal vector and your camera view vector. then draw your particles with:

glPushMatrix();
glMultMatrixf(yourInterpolatedRotationAsMatrix);

drawParticles();

glPopMatrix();

as long as your default coords for your quads are consistent with the 0,0,1 normal vector that will work well, and be reletively efficient (you only needing to do one interpolation per frame for the entire quad/particle system).

but yeah, look up billboarding, that''s probably better. i just made the other thing up some time ago responding to someone elses similar question somewhere else.

-me
I do it like this:
I push the matrix, then rotate the object with -x,-y,-z angles, draw the object, pop the matrix.
Thanks.. Billboars is just fine! =)
I''ve found a sample! =)
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"

This topic is closed to new replies.

Advertisement