public void ImportData(tfxJSONObject json_data) { m_anchor_points = new List <BezierCurvePoint>(); BezierCurvePoint curve_point; tfxJSONObject anchor_json; foreach (tfxJSONValue anchor_data in json_data["ANCHORS_DATA"].Array) { anchor_json = anchor_data.Obj; curve_point = new BezierCurvePoint(); curve_point.m_anchor_point = anchor_json["m_anchor_point"].Obj.JSONtoVector3(); curve_point.m_handle_point = anchor_json["m_handle_point"].Obj.JSONtoVector3(); m_anchor_points.Add(curve_point); } }
void DrawCurvePoint(BezierCurvePoint curve_point, Vector3 position_offset, Vector3 scale, bool start_end_point, ref bool changed) { Vector3 handle_offset = curve_point.m_handle_point - curve_point.m_anchor_point; curve_point.m_anchor_point = Vector3.Scale(Handles.PositionHandle(Vector3.Scale(curve_point.m_anchor_point, scale) + position_offset, Quaternion.identity) - position_offset, new Vector3(1 / scale.x, 1 / scale.y, 1 / scale.z)); if (!changed && GUI.changed) { changed = true; curve_point.m_handle_point = curve_point.m_anchor_point + handle_offset; } curve_point.m_handle_point = Vector3.Scale(Handles.PositionHandle(Vector3.Scale(curve_point.m_handle_point, scale) + position_offset, Quaternion.identity) - position_offset, new Vector3(1 / scale.x, 1 / scale.y, 1 / scale.z)); Handles.color = Color.white; Handles.DrawLine(!start_end_point ? Vector3.Scale(curve_point.m_anchor_point, scale) + Vector3.Scale((curve_point.m_anchor_point - curve_point.m_handle_point), scale) + position_offset : Vector3.Scale(curve_point.m_anchor_point, scale) + position_offset, Vector3.Scale(curve_point.m_handle_point, scale) + position_offset); }
public void AddNewAnchor() { if (m_anchor_points == null || m_anchor_points.Count == 0) { m_anchor_points = new List <BezierCurvePoint>(); m_anchor_points.Add(new BezierCurvePoint() { m_anchor_point = new Vector3(-5, 0, 0), m_handle_point = new Vector3(-2.5f, 4f, 0) }); m_anchor_points.Add(new BezierCurvePoint() { m_anchor_point = new Vector3(5, 0, 0), m_handle_point = new Vector3(2.5f, 4f, 0) }); } else { BezierCurvePoint last_point = m_anchor_points[m_anchor_points.Count - 1]; m_anchor_points.Add(new BezierCurvePoint() { m_anchor_point = last_point.m_anchor_point + new Vector3(5, 0, 0), m_handle_point = last_point.m_handle_point + new Vector3(5, 0, 0) }); } }
void DrawCurvePoint(BezierCurvePoint curve_point, Vector3 position_offset, Vector3 scale, bool start_end_point, ref bool changed) { Vector3 handle_offset = curve_point.m_handle_point - curve_point.m_anchor_point; curve_point.m_anchor_point = Vector3.Scale(Handles.PositionHandle(Vector3.Scale(curve_point.m_anchor_point,scale) + position_offset, Quaternion.identity) - position_offset, new Vector3(1/scale.x,1/scale.y,1/scale.z)); if(!changed && GUI.changed) { changed = true; curve_point.m_handle_point = curve_point.m_anchor_point + handle_offset; } curve_point.m_handle_point = Vector3.Scale(Handles.PositionHandle(Vector3.Scale(curve_point.m_handle_point,scale) + position_offset, Quaternion.identity) - position_offset, new Vector3(1/scale.x,1/scale.y,1/scale.z)); Handles.color = Color.white; Handles.DrawLine(!start_end_point ? Vector3.Scale(curve_point.m_anchor_point, scale) + Vector3.Scale((curve_point.m_anchor_point - curve_point.m_handle_point), scale) + position_offset : Vector3.Scale(curve_point.m_anchor_point, scale) + position_offset, Vector3.Scale(curve_point.m_handle_point, scale) + position_offset); }
public void ImportData(Boomlagoon.JSON.JSONObject json_data) { m_anchor_points = new List<BezierCurvePoint>(); BezierCurvePoint curve_point; Boomlagoon.JSON.JSONObject anchor_json; foreach(Boomlagoon.JSON.JSONValue anchor_data in json_data["ANCHORS_DATA"].Array) { anchor_json = anchor_data.Obj; curve_point = new BezierCurvePoint(); curve_point.m_anchor_point = anchor_json["m_anchor_point"].Obj.JSONtoVector3(); curve_point.m_handle_point = anchor_json["m_handle_point"].Obj.JSONtoVector3(); m_anchor_points.Add(curve_point); } }