Mouse Relative vs Real position

Jan 9, 2008 at 11:53 PM
I'm currently doing the mouse control. I'm thinking about doing that using relative position, which means that the mouse just reports how much it has traveled since last update. this means that the mouse can travel far greater distances than the screen size. The drawback of this is that I need to lock the mouse at a fixed point at each update, which means that it can not be used as a windows mouse which the game is running (or has focus).

Another approach is using rela position which means that the mouse can only travel the screen distance. This means that if you are using a FreeLook camera you won't be able to turn all the way around (unless you have a really big screen).

I've successfully implemented the relative in previous projects, though that did mean we were forced to create a custom cursor class which we used in the game.
Jan 10, 2008 at 12:41 AM
I'd stick with relative, though how hard would it be to make this a flag somewhere?
Jan 10, 2008 at 12:52 AM
I'll rather make two mouse handler classes then the user can just load the one that fit the needs.
Jan 10, 2008 at 2:16 AM
I was thinking of the case of wanting to use relative mouse coordinates for gameplay and absolute coordinates for menus where the couple frame delay between rendering the mouse and it actually appearing on screen may be noticable, but XNA doesn't support hardware mouse cursors anyway so that's not really an issue.
Jan 10, 2008 at 6:51 AM
The mouse class can easily take this into consideration. Since most will want to implement their own mouse cursor anyway (at least for having a different pointer) I'll initially only create the relative mouse. If the needs arise I'll implement the real position handler.

Now I just need to figure out how to create a mouse pointer class that can display on screen on top of everything else (any pointers??).
Jan 10, 2008 at 1:55 PM
I am proably very wrong, but why not just have a 2d overlay, added to the draw after everything else. I have seen someone use a 3d rectangle with a transparent texture drawn a distance from the camera, and it moves as the user moves, giving the illusion of a crosshair or whatever.

As long as the mouse switches to a standard windows-style mouse for menus, I have no problem with relative.
Jan 10, 2008 at 2:04 PM
The picking with triangle accuracy sample has a nice mouse class.
Jan 10, 2008 at 3:15 PM
You can set up a new IScreen class, and add it to the end of the compositor chain. See the QuickStartSampleGame constructor for examples of adding screens. Then, just use the given SpriteBatch to draw a 32x32 sprite at the virtual mouse position, bounding it of course. You should be able to hook into the input events from that class. If you find any functionality missing in the compositor, let me know!
Jan 10, 2008 at 3:21 PM
I was looking doing exactly that, but adding it to the end is not good enough as others can just add another layer later, I think I'm going to add a cursor layer to the scene and then make sure that's rendered last. Most likely I'm going to add a collection of cursors, as most games have more than one cursor, also adding ActiveCamera property.

It's not required for the 0.19 release so I'll add a feature for 0.20 release.
Jan 10, 2008 at 4:47 PM
On that subject, I was looking earlier, and we dont seem to have an issue for controls like menus and buttons etc. Im willing to take that on, after the 0.19 release. Im only planning on doing sockets for the network alongisde streamlining for that release
Jan 10, 2008 at 6:13 PM
Do you mean:

GUI - More Gui controls and ability to build some kind of menu

It's in the plans for 0.20. I just haven't created any issues for 0.20 features at this time, I will do that when we end 0.19
Jan 10, 2008 at 6:36 PM
Also keep in mind that the buttons/menus are part of a larger GUI project. We need to create GUI element containers, like windows/panels and such to create an actual functional GUI.
Jan 10, 2008 at 6:38 PM
That's all part of the feature outlined under the 0.20 release.
Jan 10, 2008 at 6:40 PM
Sure thing Sturm. I feel like giving it a go Shaw as I would like to give some part of the graphical side of the engine a go. Im probably not realisng what im getting myself into :)
Jan 10, 2008 at 6:52 PM
There are mainly two areas in GUI:
  • Creating the drawing code for the controls
  • Creating the object model for the GUI hirarchy

I think you and whoever is going to work on it (Shaw?) should get together, I guess you would like to work on the graphical side of it not the OM side?
Jan 10, 2008 at 11:26 PM
I believe you'll need both relative and absolute. What about games like WoW in which you have a UI you can click on at anytime, but when you hold down the mouse you can control the camera and/or player? During camera or player control you will likely need relative, but when you want to use the UI you will need absolute.
Jan 10, 2008 at 11:41 PM
This is very easily handled by the cursor class., I guess the real question is if you want to retain the ability to move the mouse outside our game window, We actually want to be able to do this when using the editor,so I guess I'm implementing both.