Skip to main content
gamedev.net
🔒 Locked

Billboarding

Started by aker_jus Feb 23, 2003 at 6:20 AM 4 replies 250+ views
Original Post
aker_jus
aker_jus
How can I rotate my mesh so it will always face the camera? I get the view matrix using GetTransform, but then what. I have studied Nate''s document about billboarding, but that doesn''t show how to rotate the object, it just places the vertices accordingly. Any help? Thanks
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
masonium
masonium
I believe the easy way is to take the 3x3 submatrix of the ?world? matrix and make it the identity matrix

a b c d
e f g h
i j k l
m n o p

change to

1 0 0 d
0 1 0 h
0 0 1 l
m n o p

You do this with either the view matrix or the world matrix, i''m not sure.

''There''s something out there....something stupid...''
''I think I''m going to be ill. Is that a problem for you?''
''[You] overestimate my conscience by assuming that I have one.''
- Daria

DirectInput8 with the Keyboard , DirectInput8 with the Mouse , Using DirectX Audio 8
aker_jus
aker_jus
That is far from helpful, as I ened to use the inverse of the view matrix. If I set it to identity then I have nothing.

So, I have the inverse.. Then what. DX SDK samples dont use that.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
S1CA
S1CA
1) Take a copy of the view matrix.
2) Transpose the top left 3x3 part of the copy.
3) Put the object position in the translation part of the copy.
4) Set the copy as the world matrix.
5) Render the object which should face the camera.

The top left 3x3 part of the matrix is the part which contains the rotation information.

Because the view matrix is very likely to be orthonormal you can get the inverse of of its rotation by taking the transpose (e.g. M-1=MT).

Multiplying a matrix by its inverse gives you the identity matrix (i.e. no transformation):
M-1 * M = I


When D3D comes to render your object, it will multiply the view matrix by the world matrix. So if the rotation part of your world matrix is is the inverse of the rotation part of your view matrix, the rotation part of the result will be identity (i.e. no camera or world rotation for that object).

This is exactly what you require - you don''t actually "rotate the object so it faces the camera", instead you change the rotation part of the transformation be in camera space.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
aker_jus
aker_jus
Thank you very much, I will do just that.

As I see from previous posts, you always post useful things See you!
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Muhammad Haggag
Muhammad Haggag
There''s a great excerpt from "real-time rendering" on flipcode.com, that explains billboarding.

Also, you can find another good tutorial at www.mvps.org/directx

Cheers,
Muhammad Haggag

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.