Пример #1
0
    public void ImportData(JSONObject json_data)
    {
        m_anchor_points = new List <BezierCurvePoint>();

        BezierCurvePoint curve_point;
        JSONObject       anchor_json;

        foreach (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);
        }
    }
Пример #2
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);
    }
Пример #3
0
    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)
            });
        }
    }
Пример #4
0
    private void DrawCurvePoint(BezierCurvePoint curve_point, Vector3 position_offset, Vector3 scale, bool start_end_point, ref bool changed)
    {
        var 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);
    }
Пример #5
0
    public void ImportData(JSONObject json_data)
    {
        m_anchor_points = new List<BezierCurvePoint>();

        BezierCurvePoint curve_point;
        JSONObject anchor_json;

        foreach (var 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);
        }
    }
    public void SetBezierCurve(params Vector3[] curve_points)
    {
        m_progression_idx = CURVE_OPTION_INDEX;

        var bezier_curve = new TextFxBezierCurve();
        bezier_curve.m_anchor_points = new List<BezierCurvePoint>();

        BezierCurvePoint curve_point = null;
        var idx = 0;
        foreach (var point in curve_points)
        {
            if (idx % 2 == 0)
            {
                curve_point = new BezierCurvePoint();
                curve_point.m_anchor_point = point;
            }
            else
            {
                curve_point.m_handle_point = point;
                bezier_curve.m_anchor_points.Add(curve_point);
            }

            idx++;
        }

        if (idx % 2 == 1)
        {
            curve_point.m_handle_point = curve_point.m_anchor_point;
            bezier_curve.m_anchor_points.Add(curve_point);
        }

        m_bezier_curve = bezier_curve;
    }