protected override void Update(GameTime gameTime)
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (gamePadState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            MouseState    mouseState = Mouse.GetState();
            KeyboardState keyState   = Keyboard.GetState();

            fpsCam.Update(mouseState, keyState, gamePadState);

            float   time        = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;
            Vector3 startingPos = new Vector3(0, 0, -10);
            Matrix  rotMatrix   = Matrix.CreateRotationY(time);

            modelPos = Vector3.Transform(startingPos, rotMatrix);

            UpdateSoundPosition(cue1, modelPos, fpsCam.Position, fpsCam.Forward, fpsCam.UpVector);

            if (cue1.IsPrepared)
            {
                cue1.Play();
            }

            audioEngine.Update();

            base.Update(gameTime);
        }
Beispiel #2
0
        protected override void Update(GameTime gameTime)
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (gamePadState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            MouseState    mouseState = Mouse.GetState();
            KeyboardState keyState   = Keyboard.GetState();

            fpsCam.Update(mouseState, keyState, gamePadState);

            base.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            //process user input
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (gamePadState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            MouseState    mouseState = Mouse.GetState();
            KeyboardState keyState   = Keyboard.GetState();

            fpsCam.Update(mouseState, keyState, gamePadState);

            //update lights
            float coneAngle = MathHelper.PiOver4;
            float time      = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;
            float sine      = (float)Math.Sin(time);

            for (int i = 0; i < NumberOfLights; i++)
            {
                Matrix yRot    = Matrix.CreateRotationY(time / 2.0f + (float)i * MathHelper.Pi * 2.0f / (float)NumberOfLights);
                Matrix xRot    = Matrix.CreateRotationX(-MathHelper.PiOver2 + sine + 0.4f);
                Matrix fullRot = xRot * yRot;

                Vector3 lightPosition  = new Vector3(0.0f, 1.5f, 0.0f) + 5.0f * Vector3.Transform(Vector3.Forward, yRot);
                Vector3 lightDirection = Vector3.Transform(Vector3.Forward, fullRot);
                Vector3 lightUp        = Vector3.Transform(Vector3.Up, fullRot);;

                spotLights[i].Position   = lightPosition;
                spotLights[i].Strength   = 0.4f;
                spotLights[i].Direction  = lightDirection;
                spotLights[i].ConeAngle  = (float)Math.Cos(coneAngle);
                spotLights[i].ConeDecay  = 1.5f;
                spotLights[i].ViewMatrix = Matrix.CreateLookAt(lightPosition, lightPosition + lightDirection, lightUp);
                float viewAngle = (float)Math.Acos(spotLights[i].ConeAngle);
                spotLights[i].ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(coneAngle * 2.0f, 1.0f, 0.5f, 1000.0f);
            }

            base.Update(gameTime);
        }
Beispiel #4
0
        protected override void Update(GameTime gameTime)
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (gamePadState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            MouseState    mouseState = Mouse.GetState();
            KeyboardState keyState   = Keyboard.GetState();

            fpsCam.Update(mouseState, keyState, gamePadState);

            UpdateTriangles();
            UpdateIndexBuffer();

            Window.Title = "Triangles drawn: " + triangleList.Count.ToString();

            base.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (gamePadState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            MouseState    mouseState = Mouse.GetState();
            KeyboardState keyState   = Keyboard.GetState();

            fpsCam.Update(mouseState, keyState, gamePadState);

            float   treshold      = 3.0f;
            float   terrainHeight = terrain.GetExactHeightAt(fpsCam.Position.X, -fpsCam.Position.Z);
            Vector3 newPos        = fpsCam.Position;

            newPos.Y        = terrainHeight + treshold;
            fpsCam.Position = newPos;

            base.Update(gameTime);
        }