Original Post
🔒 Locked
Billboarding
Advertisement
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
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
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
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
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
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.
Advertisement