About Store Forum Documentation Contact



Post Reply 
Lock mouse position
Author Message
Dwight Offline
Member

Post: #1
Lock mouse position
Good morning to all of you! smile

Now my switching from Third person to first person and vise versa is going sweet, but since it will checks in both views what is under the mouse in the future, I would like to freeze the mouse (Ms.freeze()) at the center of the screen (also the position of the crosshair).

When I place my mouse in a random position on the screen in TPP and switch to FPP, it already freezes, but only at that random position I was at with my mouse. The following code is what I put in the FPP:

Code:
if (Ms.visible())
            {
            Ms.toggle();
            // Lock the mouse here in the center of the application..
            Ms.freeze();
            }

I checked the mouse.h but could only came up with ways to get the mouse position, and not set the position.

Thanks again in advance!!!

SnowCloud Entertainment - We are recruiting!
http://www.sc-entertainment.com
02-04-2011 11:19 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Lock mouse position
in freeze there's comment you need to call it every frame
02-04-2011 06:06 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #3
RE: Lock mouse position
It stays at one position. But instead it should not freeze at the position where the mouse is at the time of switching, but in the center.

Steps as it should be:
1. Go to first person view
2. force mouse to the center of the screen (location 0,0 if you like)
3. freeze the mouse in the center of the screen

Steps as they are now.
1. Go to first person mode
2. mouse freezes at the point where the mouse was located in third person view at first
3. ...

Thus basically, instead of getting the mouse location, I want to override the mouse control, and force the cursor to the center of the screen, where it should stay put until back to third person perspective again.

SnowCloud Entertainment - We are recruiting!
http://www.sc-entertainment.com
(This post was last modified: 02-04-2011 07:32 PM by Dwight.)
02-04-2011 07:27 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Lock mouse position
why you want to force mouse cursor at 0,0?
if you want to have crosshair or some other icon just draw it manually Image::draw, and hide mouse cursor
02-05-2011 12:00 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #5
RE: Lock mouse position
The crosshair is drawn correctly like in the Bloody Massacre, but when the mouse hovers over a target, it's name has to change from white to a different colour.

I was thus thinking if the mouse hovers over a character while the mouse is hidden in a random position in FPP from switching from TPP, that would not occur correctly...

?

SnowCloud Entertainment - We are recruiting!
http://www.sc-entertainment.com
02-05-2011 12:10 PM
Find all posts by this user Quote this message in a reply
Seba Offline
Member

Post: #6
RE: Lock mouse position
Maybe try to make it like lit items in tutorials:
Quote:/******************************************************************************/
Bool CROOSHAIRHIT::hit(EE::PhysHit &phys_hit)
{
Vec test_pos=Players[0].pos()-Vec(0,Players[0].ctrl.height()/2,0);
if(PLAYER *player=CAST(PLAYER,phys_hit.obj))
{
return true;
}
else
if(ITEM *item=CAST(ITEM,phys_hit.obj))
{
if(Dist(test_pos,item->mesh->box*item->matrixScaled())<=Players[0].ctrl.radius()+4.0f)
Lit_Item=phys_hit.obj;
return false;
}
else
if(MONSTER *monster=CAST(MONSTER,phys_hit.obj))
{
if(Dist(test_pos,monster->mesh->box*monster->matrix())<=Players[0].ctrl.radius()+4.0f)
Lit_Monster=phys_hit.obj;
return false;
}
return false;
}
void GetWorldObjectUnderCursor()
{
Lit_Item=NULL;
Lit_Monster=NULL;
if(!Gui.ms() || Gui.ms()==Gui.desktop())
{
Vec pos,dir; ScreenToPosDir(Vec2(0,0),pos,dir);
CROOSHAIRHIT CrooshairHit;
Physics.ray(pos,dir*D.viewRange(),CrooshairHit);
}
}
/******************************************************************************/
02-05-2011 12:33 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Lock mouse position
Ms.hidden() ? Vec2(0,0) : Ms.pos()
02-05-2011 12:37 PM
Find all posts by this user Quote this message in a reply
Post Reply