
Hello
What will be the 3D Matrix required to make each of the Objects to face the camera at any given moment. This will be useful when the objects are text labels and one would want those to face the camera so they can be readable.
Thank you in advance
Tzanimir


Coordinator
Apr 22, 2010 at 12:57 PM

You will have to calculate the normal vector of the object (n) and the view vector of the camera (r). Then calculate the angle between these two vectors and rotate the object accordingly.
r = Camera.Target  Camera.Position
n = If the object wasn't rotated the normal vector should be (0, 0, 1) or (0, 0, 1).
Such objects are usually called Billboards. Search the web to find some more info. Here are some links that should help you:
http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/index.htm
http://www.gamedev.net/community/forums/topic.asp?topic_id=104435


Apr 28, 2010 at 2:44 PM
Edited Apr 28, 2010 at 2:46 PM

How to use billboard with this engine: /*Camera: your custom class to hold world projection matrix*/ void Render(Camera mCamera) { /*rotation matrix*/ Matrix3D resultingMatrixWithoutTranslation = ViewCalculations.CreateRotationX( MathHelper.ToRadians(RotationX))*
ViewCalculations.CreateRotationY( MathHelper.ToRadians(RotationY))* ViewCalculations.CreateRotationZ( MathHelper.ToRadians(RotationZ)); /*TranslationMatrix */ Matrix3D translationmatrix = ViewCalculations.CreateTranslation(X, Y, Z); if (BillBoard) { /*Creating
billBoard translation with help of lookAt matrix of the camera*/ translationmatrix.M11 = mCamera.LookAtMatrix.M11; translationmatrix.M12 = mCamera.LookAtMatrix.M21; translationmatrix.M13 = mCamera.LookAtMatrix.M31; translationmatrix.M21 = mCamera.LookAtMatrix.M12;
translationmatrix.M22 = mCamera.LookAtMatrix.M22; translationmatrix.M23 = mCamera.LookAtMatrix.M32; translationmatrix.M31 = mCamera.LookAtMatrix.M13; translationmatrix.M32 = mCamera.LookAtMatrix.M23; translationmatrix.M33 = mCamera.LookAtMatrix.M33; } /*applying
billboard to resulting projection in right order*/ Matrix3D resultingProjection = resultingMatrixWithoutTranslation*translationmatrix* mCamera.ProjectionMatrix; /*applying projection*/ RenderingObject.Projection = new Matrix3DProjection {ProjectionMatrix =
resultingProjection}; }

