Jump to content
  • Advertisement

Archived

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

ATronic

Billboarding

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


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

Try this one instead :

  
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 this post


Link to post
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.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
I have found this works fine for me:

float m[16];

glGetFloatv(GL_MODELVIEW_MATRIX, m);
glPushMatrix();
glLoadIdentity();
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 this post


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

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!