I have been working on my camera in DirectX 9 for a while now. No matter what I try I can not create a 6DOF (space ship) camera. I came upon a thread on this forum by a user nameddarksaidin. I implemented it into my own code but I still suffer from that damn rolling up and down when I rotate horizontaly. So I figured I would post my camera code here to get a possible solution to my problem. I cut out any part that doesn't deal with rotation specificaly. If anyone has any suggestions please let me know.

This is the code I got from darksaidin's postCode:`//------------------------------------------------------------------------------------------------`

Constructor

{

m_vecRight = D3DXVECTOR3( 1.0f, 0.0f, 0.0f );

m_vecUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );

m_vecLook = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );

m_vecPosition = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );

m_fRotSpeed = 15.0f; // Rotation Speed

}

//------------------------------------------------------------------------------------------------

Rotate(float pitch, float yaw, float roll, float Distance, MyUnit * in_Unit)

{

D3DXVECTOR3 tempRot(pitch, yaw, roll); // Create Vector out of user input

D3DXVec3Normalize(&tempRot, &tempRot); // Norm input

tempRot *= m_fRotSpeed * Distance; //Scale by time and speed

if(tempRot.x != 0) // Pitch Camera

{

RotateInPlane(m_vecLook, m_vecUp, -D3DX_PI/180 * tempRot.x);

}

if( tempRot.y != 0 ) // Yaw Camera

{

RotateInPlane(m_vecRight, m_vecLook, -D3DX_PI/180 * tempRot.y);

}

if ( tempRot.z != 0 ) // Roll Camera

{

RotateInPlane(m_vecRight, m_vecUp, D3DX_PI/180 * tempRot.z);

}

m_bcon_ViewDirty = true; // View is dirty must be rebuilt

}

//------------------------------------------------------------------------------------------------

GetViewMatrix()

{

if(m_bcon_ViewDirty)

{

// Clean up the axises

D3DXVec3Normalize( &m_vecLook, &m_vecLook );

D3DXVec3Cross( &m_vecUp, &m_vecLook, &m_vecRight );

D3DXVec3Normalize( &m_vecUp, &m_vecUp );

D3DXVec3Cross( &m_vecRight, &m_vecUp, &m_vecLook );

D3DXVec3Normalize( &m_vecRight, &m_vecRight );

// --- Build the view matrix using the altered axises ---

m_mtxView._11 = m_vecRight.x; m_mtxView._12 = m_vecUp.x; m_mtxView._13 = m_vecLook.x;

m_mtxView._21 = m_vecRight.y; m_mtxView._22 = m_vecUp.y; m_mtxView._23 = m_vecLook.y;

m_mtxView._31 = m_vecRight.z; m_mtxView._32 = m_vecUp.z; m_mtxView._33 = m_vecLook.z;

m_mtxView._41 =- D3DXVec3Dot( &m_vecPos, &m_vecRight );

m_mtxView._42 =- D3DXVec3Dot( &m_vecPos, &m_vecUp );

m_mtxView._43 =- D3DXVec3Dot( &m_vecPos, &m_vecLook );

m_bcon_ViewDirty = false;

}

return m_mtxView;

}

//------------------------------------------------------------------------------------------------

Anyone have any comments or suggestions? Is there a problem in my logic or code? I would also appreciate any links to source code for 6DOF cameras. I have tried a number of other ways to do it (using various tutorials)Code:`// rotate 2 vectors in the plane they span`

void RotateInPlane(D3DXVECTOR3 &vA, D3DXVECTOR3 &vB, float fAngle)

{

float fCos= cos(fAngle);

float fSin= sin(fAngle);

D3DXVECTOR3 vTemp;

// calc temp vector between vA and vB in their plane.

// this will be vA later, but we can't yet overwrite it

// since we still need it for vB

vTemp.x= fCos *vA.x +fSin *vB.x;

vTemp.y= fCos *vA.y +fSin *vB.y;

vTemp.z= fCos *vA.z +fSin *vB.z;

// same for vB but -90 degrees

// cos(f+90)=-sin(f) to reduce cos/sin usage

vB.x= -fSin *vA.x +fCos *vB.x;

vB.y= -fSin *vA.y +fCos *vB.y;

vB.z= -fSin *vA.z +fCos *vB.z;

// now update vA

vA= vTemp;

}