Пример #1
0
        /// <summary>
        /// Handles the Click event of the itemRemoveNode control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void itemRemoveNode_Click(object sender, EventArgs e)
        {
            // If we right click, then drop the node.
            if (GorgonDialogs.ConfirmBox(ParentForm, Resources.GORFNT_DLG_BRUSH_GRAD_DROP_NODE) == ConfirmationResult.No)
            {
                return;
            }

            try
            {
                _handles.Remove(_selectedNode);
                SortWeightHandles();

                _selectedNode = null;

                OnChanged();
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(ParentForm, ex);
            }
            finally
            {
                DrawControls();
                DrawGradientDisplay();
                DrawSelectedColor();
                DrawPreview();
                ValidateControls();
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the Click event of the buttonClearNodes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void buttonClearNodes_Click(object sender, EventArgs e)
        {
            try
            {
                if (GorgonDialogs.ConfirmBox(ParentForm, Resources.GORFNT_DLG_BRUSH_NODES_CLEAR) == ConfirmationResult.No)
                {
                    return;
                }

                _handles = new List <WeightHandle>
                {
                    new WeightHandle(0, Color.Black, 0),
                    new WeightHandle(1, Color.White, 1)
                };

                _selectedNode = null;

                OnChanged();
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(ParentForm, ex);
            }
            finally
            {
                DrawGradientDisplay();
                DrawControls();
                DrawSelectedColor();
                DrawPreview();
                ValidateControls();
            }
        }
    public override void Start()
    {
        Chad = gameObject.GetComponent <ChadControls>();
        if (Skin != null)
        {
            if (Animations.Count > 0)
            {
                foreach (var state in Animations)
                {
                    if (state.Key != ChadControls.STATE.RAGDOLL) // No Ragdoll animations
                    {
                        BlendNode newBlendNode = new BlendNode(Skin.model);
                        for (int i = 0; i < state.Value.Count; ++i)
                        {
                            if (state.Key == ChadControls.STATE.THROWING)
                            {
                                state.Value[i].Node = newBlendNode.appendNode(state.Value[i].Animation, false);
                            }
                            else
                            {
                                state.Value[i].Node = newBlendNode.appendNode(state.Value[i].Animation, true);
                            }
                        }
                        BlendNodes.Add(state.Key, newBlendNode);

                        WeightHandle newWeightHandle = BlendNodes[state.Key].generateWeightHandle();
                        WeightHandles.Add(state.Key, newWeightHandle);
                    }
                }

                WeightHandles[ChadControls.STATE.CHADING].setWeight(0, new WeightTripple(1f));
                Skin.setBlendTreeNode(BlendNodes[ChadControls.STATE.CHADING]);
            }
        }
    }
    public override void Start()
    {
        //Blabla initial setup

        BlendNode blend = new BlendNode(skinn.model);

        foreach (var node in nodes)
        {
            blend.appendNode(node.animation, true);
        }
        weight = blend.generateWeightHandle();
        skinn.setBlendTreeNode(blend);
    }
Пример #5
0
        /// <summary>
        /// Handles the MouseDown event of the panelBrushPreview control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void panelGradControls_MouseDown(object sender, MouseEventArgs e)
        {
            if (_nodeDrag)
            {
                return;
            }

            try
            {
                // Select nodes that are not the static nodes first.
                WeightHandle selectedNode = _handles.FirstOrDefault(item =>
                                                                    item.HitTest(e.Location, panelGradControls.ClientRectangle) &&
                                                                    item.Index > 0 && item.Index < _handles.Count - 1);


                _selectedNode = selectedNode ?? _handles.FirstOrDefault(item =>
                                                                        item.HitTest(e.Location, panelGradControls.ClientRectangle) &&
                                                                        (item.Index == 0 || item.Index <= _handles.Count - 1));

                switch (e.Button)
                {
                case MouseButtons.Left:
                    if (_selectedNode == null)
                    {
                        return;
                    }

                    _nodeDragOffset = _selectedNode.GetDragOffset(e.Location, panelGradControls.ClientRectangle);
                    _nodeDrag       = ((_selectedNode.Index > 0) && (_selectedNode.Index < _handles.Count - 1));
                    break;

                case MouseButtons.Right:
                    ValidateControls();
                    popupNodeEdit.Show(panelGradControls, e.Location);
                    break;
                }
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(ParentForm, ex);
            }
            finally
            {
                ValidateControls();
                DrawSelectedColor();
                DrawControls();
            }
        }
Пример #6
0
    private void OnSceneGUI()
    {
        weightHandle = (WeightHandle)target;

        if (weightHandle == null || weightHandle.weights.Count == 0)
        {
            return;
        }

        Handles.color = Color.red;

        for (int i = 0; i < weightHandle.textPositions.Count; i++)
        {
            Handles.Label(weightHandle.textPositions[i], weightHandle.weights[i].ToString("0.00") + " meter(s)");
        }
    }
Пример #7
0
        /// <summary>
        /// Handles the MouseDoubleClick event of the panelBrushPreview control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void panelGradControls_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            WeightHandle selectedHandle = null;

            foreach (WeightHandle handle in _handles)
            {
                if (handle.HitTest(e.Location, panelGradControls.ClientRectangle))
                {
                    selectedHandle = handle;
                }
            }

            if (selectedHandle == null)
            {
                return;
            }

            GetNodeColor(selectedHandle);
        }
Пример #8
0
        /// <summary>
        /// Handles the Click event of the itemDuplicateNode control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void itemDuplicateNode_Click(object sender, EventArgs e)
        {
            try
            {
                if ((_selectedNode == null) ||
                    (_controlPanelImage == null))
                {
                    return;
                }

                float weightPosition = _selectedNode.Weight * _controlPanelImage.Width;

                if (weightPosition < _controlPanelImage.Width - 16)
                {
                    weightPosition = (weightPosition + 16.0f) / _controlPanelImage.Width;
                }
                else
                {
                    weightPosition = (weightPosition - 16.0f) / _controlPanelImage.Width;
                }

                _selectedNode = new WeightHandle(weightPosition, _selectedNode.Color, -1);
                _handles.Add(_selectedNode);
                SortWeightHandles();

                OnChanged();
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(ParentForm, ex);
            }
            finally
            {
                DrawControls();
                DrawGradientDisplay();
                DrawSelectedColor();
                DrawPreview();
                ValidateControls();
            }
        }
Пример #9
0
        /// <summary>
        /// Handles the MouseDoubleClick event of the panelGradientDisplay control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void panelGradientDisplay_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (_gradDisplayImage == null)
            {
                return;
            }

            try
            {
                float weight = (float)e.X / (panelGradientDisplay.ClientSize.Width - 1);

                // If we're sharing a weight with another node, then don't add it.
                if (_handles.Any(item => item.Weight.EqualsEpsilon(weight)))
                {
                    return;
                }

                // Get the color of the pixel at the selected point.
                GorgonColor color = _gradientImage.GetPixel(e.X, panelGradientDisplay.ClientSize.Height / 2);

                _selectedNode = new WeightHandle(weight, color, -1);
                _handles.Add(_selectedNode);
                SortWeightHandles();

                OnChanged();
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(ParentForm, ex);
            }
            finally
            {
                DrawControls();
                DrawGradientDisplay();
                DrawPreview();
                DrawSelectedColor();
                ValidateControls();
            }
        }
Пример #10
0
        /// <summary>
        /// Function to allow for picking of the handle color.
        /// </summary>
        /// <param name="selectedHandle">Selected handle.</param>
        private void GetNodeColor(WeightHandle selectedHandle)
        {
            ColorPickerDialog color = null;

            try
            {
                color = new ColorPickerDialog
                {
                    SelectedColor = selectedHandle.Color,
                    OldColor      = selectedHandle.Color,
                    AlphaEnabled  = true
                };

                if (color.ShowDialog(ParentForm) != DialogResult.OK)
                {
                    return;
                }

                selectedHandle.Color = color.SelectedColor;
                OnChanged();
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(ParentForm, ex);
            }
            finally
            {
                DrawControls();
                DrawGradientDisplay();
                DrawPreview();
                DrawSelectedColor();

                if (color != null)
                {
                    color.Dispose();
                }
            }
        }