Archived

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

Billboarding using rotation

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

Recommended Posts

I have a simple bilboard that uses the inverse of the camera rotation to always face the screen. It works perfectly for the Y axis (Pitch) but not for the X axiz (Yaw). When i rotate around it gradually gets flatter and flatter I think this problem may be caused by the fact that the camera rotates around the ''focal point''. Can I fix the rotation angle, or is ther a trig trick to use A solution could be to use already transformed vertexes. Are they still scaled on the Z axis?

Share on other sites
Do you want the billboard to face the camera in all ways? (on the x, y, and z axis?)

Moe''s Site

Share on other sites
a clean way to do it if you''re using untransformed vertices is to take the inverse of the view matrix as the world matrix for
those vertices.

a quick way to do this (rather than using D3DXInverse..())
is to transpose the 3x3 rotation matrix in the top-left corner
of the view matrix, and take the negative of the translation
vector which is the last row of the view matrix.

Share on other sites
The billboard should face the camera at all times. The camera rotates around the focal point using Yaw and Pitch (by translating then rotating)

so to do the view matrix is to copy 11,12,13,21,22,23,31,32,33 from the view matrix into the world matrix, and copy the negative X, Y and Z position of the object into 41,42,and 43 (leaving 44 = 1 I assume)?

Share on other sites
  //get the current view matrix lpd3ddevice->GetTransform(D3DTS_VIEW, &matView); //get the transposed matrix D3DXMatrixTranspose(&matTransposed, &matView); matTransposed._14 = matTransposed._24 = matTransposed._34 = 0.0f; //position the billboard matTransposed._41 = bb.position.x; matTransposed._42 = bb.position.y; matTransposed._43 = bb.position.z; // Set as world transformation matrix lpd3ddevice->SetTransform(D3DTS_WORLD, &matTransposed); // Draw whatever - will be aligned with view

Moe''s Site

Share on other sites
D3DXMatrixTranspose, D''OH!!!! thanks man! works perfectly!

Share on other sites
It worked perfect for me as well (well, ok, that part of my program worked perfectly).

Moe''s Site

Share on other sites
just an idea, but if you already have to touch some data for 4 vertices (!) with the CPU, why not just do the whole projection in CPU and use transformed & lit vertices?
just an idea, but it should be sufficient to transform the center of the billboard, divide width and height by the "w" of the transformed centerpoint and construct the quad from it.

shouldnt be slower -- maybe not faster, but...
but then again, never touch a running system

bye,

--- foobar
We push more polygons before breakfast than most people do in a day

Share on other sites
When using the camera object, it is very simple

D3DXMATRIX mat = pView->m_Camera.GetBillboardMatrix();
mat._41 = m_vPos.x ;
mat._42 = m_vPos.y ;
mat._43 = m_vPos.z ;
pd3dDevice->SetTransform( D3DTS_WORLD, &mat );

The view matrix is inverted only once, when setting the camera.

Laurent

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 10
• 13
• Forum Statistics

• Total Topics
632984
• Total Posts
3009713
• Who's Online (See full list)

There are no registered users currently online

×