Jump to content
  • Advertisement


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.

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


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


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!