Hi iifuzz, this is reasonably complicated and something that I preferred to actually write my own routine for making a view matrix rather than using directX
Some things in general:
i. we are using a left handed co-ordinate system where, once everything is all view transformed we are looking down the z axis in a positive direction, +x is to the right and +Y is up
ii. Camera Focus = Camera position for a first person view
iii. vRel is the relative vector between focus and pos = (0,0,0)
iv. Rot is the rotation of your camera X = pitch, Y = yaw, Z = roll all camera rotation directions should be the opposite of the direction that the plane has moved in
v. Think of look as the player turning their head inside the plane to look outside a window etc...
The process is basically an affine transformation where we do
1) a compensatory translation (to offset the effects of focus/pos being non-zero... especially if one does not want a first person effect)
2) Rotations in the correct order... Y,X,Z,Look First we rotate the plane, then we tilt the nose then we roll about the long axis of the plane then we look out the window
3) a translation back to the correct world position.
none of this will actually work if you copy and paste it since you don't have all the supporting functions but the general gist of it is there
Code:
'*****************************************************
' Purpose: creates a modified camera matrix
'*****************************************************
Public Function D3DViewMatrix(Focus As D3DVECTOR, Pos As D3DVECTOR, Rot As D3DVECTOR, _
vRel As D3DVECTOR, Look as single) As D3DMATRIX
Dim M As D3DMATRIX
'translate camera position relative to focus to origin
M = D3DTranslateMatrix(-(Pos.X - Focus.X) - Focus.X, _
-(Pos.Y - Focus.Y) - Focus.Y, _
-(Pos.Z - Focus.Z) - Focus.Z)
'rotate world around camera so looking down Z-axis in positive direction
If Rot.Y <> 0 Then M = D3DMatrixRotateY(M, Rot.Y)
If Rot.X <> 0 Then M = D3DMatrixRotateX(M, Rot.X)
'roll camera around z-axis
If Rot.Z <> 0 Then M = D3DMatrixRotateZ(M, Rot.Z)
'rotate to look direction
If Look <> 0 Then M = D3DMatrixRotateY(M, Look)
'position observer relative to camera
M.rc41 = M.rc41 - vRel.X
M.rc42 = M.rc42 - vRel.Y
M.rc43 = M.rc43 - vRel.Z
'return camera matrix
D3DViewMatrix = M
End Function