| 2008-08-24 | Mouse handling |
It's been some weeks since the mouse has been implemented in Daídalos but i haven't told about it yet. So i've prepared an explanation for the people who
want to know how this works.
Introduction:
In most recent FPS, the mouse allows us to explore the environment around us.
It has not always been that way and the firsts FPS didn't used the mouse (mostly
because old FPS were not in real 3D). Daídalos draws its inspiration in old FPS, but it seems important to me to allow the use of the mouse, because it brings
great comfort in this kind of game.
The principle:
The operating principle is simple, because it consists of transforming a translation movement (mouse) into a rotation movement (the player).

So in order to orientate the camera, we get the distance done by the mouse on the screen between two frames.
If the x value is negative, then the mouse has been moved to the left and if the x value is positive, the mouse has been moved to the right. The same principle apply
to the y value. After that in order to convert this data in an exploitable form, we affect a factor to this data. This factor is in fact what we modify when we change
the mouse sensibility: we increase this factor to increase the sensibility.
The limits of the theory:
Unfortunately all is not so simple and it was almost too easy to be real.
Firstly we need to take into account that the mouse pointer is not glued to the window automatiquely. In most FPS we can move the mouse without problems and without
being limited by the window. To do this the easier way is to replace the mouse pointer at the center of the window on each frame.
The second problem is not easy to find without actually encountering it. In theory when the user moves the mouse, the movement of the player is smooth and continues
until the user stops its movement.
In reality some frames will count as a mouse movement, some will not. We have the illusion of a smooth movement but it's not
the case actually.
With what we have seen before, the movement will appears as jerky and it will be very annoying. In order to avoid that the easier way is to have a memory effect of
the movement. If a frame is during a mouse mouvement phase but the pointer is not modified, we use the movement value memorised instead.
That's all, i hope that my little explanation have helped you understanding how the mouse works in Daídalos, and probably in most games that uses a mouse.