PDA

View Full Version : Billboarding



Jan
06-08-2002, 06:51 AM
Hi, i want to use billboarding for a particle-system. I know how to do billboarding, but i am not sure if it is the only and best way. I read it in a book:

// get the modelview matrix
float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mat);

// get the right and up vectors
VECTOR right(mat[0], mat[4], mat[8]);
VECTOR up(mat[1], mat[5], mat[9]);

float size = 2.0f;

// bottom left corner
glVertex3fv((pos + (right + up) * -size).v ());
// bottom right corner
glVertex3fv((pos + (right - up) * size).v ());
// top right corner
glVertex3fv((pos + (right + up) * size).v ());
// top left corner
glVertex3fv((pos + (up - right) * size).v ());


This would create a 4*4 quad. However this is a bit much of work to do, i think. It means many calculations for every single sprite. Do you know, if one could do this easier? I thought it might be possible to rotate the camera in a way so that every quad i draw in the xy-plane should be parallel to the screeen.

I hope you understand what i mean.

Thanks,
Jan.

Jambolo
06-08-2002, 10:09 AM
If all the quads are the same size, you can precompute the vertex offets

rhmazza
06-10-2002, 09:32 AM
hmm...

what storing in bitmap format in an array of GLubytes, then using

glRasterPos3f(x, y, z);
glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bits);

I know this will always draw the sprite with the orientation you want, but I have not tried it. So I don't know how tough it would be to load or if it's any more or less optimal.

If anybody has any thoughts on this please let me know.