Reactor.RCameraComponent.UpdateCamera C# (CSharp) Method

UpdateCamera() private method

Updates the state of the camera based on player input.
private UpdateCamera ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime Elapsed game time.
return void
        private void UpdateCamera(GameTime gameTime)
        {
            float elapsedTimeSec = 0.0f;

            if (Game.IsFixedTimeStep)
                elapsedTimeSec = (float)gameTime.ElapsedGameTime.TotalSeconds;
            else
                elapsedTimeSec = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Vector3 direction = new Vector3();

            GetMovementDirection(out direction);

            float dx = 0.0f;
            float dy = 0.0f;
            float dz = 0.0f;

            switch (camera.CurrentBehavior)
            {
                case RCamera.Behavior.FirstPerson:
                case RCamera.Behavior.Spectator:
                    dx = smoothedMouseMovement.X;
                    dy = smoothedMouseMovement.Y;

                    RotateSmoothly(dx, dy, 0.0f);
                    UpdatePosition(ref direction, elapsedTimeSec);
                    break;

                case RCamera.Behavior.Flight:
                    dy = -smoothedMouseMovement.Y;
                    dz = smoothedMouseMovement.X;

                    RotateSmoothly(0.0f, dy, dz);

                    if ((dx = direction.X * flightYawSpeed * elapsedTimeSec) != 0.0f)
                        camera.Rotate(dx, 0.0f, 0.0f);

                    direction.X = 0.0f; // ignore yaw motion when updating camera's velocity
                    UpdatePosition(ref direction, elapsedTimeSec);
                    break;
                case RCamera.Behavior.Free:
                    dy = smoothedMouseMovement.Y;
                    dz = smoothedMouseMovement.X;

                    RotateSmoothly(dz, dy, 0.0f);
                    UpdatePosition(ref direction, elapsedTimeSec);
                    break;
                case RCamera.Behavior.Orbit:
                    dx = -smoothedMouseMovement.X;
                    dy = -smoothedMouseMovement.Y;

                    RotateSmoothly(dx, dy, 0.0f);

                    if (!camera.PreferTargetYAxisOrbiting)
                    {
                        if ((dz = direction.X * orbitRollSpeed * elapsedTimeSec) != 0.0f)
                            camera.Rotate(0.0f, 0.0f, dz);
                    }

                    if ((dz = GetMouseWheelDirection() * mouseWheelSpeed) != 0.0f)
                        camera.Zoom(dz, camera.OrbitMinZoom, camera.OrbitMaxZoom);

                    break;

                default:
                    break;
            }
        }