Camera rotation - mouse input problem

Jan 19, 2010 at 2:56 PM

 

hey,
I have a problem with the mouse position in the third person view.
I use a first person and a third person camera. 
In the third person camera you're able to walk around. With the first person camera you can look around. 
To rotate the camera in first person view, you've to move the mouse around. 
It is possible to rotate 360° around the Y-axis, but it is limited to look up and down.
The mouse position is centred! 
if(firstCamAct){
                fisrtCamAngelX += (oldMouse.X - currMouse.X) / 40.0f;
                firstCamAngelY += (oldMouse.Y - currMouse.Y) / 20.0f;
                firstPersonCam.Orientation *= Matrix.CreateRotationY(fisrtCamAngelX); // rotate around the Y-axis
                firstCamFullAngelY += firstCamAngelY;
                if(firstCamFullAngelY < 1.2f && firstCamFullAngelY > -1.1f) 
                    firstPersonCam.Orientation *= Matrix.CreateFromAxisAngle(Vector3.Cross(firstPersonCam.Forward, firstPersonCam.Up), firstCamAngelY); // look up and down
}
fisrtCamAngelX has the values between -20, 0 (if the mouse doesn't moved), 20.
In the third person camera I get the hole time the value of -320! 
My viewport size are in width: 640 h: 480!
I hope the error is reproducible.

 

hey,

 

I have a problem with the mouse position in the third person view.

 

I use a first person and a third person camera. 

In the third person camera you're able to walk around. With the first person camera you can look around. 

 

To rotate the camera in first person view, you've to move the mouse around. 

It is possible to rotate 360° around the Y-axis, but it is limited to look up and down.

The mouse position is centred! 

 

 

if(firstCamAct){

                fisrtCamAngelX += (oldMouse.X - currMouse.X) / 40.0f;
                firstCamAngelY += (oldMouse.Y - currMouse.Y) / 20.0f;
                firstPersonCam.Orientation *= Matrix.CreateRotationY(fisrtCamAngelX); // rotate around the Y-axis
                firstCamFullAngelY += firstCamAngelY;
                if(firstCamFullAngelY < 1.2f && firstCamFullAngelY > -1.1f) 

                    firstPersonCam.Orientation *= Matrix.CreateFromAxisAngle(Vector3.Cross(firstPersonCam.Forward, firstPersonCam.Up), firstCamAngelY); // look up and down

}

 

 

 

fisrtCamAngelX has the values between -20, 0 (if the mouse doesn't moved), 20.

Here the code for the third person camera

 

            if (!isFirstPersonCamAct)
            {

                thirdCamAngelY -= (currMouse.X - oldMouse.X);
                Console.WriteLine(thirdCamAngelY); // -320


                // increase the camera distance to the player
                if (oldMouse.ScrollWheelValue > currMouse.ScrollWheelValue) 
                {
                    if(camDistFac<100)
                        camDistFac++;
                }
                // decrease the camera distance to the player
                if (oldMouse.ScrollWheelValue < currMouse.ScrollWheelValue)
                {
                    if(camDistFac>40)
                        camDistFac--;
                }
            }

 

 

In the third person camera I get the hole time the value of -320! 

My viewport size are in width: 640 h: 480!

 

I hope the error is reproducible.

 

 

 

Coordinator
Jan 20, 2010 at 12:17 AM

I don't know how to diagnose your problem. Specifically, what part(s) of the Ox API do you think is behaving incorrectly?

cheers!

 

Editor
Jan 20, 2010 at 7:38 AM
Edited Jan 20, 2010 at 7:40 AM

i use a function like this

public void rotateCamera()

{

xLook += Engine.GamePadState.ThumbSticks.Right.Y * 0.1f;

yLook += Engine.GamePadState.ThumbSticks.Right.X * 0.1f;

RotMatrix =Matrix.CreateRotationX(-xLook) * Matrix.CreateRotationY(-yLook);ref RotMatrix);

Engine.Camera.SetOrientation(RotMatrix);

}

you have full 360degree vision, im sure with a little bit of tweaking you can implement a

MathHelper.Clamp(xLook, 90, 320);

or similar to restrict the movement on one axis before the matrix rotation is carried out.