#### Archived

This topic is now archived and is closed to further replies.

# Billboarding

This topic is 6206 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I''ve been using the following function for billboarding.
  void teBillboard() { float temp[16]={1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, m[16]; glGetFloatv(GL_MODELVIEW_MATRIX, m); temp[0]=m[0]; temp[1]=m[4]; temp[2]=m[8]; temp[4]=m[1]; temp[5]=m[5]; temp[6]=m[9]; temp[8]=m[2]; temp[9]=m[6]; temp[10]=m[10]; glMultMatrixf(temp); } 
It works fine asside from one problem. It makes the particles face the camera AND eliminates all effects of rotation. It should make them face the camera, but is there a way to do this with the particles being in the resulting rotated position?

##### Share on other sites
I think you are missing the whole point with billboarding here!
You use billboarding to make the particles always face the camera, and that will make it a little hard to rotate them!

- -- ---[XaOs]--- -- -

[ project fy ]

##### Share on other sites
You don''t see what I''m saying. When I rotate the camera, everything moves exept the particles. I WANT them to face the camera, but to have their center position moved. Understand what I''m saying? I just want to know if that is possible.

A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."

##### Share on other sites
When you multiply the current matrix by your "temp" matrix, you lose all translation informations.

  float temp[16]={ 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}

##### Share on other sites
I''m afraid that one just kills everything. When I use your temp it makes the particles all stretch from the center of the screen out to the lower left corner of the screen. I think you messed up somewhere.

A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."

##### Share on other sites
I have found this works fine for me:

float m[16];

glGetFloatv(GL_MODELVIEW_MATRIX, m);
glPushMatrix();
glTranslatef(m[12],m[13],m[14]);

... draw particle ...

glPopMatrix();

I suppose you could glLoadMatrix(m) at the end instead of the push/pop but I think the card probably does it faster than sending 16 floats...

##### Share on other sites
you do that for EVERY particle? Yikes! Overhead must be INSANE.

A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."

##### Share on other sites
OK what you need to do is NOT invert the 4th column of the matrix. I think how to do that is get the transformation matrix, then set everything to identity except the fourth column. This will reset all rotation and scaling to none (hopefully) giving you a quick billboard.

I read that somewhere on the Internet but I can''t find it now.

##### Share on other sites
Yeah, it kinda seems that way, eh? Is there a better technique? If you''ve got a bunch of seperate items that all need to point back at the camera, I can''t think any method will get around having to do a bunch of work each particle.

It''s not that bad, really. It''s all internal to the card ''cept for the get matrix call and the translate.

##### Share on other sites
My way you just call once, then draw all particles, then pop the matrix. Simple enough. But I think I''m inverting part I should not be.... I''ll figure it out soon enough.

A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."

1. 1
Rutin
73
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633426
• Total Posts
3011815
• ### Who's Online (See full list)

There are no registered users currently online

×