Exemplo n.º 1
0
        /// <summary>
        /// Loads the game content
        /// </summary>
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // Hides the mouse
            IsMouseVisible = false;

            // Set fog values
            GraphicsDevice.Parameters.Set(FogEffectKeys.fogNearPlaneZ, 100f);
            GraphicsDevice.Parameters.Set(FogEffectKeys.fogFarPlaneZ, 160f);

            // Create the Atmosphere lighting
            Atmosphere = AtmosphereBuilder.Generate(GraphicsDevice, EffectSystem);
            CreateSunLight();

            // Lights
            EnviromentLight1 = CreateDirectLight(new Vector3(-1, -1, -1), new Color3(1, 1, 1), .3f);
            EnviromentLight2 = CreateDirectLight(new Vector3(1, 1, 1), new Color3(1, 1, 1), .3f);

            // Create the pipeline
            CreatePipeline();
            CreateCursor();

            // Entities
            LoadTerrain();
            LoadCamera();

            // Scripts
            Script.Add(MovementScript);
            Script.Add(RenderChunksScript);
            Script.Add(BuildTerrain);
            Script.Add(LightCycleScript);
        }
Exemplo n.º 2
0
        public static AtmosphereData Generate(GraphicsDevice device, EffectSystem effectSystem)
        {
            if (VirtualFileSystem.ApplicationCache.FileExists("atmosphere"))
            {
                using (var stream = VirtualFileSystem.ApplicationCache.OpenStream("atmosphere", VirtualFileMode.Open, VirtualFileAccess.Read))
                {
                    return(AtmosphereData.Load(device, stream));
                }
            }
            else
            {
                using (var builder = new AtmosphereBuilder(device, effectSystem))
                {
                    builder.Generate(device);

                    using (var stream = VirtualFileSystem.ApplicationCache.OpenStream("atmosphere", VirtualFileMode.Create, VirtualFileAccess.Write))
                    {
                        builder.Data.Save(stream);
                    }

                    return(builder.Data);
                }
            }
        }