Skip to main content
GameDev.net gamedev.net
🔒 Locked

Bilboard question

Started by Julien Sep 15, 2000 at 7:48 AM 2 replies 450+ views
Original Post
Julien
Julien
Hi, I have a simple textured rectangular polygon and I''d like it to always face the camera, I think it''s called something like biboard, but I''m not sure. I''ve tried to make the inverse transformation on that object, but it doesn''t work (or I''ve done something wrong). Is there someone who could explain me or give the code to do that ? Thanks in advance. See my page at http://perso.libertysurf.fr/amsellem
Meduzza
Meduzza
Two ways.

1. This one is usually used for particles. Knowing particle position and size: transform position into the camera space and create four points using radius (in camera space):

V - pos; R - radius.
VecMatMul( &V, &viewMatrix );
vertex[0] = Vec( V.x - R, V.y - R, V.z );
vertex[1] = Vec( V.x + R, V.y - R, V.z );
vertex[2] = Vec( V.x + R, V.y + R, V.z );
vertex[3] = Vec( V.x - R, V.y + R, V.z );


2. Classic "billboard" method:
You need to create billboard matrix. It works almost like createion of "look at" view matrix:

zAxis = billboardPos - cameraPos;
yAxis = Vec( 0, 1, 0 );
xAxis = VecCross( yAxis, zAxis );


-------------

Salut!
Meduzza
Nate
Nate
Or you could try this :

Get your current model view matrix from OpenGL.
glGetFloatv(GL_MODELVIEW_MATRIX, mat)

Take the transpose of that matrix and store it.
tmat = mat.Transpose().

Create two vectors, x and y, and set them as follows using the transposed matrix.
x.Set(tmat[0], tmat[1], tmat[2]);
y.Set(tmat[4], tmat[5], tmat[6]);

x is a vector that points right and y is a vector that points up. With these two vectors you can easily construct triangles that will always face the camera

Nate Miller
http://nate.scuzzy.net

Julien
Julien
Thanks for you answers, now I''ve everything I need to de it :p .
It''s for a particles engine, you''ll find the current version on my web page, and as soon as bilboard will be coded I''ll update it.
Thanks again guys.
Julien

My Web Page

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.