Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            QuadTreeNode.CalculateIndexData(GraphicsDevice);

            _oldMouseState    = Mouse.GetState();
            _oldKeyboardState = Keyboard.GetState();

            int            worldSeed               = 1;
            NoiseProvider  mainNoiseProvider       = new NoiseProvider(worldSeed, 4, 0.3f, 6000);
            NoiseProvider  modulationNoiseProvider = new NoiseProvider(worldSeed + 1, 2, 0.2f, 50000);
            DirectionLight light      = new DirectionLight(Vector3.Normalize(new Vector3(0, -0.3f, 1)), 1, 0.1f);
            Atmosphere     atmosphere = new Atmosphere(150000, new Color(0.3f, 0.5f, 0.9f));

            _world = new World(GraphicsDevice, new TerrainHeightProvider(mainNoiseProvider, modulationNoiseProvider), 1737000, light, new Random(worldSeed), atmosphere);

            Matrix cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), GraphicsDevice.Viewport.AspectRatio, CentredCamera.NearPlaneDistance, CentredCamera.FarPlaneDistance);

            _camera = new CentredCamera()
            {
                Position         = new Vector3Double(0, _world.Radius + 3000, 0),
                Orientation      = Matrix.Identity,
                ProjectionMatrix = cameraProjectionMatrix,
                MovementSpeed    = 1000
            };

            _starTexture = new Texture2D(GraphicsDevice, 1, 1);
            _starTexture.SetData(new Color[] { Color.White });

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            base.Initialize();
        }