Direction
- is it eular angles in radians/degrees
- or it's a point where camera should look?
- or its something like unit vector (0.707, 0, 0.707)
Direction
procedure RotationToDirection(Rotation:TD3DVector; var Direction, Up, Right:TD3DVector);var m,m2:TD3DMatrix;begin D3DXMatrixRotationX(m2,-DegToRad(Rotation.X)); D3DXMatrixRotationY(m,-DegToRad(Rotation.Y)); D3DXMatrixMultiply(m2,m2,m); D3DXMatrixRotationZ(m,-DegToRad(Rotation.Z)); D3DXMatrixMultiply(m2,m2,m); Right:=D3DXVector3(m2._11,m2._12,m2._13); Up:=D3DXVector3(m2._21,m2._22,m2._23); Direction:=D3DXVector3(m2._31,m2._32,m2._33);end;
Quote:Original post by redasD3DXMatrixRotationYawPitchRoll(&rotation,D3DXToRadian(Yaw),D3DXToRadian(Pitch),D3DXToRadian(Roll)); D3DXMatrixTranslation(&position,X,Y,Z); view = rotation * position; d3dDevice->SetTransform(D3DTS_VIEW, &view);
Mcomposition = Mlast...MsecondMfirst.
Perhaps you'd have some more success if the view matrix was calculated usingview = position * rotation
Also, D3DXMatrixTranslation creates a matrix that translates by (x, y, z). If you'd like (x, y, z) to end up at the origin, you should writeD3DXMatrixTranslation(&position, -X, -Y, -Z)