How to do frame rate independent mouse?
How to do frame rate independent mouse?
For example I want the mouse movement speed to be the same in 640x480 resolution and in 1600x1200.
I guess a solution would be to check with percentages but I don't have a clue on how to do that?
Or do you have a better solution?
Thanks.
I guess a solution would be to check with percentages but I don't have a clue on how to do that?
Or do you have a better solution?
Thanks.
Do you mean that it takes the same physical mouse movement to get the mouse to move from one side of the screen to the other, or for camera rotation like an FPS camera? For the latter, getRelativePosition, but I suspect you mean the former.
The simplest way I can think of doing it is to use trig to find the direction of movement, then recalculate how far it would have gone using a timer and a relative position.
The simplest way I can think of doing it is to use trig to find the direction of movement, then recalculate how far it would have gone using a timer and a relative position.
-
danieLs0xFF
- Posts: 14
- Joined: Wed Aug 16, 2006 6:58 pm
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
I doubt it.MasterGod wrote:Don't you think [...]danieLs0xFF wrote:i think separate thread for mouse handling would do the trick
Aaaanyway, to repeat the question: do you mean the movement of the cursor across the screen, or the effect of that movement on (e.g.) a FPS camera? Can you please be specific about your requirements.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ok, I'll try to describe it better.rogerborg wrote:Aaaanyway, to repeat the question: do you mean the movement of the cursor across the screen, or the effect of that movement on (e.g.) a FPS camera? Can you please be specific about your requirements.
Let's say I have a sphere mesh.
When I raise the mouse up it rotates on -X and down on +X.
The mouse cursor is locked to the center of the screen.
Now, if I move the mouse up fast it moves lets say 10 unites. if I move the mouse slow, the same distance on my desk, it moves 75 unites. (10 and 75 for example).
P.S
I'm starting to think now the problem might not be with making the mouse "time-based" but with something else..
-
robertgarand
- Posts: 69
- Joined: Fri Feb 22, 2008 6:47 pm
- Location: montreal
- Contact:
Hi,
I m using the mouse to direct a cannon on the screen,
I use factor to multiply actual mousemov. it is currently
hard coded ( the 70's), but one culd just implement different
factors base on current screen resolution.
hope it helps.
Hope it helps.
Robert
I m using the mouse to direct a cannon on the screen,
I use factor to multiply actual mousemov. it is currently
hard coded ( the 70's), but one culd just implement different
factors base on current screen resolution.
hope it helps.
Code: Select all
//.5 is center of screen in absolute mouse pos
const f32 anglecanon = 0.5;
video::IVideoDriver* driver = Device->getVideoDriver();
core::vector3df canonrot;
f32 offsetx, offsety;
if (!Device->isWindowActive()) {return;}
gui::ICursorControl* cursorcontrol = Device->getCursorControl();
core::position2d<f32> cursorpos = cursorcontrol->getRelativePosition();
offsetx = (cursorpos.X-anglecanon)*70;
offsety = (cursorpos.Y-anglecanon)*70;
core::vector3df canon_rot= (canon->getRotation());
//X & Y is inverted on screen resolution versus gui mousePOS
canonrot.Y =offsetx;
canonrot.X =offsety;
canonrot.Z=0;
canon->setRotation(canonrot);
Robert
If it can't be writen, it can't exist
Oh, I see. So the same distance on the desk produces different results based on speed? I didn't even know it worked that way.
If you moved the mouse one centimeter physically, and that equaled 10 pixels on the screen, are you saying that if you move the mouse another centimeter but faster it will move less than or more than 10 pixels. If so, I don't think its something that can be changed in Irrlicht. It sounds like a problem in the operating system or the mouse.
If you moved the mouse one centimeter physically, and that equaled 10 pixels on the screen, are you saying that if you move the mouse another centimeter but faster it will move less than or more than 10 pixels. If so, I don't think its something that can be changed in Irrlicht. It sounds like a problem in the operating system or the mouse.
No, it doesn't happen outside Irrlicht, or at least my app (didn't tested it on the examples yet).Ion Dune wrote:Oh, I see. So the same distance on the desk produces different results based on speed? I didn't even know it worked that way.
If you moved the mouse one centimeter physically, and that equaled 10 pixels on the screen, are you saying that if you move the mouse another centimeter but faster it will move less than or more than 10 pixels. If so, I don't think its something that can be changed in Irrlicht. It sounds like a problem in the operating system or the mouse.
On windows/GTA SA 10 cm equals the same distance no matter what speed I move the mouse.
I'll check the behavior on the examples tomorrow and report back.
@robertgarand: I'll check it tomorrow, thanks.
It didn't do the trick.Ion Dune wrote:Ahh! I see now. I believe that I had a similar problem once, and that I was able to fix it by going from cursorcontrol->getPosition to getRelativePosition.
Maybe the following video will describe good enough my problem:
http://www.youtube.com/watch?v=WX2moCiCuEg
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
(Sorry, I missed your earlier reply)
Answer: dunno. How are you retrieving and interpreting the mouse position/movement?
Answer: dunno. How are you retrieving and interpreting the mouse position/movement?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
