Beispiel #1
0
        public bool Frame(float frameTime)
        {
            _frameCounter.Frame();

            TimeOfDay.Frame(frameTime);

            var result = _input.Frame();

            var heightDifference = 0.0f;

            if (_quadTree.GetHeightAtPosition(_camera.Position.X, _camera.Position.Z, out float height))
            {
                heightDifference = _camera.Position.Y - (height + 2.0f);
            }

            result &= HandleInput(frameTime, heightDifference);

            if (_camera.Position.Y < (height + 2.0f))
            {
                _camera.Position.Y = height + 2.0f;
            }

            result &= _userInterface.Frame(_frameCounter.FPS, _player.Position, _player.Rotation, _directX.DeviceContext);
            result &= _foliage.Frame(_camera.Position, _directX.DeviceContext);

            _skyPlane.Frame();

            result &= Render();

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            fc.Frame();

            device.BlendState        = BlendState.NonPremultiplied;
            device.DepthStencilState = DepthStencilState.Default;


            device.Clear(new Color(0.6f, 0.7f, 1.0f));

            float r = 0.7f;

            //Vector3 eyePos = new Vector3(r * (float)Math.Cos(angle)+1f, 0.3f, r * (float)Math.Sin(angle)+1f);

            //this.player.Position = this.terrain.ClampToGround(new Vector3(r * (float)Math.Cos(angle) + 1f, 0.0f, r * (float)Math.Sin(angle) + 1f));
            this.player.Position = this.terrain.ClampToGround(this.player.Position);

            //this.player.Position = eyePos;
            this.viewMatrix = this.player.ViewMatrix;

            //this.viewMatrix = Matrix.CreateLookAt(eyePos, new Vector3(0.2f, 0.0f, 0.5f), new Vector3(0, 1, 0));



            Matrix worldMatrix = Matrix.Identity;
            // light direction
            Vector3 lightDirection = new Vector3(1.0f, 1.0f, 0.2f);

            lightDirection.Normalize();


            terrainTileEffect.CurrentTechnique = terrainTileEffect.Techniques["RaycastTile1"];
            this.terrain.Draw(gameTime, device, terrainTileEffect, this.player.EyePos, viewMatrix, worldMatrix, projectionMatrix, lightDirection);

            terrainTileEffect.CurrentTechnique = terrainTileEffect.Techniques["BBox"];
            this.terrain.DrawBox(gameTime, device, terrainTileEffect, this.player.EyePos, viewMatrix, worldMatrix, projectionMatrix, lightDirection);


            sprites.Begin();
            sprites.DrawString(statusFont, string.Format("FPS: {0:###0}", fc.FPS), new Vector2(0, 0), Color.Wheat);

            sprites.DrawString(statusFont, string.Format("Eye: {0:0}", this.player.Position.ToString()), new Vector2(0, 16), Color.Wheat);
            sprites.End();


            base.Draw(gameTime);
        }
Beispiel #3
0
        protected override void Draw(GameTime gameTime)
        {
            fc.Frame();


            //Draw2DTerrain(gameTime);
            DrawTile(gameTime);

            sprites.Begin();
            sprites.DrawString(statusFont, string.Format("FPS: {0:###0}", fc.FPS), new Vector2(0, 0), Color.Wheat);
            sprites.DrawString(statusFont, string.Format("Generation: {0:###0.000}ms", this.generationSeconds * 1000.0), new Vector2(0, 20), Color.Wheat);

            if (!string.IsNullOrWhiteSpace(this.StatusMessage))
            {
                sprites.DrawString(statusFont, this.StatusMessage, new Vector2(0, 40), Color.Red);
            }

            sprites.End();

            base.Draw(gameTime);
        }
Beispiel #4
0
        protected override void Draw(GameTime gameTime)
        {
            fc.Frame();

            DrawTile(gameTime);

            sprites.Begin();
            sprites.DrawString(statusFont, string.Format("FPS: {0:###0}", fc.FPS), new Vector2(0, 0), Color.Orange);
            sprites.DrawString(statusFont, string.Format("Generation: {0:###0.000}ms", this.generationSeconds * 1000.0), new Vector2(0, 20), Color.Orange);


            sprites.DrawString(statusFont, string.Format("Eye: X:{0:###0.00} Y:{2:###0.00} H:{1:###0.00} E:{3:###0.00}", this.walkCamera.Position.X * this.Terrain.Width, this.walkCamera.Position.Y * this.Terrain.Width, this.walkCamera.Position.Z * this.Terrain.Width, this.walkCamera.EyeHeight * this.Terrain.Width), new Vector2(0, 40), Color.Orange);

            if (!string.IsNullOrWhiteSpace(this.StatusMessage))
            {
                sprites.DrawString(statusFont, this.StatusMessage, new Vector2(0, 60), Color.Red);
            }

            sprites.End();

            base.Draw(gameTime);
        }