Пример #1
0
        public FirstPersonCamera(Game game)
            : base(game)
        {
            UpdateOrder = 1;

            // Initialize camera state.

            accumHeadingDegrees = 0.0f;
            accumPitchDegrees = 0.0f;
            eye = Vector3.Zero;
            target = Vector3.Zero;
            targetYAxis = Vector3.UnitY;
            xAxis = Vector3.UnitX;
            yAxis = Vector3.UnitY;
            zAxis = Vector3.UnitZ;
            viewDir = Vector3.Forward;
            acceleration = new Vector3(DEFAULT_ACCELERATION_X, DEFAULT_ACCELERATION_Y, DEFAULT_ACCELERATION_Z);
            velocityWalking = new Vector3(DEFAULT_VELOCITY_X, DEFAULT_VELOCITY_Y, DEFAULT_VELOCITY_Z);
            velocityRunning = velocityWalking * DEFAULT_RUNNING_MULTIPLIER;
            velocity = velocityWalking;
            orientation = Quaternion.Identity;
            viewMatrix = Matrix.Identity;
            rotationSpeed = 0.2f;

            PCinput = new SystemInput.PCinput();

            // Setup perspective projection matrix.
            clientBounds = game.Window.ClientBounds;
            float aspect = (float)clientBounds.Width / (float)clientBounds.Height;
            Perspective(DEFAULT_FOVX, aspect, DEFAULT_ZNEAR, DEFAULT_ZFAR);

            direction = new Vector3();
            smoothedMouseMovement = new Vector2();
        }
Пример #2
0
        protected override void Initialize()
        {
            base.Initialize();

            // Setup the window to be a quarter the size of the desktop.
            windowWidth  = GraphicsDevice.DisplayMode.Width / 2;
            windowHeight = GraphicsDevice.DisplayMode.Height / 2;

            // Setup frame buffer.
            graphics.SynchronizeWithVerticalRetrace = false;
            graphics.PreferredBackBufferWidth       = windowWidth;
            graphics.PreferredBackBufferHeight      = windowHeight;
            graphics.PreferMultiSampling            = true;
            graphics.ApplyChanges();

            // Initially enable the diffuse color map texture.
            enableColorMap = true;

            // Initially enable parallax mapping.
            enableParallax = true;

            // Initial position for text rendering.
            fontPos = new Vector2(1.0f, 1.0f);

            // Setup the camera.

            camera.Acceleration = new Vector3(
                CAMERA_ACCELERATION_X,
                CAMERA_ACCELERATION_Y,
                CAMERA_ACCELERATION_Z);
            camera.VelocityWalking = new Vector3(
                CAMERA_VELOCITY_X,
                CAMERA_VELOCITY_Y,
                CAMERA_VELOCITY_Z);
            camera.VelocityRunning = new Vector3(
                camera.VelocityWalking.X * CAMERA_RUNNING_MULTIPLIER,
                camera.VelocityWalking.Y * CAMERA_RUNNING_JUMP_MULTIPLIER,
                camera.VelocityWalking.Z * CAMERA_RUNNING_MULTIPLIER);
            camera.Perspective(
                CAMERA_FOVX,
                (float)windowWidth / (float)windowHeight,
                CAMERA_ZNEAR, CAMERA_ZFAR);

            // Initialize the weapon matrices.
            weaponTransforms  = new Matrix[weapon.Bones.Count];
            weaponWorldMatrix = Matrix.Identity;

            // Get the initial keyboard state.
            currentKeyboardState = Keyboard.GetState();



            PCinput = new SystemInput.PCinput();

            List <Bullets.Basic> bulletList = new List <Bullets.Basic>();
        }
Пример #3
0
        public FirstPersonCamera(Game game)
            : base(game)
        {
            UpdateOrder = 1;

            // Initialize camera state.

            accumHeadingDegrees = 0.0f;
            accumPitchDegrees   = 0.0f;
            eye             = Vector3.Zero;
            target          = Vector3.Zero;
            targetYAxis     = Vector3.UnitY;
            xAxis           = Vector3.UnitX;
            yAxis           = Vector3.UnitY;
            zAxis           = Vector3.UnitZ;
            viewDir         = Vector3.Forward;
            acceleration    = new Vector3(DEFAULT_ACCELERATION_X, DEFAULT_ACCELERATION_Y, DEFAULT_ACCELERATION_Z);
            velocityWalking = new Vector3(DEFAULT_VELOCITY_X, DEFAULT_VELOCITY_Y, DEFAULT_VELOCITY_Z);
            velocityRunning = velocityWalking * DEFAULT_RUNNING_MULTIPLIER;
            velocity        = velocityWalking;
            orientation     = Quaternion.Identity;
            viewMatrix      = Matrix.Identity;
            rotationSpeed   = 0.2f;


            PCinput = new SystemInput.PCinput();

            // Setup perspective projection matrix.
            clientBounds = game.Window.ClientBounds;
            float aspect = (float)clientBounds.Width / (float)clientBounds.Height;

            Perspective(DEFAULT_FOVX, aspect, DEFAULT_ZNEAR, DEFAULT_ZFAR);

            direction             = new Vector3();
            smoothedMouseMovement = new Vector2();
        }
Пример #4
0
        protected override void Initialize()
        {
            base.Initialize();

            // Setup the window to be a quarter the size of the desktop.
            windowWidth = GraphicsDevice.DisplayMode.Width / 2;
            windowHeight = GraphicsDevice.DisplayMode.Height / 2;

            // Setup frame buffer.
            graphics.SynchronizeWithVerticalRetrace = false;
            graphics.PreferredBackBufferWidth = windowWidth;
            graphics.PreferredBackBufferHeight = windowHeight;
            graphics.PreferMultiSampling = true;
            graphics.ApplyChanges();

            // Initially enable the diffuse color map texture.
            enableColorMap = true;

            // Initially enable parallax mapping.
            enableParallax = true;

            // Initial position for text rendering.
            fontPos = new Vector2(1.0f, 1.0f);

            // Setup the camera.

            camera.Acceleration = new Vector3(
                CAMERA_ACCELERATION_X,
                CAMERA_ACCELERATION_Y,
                CAMERA_ACCELERATION_Z);
            camera.VelocityWalking = new Vector3(
                CAMERA_VELOCITY_X,
                CAMERA_VELOCITY_Y,
                CAMERA_VELOCITY_Z);
            camera.VelocityRunning = new Vector3(
                camera.VelocityWalking.X * CAMERA_RUNNING_MULTIPLIER,
                camera.VelocityWalking.Y * CAMERA_RUNNING_JUMP_MULTIPLIER,
                camera.VelocityWalking.Z * CAMERA_RUNNING_MULTIPLIER);
            camera.Perspective(
                CAMERA_FOVX,
                (float)windowWidth / (float)windowHeight,
                CAMERA_ZNEAR, CAMERA_ZFAR);

            // Initialize the weapon matrices.
            weaponTransforms = new Matrix[weapon.Bones.Count];
            weaponWorldMatrix = Matrix.Identity;

            // Get the initial keyboard state.
            currentKeyboardState = Keyboard.GetState();

            PCinput = new SystemInput.PCinput();

            List<Bullets.Basic> bulletList = new List<Bullets.Basic>();
        }