public override void DrawSceneGUI()
    {
        MegaRubber mod = (MegaRubber)target;

        if (mod.showweights && mod.vr != null)
        {
            Color col = Color.black;

            Matrix4x4 tm = mod.gameObject.transform.localToWorldMatrix;
            Handles.matrix = tm;                //Matrix4x4.identity;

            for (int i = 0; i < mod.vr.Length; i++)
            {
                float w = mod.vr[i].weight;
                if (w > 0.5f)
                {
                    col = Color.Lerp(Color.green, Color.red, (w - 0.5f) * 2.0f);
                }
                else
                {
                    col = Color.Lerp(Color.blue, Color.green, w * 2.0f);
                }
                Handles.color = col;

                Vector3 p = mod.vr[i].cpos;                     //tm.MultiplyPoint(mod.vr[i].cpos);
                MegaHandles.DotCap(i, p, Quaternion.identity, mod.size);
            }

            Handles.matrix = Matrix4x4.identity;
        }
    }
Exemplo n.º 2
0
    public override void DrawSceneGUI()
    {
        MegaSelection mod = (MegaSelection)target;

        MegaModifiers mc = mod.gameObject.GetComponent <MegaModifiers>();

        float[] sel = mod.GetSel();

        if (mc != null && sel != null)
        {
            Color col = Color.black;

            Matrix4x4 tm = mod.gameObject.transform.localToWorldMatrix;
            Handles.matrix = Matrix4x4.identity;

            for (int i = 0; i < sel.Length; i++)
            {
                float w = sel[i];
                if (w > 0.5f)
                {
                    col = Color.Lerp(Color.green, Color.red, (w - 0.5f) * 2.0f);
                }
                else
                {
                    col = Color.Lerp(Color.blue, Color.green, w * 2.0f);
                }
                Handles.color = col;

                Vector3 p = tm.MultiplyPoint(mc.sverts[i]);
                MegaHandles.DotCap(i, p, Quaternion.identity, 0.01f);
            }

            Handles.matrix = Matrix4x4.identity;
        }
    }
