Пример #1
0
        /* ---------------------------------------------------------------------------------
         * Methods
         * -------------------------------------------------------------------------------*/
        #region Methods
        /// <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();
        }
Пример #2
0
        /// <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();
        }