• Advertisement

Archived

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

Billboarding using rotation

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

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


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


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


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


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


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

Share this post


Link to post
Share on other sites

  • Advertisement