Problem trying to set basic camera angle

Started by
11 comments, last by TheAdmiral 17 years, 1 month ago
What represents this vector?
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)
Advertisement
maybe this help you

following code transform eular angles (rotation) to directions
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;

and its up to you but its better if you make your camera look side "direction"
Quote:Original post by redas
   D3DXMatrixRotationYawPitchRoll(&rotation,D3DXToRadian(Yaw),D3DXToRadian(Pitch),D3DXToRadian(Roll));   D3DXMatrixTranslation(&position,X,Y,Z);   view = rotation * position;   d3dDevice->SetTransform(D3DTS_VIEW, &view);

Watch out. Direct3D uses row-vectors, so the transformation of M on x is Mx, not xM. For this reason, transformation matrices compose in the order of:
Mcomposition = Mlast...MsecondMfirst.
Perhaps you'd have some more success if the view matrix was calculated using
view = 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 write
D3DXMatrixTranslation(&position, -X, -Y, -Z)

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

This topic is closed to new replies.

Advertisement