Sign in to follow this  

Camera Mouse Look

This topic is 3466 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have been trying to do a mouse look for a camera, however, I just can not do it. The effect I am getting is a paging effect inbetween frames when I don't even move the mouse. Does anyone see why?
	CMouse *pMouse = CMouse::GetInstance();
	int nMouseX = pMouse->GetMouseX();
	int nMouseY = pMouse->GetMouseY();

	nMouseXDifference = nMouseX * fElapsedTime;
	nMouseYDifference = nMouseY * fElapsedTime;

	D3DXMATRIX mOldMatrix = m_mViewMatrix;

	D3DXMatrixIdentity(&m_mViewMatrix);
	D3DXMatrixRotationY(&m_mViewMatrix, nMouseXDifference);
	D3DXMatrixRotationX(&m_mViewMatrix, nMouseYDifference);

	D3DXVECTOR3 zAxis = D3DXVECTOR3(m_mViewMatrix._31, m_mViewMatrix._32, m_mViewMatrix._33);
	D3DXVECTOR3 xAxis;
	D3DXVec3Cross(&xAxis, &D3DXVECTOR3(0.0f, 1.0f, 0.0f), &zAxis);

	D3DXVECTOR3 yAxis;
	D3DXVec3Cross(&yAxis, &zAxis, &xAxis);
	m_mViewMatrix._11 = xAxis.x;
	m_mViewMatrix._12 = xAxis.y;
	m_mViewMatrix._13 = xAxis.z;

	m_mViewMatrix._21 = yAxis.x;
	m_mViewMatrix._22 = yAxis.y;
	m_mViewMatrix._23 = yAxis.z;

	m_mViewMatrix._31 = zAxis.x;
	m_mViewMatrix._32 = zAxis.y;
	m_mViewMatrix._33 = zAxis.z;

The MouseX/Y variables are in relative space to the screen. They start in 400/300 of a 800/600 application.

Share this post


Link to post
Share on other sites
D3DXMatrixIdentity(&m_mViewMatrix);
D3DXMatrixRotationY(&m_mViewMatrix, nMouseXDifference);
D3DXMatrixRotationX(&m_mViewMatrix, nMouseYDifference);

You are overwriting the matrix every call !


Share this post


Link to post
Share on other sites

This topic is 3466 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this