/// <summary>
        /// Sets the current index for use in route traversal
        /// </summary>
        /// <param name="valueWaypoint">Interface to modify</param>
        /// <param name="controlSection">Current control section will be set by calculation</param>
        internal static void CalculateCurrentIndex(IValueSmoothWaypoint valueWaypoint, out CurveControlSection controlSection)
        {
            IControlNode[] controlNodes = new IControlNode[valueWaypoint.nodes.Length];
            for (int i = 0; i < valueWaypoint.nodes.Length; i++)
            {
                controlNodes[i] = ControlNode.CreateNode(i, valueWaypoint.nodes[i], Quaternion.identity, valueWaypoint.curveScales[i]);
            }
            CurveControlSection[] controlSections = CurveControlArgs.GetComputedAndSlicedSections(new CurveControlArgs(controlNodes, true));
            controlSection = controlSections[valueWaypoint.minIndex];

            float routeTime = (valueWaypoint.minIndex + valueWaypoint.current) / controlSections.Length;

            valueWaypoint.currentIndex = (int)(controlSections.Length * routeTime);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws scene view handles
        /// </summary>
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();
            IValueSmoothWaypoint valueSmoothWaypoint = m_MemberTarget.valueControl as IValueSmoothWaypoint;

            ValueWaypointEditorUtils.SelectionHandles(valueSmoothWaypoint, target, transform, m_ReorderableSmoothWaypoint.index);

            Color color = Handles.color;

            Handles.color = Color.green;

            if (valueSmoothWaypoint.selectionType != SelectionType.None)
            {
                IControlNode[] controlNodes = new IControlNode[valueSmoothWaypoint.nodes.Length];
                for (int i = 0; i < valueSmoothWaypoint.nodes.Length; i++)
                {
                    controlNodes[i] = ControlNode.CreateNode(i, valueSmoothWaypoint.nodes[i], Quaternion.identity, valueSmoothWaypoint.curveScales[i]);
                }

                var   controlSections = CurveControlArgs.GetComputedAndSlicedSections(new CurveControlArgs(controlNodes, true));
                float lineWidth       = 2;
                for (int i = 0; i < controlSections.Length; i++)
                {
                    var item = controlSections[i];
                    Handles.DrawBezier(item.p0.position,
                                       item.p1.position,
                                       item.q0.position,
                                       item.q1.position,
                                       Handles.color,
                                       null,
                                       lineWidth);
                }

                m_ReorderableSmoothWaypoint.SceneViewDrawSelected(valueSmoothWaypoint, Color.yellow);
                m_ReorderableSmoothWaypoint.SceneViewCreateWaypoint(valueSmoothWaypoint);
            }

            Handles.color = color;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Copies all source values to the current object.
 /// <para>Use this method to avoid creating a new object or to resuse this object.</para>
 /// </summary>
 /// <param name="source">The source object to copy values from.</param>
 public void Copy(IValueSmoothWaypoint source)
 {
     base.Copy(source);
     Set(source.curveScales);
 }