I have made a arrow model with tail at origin and tip pointing 0 0 1 (forward).
So i can assume that basis vectors is this?:
right 1 0 0
up 0 1 0
forward 0 0 1
and then i take some arbitrary point to be my new target at witch arrow will point.
newForwardDir = targetPos - myPosition;
and now i want to buid new matrix so i need all other vectors transformed.
So i am thinking that new UP vector is:
newUPDir = newForwardDir cross oldForwardDir
right? yes/no?
And if so then:
newRightDIr = newUpDir cross newForwardDir
right?
Then i tried:
D3DXMATRIX mat;
D3DXMatrixIdentity(&mat);
mat._11 = rightDir.x;
mat._12 = rightDir.y;
mat._13 = rightDir.z;
mat._21 = upDir.x;
mat._22 = upDir.y;
mat._23 = upDir.z;
mat._31 = forwDir.x;
mat._32 = forwDir.y;
mat._33 = forwDir.z;
D3DDevice->SetTransform(D3DTS_WORLD, &mat);
arrowMesh->DrawSubset(0);
and it looks ok but i don't know am i right?
And my questions is :
1. As book says about cross product that it depends on order of vectors as a cross b is not same as b cross a as it will point in opposite directions, how should i know in witch order to set vectors as parameters?
2. How can i build a rot. matrix with D3DXMatrixRotationAxis as i don't know what to specify for rotation axis, what is it?
What about angle parameter for that function, is that a :
angle = acos( newForward dot oldForward )
Thanks for your patience.