public SplinePoint(Vector3 p, Vector3 c1, Vector3 c2, BezierPointType t) { mPoint = p; mPrevctrl = c1; mNextctrl = c2; mBezierType = t; }
public BezierPoint(Vector3 position, Vector3 handle1, Vector3 handle2, string name = "Point") { this.name = name; this.position = position; this.handle1 = handle1; this.handle2 = handle2; this.pointType = BezierPointType.None; }
public void InsertPoint(int idx, Vector3 pos, BezierPointType type, Vector3 cp1, Vector3 cp2) { if (idx < 0 || idx > mPoints.Count) { throw (new IndexOutOfRangeException()); } mPoints.Insert(idx, new SplinePoint(pos, cp1, cp2, type)); }
private void DrawInspectorBezierPointControls() { List <BezierPoint> points = bezierCurve.GetAnchorPoints(); string[] bezierPointTypes = System.Enum.GetNames(typeof(BezierPointType)); if (points == null) { return; } for (int i = 0; i < points.Count; i++) { BezierPoint bezierPoint = points [i]; GUILayout.BeginHorizontal(); GUILayout.Label(bezierPoint.name); EditorGUI.BeginChangeCheck(); BezierPointType pointType = (BezierPointType)EditorGUILayout.Popup((int)bezierPoint.pointType, bezierPointTypes); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(bezierCurve, "Change Point Type"); bezierPoint.pointType = pointType; SceneView.RepaintAll(); } if (GUILayout.Button("X", GUILayout.Width(15), GUILayout.Height(15))) { RemovePoint(bezierPoint); } GUILayout.EndHorizontal(); Vector3 position = EditorGUILayout.Vector3Field(" Position: ", bezierPoint.position); if (bezierPoint.pointType != BezierPointType.None) { Vector3 handle1 = EditorGUILayout.Vector3Field(" Handle 1: ", bezierPoint.handle1); Vector3 handle2 = EditorGUILayout.Vector3Field(" Handle 2: ", bezierPoint.handle2); if (bezierPoint.GetHandle1LocalPosition() != handle1) { Undo.RecordObject(target, "Move Handle Point 1"); bezierPoint.handle1 = handle1; } if (bezierPoint.GetHandle2LocalPosition() != handle2) { Undo.RecordObject(target, "Move Handle Point 2"); bezierPoint.handle2 = handle2; } } if (bezierPoint.GetLocalPosition() != position) { Undo.RecordObject(target, "Move Point"); bezierPoint.SetPosition(position); } } }
public void AppendPoint(Vector3 pos, BezierPointType type, Vector3 cp1, Vector3 cp2) { mPoints.Add(new SplinePoint(pos, cp1, cp2, type)); }