Jump to content
  • Advertisement

Archived

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

Alan Kemp

Billboarding math

This topic is 5613 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

Hi, I am trying to get my particles to face the camera, but even though I think I understand how it should work, can''t quite get it right. As I understand it I get the view matrix, extract the right and up vectors and normalize them. Now I simple create four verticies around the particle position like this (HalfSize is half the size of a particle): Vertex[0] = VecPosition - (RightVector * HalfSize); Vertex[1] = VecPosition + (RightVector * HalfSize); Vertex[2] = VecPosition - (UpVector * HalfSize); Vertex[3] = VecPosition + (UpVector * HalfSize); However, starting with the particle in the center of the screen it looks fine. As I turn to the left the particle rotates around its up vector in the opposite direction. What am I missing? Any help or hints would be greatly appreciated. Thanks for your time, Alan

Share this post


Link to post
Share on other sites
Advertisement
instead of right and up vector use base like : (1,0,0) and (0,1,0)

And set the 3x3 to I(identical) in your viewmatrix.


Share this post


Link to post
Share on other sites
pAt; //D3DXVECTOR3 structure that defines the camera look-at target.
pEye; // D3DXVECTOR3 structure that defines the eye point. This value is used in translation.

p=pEye-pAt ;//vector

tan(degree)=p.x/p.z;
degree=atan(p.x/p.z);

Then you rotates around the y-axis with inv-degree.

Share this post


Link to post
Share on other sites
Thanks for the tips, for some reason my call to set the view matrix to identity was failing. Instead I am now inverting the view matrix and taking the up and right vectors from that.

Alan

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!