/// <summary> /// Creates the configuration controls of this component. /// </summary> public static void AddControls(SpotLight spotLight, ClipControl owner) { // Enabled CheckBox enabled = CommonControls.CheckBox("Enabled", owner, spotLight.Enabled, spotLight, "Enabled"); enabled.Top = 10; // Intensity var intensity = CommonControls.SliderNumericFloat("Intensity", owner, spotLight.Intensity, false, true, 0, 100, spotLight, "Intensity"); // Diffuse Color var diffuseColor = CommonControls.SliderColor("Color", owner, spotLight.Color, spotLight, "Color"); // Range var range = CommonControls.SliderNumericFloat("Range", owner, spotLight.Range, false, true, 0, 500, spotLight, "Range"); // Inner Cone Angle var innerConeAngle = CommonControls.SliderNumericFloat("Inner Cone Angle", owner, spotLight.InnerConeAngle, false, false, 0, 175, spotLight, "InnerConeAngle"); // Outer Cone Angle var outerConeAngle = CommonControls.SliderNumericFloat("Outer Cone Angle", owner, spotLight.OuterConeAngle, false, false, 0, 175, spotLight, "OuterConeAngle"); // Mask Texture var maskTexture = CommonControls.AssetSelector<Texture>("Mask Texture", owner, spotLight, "LightMaskTexture"); // Shadow var shadow = CommonControls.AssetSelector<BasicShadow>("Shadow", owner, spotLight, "Shadow"); // Enabled enabled.CheckedChanged += delegate { intensity.Enabled = spotLight.Enabled; diffuseColor.Enabled = spotLight.Enabled; range.Enabled = spotLight.Enabled; innerConeAngle.Enabled = spotLight.Enabled; outerConeAngle.Enabled = spotLight.Enabled; maskTexture.Enabled = spotLight.Enabled; shadow.Enabled = spotLight.Enabled; }; owner.AdjustHeightFromChildren(); } // AddControls
/// <summary> /// Creates the configuration controls of this component. /// </summary> public static void AddControls(ModelRenderer modelRenderer, ClipControl owner) { // Enabled CheckBox enabled = CommonControls.CheckBox("Enabled", owner, modelRenderer.Enabled, modelRenderer, "Enabled"); enabled.Top = 10; // Material var material = CommonControls.AssetSelector<Material>("Material", owner, modelRenderer, "Material"); // Enabled enabled.CheckedChanged += delegate { material.Enabled = modelRenderer.Enabled; }; owner.AdjustHeightFromChildren(); } // AddControls
/// <summary> /// Creates the configuration controls of this asset. /// </summary> public static void AddControls(Shadow asset, Window owner, ComboBox comboBoxResource) { GroupBox groupGeneral = CommonControls.Group("General", owner); // Enabled CheckBox enabled = CommonControls.CheckBox("Enabled", groupGeneral, asset.Enabled, asset, "Enabled"); // Depth Bias var depthBias = CommonControls.SliderNumericFloat("Depth Bias", groupGeneral, asset.DepthBias, false, false, 0, 0.1f, asset, "DepthBias"); // Enabled enabled.CheckedChanged += delegate { depthBias.Enabled = asset.Enabled; }; groupGeneral.AdjustHeightFromChildren(); } // AddControls
/// <summary> /// Creates the configuration controls of this component. /// </summary> public static void AddControls(DirectionalLight directionalLight, ClipControl owner) { // Enabled CheckBox enabled = CommonControls.CheckBox("Enabled", owner, directionalLight.Enabled, directionalLight, "Enabled"); enabled.Top = 10; // Intensity var intensity = CommonControls.SliderNumericFloat("Intensity", owner, directionalLight.Intensity, false, true, 0, 100, directionalLight, "Intensity"); // Diffuse Color var diffuseColor = CommonControls.SliderColor("Color", owner, directionalLight.Color, directionalLight, "Color"); // Shadow var shadow = CommonControls.AssetSelector<Shadow>("Shadow", owner, directionalLight, "Shadow"); // Enabled enabled.CheckedChanged += delegate { intensity.Enabled = directionalLight.Enabled; diffuseColor.Enabled = directionalLight.Enabled; shadow.Enabled = directionalLight.Enabled; }; owner.AdjustHeightFromChildren(); } // AddControls
/// <summary> /// Creates the configuration controls of this component. /// </summary> public static void AddControls(PointLight pointLight, ClipControl owner) { // Enabled CheckBox enabled = CommonControls.CheckBox("Enabled", owner, pointLight.Enabled, pointLight, "Enabled"); enabled.Top = 10; // Intensity var intensity = CommonControls.SliderNumericFloat("Intensity", owner, pointLight.Intensity, false, true, 0, 100, pointLight, "Intensity"); // Diffuse Color var diffuseColor = CommonControls.SliderColor("Color", owner, pointLight.Color, pointLight, "Color"); // Range var range = CommonControls.SliderNumericFloat("Range", owner, pointLight.Range, false, true, 0, 500, pointLight, "Range"); // Enabled enabled.CheckedChanged += delegate { intensity.Enabled = pointLight.Enabled; diffuseColor.Enabled = pointLight.Enabled; range.Enabled = pointLight.Enabled; }; owner.AdjustHeightFromChildren(); } // AddControls
/// <summary> /// Creates the configuration controls of this component. /// </summary> public static void AddControls(Camera camera, ClipControl owner) { // Enabled var enabled = CommonControls.CheckBox("Enabled", owner, camera.Enabled, camera, "Enabled"); enabled.Top = 10; // Clear Color var clearColor = CommonControls.SliderColor("Clear Color", owner, camera.ClearColor, camera, "ClearColor"); var sky = CommonControls.AssetSelector<Sky>("Sky", owner, camera, "Sky"); var postProcess = CommonControls.AssetSelector<PostProcess>("Post Process", owner, camera, "PostProcess"); var ambientLight = CommonControls.AssetSelector<AmbientLight>("Ambient Light", owner, camera, "AmbientLight"); enabled.CheckedChanged += delegate { clearColor.Enabled = enabled.Checked; sky.Enabled = enabled.Checked; postProcess.Enabled = enabled.Checked; ambientLight.Enabled = enabled.Checked; }; owner.AdjustHeightFromChildren(); } // AddControls
/// <summary> /// Creates the configuration controls of this asset. /// </summary> public static void AddControls(CarPaint asset, Window owner) { #region Diffuse GroupBox groupDiffuse = CommonControls.Group("Diffuse", owner); // Base Paint Color var sliderBasePaintColor = CommonControls.SliderColor("Base Paint Color", groupDiffuse, asset.BasePaintColor, asset, "BasePaintColor"); // Second Base Paint Color var sliderSecondBasePaintColor = CommonControls.SliderColor("Second Base Paint Color", groupDiffuse, asset.SecondBasePaintColor, asset, "SecondBasePaintColor"); // Flake Layer Color 1 var sliderFlakeLayerColor1 = CommonControls.SliderColor("Third Base Paint Color", groupDiffuse, asset.ThirdBasePaintColor, asset, "ThirdBasePaintColor"); 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"); groupNormals.AdjustHeightFromChildren(); #endregion #region Flakes var groupFlakes = CommonControls.Group("Flakes", owner); // Flakes Color var sliderFlakesColor = CommonControls.SliderColor("Flake Color", groupFlakes, asset.FlakesColor, asset, "FlakesColor"); // Flakes Scale var sliderFlakesScale = CommonControls.SliderNumericFloat("Flakes Scale", groupFlakes, asset.FlakesScale, true, true, 0, 500, asset, "FlakesScale"); // Flakes Exponent var sliderFlakesExponent = CommonControls.SliderNumericFloat("Flakes Exponent", groupFlakes, asset.FlakesExponent, true, true, 0, 500, asset, "FlakesExponent"); // Flake Perturbation var sliderFlakePerturbation = CommonControls.SliderNumericFloat("Flake Perturbation", groupFlakes, asset.MicroflakePerturbation, false, false, -1, 1, asset, "MicroflakePerturbation"); // Flake Perturbation A var sliderFlakePerturbationA = CommonControls.SliderNumericFloat("Flake Perturbation A", groupFlakes, asset.MicroflakePerturbationA, false, false, 0, 1, asset, "MicroflakePerturbationA"); // Normal Perturbation var sliderNormalPerturbation = CommonControls.SliderNumericFloat("Normal Perturbation", groupFlakes, asset.NormalPerturbation, false, false, -1, 1, asset, "NormalPerturbation"); groupFlakes.AdjustHeightFromChildren(); #endregion } // 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
/// <summary> /// Creates the configuration controls of this asset. /// </summary> public static void AddControls(PostProcess asset, Window owner, ComboBox comboBoxResource) { #region Group Lens Exposure GroupBox groupToneMapping = CommonControls.Group("Tone Mapping", owner); // Lens Exposure var sliderLensExposure = CommonControls.SliderNumericFloat("Lens Exposure", groupToneMapping, asset.ToneMapping.LensExposure, true, true, -10, 10, asset.ToneMapping, "LensExposure"); // Auto Exposure Enabled CheckBox checkBoxAutoExposureEnabled = CommonControls.CheckBox("Auto Exposure Enabled", groupToneMapping, asset.ToneMapping.AutoExposureEnabled, asset.ToneMapping, "AutoExposureEnabled"); // Auto Exposure Adaptation Time Multiplier var sliderAutoExposureAdaptationTimeMultiplier = CommonControls.SliderNumericFloat("Adaptation Time Multiplier", groupToneMapping, asset.ToneMapping.AutoExposureAdaptationTimeMultiplier, false, true, 0, 10, asset.ToneMapping, "AutoExposureAdaptationTimeMultiplier"); // Auto Exposure Luminance Low Threshold var sliderAutoExposureLuminanceLowThreshold = CommonControls.SliderNumericFloat("Luminance Low Threshold", groupToneMapping, asset.ToneMapping.AutoExposureLuminanceLowThreshold, false, true, 0, 0.5f, asset.ToneMapping, "AutoExposureLuminanceLowThreshold"); // Auto Exposure Luminance High Threshold var sliderAutoExposureLuminanceHighThreshold = CommonControls.SliderNumericFloat("Luminance High Threshold", groupToneMapping, asset.ToneMapping.AutoExposureLuminanceHighThreshold, false, true, 0.5f, 20f, asset.ToneMapping, "AutoExposureLuminanceHighThreshold"); // Auto Exposure Enabled checkBoxAutoExposureEnabled.CheckedChanged += delegate { sliderLensExposure.Enabled = !asset.ToneMapping.AutoExposureEnabled; sliderAutoExposureAdaptationTimeMultiplier.Enabled = asset.ToneMapping.AutoExposureEnabled; sliderAutoExposureLuminanceLowThreshold.Enabled = asset.ToneMapping.AutoExposureEnabled; sliderAutoExposureLuminanceHighThreshold.Enabled = asset.ToneMapping.AutoExposureEnabled; }; #region Tone Mapping Curve ComboBox comboBoxToneMappingCurve = CommonControls.ComboBox("Tone Mapping Curve", groupToneMapping); comboBoxToneMappingCurve.Items.AddRange(new[] { "Filmic ALU", "Filmic Uncharted 2", "Duiker", "Reinhard", "Reinhard Modified", "Exponential", "Logarithmic", "Drago Logarithmic" }); comboBoxToneMappingCurve.ItemIndex = (int)asset.ToneMapping.ToneMappingFunction; comboBoxToneMappingCurve.ItemIndexChanged += delegate { asset.ToneMapping.ToneMappingFunction = (ToneMapping.ToneMappingFunctionEnumerate)comboBoxToneMappingCurve.ItemIndex; }; comboBoxToneMappingCurve.Draw += delegate { if (comboBoxToneMappingCurve.ListBoxVisible) return; comboBoxToneMappingCurve.ItemIndex = (int)asset.ToneMapping.ToneMappingFunction; }; #endregion // White Level var sliderWhiteLevel = CommonControls.SliderNumericFloat("White Level", groupToneMapping, asset.ToneMapping.ToneMappingWhiteLevel, false, true, 0f, 50f, asset.ToneMapping, "ToneMappingWhiteLevel"); // Luminance Saturation var sliderLuminanceSaturation = CommonControls.SliderNumericFloat("Luminance Saturation", groupToneMapping, asset.ToneMapping.ToneMappingLuminanceSaturation, false, true, 0f, 2f, asset.ToneMapping, "ToneMappingLuminanceSaturation"); // Drago Bias var sliderDragoBias = CommonControls.SliderNumericFloat("Drago Bias", groupToneMapping, asset.ToneMapping.DragoBias, false, true, 0f, 1f, asset.ToneMapping, "DragoBias"); // Shoulder Strength var sliderShoulderStrength = CommonControls.SliderNumericFloat("Shoulder Strength", groupToneMapping, asset.ToneMapping.Uncharted2ShoulderStrength, false, true, 0f, 1f, asset.ToneMapping, "Uncharted2ShoulderStrength"); // Linear Strength var sliderLinearStrength = CommonControls.SliderNumericFloat("Linear Strength", groupToneMapping, asset.ToneMapping.Uncharted2LinearStrength, false, true, 0f, 1f, asset.ToneMapping, "Uncharted2LinearStrength"); // Linear Angle var sliderLinearAngle = CommonControls.SliderNumericFloat("Linear Angle", groupToneMapping, asset.ToneMapping.Uncharted2LinearAngle, false, true, 0f, 3f, asset.ToneMapping, "Uncharted2LinearAngle"); // Toe Strength var sliderToeStrength = CommonControls.SliderNumericFloat("Toe Strength", groupToneMapping, asset.ToneMapping.Uncharted2ToeStrength, false, true, 0f, 1f, asset.ToneMapping, "Uncharted2ToeStrength"); // Toe Numerator var sliderToeNumerator = CommonControls.SliderNumericFloat("Toe Numerator", groupToneMapping, asset.ToneMapping.Uncharted2ToeNumerator, false, true, 0f, 0.1f, asset.ToneMapping, "Uncharted2ToeNumerator"); // Toe Denominator var sliderToeDenominator = CommonControls.SliderNumericFloat("Toe Denominator", groupToneMapping, asset.ToneMapping.Uncharted2ToeDenominator, false, true, 0f, 1f, asset.ToneMapping, "Uncharted2ToeDenominator"); // Linear White var sliderLinearWhite = CommonControls.SliderNumericFloat("Linear White", groupToneMapping, asset.ToneMapping.Uncharted2LinearWhite, false, true, 0f, 40f, asset.ToneMapping, "Uncharted2LinearWhite"); #region Sliders enabled? comboBoxToneMappingCurve.ItemIndexChanged += delegate { sliderWhiteLevel.Enabled = false; sliderLuminanceSaturation.Enabled = false; sliderDragoBias.Enabled = false; sliderShoulderStrength.Enabled = false; sliderLinearStrength.Enabled = false; sliderLinearAngle.Enabled = false; sliderToeStrength.Enabled = false; sliderToeNumerator.Enabled = false; sliderToeDenominator.Enabled = false; sliderLinearWhite.Enabled = false; if (asset.ToneMapping.ToneMappingFunction == ToneMapping.ToneMappingFunctionEnumerate.DragoLogarithmic) { sliderWhiteLevel.Enabled = true; sliderLuminanceSaturation.Enabled = true; sliderDragoBias.Enabled = true; } else if (asset.ToneMapping.ToneMappingFunction == ToneMapping.ToneMappingFunctionEnumerate.Exponential) { sliderWhiteLevel.Enabled = true; sliderLuminanceSaturation.Enabled = true; } else if (asset.ToneMapping.ToneMappingFunction == ToneMapping.ToneMappingFunctionEnumerate.FilmicUncharted2) { sliderShoulderStrength.Enabled = true; sliderLinearStrength.Enabled = true; sliderLinearAngle.Enabled = true; sliderToeStrength.Enabled = true; sliderToeNumerator.Enabled = true; sliderToeDenominator.Enabled = true; sliderLinearWhite.Enabled = true; } else if (asset.ToneMapping.ToneMappingFunction == ToneMapping.ToneMappingFunctionEnumerate.Logarithmic) { sliderWhiteLevel.Enabled = true; sliderLuminanceSaturation.Enabled = true; } else if (asset.ToneMapping.ToneMappingFunction == ToneMapping.ToneMappingFunctionEnumerate.Reinhard) { sliderLuminanceSaturation.Enabled = true; } else if (asset.ToneMapping.ToneMappingFunction == ToneMapping.ToneMappingFunctionEnumerate.ReinhardModified) { sliderWhiteLevel.Enabled = true; sliderLuminanceSaturation.Enabled = true; } }; #endregion groupToneMapping.AdjustHeightFromChildren(); #endregion #region Group Bloom GroupBox groupBloom = CommonControls.Group("Bloom", owner); // Enabled CheckBox checkBoxBloomEnabled = CommonControls.CheckBox("Enabled", groupBloom, asset.Bloom.Enabled, asset.Bloom, "Enabled", "The effect produces fringes (or feathers) of light around very bright objects in an image."); // Scale var sliderBloomScale = CommonControls.SliderNumericFloat("Scale", groupBloom, asset.Bloom.Scale, false, true, 0, 2, asset.Bloom, "Scale"); // Threshold var sliderBloomThreshold = CommonControls.SliderNumericFloat("Threshold", groupBloom, asset.Bloom.Threshold, false, true, 0, 10, asset.Bloom, "Threshold"); // Enabled checkBoxBloomEnabled.CheckedChanged += delegate { sliderBloomScale.Enabled = asset.Bloom.Enabled; sliderBloomThreshold.Enabled = asset.Bloom.Enabled; }; groupBloom.AdjustHeightFromChildren(); #endregion #region Group MLAA GroupBox groupMlaa = CommonControls.Group("MLAA", owner); // Enabled CheckBox checkBoxMlaaEnabled = CommonControls.CheckBox("Enabled", groupMlaa, asset.MLAA.Enabled, asset.MLAA, "Enabled", "Enables Morphological Antialiasing."); #region Edge Detection var comboBoxEdgeDetection = CommonControls.ComboBox("Edge Detection Type", groupMlaa, "Color: uses the color information. Good for texture and geometry aliasing. Depth: uses the depth buffer. Great for geometry aliasing. Both: the two at the same time. A little more costly with slightly better results."); // Add textures name comboBoxEdgeDetection.Items.Add("Both"); comboBoxEdgeDetection.Items.Add("Color"); comboBoxEdgeDetection.Items.Add("Depth"); // Events comboBoxEdgeDetection.ItemIndexChanged += delegate { switch (comboBoxEdgeDetection.ItemIndex) { case 0: asset.MLAA.EdgeDetection = MLAA.EdgeDetectionType.Both; break; case 1: asset.MLAA.EdgeDetection = MLAA.EdgeDetectionType.Color; break; case 2: asset.MLAA.EdgeDetection = MLAA.EdgeDetectionType.Depth; break; } }; comboBoxEdgeDetection.Draw += delegate { if (comboBoxEdgeDetection.ListBoxVisible) return; switch (asset.MLAA.EdgeDetection) { case MLAA.EdgeDetectionType.Both: comboBoxEdgeDetection.ItemIndex = 0; break; case MLAA.EdgeDetectionType.Color: comboBoxEdgeDetection.ItemIndex = 1; break; case MLAA.EdgeDetectionType.Depth: comboBoxEdgeDetection.ItemIndex = 2; break; } }; #endregion // Threshold Color var sliderMlaaColorThreshold = CommonControls.SliderNumericFloat("Color Threshold", groupMlaa, asset.MLAA.ThresholdColor, false, false, 0, 0.5f, asset.MLAA, "ThresholdColor"); // Threshold Depth var sliderMlaaDepthThreshold = CommonControls.SliderNumericFloat("Depth Threshold", groupMlaa, asset.MLAA.ThresholdDepth, false, false, 0, 0.5f, asset.MLAA, "ThresholdDepth"); checkBoxMlaaEnabled.CheckedChanged += delegate { comboBoxEdgeDetection.Enabled = asset.MLAA.Enabled; sliderMlaaColorThreshold.Enabled = asset.MLAA.Enabled; sliderMlaaDepthThreshold.Enabled = asset.MLAA.Enabled; }; groupMlaa.AdjustHeightFromChildren(); #endregion #region Group Film Grain GroupBox groupFilmGrain = CommonControls.Group("Film Grain", owner); // Enabled CheckBox checkBoxFilmGrainEnabled = CommonControls.CheckBox("Enabled", groupFilmGrain, asset.FilmGrain.Enabled, asset.FilmGrain, "Enabled", "Is the random optical texture of processed photographic film."); // Strength var sliderFilmgrainStrength = CommonControls.SliderNumericFloat("Strength", groupFilmGrain, asset.FilmGrain.Strength, false, true, 0, 0.5f, asset.FilmGrain, "Strength"); // Random Noise Strength var sliderFilmGrainRandomNoiseStrength = CommonControls.SliderNumericFloat("Random Noise Strength", groupFilmGrain, asset.FilmGrain.RandomNoiseStrength, false, false, 0, 5, asset.FilmGrain, "RandomNoiseStrength"); // Accentuate Dark Noise Power var sliderFilmGrainAccentuateDarkNoisePower = CommonControls.SliderNumericFloat("Accentuate Dark Noise Power", groupFilmGrain, asset.FilmGrain.AccentuateDarkNoisePower, false, false, 0, 10, asset.FilmGrain, "AccentuateDarkNoisePower"); checkBoxFilmGrainEnabled.CheckedChanged += delegate { sliderFilmgrainStrength.Enabled = asset.FilmGrain.Enabled; sliderFilmGrainRandomNoiseStrength.Enabled = asset.FilmGrain.Enabled; sliderFilmGrainAccentuateDarkNoisePower.Enabled = asset.FilmGrain.Enabled; }; groupFilmGrain.AdjustHeightFromChildren(); #endregion #region Group Adjust Levels GroupBox groupAdjustLevels = CommonControls.Group("Adjust Levels", owner); // Enabled CheckBox checkBoxAdjustLevelsEnabled = CommonControls.CheckBox("Enabled", groupAdjustLevels, asset.AdjustLevels.Enabled, asset.AdjustLevels, "Enabled", "Adjust color levels just like Photoshop."); // Input Black var sliderAdjustLevelsInputBlack = CommonControls.SliderNumericFloat("Input Black", groupAdjustLevels, asset.AdjustLevels.InputBlack, false, false, 0, 0.9f, asset.AdjustLevels, "InputBlack"); // Input White var sliderAdjustLevelsInputWhite = CommonControls.SliderNumericFloat("Input White", groupAdjustLevels, asset.AdjustLevels.InputWhite, false, false, 0.1f, 1f, asset.AdjustLevels, "InputWhite"); // Input Gamma var sliderAdjustLevelsInputGamma = CommonControls.SliderNumericFloat("Input Gamma", groupAdjustLevels, asset.AdjustLevels.InputGamma, false, false, 0.01f, 9.99f, asset.AdjustLevels, "InputGamma"); // Output Black var sliderAdjustLevelsOutputBlack = CommonControls.SliderNumericFloat("Output Black", groupAdjustLevels, asset.AdjustLevels.OutputBlack, false, false, 0, 1, asset.AdjustLevels, "OutputBlack"); // Output White var sliderAdjustLevelsOutputWhite = CommonControls.SliderNumericFloat("Output White", groupAdjustLevels, asset.AdjustLevels.OutputWhite, false, false, 0, 1, asset.AdjustLevels, "OutputWhite"); checkBoxAdjustLevelsEnabled.CheckedChanged += delegate { sliderAdjustLevelsInputBlack.Enabled = asset.AdjustLevels.Enabled; sliderAdjustLevelsInputWhite.Enabled = asset.AdjustLevels.Enabled; sliderAdjustLevelsInputGamma.Enabled = asset.AdjustLevels.Enabled; sliderAdjustLevelsOutputBlack.Enabled = asset.AdjustLevels.Enabled; sliderAdjustLevelsOutputWhite.Enabled = asset.AdjustLevels.Enabled; }; groupAdjustLevels.AdjustHeightFromChildren(); #endregion #region Group Color Correction GroupBox groupColorCorrection = CommonControls.Group("Color Correction", owner); // Enabled CheckBox checkBoxColorCorrectionEnabled = CommonControls.CheckBox("Enabled", groupColorCorrection, asset.ColorCorrection.Enabled, asset.ColorCorrection, "Enabled"); // First Lookup Table var assetCreatorFirstLookupTable = CommonControls.AssetSelector<LookupTable>("First Lookup Table", groupColorCorrection, asset.ColorCorrection, "FirstLookupTable"); // Second Lookup Table var assetCreatorSecondLookupTable = CommonControls.AssetSelector<LookupTable>("Second Lookup Table", groupColorCorrection, asset.ColorCorrection, "SecondLookupTable"); assetCreatorSecondLookupTable.Draw += delegate { assetCreatorSecondLookupTable.Enabled = asset.ColorCorrection.FirstLookupTable != null && checkBoxColorCorrectionEnabled.Checked; }; // Lerp Original Color Amount var sliderLerpOriginalColorAmount = CommonControls.SliderNumericFloat("Lerp Original Color", groupColorCorrection, asset.ColorCorrection.LerpOriginalColorAmount, false, false, 0, 1, asset.ColorCorrection, "LerpOriginalColorAmount"); sliderLerpOriginalColorAmount.Draw += delegate { sliderLerpOriginalColorAmount.Enabled = asset.ColorCorrection.FirstLookupTable != null && checkBoxColorCorrectionEnabled.Checked; }; // Lerp Lookup Tables Amount var sliderLerpLookupTablesAmount = CommonControls.SliderNumericFloat("Lerp Lookup Tables", groupColorCorrection, asset.ColorCorrection.LerpLookupTablesAmount, false, false, 0, 1, asset.ColorCorrection, "LerpLookupTablesAmount"); sliderLerpLookupTablesAmount.Draw += delegate { sliderLerpLookupTablesAmount.Enabled = asset.ColorCorrection.SecondLookupTable != null && asset.ColorCorrection.FirstLookupTable != null && checkBoxColorCorrectionEnabled.Checked; }; checkBoxColorCorrectionEnabled.CheckedChanged += delegate { assetCreatorFirstLookupTable.Enabled = asset.ColorCorrection.Enabled; }; groupColorCorrection.AdjustHeightFromChildren(); #endregion } // AddControls
} // AddGameObjectControlsToInspector /// <summary> /// Add game object component controls to the specified control. /// </summary> public static void AddGameObjectControls(GameObject gameObject, ClipControl control) { if (gameObject == null) { throw new ArgumentNullException("gameObject"); } if (control == null) { throw new ArgumentNullException("control"); } #region Name var nameLabel = new Label { Parent = control, Text = "Name", Left = 10, Top = 10, Height = 25, Alignment = Alignment.BottomCenter, }; var nameTextBox = new TextBox { Parent = control, Width = control.ClientWidth - nameLabel.Width - 12, Text = gameObject.Name, Left = 60, Top = 10, Anchor = Anchors.Left | Anchors.Top | Anchors.Right }; var lastSetName = gameObject.Name; nameTextBox.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.Key == Keys.Enter) { string oldName = gameObject.Name; gameObject.Name = nameTextBox.Text; //asset.SetUniqueName(window.AssetName); if (oldName != gameObject.Name) { nameTextBox.Text = gameObject.Name; // The name could be change if the name entered was not unique. gameObject.Name = oldName; // This is done for the undo. using (Transaction.Create()) { // Apply the command and store for the undo feature. ActionManager.SetProperty(gameObject, "Name", nameTextBox.Text); ActionManager.CallMethod(// Redo UserInterfaceManager.Invalidate, // Undo UserInterfaceManager.Invalidate); } } lastSetName = gameObject.Name; } }; nameTextBox.FocusLost += delegate { string oldName = gameObject.Name; gameObject.Name = nameTextBox.Text; //asset.SetUniqueName(window.AssetName); if (oldName != gameObject.Name) { nameTextBox.Text = gameObject.Name; // The name could be change if the name entered was not unique. gameObject.Name = oldName; // This is done for the undo. using (Transaction.Create()) { // Apply the command and store for the undo feature. ActionManager.SetProperty(gameObject, "Name", nameTextBox.Text); ActionManager.CallMethod(// Redo UserInterfaceManager.Invalidate, // Undo UserInterfaceManager.Invalidate); } lastSetName = gameObject.Name; } }; nameTextBox.Draw += delegate { if (lastSetName != gameObject.Name) { lastSetName = gameObject.Name; nameTextBox.Text = gameObject.Name; } }; #endregion #region Layer var comboBoxLayer = CommonControls.ComboBox("", control); comboBoxLayer.MaxItemsShow = 30; comboBoxLayer.ItemIndexChanged += delegate { // Store new asset. if (gameObject.Layer.Number != comboBoxLayer.ItemIndex) // If it change { using (Transaction.Create()) { // Apply the command and store for the undo feature. ActionManager.SetProperty(gameObject, "Layer", Layer.GetLayerByNumber(comboBoxLayer.ItemIndex)); ActionManager.CallMethod(// Redo UserInterfaceManager.Invalidate, // Undo UserInterfaceManager.Invalidate); } } }; comboBoxLayer.Draw += delegate { // Add layer names here because someone could change them. comboBoxLayer.Items.Clear(); for (int i = 0; i < 30; i++) { comboBoxLayer.Items.Add(Layer.GetLayerByNumber(i).Name); } if (comboBoxLayer.ListBoxVisible) { return; } // Identify current index comboBoxLayer.ItemIndex = gameObject.Layer.Number; }; #endregion ) #region Active CheckBox active = CommonControls.CheckBox("Active", control, gameObject.Active, gameObject, "Active"); active.Top = comboBoxLayer.Top + 5; #endregion if (gameObject is GameObject3D) { GameObject3D gameObject3D = (GameObject3D)gameObject; #region Transform Component var panel = CommonControls.PanelCollapsible("Transform", control, 0); // Position var vector3BoxPosition = CommonControls.Vector3Box("Position", panel, gameObject3D.Transform.LocalPosition, gameObject3D.Transform, "LocalPosition"); // Orientation. // This control has too many special cases, I need to do it manually. Vector3 initialValue = new Vector3(gameObject3D.Transform.LocalRotation.GetYawPitchRoll().Y * 180 / (float)Math.PI, gameObject3D.Transform.LocalRotation.GetYawPitchRoll().X * 180 / (float)Math.PI, gameObject3D.Transform.LocalRotation.GetYawPitchRoll().Z * 180 / (float)Math.PI); initialValue.X = (float)Math.Round(initialValue.X, 4); initialValue.Y = (float)Math.Round(initialValue.Y, 4); initialValue.Z = (float)Math.Round(initialValue.Z, 4); var vector3BoxRotation = CommonControls.Vector3Box("Rotation", panel, initialValue); vector3BoxRotation.ValueChanged += delegate { Vector3 propertyValue = new Vector3(gameObject3D.Transform.LocalRotation.GetYawPitchRoll().Y * 180 / (float)Math.PI, gameObject3D.Transform.LocalRotation.GetYawPitchRoll().X * 180 / (float)Math.PI, gameObject3D.Transform.LocalRotation.GetYawPitchRoll().Z * 180 / (float)Math.PI); // Round to avoid precision problems. propertyValue.X = (float)Math.Round(propertyValue.X, 4); propertyValue.Y = (float)Math.Round(propertyValue.Y, 4); propertyValue.Z = (float)Math.Round(propertyValue.Z, 4); // I compare the value of the transform property rounded to avoid a precision mismatch. if (propertyValue != vector3BoxRotation.Value) { using (Transaction.Create()) { Quaternion newValue = Quaternion.CreateFromYawPitchRoll(vector3BoxRotation.Value.Y * (float)Math.PI / 180, vector3BoxRotation.Value.X * (float)Math.PI / 180, vector3BoxRotation.Value.Z * (float)Math.PI / 180); ActionManager.SetProperty(gameObject3D.Transform, "LocalRotation", newValue); ActionManager.CallMethod(// Redo UserInterfaceManager.Invalidate, // Undo UserInterfaceManager.Invalidate); } } }; vector3BoxRotation.Draw += delegate { Vector3 localRotationDegrees = new Vector3(gameObject3D.Transform.LocalRotation.GetYawPitchRoll().Y * 180 / (float)Math.PI, gameObject3D.Transform.LocalRotation.GetYawPitchRoll().X * 180 / (float)Math.PI, gameObject3D.Transform.LocalRotation.GetYawPitchRoll().Z * 180 / (float)Math.PI); // Round to avoid precision problems. localRotationDegrees.X = (float)Math.Round(localRotationDegrees.X, 4); localRotationDegrees.Y = (float)Math.Round(localRotationDegrees.Y, 4); localRotationDegrees.Z = (float)Math.Round(localRotationDegrees.Z, 4); if (vector3BoxRotation.Value != localRotationDegrees) { vector3BoxRotation.Value = localRotationDegrees; } }; // Scale var vector3BoxScale = CommonControls.Vector3Box("Scale", panel, gameObject3D.Transform.LocalScale, gameObject3D.Transform, "LocalScale"); #endregion #region Camera if (gameObject3D.Camera != null) { var panelCamera = CommonControls.PanelCollapsible("Camera", control, 0); CameraControls.AddControls(gameObject3D.Camera, panelCamera); } #endregion #region Model Filter if (gameObject3D.ModelFilter != null) { var panelModelFilter = CommonControls.PanelCollapsible("Model Filter", control, 0); ModelFilterControls.AddControls(gameObject3D.ModelFilter, panelModelFilter); } #endregion #region Model Renderer if (gameObject3D.ModelRenderer != null) { var panelModelRenderer = CommonControls.PanelCollapsible("Model Renderer", control, 0); ModelRendererControls.AddControls(gameObject3D.ModelRenderer, panelModelRenderer); } #endregion #region Light if (gameObject3D.Light != null) { if (gameObject3D.SpotLight != null) { var panelSpotLight = CommonControls.PanelCollapsible("Spot Light", control, 0); SpotLightControls.AddControls(gameObject3D.SpotLight, panelSpotLight); } if (gameObject3D.PointLight != null) { var panelPointLight = CommonControls.PanelCollapsible("Point Light", control, 0); PointLightControls.AddControls(gameObject3D.PointLight, panelPointLight); } if (gameObject3D.DirectionalLight != null) { var panelDirectionalLight = CommonControls.PanelCollapsible("Directional Light", control, 0); DirectionalLightControls.AddControls(gameObject3D.DirectionalLight, panelDirectionalLight); } } #endregion } else { GameObject2D gameObject2D = (GameObject2D)gameObject; } } // AddGameObjectControls