I don't see why the joystick wouldn't work.
You can convert this arc ball camera implementation from DirectX SDK samples - look up CD3DArcBall on the Internet.
class
CMeshArcBall : public CD3DArcBall
{
public
:
void OnBegin (
int nX,
int nY,
D3DXMATRIXA16* pmInvViewRotate
);
void OnMove (
int nX,
int nY,
D3DXMATRIXA16* pmInvViewRotate
);
LRESULT HandleMessages (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
D3DXMATRIXA16* pmInvViewRotate
);
};
//
// Arc-ball for mesh viewing
//
void
CMeshArcBall::OnBegin (
int nX,
int nY,
D3DXMATRIXA16* pmInvViewRotate
)
{
m_bDrag = true;
m_qDown = m_qNow;
m_vDownPt = ScreenToVector( (float)nX, (float)nY );
D3DXVECTOR4 v;
D3DXVec3Transform( &v, &m_vDownPt, pmInvViewRotate );
m_vDownPt = (D3DXVECTOR3)v;
}
void
CMeshArcBall::OnMove (
int nX,
int nY,
D3DXMATRIXA16* pmInvViewRotate
)
{
if (m_bDrag)
{
m_vCurrentPt = ScreenToVector( (float)nX, (float)nY );
D3DXVECTOR4 v;
D3DXVec3Transform( &v, &m_vCurrentPt, pmInvViewRotate );
m_vCurrentPt = (D3DXVECTOR3)v;
m_qNow = m_qDown * QuatFromBallPoints( m_vDownPt, m_vCurrentPt );
}
}
LRESULT CMeshArcBall::HandleMessages (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
D3DXMATRIXA16* pmInvViewRotate
)
{
// Current mouse position
int iMouseX = (short)LOWORD(lParam);
int iMouseY = (short)HIWORD(lParam);
switch( uMsg )
{
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK: {
SetCapture( hWnd );
OnBegin( iMouseX, iMouseY, pmInvViewRotate );
return TRUE;
}
case WM_LBUTTONUP: {
ReleaseCapture();
OnEnd();
return TRUE;
}
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN: {
// Store off the position of the cursor when the button is pressed
m_ptLastMouse.x = iMouseX;
m_ptLastMouse.y = iMouseY;
return TRUE;
}
case WM_MOUSEMOVE:
if( MK_LBUTTON & wParam )
{
OnMove( iMouseX, iMouseY, pmInvViewRotate );
}
else if( (MK_RBUTTON & wParam) || (MK_MBUTTON & wParam) )
{
// Normalize based on size of window and bounding sphere radius
FLOAT fDeltaX =
( m_ptLastMouse.x - iMouseX ) * m_fRadiusTranslation / m_nWidth;
FLOAT fDeltaY =
( m_ptLastMouse.y -
iMouseY ) * m_fRadiusTranslation / m_nHeight;
if( wParam & MK_RBUTTON )
{
D3DXVECTOR3 v = D3DXVECTOR3( -2 * fDeltaX, 2 * fDeltaY, 0.0f );
D3DXVec3TransformCoord( &v, &v, pmInvViewRotate );
D3DXMatrixTranslation( &m_mTranslationDelta, v.x, v.y, v.z ); //-2*fDeltaX,
//
//
// 2*fDeltaY,
//
//
// 0.0f
//
//
// );
D3DXMatrixMultiply( &m_mTranslation,
&m_mTranslation,
&m_mTranslationDelta );
}
else // wParam & MK_MBUTTON
{
D3DXVECTOR3 v = D3DXVECTOR3( 0.0f, 0.0f, 5 * fDeltaY );
D3DXVec3TransformCoord( &v, &v, pmInvViewRotate );
D3DXMatrixTranslation( &m_mTranslationDelta, v.x, v.y, v.z ); //0.0f,
//
//
// 0.0f,
//
//
// 5*fDeltaY
D3DXMatrixMultiply( &m_mTranslation,
&m_mTranslation,
&m_mTranslationDelta );
}
// Store mouse coordinate
m_ptLastMouse.x = iMouseX;
m_ptLastMouse.y = iMouseY;
}
return TRUE;
}
return FALSE;
}