I've read that directInput is deprecated so I'm not using that. Is rawInput what I should be using or is what I have fine for mouse input?
Anyway, here is the section of code dealing with view transformations etc in relation to the camera. Everything else in the program works fine. It's taken directly from Luna's crate example and I'm just changing the view functionality. I believe once I get the rotation part figured out moving the camera around should be relatively easy.
GetCursorPos(&curMousePoint);
int xCenter = (int)mClientWidth/2 + mWinPosX;
int yCenter = (int)mClientHeight/2 + mWinPosY;
D3DXVECTOR3 lUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f); //local up vector
D3DXVECTOR3 lDir = D3DXVECTOR3(0.0f, 0.0f, 1.0f); //local direction vector
if(curMousePoint.x != xCenter)
{
deltaX += (curMousePoint.x - xCenter)/500.0f;
//Yaw (around y axis)
D3DXMATRIX yRotMatrix;
D3DXMatrixRotationY(&yRotMatrix, deltaX);
D3DXVec3TransformCoord(&wDir, &lDir, &yRotMatrix); //wDir is world direction vector
}
if( curMousePoint.y != yCenter)
{
deltaY += (curMousePoint.y - yCenter)/500.0f;
//Pitch (around x axis)
//D3DXMATRIX xRotMatrix;
//D3DXMatrixRotationX(&xRotMatrix, deltaY);
//D3DXVec3TransformCoord(&wUp, &lUp, &xRotMatrix); //wUp is world up vector
}
target = mEyePos + wDir; //Should point in direction of target
D3DXMatrixLookAtLH(&mView, &mEyePos, &target, &lUp);
SetCursorPos((int)mClientWidth/2 + mWinPosX, (int)mClientHeight/2 + mWinPosY);
I haven't worried about over rotating yet.
What I would like to know is: is this along the right track? What should be changed?
I have the pitch portion commented out for simplicity