Exemplo n.º 3
0
    //public void OnSceneGUI()
    public override void DrawSceneGUI()
    {
        MegaPointCache mod = (MegaPointCache)target;

        if (mod.showmapping)
        {
            if (mod.Verts != null && mod.Verts[0] != null)
            {
                float     vsize  = mod.mappingSize;
                float     vsize1 = vsize * 0.75f;
                Matrix4x4 tm     = mod.gameObject.transform.localToWorldMatrix;
                Handles.matrix = tm;                    //Matrix4x4.identity;
                Handles.color  = Color.green;

                if (mo == null)
                {
                    mo = mod.gameObject.GetComponent <MegaModifyObject>();
                }

                if (mo)
                {
                    for (int i = 0; i < mo.verts.Length; i++)
                    {
                        Vector3 p = mo.verts[i];
                        MegaHandles.DotCap(i, p, Quaternion.identity, vsize);
                    }
                }

                if (mod.mapEnd >= mod.Verts.Length)
                {
                    mod.mapEnd = mod.Verts.Length - 1;
                }

                if (mod.mapStart > mod.mapEnd)
                {
                    mod.mapStart = mod.mapEnd;
                }

                Handles.color = Color.white;                    //red;

                int findex = 0;
                if (uselastframe)
                {
                    findex = mod.Verts[0].points.Length - 1;
                }
                for (int i = mod.mapStart; i < mod.mapEnd; i++)
                {
                    Vector3 p = mod.Verts[i].points[findex];
                    MegaHandles.DotCap(i, p, Quaternion.identity, vsize1);
                }

                Handles.matrix = Matrix4x4.identity;
            }
        }
    }
    public override void DrawSceneGUI()
    {
        MegaModifier mod = (MegaModifier)target;

        if (mod.ModEnabled && mod.DisplayGizmo && MegaModifiers.GlobalDisplay)
        {
            MegaModifiers context = mod.GetComponent <MegaModifiers>();

            if (context != null && context.Enabled && context.DrawGizmos)
            {
                float a   = mod.gizCol1.a;
                Color col = Color.white;

                Quaternion rot = mod.transform.localRotation;

                Handles.matrix = Matrix4x4.identity;

                if (mod.Offset != Vector3.zero)
                {
                    Vector3 pos = mod.transform.localToWorldMatrix.MultiplyPoint(Vector3.Scale(-mod.gizmoPos - mod.Offset, mod.bbox.Size()));
                    Handles.Label(pos, mod.ModName() + " Pivot\n" + mod.Offset.ToString("0.000"));
                    col           = Color.blue;
                    col.a         = a;
                    Handles.color = col;
                    MegaHandles.ArrowCap(0, pos, rot * Quaternion.Euler(180.0f, 0.0f, 0.0f), mod.GizmoSize());
                    col           = Color.green;
                    col.a         = a;
                    Handles.color = col;
                    MegaHandles.ArrowCap(0, pos, rot * Quaternion.Euler(90.0f, 0.0f, 0.0f), mod.GizmoSize());
                    col           = Color.red;
                    col.a         = a;
                    Handles.color = col;
                    MegaHandles.ArrowCap(0, pos, rot * Quaternion.Euler(0.0f, -90.0f, 0.0f), mod.GizmoSize());
                }

                Handles.matrix = Matrix4x4.identity;
            }
        }
    }
    // option to use base verts or current stack verts for distance calc
    // flag to display weights
    // size of weights and color of gizmo

    public override void DrawSceneGUI()
    {
        MegaVolSelect mod = (MegaVolSelect)target;

        if (!mod.ModEnabled)
        {
            return;
        }

        MegaModifiers mc = mod.gameObject.GetComponent <MegaModifiers>();

        float[] sel = mod.GetSel();

        if (mc != null && sel != null)
        {
            //Color col = Color.black;

            Matrix4x4 tm = mod.gameObject.transform.localToWorldMatrix;
            Handles.matrix = tm;                //Matrix4x4.identity;

            if (mod.displayWeights)
            {
                for (int i = 0; i < sel.Length; i++)
                {
                    float w = sel[i];
                    if (w > 0.001f)
                    {
                        if (w > 0.5f)
                        {
                            Handles.color = Color.Lerp(Color.green, Color.red, (w - 0.5f) * 2.0f);
                        }
                        else
                        {
                            Handles.color = Color.Lerp(Color.blue, Color.green, w * 2.0f);
                        }

                        MegaHandles.DotCap(i, mc.sverts[i], Quaternion.identity, mod.gizSize);
                    }
                }
            }

            Handles.color = mod.gizCol;                 //new Color(0.5f, 0.5f, 0.5f, 0.2f);

            //Handles.DrawWireDisc(0, tm.MultiplyPoint(mod.origin), Quaternion.identity, mod.radius);
            //Handles.DrawWireDisc(tm.MultiplyPoint(mod.origin), Vector3.up, mod.radius);
            //Handles.DrawWireDisc(tm.MultiplyPoint(mod.origin), Vector3.right, mod.radius);
            //Handles.DrawWireDisc(tm.MultiplyPoint(mod.origin), Vector3.forward, mod.radius);
            if (mod.volType == MegaVolumeType.Sphere)
            {
                MegaHandles.SphereCap(0, tm.MultiplyPoint(mod.origin), Quaternion.identity, mod.radius * 2.0f);
            }

            Handles.matrix = tm;

            Vector3 origin = Handles.PositionHandle(mod.origin, Quaternion.identity);

            if (origin != mod.origin)
            {
                mod.origin = origin;
                EditorUtility.SetDirty(target);
            }
            Handles.matrix = Matrix4x4.identity;
        }
    }
