Example #1
0
    static void RenderGizmo(MegaHose hose, GizmoType gizmoType)
    {
        if ((gizmoType & GizmoType.Active) != 0 && Selection.activeObject == hose.gameObject)
        {
            if (!hose.displayspline)
            {
                return;
            }

            if (hose.custnode == null || hose.custnode2 == null)
            {
                return;
            }

            DrawGizmos(hose, new Color(1.0f, 1.0f, 1.0f, 1.0f));
            Color col = Color.yellow;
            col.a        = 0.5f;        //0.75f;
            Gizmos.color = col;         //Color.yellow;

            Matrix4x4 RingTM = Matrix4x4.identity;
            hose.CalcMatrix(ref RingTM, 0.0f);
            RingTM = hose.transform.localToWorldMatrix * RingTM;

            float gsize = 0.0f;
            switch (hose.wiretype)
            {
            case MegaHoseType.Round:                gsize = hose.rnddia;    break;

            case MegaHoseType.Rectangle:    gsize = (hose.rectdepth + hose.rectwidth) * 0.5f; break;

            case MegaHoseType.DSection:             gsize = (hose.dsecdepth + hose.dsecwidth) * 0.5f; break;
            }

            gsize *= 0.1f;

            for (int p = 0; p < hose.hosespline.knots.Count; p++)
            {
                Vector3 p1 = RingTM.MultiplyPoint(hose.hosespline.knots[p].p);
                Vector3 p2 = RingTM.MultiplyPoint(hose.hosespline.knots[p].invec);
                Vector3 p3 = RingTM.MultiplyPoint(hose.hosespline.knots[p].outvec);

                Gizmos.color = Color.black;
                Gizmos.DrawLine(p2, p1);
                Gizmos.DrawLine(p3, p1);

                Gizmos.color = Color.green;
                Gizmos.DrawSphere(p1, gsize);

                Gizmos.color = Color.red;
                Gizmos.DrawSphere(p2, gsize);
                Gizmos.DrawSphere(p3, gsize);
            }
        }
    }
Example #2
0
    static void DrawGizmos(MegaHose hose, Color modcol1)
    {
        Matrix4x4 RingTM = Matrix4x4.identity;
        Matrix4x4 tm     = hose.transform.localToWorldMatrix;

        float ldist = 1.0f * 0.1f;

        if (ldist < 0.01f)
        {
            ldist = 0.01f;
        }

        Color modcol = modcol1;

        if (hose.hosespline.length / ldist > 500.0f)
        {
            ldist = hose.hosespline.length / 500.0f;
        }

        float ds = hose.hosespline.length / (hose.hosespline.length / ldist);

        if (ds > hose.hosespline.length)
        {
            ds = hose.hosespline.length;
        }

        int c  = 0;
        int k  = -1;
        int lk = -1;

        Vector3 first = hose.hosespline.Interpolate(0.0f, true, ref lk);

        hose.CalcMatrix(ref RingTM, 0.0f);
        RingTM = tm * RingTM;

        for (float dist = ds; dist < hose.hosespline.length; dist += ds)
        {
            float alpha = dist / hose.hosespline.length;

            Vector3 pos = hose.hosespline.Interpolate(alpha, true, ref k);

            if ((c & 1) == 1)
            {
                Gizmos.color = Color.black * modcol;
            }
            else
            {
                Gizmos.color = Color.yellow * modcol;
            }

            if (k != lk)
            {
                for (lk = lk + 1; lk <= k; lk++)
                {
                    Gizmos.DrawLine(RingTM.MultiplyPoint(first), RingTM.MultiplyPoint(hose.hosespline.knots[lk].p));
                    first = hose.hosespline.knots[lk].p;
                }
            }

            lk = k;

            Gizmos.DrawLine(RingTM.MultiplyPoint(first), RingTM.MultiplyPoint(pos));

            c++;

            first = pos;
        }

        if ((c & 1) == 1)
        {
            Gizmos.color = Color.blue * modcol;
        }
        else
        {
            Gizmos.color = Color.yellow * modcol;
        }

        Vector3 lastpos;

        if (hose.hosespline.closed)
        {
            lastpos = hose.hosespline.Interpolate(0.0f, true, ref k);
        }
        else
        {
            lastpos = hose.hosespline.Interpolate(1.0f, true, ref k);
        }

        Gizmos.DrawLine(RingTM.MultiplyPoint(first), RingTM.MultiplyPoint(lastpos));
    }
