Пример #1
0
 /// <summary>
 /// This initializes a new terrain chunk given the provided world transform.
 /// </summary>
 public TerrainChunk(TerrainQuadTree quadTree, TerrainChunk parent, Vector3 centerWorldPosition, float scalingFactor)
 {
     this.quadTree = quadTree;
     this.parent = parent;
     this.centerWorldPosition = centerWorldPosition;
     this.scaleFactor = scalingFactor;
 }
Пример #2
0
 /// <summary>
 /// This initializes a new terrain chunk given the provided world transform.
 /// </summary>
 public TerrainChunk(TerrainQuadTree quadTree, TerrainChunk parent, Vector3 centerWorldPosition, float scalingFactor)
 {
     this.quadTree            = quadTree;
     this.parent              = parent;
     this.centerWorldPosition = centerWorldPosition;
     this.scaleFactor         = scalingFactor;
 }
Пример #3
0
        /// <summary>
        /// This constructs a new GrassChunk, including the grass geometry.
        /// </summary>
        public GrassChunk(Game game, TerrainQuadTree quadTree, int dimension, float starSeparation)
        {
            this.game = game;
            this.quadTree = quadTree;
            this.dimension = dimension;
            this.starSeparation = starSeparation;

            starPositions = new List<Vector3>();

            LoadGraphicsContent();
        }
Пример #4
0
        /// <summary>
        /// This constructs a new GrassChunk, including the grass geometry.
        /// </summary>
        public GrassChunk(Game game, TerrainQuadTree quadTree, int dimension, float starSeparation)
        {
            this.game           = game;
            this.quadTree       = quadTree;
            this.dimension      = dimension;
            this.starSeparation = starSeparation;

            starPositions = new List <Vector3>();

            LoadGraphicsContent();
        }
Пример #5
0
        /// <summary>
        /// Loads graphics resources needed for the game.
        /// </summary>
        public override void LoadGraphicsContent(bool loadAllContent)
        {
            // Initialize the camera

            camera = new FirstPersonCamera(GameOptions.CameraAccelerationMagnitude, GameOptions.CameraRotationSpeed,
                                           GameOptions.CameraVelocityDecayRate);
            camera.AspectRatio = (float)ScreenManager.GraphicsDevice.Viewport.Width /
                                 (float)ScreenManager.GraphicsDevice.Viewport.Height;
            camera.Position = new Vector3(0, GameOptions.TerrainMaxHeight, 0);
            camera.Angles   = new Vector3(-MathHelper.PiOver2, 0.0f, 0.0f);

            if (loadAllContent)
            {
                // Load the sky box
                skyBox = new SkyBox(ScreenManager.Game, ScreenManager.Content, camera);

                // Set up the terrain parameters
                TerrainQuadTreeParameters parameters = new TerrainQuadTreeParameters();

                parameters.HeightMapName    = "Content\\Textures\\Heightmap";
                parameters.LayerMap0Name    = "Content\\Textures\\grass01";
                parameters.LayerMap1Name    = "Content\\Textures\\rock01";
                parameters.LayerMap2Name    = "Content\\Textures\\snow01";
                parameters.GrassTextureName = "Content\\Textures\\grass";

                parameters.MaxHeight    = GameOptions.TerrainMaxHeight;
                parameters.TerrainScale = GameOptions.TerrainScale;

                parameters.MaxScreenSpaceError = 0.075f;
                parameters.ScreenHeight        = ScreenManager.Game.GraphicsDevice.Viewport.Height;
                parameters.FieldOfView         = camera.FieldOfView;

                parameters.GrassChunkDimension        = 30;
                parameters.GrassChunkStarSeparation   = 266.6f;
                parameters.GrassStartFadingInDistance = 4000.0f;
                parameters.GrassStopFadingInDistance  = 3900.0f;

                parameters.WindStrength  = 100.0f;
                parameters.WindDirection = new Vector4(-1.0f, 0.0f, 0.0f, 0.0f);

                parameters.DoPreprocessing = true;

                parameters.ComputePerspectiveScalingFactor();

                terrain = new TerrainQuadTree(ScreenManager.Game, ScreenManager.Content, parameters);

                // Iniialize the water manager
                waterManager = new WaterManager(ScreenManager.Game, GameOptions.WaterHeight);
            }
        }
Пример #6
0
        /// <summary>
        /// Loads graphics resources needed for the game.
        /// </summary>
        public override void LoadGraphicsContent(bool loadAllContent)
        {
            // Initialize the camera

            camera = new FirstPersonCamera(GameOptions.CameraAccelerationMagnitude, GameOptions.CameraRotationSpeed,
                                           GameOptions.CameraVelocityDecayRate);
            camera.AspectRatio = (float)ScreenManager.GraphicsDevice.Viewport.Width /
                                    (float)ScreenManager.GraphicsDevice.Viewport.Height;
            camera.Position = new Vector3(0, GameOptions.TerrainMaxHeight, 0);
            camera.Angles = new Vector3(-MathHelper.PiOver2, 0.0f, 0.0f);

            if (loadAllContent)
            {
                // Load the sky box
                skyBox = new SkyBox(ScreenManager.Game, ScreenManager.Content, camera);

                // Set up the terrain parameters
                TerrainQuadTreeParameters parameters = new TerrainQuadTreeParameters();

                parameters.HeightMapName = "Content\\Textures\\Heightmap";
                parameters.LayerMap0Name = "Content\\Textures\\grass01";
                parameters.LayerMap1Name = "Content\\Textures\\rock01";
                parameters.LayerMap2Name = "Content\\Textures\\snow01";
                parameters.GrassTextureName = "Content\\Textures\\grass";

                parameters.MaxHeight = GameOptions.TerrainMaxHeight;
                parameters.TerrainScale = GameOptions.TerrainScale;

                parameters.MaxScreenSpaceError = 0.075f;
                parameters.ScreenHeight = ScreenManager.Game.GraphicsDevice.Viewport.Height;
                parameters.FieldOfView = camera.FieldOfView;

                parameters.GrassChunkDimension = 30;
                parameters.GrassChunkStarSeparation = 266.6f;
                parameters.GrassStartFadingInDistance = 4000.0f;
                parameters.GrassStopFadingInDistance = 3900.0f;

                parameters.WindStrength = 100.0f;
                parameters.WindDirection = new Vector4(-1.0f, 0.0f, 0.0f, 0.0f);

                parameters.DoPreprocessing = true;

                parameters.ComputePerspectiveScalingFactor();

                terrain = new TerrainQuadTree(ScreenManager.Game, ScreenManager.Content, parameters);

                // Iniialize the water manager
                waterManager = new WaterManager(ScreenManager.Game, GameOptions.WaterHeight);
            }
        }