Exemplo n.º 6
0
    void DisplayDebug()
    {
        MegaWrap mod = (MegaWrap)target;

        if (mod.target)
        {
            if (mod.bindverts != null && mod.bindverts.Length > 0)
            {
                if (mod.targetIsSkin && !mod.sourceIsSkin)
                {
                    Color col = Color.black;
                    Handles.matrix = Matrix4x4.identity;

                    MegaBindVert bv = mod.bindverts[mod.vertindex];

                    for (int i = 0; i < bv.verts.Count; i++)
                    {
                        MegaBindInf bi = bv.verts[i];
                        float       w  = bv.verts[i].weight / bv.weight;

                        if (w > 0.5f)
                        {
                            col = Color.Lerp(Color.green, Color.red, (w - 0.5f) * 2.0f);
                        }
                        else
                        {
                            col = Color.Lerp(Color.blue, Color.green, w * 2.0f);
                        }
                        Handles.color = col;

                        Vector3 p = (mod.skinnedVerts[bv.verts[i].i0] + mod.skinnedVerts[bv.verts[i].i1] + mod.skinnedVerts[bv.verts[i].i2]) / 3.0f; //tm.MultiplyPoint(mod.vr[i].cpos);
                        MegaHandles.DotCap(i, p, Quaternion.identity, mod.size);                                                                     //0.01f);

                        Vector3 p0 = mod.skinnedVerts[bi.i0];
                        Vector3 p1 = mod.skinnedVerts[bi.i1];
                        Vector3 p2 = mod.skinnedVerts[bi.i2];

                        Vector3 cp = mod.GetCoordMine(p0, p1, p2, bi.bary);
                        Handles.color = Color.gray;
                        Handles.DrawLine(p, cp);

                        Vector3 norm = mod.FaceNormal(p0, p1, p2);
                        Vector3 cp1  = cp + (((bi.dist * mod.shrink) + mod.gap) * norm.normalized);
                        Handles.color = Color.green;
                        Handles.DrawLine(cp, cp1);
                    }
                }
                else
                {
                    Color     col = Color.black;
                    Matrix4x4 tm  = mod.target.transform.localToWorldMatrix;
                    Handles.matrix = tm;                        //Matrix4x4.identity;

                    MegaBindVert bv = mod.bindverts[mod.vertindex];

                    for (int i = 0; i < bv.verts.Count; i++)
                    {
                        MegaBindInf bi = bv.verts[i];
                        float       w  = bv.verts[i].weight / bv.weight;

                        if (w > 0.5f)
                        {
                            col = Color.Lerp(Color.green, Color.red, (w - 0.5f) * 2.0f);
                        }
                        else
                        {
                            col = Color.Lerp(Color.blue, Color.green, w * 2.0f);
                        }
                        Handles.color = col;

                        Vector3 p = (mod.target.sverts[bv.verts[i].i0] + mod.target.sverts[bv.verts[i].i1] + mod.target.sverts[bv.verts[i].i2]) / 3.0f; //tm.MultiplyPoint(mod.vr[i].cpos);
                        MegaHandles.DotCap(i, p, Quaternion.identity, mod.size);                                                                        //0.01f);

                        Vector3 p0 = mod.target.sverts[bi.i0];
                        Vector3 p1 = mod.target.sverts[bi.i1];
                        Vector3 p2 = mod.target.sverts[bi.i2];

                        Vector3 cp = mod.GetCoordMine(p0, p1, p2, bi.bary);
                        Handles.color = Color.gray;
                        Handles.DrawLine(p, cp);

                        Vector3 norm = mod.FaceNormal(p0, p1, p2);
                        Vector3 cp1  = cp + (((bi.dist * mod.shrink) + mod.gap) * norm.normalized);
                        Handles.color = Color.green;
                        Handles.DrawLine(cp, cp1);
                    }
                }

                // Show unmapped verts
                Handles.color = Color.yellow;
                for (int i = 0; i < mod.bindverts.Length; i++)
                {
                    if (mod.bindverts[i].weight == 0.0f)
                    {
                        Vector3 pv1 = mod.freeverts[i];
                        MegaHandles.DotCap(0, pv1, Quaternion.identity, mod.size);                              //0.01f);
                    }
                }
            }

            if (mod.verts != null && mod.verts.Length > mod.vertindex)
            {
                Handles.color  = Color.red;
                Handles.matrix = mod.transform.localToWorldMatrix;
                Vector3 pv = mod.verts[mod.vertindex];
                MegaHandles.DotCap(0, pv, Quaternion.identity, mod.size);                       //0.01f);
            }
        }
    }