Example #3
0
    static void RenderGizmo(MegaHose hose, GizmoType gizmoType)
    {
        if ( (gizmoType & GizmoType.Active) != 0 )
        {
            if ( !hose.displayspline )
                return;

            if ( hose.custnode == null || hose.custnode2 == null )
                return;

            DrawGizmos(hose, new Color(1.0f, 1.0f, 1.0f, 1.0f));
            Color col = Color.yellow;
            col.a = 0.5f;	//0.75f;
            Gizmos.color = col;	//Color.yellow;

            Matrix4x4 RingTM = Matrix4x4.identity;
            hose.CalcMatrix(ref RingTM, 0.0f);
            RingTM = hose.transform.localToWorldMatrix * RingTM;

            float gsize = 0.0f;
            switch ( hose.wiretype )
            {
                case MegaHoseType.Round:		gsize = hose.rnddia;	break;
                case MegaHoseType.Rectangle:	gsize = (hose.rectdepth + hose.rectwidth) * 0.5f; break;
                case MegaHoseType.DSection:		gsize = (hose.dsecdepth + hose.dsecwidth) * 0.5f; break;
            }

            gsize *= 0.1f;

            for ( int p = 0; p < hose.hosespline.knots.Count; p++ )
            {
                Vector3 p1 = RingTM.MultiplyPoint(hose.hosespline.knots[p].p);
                Vector3 p2 = RingTM.MultiplyPoint(hose.hosespline.knots[p].invec);
                Vector3 p3 = RingTM.MultiplyPoint(hose.hosespline.knots[p].outvec);

                Gizmos.color = Color.black;
                Gizmos.DrawLine(p2, p1);
                Gizmos.DrawLine(p3, p1);

                Gizmos.color = Color.green;
                Gizmos.DrawSphere(p1, gsize);

                Gizmos.color = Color.red;
                Gizmos.DrawSphere(p2, gsize);
                Gizmos.DrawSphere(p3, gsize);
            }
        }
    }
Example #4
0
    static void DrawGizmos(MegaHose hose, Color modcol1)
    {
        Matrix4x4 RingTM = Matrix4x4.identity;
        Matrix4x4 tm = hose.transform.localToWorldMatrix;

        float ldist = 1.0f * 0.1f;
        if ( ldist < 0.01f )
            ldist = 0.01f;

        Color modcol = modcol1;

        if ( hose.hosespline.length / ldist > 500.0f )
            ldist = hose.hosespline.length / 500.0f;

        float ds = hose.hosespline.length / (hose.hosespline.length / ldist);

        if ( ds > hose.hosespline.length )
            ds = hose.hosespline.length;

        int c	= 0;
        int k	= -1;
        int lk	= -1;

        Vector3 first = hose.hosespline.Interpolate(0.0f, true, ref lk);

        hose.CalcMatrix(ref RingTM, 0.0f);
        RingTM = tm * RingTM;

        for ( float dist = ds; dist < hose.hosespline.length; dist += ds )
        {
            float alpha = dist / hose.hosespline.length;

            Vector3 pos = hose.hosespline.Interpolate(alpha, true, ref k);

            if ( (c & 1) == 1 )
                Gizmos.color = Color.black * modcol;
            else
                Gizmos.color = Color.yellow * modcol;

            if ( k != lk )
            {
                for ( lk = lk + 1; lk <= k; lk++ )
                {
                    Gizmos.DrawLine(RingTM.MultiplyPoint(first), RingTM.MultiplyPoint(hose.hosespline.knots[lk].p));
                    first = hose.hosespline.knots[lk].p;
                }
            }

            lk = k;

            Gizmos.DrawLine(RingTM.MultiplyPoint(first), RingTM.MultiplyPoint(pos));

            c++;

            first = pos;
        }

        if ( (c & 1) == 1 )
            Gizmos.color = Color.blue * modcol;
        else
            Gizmos.color = Color.yellow * modcol;

        Vector3 lastpos;
        if ( hose.hosespline.closed )
            lastpos = hose.hosespline.Interpolate(0.0f, true, ref k);
        else
            lastpos = hose.hosespline.Interpolate(1.0f, true, ref k);

        Gizmos.DrawLine(RingTM.MultiplyPoint(first), RingTM.MultiplyPoint(lastpos));
    }