示例#1
0
        /// <summary>
        /// Creates the configuration controls of this asset.
        /// </summary>
        public static void AddControls(HorizonBasedAmbientOcclusion asset, Window owner, ComboBox comboBoxResource)
        {
            GroupBox groupGeneral = CommonControls.Group("General", owner);
            
            #region Quality

            var quality = CommonControls.ComboBox("Quality", groupGeneral);
            // Add textures name
            quality.Items.Add("Low");
            quality.Items.Add("Middle");
            quality.Items.Add("High");
            // Events
            quality.ItemIndexChanged += delegate
            {
                switch (quality.ItemIndex)
                {
                    case 0: asset.Quality = HorizonBasedAmbientOcclusion.QualityType.LowQuality; break;
                    case 1: asset.Quality = HorizonBasedAmbientOcclusion.QualityType.MiddleQuality; break;
                    case 2: asset.Quality = HorizonBasedAmbientOcclusion.QualityType.HighQuality; break;
                }
            };
            quality.Draw += delegate
            {
                if (quality.ListBoxVisible)
                    return;
                switch (asset.Quality)
                {
                    case HorizonBasedAmbientOcclusion.QualityType.LowQuality    : quality.ItemIndex = 0; break;
                    case HorizonBasedAmbientOcclusion.QualityType.MiddleQuality : quality.ItemIndex = 1; break;
                    case HorizonBasedAmbientOcclusion.QualityType.HighQuality   : quality.ItemIndex = 2; break;
                }
            };

            #endregion

            var numberSteps = CommonControls.SliderNumericInt("Number Steps", groupGeneral, asset.NumberSteps, false, true, 0, 36, asset, "NumberSteps");
            var numberDirections = CommonControls.SliderNumericInt("Number Directions", groupGeneral, asset.NumberDirections, false, true, 0, 36, asset, "NumberDirections");
            var contrast = CommonControls.SliderNumericFloat("Contrast", groupGeneral, asset.Contrast, true, true, 0, 2, asset, "Contrast");
            var lineAttenuation = CommonControls.SliderNumericFloat("LineAttenuation", groupGeneral, asset.LineAttenuation, false, false, 0, 2, asset, "LineAttenuation");
            var radius = CommonControls.SliderNumericFloat("Radius", groupGeneral, asset.Radius, false, false, 0, 0.5f, asset, "Radius");
            var angleBias = CommonControls.SliderNumericFloat("AngleBias", groupGeneral, asset.AngleBias, false, false, 0, 90, asset, "AngleBias");

            groupGeneral.AdjustHeightFromChildren();

        } // AddControls       
        /// <summary>
        /// Creates the configuration controls of this asset.
        /// </summary>
        public static void AddControls(BlinnPhong asset, Window owner)
        {

            #region Diffuse

            GroupBox groupDiffuse = CommonControls.Group("Diffuse", owner);
            // Diffuse Color
            var sliderDiffuseColor = CommonControls.SliderColor("Diffuse Color", groupDiffuse, asset.DiffuseColor, asset, "DiffuseColor");
            // Diffuse Texture
            var assetSelectorDiffuseTexture = CommonControls.AssetSelector<Texture>("Diffuse Texture", groupDiffuse, asset, "DiffuseTexture");
            groupDiffuse.AdjustHeightFromChildren();

            #endregion

            #region Specular

            GroupBox groupSpecular = CommonControls.Group("Specular", owner);
            CheckBox checkBoxSpecularPowerFromTexture = null;
            // Specular Intensity
            var sliderSpecularIntensity = CommonControls.SliderNumericFloat("Specular Intensity", groupSpecular, asset.SpecularIntensity, false, true, 0, 2, asset, "SpecularIntensity");
            // Specular Power
            var sliderSpecularPower = CommonControls.SliderNumericFloat("Specular Power", groupSpecular, asset.SpecularPower, true, true, 0, 100, asset, "SpecularPower");
            sliderSpecularPower.Draw += delegate
            {
                sliderSpecularPower.Enabled = !checkBoxSpecularPowerFromTexture.Enabled || (checkBoxSpecularPowerFromTexture.Enabled && !checkBoxSpecularPowerFromTexture.Checked);
            };
            // Specular Texture
            var assetSelectorSpecularTexture = CommonControls.AssetSelector<Texture>("Specular Texture", groupSpecular, asset, "SpecularTexture");
            assetSelectorSpecularTexture.ItemIndexChanged += delegate { checkBoxSpecularPowerFromTexture.Enabled = asset.SpecularTexture != null; };
            // Specular Texture Power Enabled
            checkBoxSpecularPowerFromTexture = CommonControls.CheckBox("Use specular power from Texture", groupSpecular, asset.SpecularPowerFromTexture, 
                asset, "SpecularPowerFromTexture",
                "Indicates if the specular power will be read from the texture (the alpha channel of the specular texture) or from the specular power property.");
            // Reflection Texture
            var assetSelectorReflectionTexture = CommonControls.AssetSelector<TextureCube>("Reflection Texture", groupSpecular, asset, "ReflectionTexture");
            groupSpecular.AdjustHeightFromChildren();

            #endregion

            #region Normals

            GroupBox groupNormals = CommonControls.Group("Normals", owner);
            // Normal Texture
            var assetSelectorNormalTexture = CommonControls.AssetSelector<Texture>("Normal Texture", groupNormals, asset, "NormalTexture");
            // Parallax Enabled
            CheckBox checkBoxParallaxEnabled = CommonControls.CheckBox("Enabled", groupNormals, asset.ParallaxEnabled, asset, "ParallaxEnabled");
            // Parallax Threshold
            var sliderParallaxLodThreshold = CommonControls.SliderNumericInt("Parallax LOD Threshold", groupNormals,
                                             asset.ParallaxLodThreshold, false, false, 0, 10, asset, "ParallaxLodThreshold");
            // Parallax Minimum Number Samples
            var sliderParallaxMinimumNumberSamples = CommonControls.SliderNumericInt("Parallax Minimum Number Samples", groupNormals,
                                                     asset.ParallaxMinimumNumberSamples, false, false, 0, 50, asset, "ParallaxMinimumNumberSamples");
            // Parallax Maximum Number Samples
            var sliderParallaxMaximumNumberSamples = CommonControls.SliderNumericInt("Parallax Maximum Number Samples", groupNormals,
                                                     asset.ParallaxMaximumNumberSamples, false, false, 0, 500, asset, "ParallaxMaximumNumberSamples");
            // Parallax Maximum Number Samples
            var sliderParallaxHeightMapScale = CommonControls.SliderNumericFloat("Parallax Height Map Scale", groupNormals,
                                               asset.ParallaxHeightMapScale, false, false, 0, 1, asset, "ParallaxHeightMapScale");
            checkBoxParallaxEnabled.CheckedChanged += delegate
            {
                asset.ParallaxEnabled = checkBoxParallaxEnabled.Checked;
                sliderParallaxLodThreshold.Enabled = asset.ParallaxEnabled;
                sliderParallaxMinimumNumberSamples.Enabled = asset.ParallaxEnabled;
                sliderParallaxMaximumNumberSamples.Enabled = asset.ParallaxEnabled;
                sliderParallaxHeightMapScale.Enabled = asset.ParallaxEnabled;
            };
            assetSelectorNormalTexture.Draw += delegate
            {
                if (asset.NormalTexture == null)
                    checkBoxParallaxEnabled.Enabled = false;
            };
            groupNormals.AdjustHeightFromChildren();

            #endregion

        } // AddControls