Stuck with rotating a object with the camera , Directx
Posted 04 February 2010 - 06:04 AM
now i see the cube infront of the camera
now i want the cube to rotate with the camera ..
device->SetTransform(D3DTS_WORLD,&(CubeMat1 * ROT));
it does it little bit and stops on about 25 degree's of yawing left, why?
now if i set it to
then it turns with the camera but it's far away like this..
can anyone help?
Posted 04 February 2010 - 06:45 AM
D3DXMATRIX orientation; D3DXMatrixInverse(&orientation, NULL, &view); //view is your camera view matrix. orientation._41=0; orientation._42=0; orientation._43=0; orientation._14=0;orientation._24=0;orientation._34=0;orientation._44=1; //now orientation is the rotation matrix for the cube to keep it facing the camera. //it basicly just "unrotates"
All i did was invert the view matrix and took out the translation part of the matrix, so
it should only "orientate" not translate.
If you want, implement it and tell me what it does, im curious. :)
[EDIT] i tested it it works. Maybe someone would like to post a method that doesnt
take matrix inversion?[/EDIT]
Posted 04 February 2010 - 07:35 AM
Posted 04 February 2010 - 08:31 PM
I don't understand what you mean , can you show an example?
Posted 04 February 2010 - 09:13 PM
Note that for 4x4 matrices, the transpose/inverse equivalence strictly speaking applies only when the translation part of the matrix is zero. You can also use this property to speed up inversion when there is a nonzero translation but I'll leave that as an exercise for the reader.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users