Page 1 of 1
mouse look
Posted: Tue Sep 01, 2026 8:23 pm
by xmanneke
Ogre Version: : 3.0:
Operating System: : windows 11:
Render System: : any :
Hi,
I'm having an issue with my application.
I am trying to make it so that i can look around with the mouse movement.
On the samples i found the code on how to do this but when i try this it is really twitchy.
So when i move the mouse a small amount it moves the game like crazy.
I checked it with multiple fps but it stays the same
I can slow it down by multiplying the width and height by 10 but then the movement seems to lag behind
Does anybody know how to do this correct or improve this?
Mouse Move code
Code: Select all
void OgreGame::InputHandler::mouseMoved(const SDL_Event& evt)
{
float width = static_cast<float>(1024);
float height = static_cast<float>(786);
mCameraYaw += float( -evt.motion.xrel ) / width;
mCameraPitch += float( -evt.motion.yrel ) / height;
}
Camera Set Orientation code
Code: Select all
void OgreGame::Camera::setOrientation(float _yaw, float _pitch)
{
m_Camera->yaw(Ogre::Radian(_yaw));
m_Camera->pitch(Ogre::Radian(_pitch));
}
Re: mouse look
Posted: Tue Sep 01, 2026 10:02 pm
by chilly willy
We don't see the call to OgreGame::Camera::setOrientation() but I assume you pass it mCameraYaw and mCameraPitch. Those two variables, unless you are clearing them each frame, are the accumulated absolute angles (because of the += operator). But the Camera::yaw() and Camera::pitch() functions expect delta angles and apply them to the existing orientation.
Re: mouse look
Posted: Tue Sep 01, 2026 11:18 pm
by xmanneke
Yeah you are right
I was just looking at it again and indeed i was adding them so it accumulated the angles and went crazy
So just removed the + and assigned the direct and it now works
thx for the help
Re: mouse look
Posted: Wed Sep 02, 2026 9:09 am
by slapin
Also when doing things like that, use delta time to make movement less choppy and more predictable.
Re: mouse look
Posted: Wed Sep 02, 2026 3:13 pm
by rpgplayerrobin
slapin wrote: Wed Sep 02, 2026 9:09 am
Also when doing things like that, use delta time to make movement less choppy and more predictable.
Actually, I do not think that is correct.
Since the movement of the mouse is absolute (say for example, 200 pixels to the right), rotating the camera could be instant with just that value in mind.
Multiplying it with delta time would make it incorrect, as your camera movement would then be faster when on a low FPS.
If they are after a first person mouse look (such as in Counter Strike), delta time should not be used.
Re: mouse look
Posted: Thu Sep 03, 2026 5:49 pm
by slapin
rpgplayerrobin wrote: Wed Sep 02, 2026 3:13 pm
slapin wrote: Wed Sep 02, 2026 9:09 am
Also when doing things like that, use delta time to make movement less choppy and more predictable.
Actually, I do not think that is correct.
Since the movement of the mouse is absolute (say for example, 200 pixels to the right), rotating the camera could be instant with just that value in mind.
Multiplying it with delta time would make it incorrect, as your camera movement would then be faster when on a low FPS.
If they are after a first person mouse look (such as in Counter Strike), delta time should not be used.
You are right, I was speaking about motion controller in general, FPS rotation does not need this. Third person rotation needs this only for specific cases. delta time is mostly for other things.