Archived

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

Billboarding math

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