コード例 #1
0
 private void SetTwist(int index, Twist twist)
 {
     if (target is SplineControlPoint)
     {
         for (int i = 0; i < targets.Length; ++i)
         {
             SplineControlPoint controlPoint = (SplineControlPoint)targets[i];
             m_splineBase.SetTwist(controlPoint.Index, twist);
         }
     }
     else
     {
         m_splineBase.SetTwist(index, twist);
     }
 }
コード例 #2
0
        public static void SetTwistAngle(SplineBase spline, int index, float twistAngle)
        {
            RecordHierarchy(spline.Root, "Battlehub.MeshDeformer2 Twist Angle");
            EditorUtility.SetDirty(spline);
            Twist twist = spline.GetTwist(index);

            twist.Data = twistAngle;
            spline.SetTwist(index, twist);
        }
コード例 #3
0
        public static void SetTwistOffset(SplineBase spline, int index, float t1, float t2)
        {
            Twist twist = spline.GetTwist(index);

            RecordHierarchy(spline.Root, "Battlehub.MeshDeformer2 Twist Offset");
            EditorUtility.SetDirty(spline);
            twist.T1 = t1;
            twist.T2 = t2;
            spline.SetTwist(index, twist);
        }
コード例 #4
0
        private void Update()
        {
            if (m_spline == null)
            {
                return;
            }

            if (transform.localPosition != m_localPosition)
            {
                if (m_spline.SetControlPointLocal(m_index, transform.localPosition))
                {
                    m_localPosition = transform.localPosition;
                }
                else
                {
                    transform.localPosition = m_localPosition;
                }
            }


            if (transform.rotation != m_rotation)
            {
                if (m_index % 3 == 0)
                {
                    Vector3 v         = Vector3.back;
                    int     prevIndex = m_index - 1;
                    if (prevIndex < 0)
                    {
                        prevIndex = m_index + 1;
                        v         = Vector3.forward;
                    }

                    Vector3 prevPt = m_spline.GetControlPoint(prevIndex);
                    Vector3 pt     = m_spline.GetControlPoint(m_index);
                    Vector3 toPrev = (transform.rotation * v).normalized * (pt - prevPt).magnitude;

                    Twist twist = m_spline.GetTwist(m_index);

                    m_rotation = transform.rotation;
                    twist.Data = transform.eulerAngles.z;

                    m_updateAngle = false;
                    m_spline.SetTwist(m_index, twist);
                    m_spline.SetControlPoint(prevIndex, pt + toPrev);
                    m_updateAngle = true;
                }
                else
                {
                    transform.rotation = m_rotation;
                }
            }

            Thickness thickness     = m_spline.GetThickness(m_index);
            Vector3   thicknessData = thickness.Data;

            if (transform.localScale != thicknessData)
            {
                thickness.Data = transform.localScale;
                m_spline.SetThickness(m_index, thickness);
            }
        }
コード例 #5
0
ファイル: SplineBaseEditor.cs プロジェクト: TwelveAxes/Speed
        private void DrawSelectedPointInspector()
        {
            if (DrawSelectedPointInspectorOverride())
            {
                EditorGUI.BeginChangeCheck();
                ControlPointMode mode = (ControlPointMode)
                                        EditorGUILayout.EnumPopup("Mode", m_splineBase.GetControlPointMode(m_selectedIndex));
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_splineBase, UNDO_CHANGEMODE);
                    EditorUtility.SetDirty(m_splineBase);
                    m_splineBase.SetControlPointMode(m_selectedIndex, mode);
                }

                EditorGUI.BeginChangeCheck();

                int   index = (m_selectedIndex / 3) * 3;
                Twist twist = m_splineBase.GetTwist(index);
                EditorGUI.BeginChangeCheck();
                float twistAngle = EditorGUILayout.FloatField("Twist Angle", twist.Data);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_splineBase, "Battlehub.MeshDeformer2 Twist Angle");
                    EditorUtility.SetDirty(m_splineBase);
                    twist.Data = twistAngle;
                    m_splineBase.SetTwist(index, twist);
                }


                if (m_splineBase.Loop || m_selectedIndex / 3 < m_splineBase.CurveCount)
                {
                    float t1 = twist.T1;
                    float t2 = twist.T2;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.MinMaxSlider(new GUIContent("Twist Offset"), ref t1, ref t2, 0.0f, 1.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(m_splineBase, "Battlehub.MeshDeformer2 Twist Offset");
                        EditorUtility.SetDirty(m_splineBase);
                        twist.T1 = t1;
                        twist.T2 = t2;
                        m_splineBase.SetTwist(index, twist);
                    }
                }


                Thickness thickness = m_splineBase.GetThickness(index);
                EditorGUI.BeginChangeCheck();
                Vector3 thicknessValue = EditorGUILayout.Vector3Field("Thickness", thickness.Data);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_splineBase, "Battlehub.MeshDeformer2 Thickness");
                    EditorUtility.SetDirty(m_splineBase);
                    thickness.Data = thicknessValue;
                    m_splineBase.SetThickness(index, thickness);
                }

                if (m_splineBase.Loop || m_selectedIndex / 3 < m_splineBase.CurveCount)
                {
                    float t1 = thickness.T1;
                    float t2 = thickness.T2;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.MinMaxSlider(new GUIContent("Thickness Offset"), ref t1, ref t2, 0.0f, 1.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(m_splineBase, "Battlehub.MeshDeformer2 Thickness Offset");
                        EditorUtility.SetDirty(m_splineBase);
                        thickness.T1 = t1;
                        thickness.T2 = t2;
                        m_splineBase.SetThickness(index, thickness);
                    }
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();

                int   index = (m_selectedIndex / 3) * 3;
                Twist twist = m_splineBase.GetTwist(index);
                EditorGUI.BeginChangeCheck();
                float twistAngle = EditorGUILayout.FloatField("Twist Angle", twist.Data);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_splineBase, "Battlehub.MeshDeformer2 Twist Angle");
                    EditorUtility.SetDirty(m_splineBase);
                    twist.Data = twistAngle;
                    m_splineBase.SetTwist(index, twist);
                }

                Thickness thickness = m_splineBase.GetThickness(index);
                EditorGUI.BeginChangeCheck();
                Vector3 thicknessValue = EditorGUILayout.Vector3Field("Thickness", thickness.Data);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_splineBase, "Battlehub.MeshDeformer2 Thickness");
                    EditorUtility.SetDirty(m_splineBase);
                    thickness.Data = thicknessValue;
                    m_splineBase.SetThickness(index, thickness);
                }
            }
        }