Ejemplo n.º 1
0
    //-----------

        #if UNITY_EDITOR
    protected virtual void OnDrawGizmos()
    {
        //if (_verlet != null) _verlet.DrawGizmos();

        if (UnityEditor.EditorApplication.isPlaying)
        {
            return;
        }

        // position constraints
        Vector3 offset = transform.position;

        Gizmos.color = Color.red;
        for (int i = 0; init_data != null && i < init_data.Length; ++i)
        {
            int i0 = init_data[i].parent;
            if (i0 < 0 || i0 > init_data.Length)
            {
                continue;
            }

            Vector3 p0 = init_data[i].pos * SCALE;
            Vector3 p1 = init_data[i0].pos * SCALE;

            Vector3 pos0 = offset + p0;
            Vector3 pos1 = offset + p1;

            Gizmos.DrawLine(pos0, pos1);

            UtilGizmos.DrawCircleGizmo(pos0, 0.01f);
        }
    }
Ejemplo n.º 2
0
    public void DrawGizmos()
    {
        Vector3 offset = _parent == null ? Vector3.zero : _parent.position;

        // Points
        for (int i = 0; _points != null && i < _points.Length; ++i)
        {
            Gizmos.color = Color.red;
            if (_points[i].is_fixed)
            {
                Gizmos.color = Color.grey;
            }

            Vector3 p = _points[i].curr_mat.GetColumn(3);

            Gizmos.DrawCube(offset + p, Vector3.one * 0.2f);
            UtilGizmos.DrawCircleGizmo(offset + p, 0.04f);
        }

        // position constraints
        Gizmos.color = Color.black;
        for (int i = 0; _pos_constraints != null && i < _pos_constraints.Length; ++i)
        {
            int i0 = _pos_constraints[i].index_0;
            int i1 = _pos_constraints[i].index_1;

            Vector3 p0 = _points[i0].curr_mat.GetColumn(3);
            Vector3 p1 = _points[i1].curr_mat.GetColumn(3);

            Vector3 pos0 = offset + p0;
            Vector3 pos1 = offset + p1;

            Gizmos.DrawLine(pos0, pos1);
        }

        // angle constraints

        Gizmos.color = Color.white;
    }