Archived

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

Billboard matrix to rotate about the y axis

This topic is 5240 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''m currently trying to add a billboard node to my scene graph. I''ve searched the boards and have learnt how to achieve spherical rotation using the transposed view matrix.
Math::cMatrix4 Orientate = Camera->GetViewTransform().Transpose();

Orientate[3][0] = 0.0f;
Orientate[3][1] = 0.0f;
Orientate[3][2] = 0.0f;

m_WorldRotation = m_WorldRotation * Orientate; 
That results in the objects being rotated to face a plane perpendicular to the viewpoint. However, I am having trouble rotating the objects about only one axis (cylindrical rotation). Can anyone help, please? Thanx a lot
pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

Share this post


Link to post
Share on other sites
I think I've got it right, so I'll post it in the interest of people who might search at a later date

Math::cVector3 Dir = Camera->GetWorldTranslation() - m_WorldTranslation;
Math::cMatrix3 Rotate;
if(Dir.m_X > 0.0f)
Rotate.YRotation(-atanf(Dir.m_Z / Dir.m_X) + Math::PI_2);
else
Rotate.YRotation(-atanf(Dir.m_Z / Dir.m_X) - Math::PI_2);
m_WorldRotation = m_WorldRotation * Rotate;



pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

[edited by - pan narrans on August 7, 2003 5:43:43 PM]

Share this post


Link to post
Share on other sites