#### Archived

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

# 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.

## 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 on other sites
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 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 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

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 10
• 16
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632929
• Total Posts
3009276
• ### Who's Online (See full list)

There are no registered users currently online

×