예제 #1
0
        /// <summary>
        /// Read texture data and bg color from environments
        /// </summary>
        public void HandleEnvironments(RenderEnvironment.Usage usage)
        {
            SimulatedEnvironment simenv;

            switch (usage)
            {
            case RenderEnvironment.Usage.Background:

                if (BackgroundEnvironment != null)
                {
                    simenv = BackgroundEnvironment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        BgColor = simenv.BackgroundColor;
                    }
                    BitmapConverter.EnvironmentBitmapFromEvaluator(BackgroundEnvironment, BgTexture, Gamma);
                }
                else
                {
                    BgColor = Color.Empty;
                    BgTexture.Clear();
                }
                break;

            case RenderEnvironment.Usage.Skylighting:
                if (SkylightEnvironment != null)
                {
                    simenv = SkylightEnvironment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        SkyColor = simenv.BackgroundColor;
                    }
                    BitmapConverter.EnvironmentBitmapFromEvaluator(SkylightEnvironment, SkyTexture, Gamma);
                }
                else
                {
                    SkyColor = Color.Empty;
                    SkyTexture.Clear();
                }
                break;

            case RenderEnvironment.Usage.ReflectionAndRefraction:
                if (ReflectionEnvironment != null)
                {
                    simenv = ReflectionEnvironment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        ReflectionColor = simenv.BackgroundColor;
                    }
                    BitmapConverter.EnvironmentBitmapFromEvaluator(ReflectionEnvironment, ReflectionTexture, Gamma);
                }
                else
                {
                    ReflectionColor = Color.Empty;
                    ReflectionTexture.Clear();
                }
                break;
            }
        }
        /// <summary>
        /// Read texture data and bg color from environments
        /// </summary>
        public void HandleEnvironments(RenderEnvironment.Usage usage)
        {
            SimulatedEnvironment simenv;

            switch (usage)
            {
            case RenderEnvironment.Usage.Background:

                if (background_environment != null)
                {
                    simenv = background_environment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        bg_color = simenv.BackgroundColor;
                    }
                }
                else
                {
                    bg_color = Color.Empty;
                    bg.Clear();
                }
                BitmapConverter.EnvironmentBitmapFromEvaluator(background_environment, bg, Gamma, PlanarProjection);
                break;

            case RenderEnvironment.Usage.Skylighting:
                bool resampled = false;
                if (skylight_environment != null)
                {
                    simenv = skylight_environment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        sky_color = simenv.BackgroundColor;
                    }
                }
                else
                {
                    sky_color = Color.Empty;
                    sky.Clear();
                }
                if (!resampled)
                {
                    BitmapConverter.EnvironmentBitmapFromEvaluator(skylight_environment, sky, Gamma, false);
                }

                break;

            case RenderEnvironment.Usage.ReflectionAndRefraction:
                if (reflection_environment != null)
                {
                    simenv = reflection_environment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        refl_color = simenv.BackgroundColor;
                    }
                }
                else
                {
                    refl_color = Color.Empty;
                    refl.Clear();
                }
                BitmapConverter.EnvironmentBitmapFromEvaluator(reflection_environment, refl, Gamma, false);
                break;
            }
        }