public override void Update(GameTime gameTime)
        {
            _wind.Update(gameTime);
            _animator.Animate(_tree.Skeleton, _tree.AnimationState, gameTime);

            base.Update(gameTime);
        }
Beispiel #2
0
        public void Update(Microsoft.Xna.Framework.GameTime gametime, IObject obj, IList <ILight> lights)
        {
            shader.Update(gametime, obj, lights);
            wsource.Update(gametime);
            SimpleTree tree = (obj.Modelo as TreeModel).Tree;

            animator.Animate(tree.Skeleton, tree.AnimationState, gametime);
        }
Beispiel #3
0
        protected override void Update(GameTime gameTime)
        {
            lastKeyboard = keyboard;
            keyboard     = Keyboard.GetState();

            if (!base.IsActive)
            {
                return;
            }

            if (keyboard.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            camerafps.Update(gameTime);

            if (IsKeyTriggered(Keys.F5))
            {
                NewTree();
            }
            if (IsKeyTriggered(Keys.F1))
            {
                currentTree = (currentTree + profiles.Length - 1) % profiles.Length;
                NewTree();
            }
            if (IsKeyTriggered(Keys.F2))
            {
                currentTree = (currentTree + 1) % profiles.Length;
                NewTree();
            }

            if (IsKeyTriggered(Keys.T))
            {
                drawTree = !drawTree;
            }

            if (IsKeyTriggered(Keys.L))
            {
                drawLeaves = !drawLeaves;
            }

            if (IsKeyTriggered(Keys.B))
            {
                drawBones = !drawBones;
            }

            if (IsKeyTriggered(Keys.V))
            {
                drawTreeLines = !drawTreeLines;
            }

            wind.Update(gameTime);
            animator.Animate(tree.Skeleton, tree.AnimationState, gameTime);

            base.Update(gameTime);
        }
Beispiel #4
0
        public void DrawTrees(GameTime gameTime, Matrix viewMatrix, Matrix projectionMatrix)
        {
            Matrix world = Matrix.Identity;
            Matrix scale = Matrix.CreateScale(0.0015f);

            foreach (Vector3 currentV3 in treeList)
            {
                Vector2 distance = new Vector2(currentV3.X - game.Player.Position.X, currentV3.Z - game.Player.Position.Z);
                Matrix  x        = Matrix.CreateTranslation(currentV3);
                if (distance.Length() < 100.0f)
                {
                    device.BlendState        = BlendState.Opaque;
                    device.DepthStencilState = DepthStencilState.Default;
                    tree.DrawTrunk(world * scale * x, viewMatrix, projectionMatrix);
                    tree.DrawLeaves(world * scale * x, viewMatrix, projectionMatrix);
                    animator.Animate(tree.Skeleton, tree.AnimationState, gameTime);
                }
            }
        }
Beispiel #5
0
        protected override void Draw()
        {
            int deltaMs = (int)(timer.Elapsed.TotalMilliseconds - lastDraw);

            if (deltaMs * FramesPerSecond < 1000)
            {
                return;
            }

            GameTime gameTime = new GameTime(timer.Elapsed, TimeSpan.FromMilliseconds(deltaMs), timer.Elapsed, TimeSpan.FromMilliseconds(deltaMs));

            fps.NewFrame(gameTime);

            lastDraw = (int)timer.Elapsed.TotalMilliseconds;

            Camera.Target = new Vector3(0, CameraHeight, 0);
            Camera.SetThirdPersonView(CameraOrbitAngle, CameraPitchAngle, CameraDistance);

            GraphicsDevice.Clear(BackgroundColor);

            // Draw the ground
            if (EnableGround)
            {
                block.Apply();
                groundEffect.World      = groundWorld;
                groundEffect.View       = Camera.View;
                groundEffect.Projection = Camera.Projection;
                groundEffect.DirectionalLight0.Enabled = EnableLight1;
                groundEffect.DirectionalLight1.Enabled = EnableLight2;
                groundPlane.Draw(groundEffect);
            }

            tree.TrunkEffect.Parameters["DirLight0Enabled"].SetValue(EnableLight1);
            tree.LeafEffect.Parameters["DirLight0Enabled"].SetValue(EnableLight1);
            tree.TrunkEffect.Parameters["DirLight1Enabled"].SetValue(EnableLight2);
            tree.LeafEffect.Parameters["DirLight1Enabled"].SetValue(EnableLight2);

            if (EnableWind)
            {
                wind.Update(gameTime);
                animator.Animate(tree.Skeleton, tree.AnimationState, gameTime);
            }

            if (EnableTrunk)
            {
                block.Apply(); // quick way to clean up the mess left in the render states
                tree.DrawTrunk(treeWorld, Camera.View, Camera.Projection);
            }

            if (EnableLeaves)
            {
                block.Apply();
                tree.DrawLeaves(treeWorld, Camera.View, Camera.Projection);
            }

            if (EnableBones)
            {
                block.Apply();
                GraphicsDevice.RenderState.DepthBufferEnable = false;
                tree.DrawBonesAsLines(treeWorld, Camera.View, Camera.Projection);
            }
        }