Exemple #1
0
        /// <summary>
        /// Renders this spline's Curves into the Scene View.  Should only be called from OnSceneGUI.
        /// </summary>
        /// <param name="displayTangents">If true, also renders tangent lines.</param>
        public void RenderCurvesInSceneView(bool displayTangents = false)
        {
            int segCount = GetCurveCount();

            if (segCount <= 0)
            {
                return;
            }

            for (int i = segCount - 1; i >= 0; i--)
            {
                BezierCurve seg = GetCurve(i);
                DisplayCurveInSceneView(seg);

                UnityEditor.Handles.color = Color.green;

                //Display Tangents
                if (displayTangents)
                {
                    if (seg.GetStartPoint().tangentForward)
                    {
                        Vector3 p0 = transform.TransformPoint(seg.GetStartPoint().point);
                        Vector3 p1 = p0 + transform.TransformVector(seg.GetStartPoint().tangentForward.point);
                        UnityEditor.Handles.DrawLine(p0, p1);
                    }
                    if (seg.GetEndPoint().tangentBackward)
                    {
                        Vector3 p0 = transform.TransformPoint(seg.GetEndPoint().point);
                        Vector3 p1 = p0 + transform.TransformVector(seg.GetEndPoint().tangentBackward.point);
                        UnityEditor.Handles.DrawLine(p0, p1);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Renders all handles and tangents when applicable.
        /// </summary>
        private void RenderHandles()
        {
            int pointCount = spline.GetControlPointCount();
            int index      = 0;

            Handles.color = Color.white;

            for (int i = pointCount - 1; i >= 0; i--)
            {
                ControlPoint p = spline.GetControlPoint(i);
                ShowPoint(p, index);
                index++;
            }

            int segCount = spline.GetCurveCount();

            if (segCount <= 0)
            {
                return;
            }

            for (int i = segCount - 1; i >= 0; i--)
            {
                BezierCurve seg = spline.GetCurve(i);
                Handles.color = Color.green;

                //Display Tangents
                if (!deletePointMode)
                {
                    if (seg.GetStartPoint().tangentForward)
                    {
                        ShowTangentPoint(seg.GetStartPoint(), seg.GetStartPoint().tangentForward, index);
                        index++;
                    }

                    if (seg.GetEndPoint().tangentBackward)
                    {
                        ShowTangentPoint(seg.GetEndPoint(), seg.GetEndPoint().tangentBackward, index);
                        index++;
                    }
                }
            }
        }