Skip to main content
gamedev.net
🔒 Locked

Mouselook...

Started by elis-cool Dec 30, 2002 at 8:57 PM 3 replies 350+ views
Original Post
elis-cool
elis-cool
I cant seem to get mouselook working correctly... The mouse cursor hits the side of the window and so you cant move it any further to turn the camera... And the movement seems to slow right down as you get closer to the axis of the camera turning towards the other direction...
            
case WM_MOUSEMOVE:
{
	static int iDeltaX = 0, iDeltaY = 0, iLastX = 0, iLastY = 0;

	int x = LOWORD(lParam);
	int y = HIWORD(lParam);

        iDeltaX += iLastX-(x-INIT_WIDTH/2);
	iDeltaY += iLastY-(y-INIT_HEIGHT/2);

	iLastX = x-INIT_WIDTH/2;
	iLastY = y-INIT_HEIGHT/2;

	//iDeltaX += (x-INIT_WIDTH/2);  // Tryed this as well

	//iDeltaY += -(y-INIT_HEIGHT/2);


	//SetCursorPos(INIT_WIDTH/2, INIT_HEIGHT/2); // uncommenting this doesnt help either

			
	CVolatile.CAM_SetLookAt((float)iDeltaX, (float)iDeltaY, 0);
}break;            
[edited by - elis-cool on December 30, 2002 11:33:15 PM]
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
zppz
zppz
Hi elis
I think you need to set the mouse cursor back to the center of the window each time it moves:

  
case WM_MOUSEMOVE: {
GetCursorPos(&m_mousePos);
if (m_mousePos.x == m_windowCenter.x && m_mousePos.y == m_windowCenter.y)
return 0;
g_mouse.m_accumMovement.x += (m_mousePos.x - m_windowCenter.x);
g_mouse.m_accumMovement.y += (m_mousePos.y - m_windowCenter.y);
if (g_mouse.m_lockToCenter)
SetCursorPos(m_windowCenter.x, m_windowCenter.y);
return 0;
}



----------
http://www.zppz.com <- game dev stuff
billybob
billybob
how would you do that with directinput? i have the same problem but i''m not using windows messsages.
elis-cool
elis-cool
I got a friend to explain it to me, I guess theres alot more to it than what I thought, I simply cant throw those mouse deltas at my cam lookat
[email=esheppard@gmail.com]esheppard@gmail.com[/email]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.