Hi,
I control my model with mouse. The problem is that when the mouse reaches the bottom of the screen, the model stops moving. How can I capture the mouse to make the rotation infinite (while I move the mouse to one direction, the model keeps rotating)
Here is the code of the current mouse control:
MouseState mouseState = Mouse.GetState();
x = mouseState.X;
y = mouseState.Y;
if (y > previous_y)
{
modelRotationPitch += 0.01f;
previous_y = y;
}
else if (y < previous_y)
{
modelRotationPitch -= 0.01f;
previous_y = y;
}

Capturing the mouse
Michael Chancey
Thanks for all the hints, they were very useful. I mushed together the solutions and created the one I needed.
ooper
I found the same in another language, when using a mouse for a powerbar, basically, I moved the mouse to the centre of the screen, say 320,240, then in the loop, checked where the mouse was, if it was higher/lower, than 320 or 240, I knew the direction the mouse was moving.
At the end of the loop, I would re-set the mouse to 320,240 again.
Here is an example of it in my old language, Blitz+, which should be easy to figure out:-
http://www.syntaxbomb.com/forum/index.php topic=303.0
I would probably do the same in XNA!
- Dabz
Alejandro.avenger
So if the mouseState.Y is greater than or equal to the bounds of the playing area, increase your pictch and if it's less than or equal to the lower bound of your playing area (0) then decrease your pitch.
Then as long as that condition is true, the model will continue to rotate.
I hope that's what you were asking.
Sumit Chawla
In your Update loop:
#if !XBOX360
{
int cx = Window.ClientBounds.Width / 2;
int cy = Window.ClientBounds.Height / 2;
if (ms.X != cx)
{
if (ms.Y != cy)
{
Mouse.SetPosition(cx, cy);
"Clamp" is just my function that clamps the input value in a given range, to avoid too large control outputs. You can do whatever you want with "ms.X - cx" and "ms.Y - cy".
Another improvement is to ignore the first frame after you've gone active from being inactive, as there will be a jump based on where the cursor is when you re-gain active-ness.