Jump to content
  • Advertisement
Sign in to follow this  
LeonPost

Camera Mouse Look

This topic is 3744 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
Advertisement
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
Ah that is correct. However, it is still not what I am looking for. Do you happen to anything else wrong?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!