Exemple #1
0
 /// <summary>
 /// Creates the configuration controls of this component.
 /// </summary>
 public static void AddControls(ModelFilter modelFilter, ClipControl owner)
 {
     // Model
     var model = CommonControls.AssetSelector<Model>("Model", owner, modelFilter, "Model");
     model.Top = 10;
     owner.AdjustHeightFromChildren();
 } // AddControls
Exemple #2
0
 /// <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
Exemple #4
0
 /// <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
Exemple #7
0
        } // RemoveGameObjectControlsFromInspector

        /// <summary>
        /// Remove User Interface controls from a clip control.
        /// </summary>
        public static void RemoveGameObjectControls(ClipControl control)
        {
            control.RemoveControlsFromClientArea();
        } // RemoveGameObjectControls
Exemple #8
0
        } // 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