コード例 #1
0
ファイル: Program.cs プロジェクト: crissian/planets
        static void Main()
        {
            Scene scene = new Scene();
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Start();
            GameTime time = new GameTime();
            MessagePump.Run(scene.GraphicsEngine.Form, () =>
            {
                watch.Reset();
                watch.Start();

                int frameTime = 1;
                if (time.LastFrameElapsedTime.TotalMilliseconds < frameTime)
                    System.Threading.Thread.Sleep((int)(frameTime - time.LastFrameElapsedTime.TotalMilliseconds));
                scene.Update(time);
                scene.Draw();

                watch.Stop();
                time.LastFrameElapsedTime = watch.Elapsed;
                time.TotalGameTime = time.TotalGameTime + watch.Elapsed;

            });
            scene.Dispose();

            // TODO ce soir
            // frustrum culling pour la planète.
            // backface culling pour le ground.
            //
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: crissian/planets
        /// <summary>
        /// Crée l'instance unique de la scène.
        /// </summary>
        public Scene()
        {
            if (Instance != null)
                throw new InvalidOperationException();

            Instance = this;

            FPSCounter = new Debug.Profiling.FPSCounter();
            GraphicsEngine = new World.Graphics.Engine();
            ThreadPool = new Util.ThreadPool();
            Planet = new World.Planet();
            Camera = new World.Cameras.FirstPersonCamera();
            Camera.Position = new Vector3(20, -5, -20);
            Camera.RotateSide((float)Math.PI);

            // Positionnement des lumières.
            GraphicsEngine.LoadFX();
            Vector3 direction = new Vector3(0.57735f, -0.57735f, 0.57735f);
            direction.Normalize();
            GraphicsEngine.BasicEffect.DirLight = new World.Graphics.DirectionalLight()
            {
                Ambient = new Color4(0.2f, 0.2f, 0.2f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(0.5f, 0.5f, 0.5f),
                Direction = direction

            };
            GraphicsEngine.BasicEffect.PtLight = new World.Graphics.PointLight()
            {
                Ambient = new Color4(0.2f, 0.2f, 0.2f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(1f, 1f, 1f),
                Attenuation = new Vector3(0.1f, 0f, 0f),
                Range = 100f,
                Position = - GraphicsEngine.BasicEffect.DirLight.Direction * 1
            };
            GraphicsEngine.WaterEffect.DirLight = GraphicsEngine.BasicEffect.DirLight;
            GraphicsEngine.AtmosphereEffect.DirLight = GraphicsEngine.BasicEffect.DirLight;
            GraphicsEngine.BasicEffect.Texture = Ressources.ShaderRessourceViewCache.Get("Textures\\tex_3.jpg");
            GraphicsEngine.BasicEffect.Texture2 = Ressources.ShaderRessourceViewCache.Get("Textures\\tex_2.jpg");
            GraphicsEngine.BasicEffect.Texture3 = Ressources.ShaderRessourceViewCache.Get("Textures\\tex_1.jpg");
            GraphicsEngine.WaterEffect.Texture = Ressources.ShaderRessourceViewCache.Get("Textures\\tex_4.jpg");

            DiagnosisWindow = new Debug.DiagnosisWindow();
            DiagnosisWindow.Show();
            Input.ModuleInit();
        }