#### Archived

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

# Billboard matrix to rotate about the y axis

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

## 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 on other sites
Maybe this will help:
http://www.mvps.org/directx/articles/view_oriented_billboards.htm

.lick

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

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
12

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013738
×