Esempio n. 1
0
    public void OnSceneGUI()
    {
        MegaFlowSmokeGun mod = (MegaFlowSmokeGun)target;

        Handles.matrix = mod.transform.localToWorldMatrix;

        Vector3 p = Vector3.zero;               //mod.transform.position;

        Vector3[] verts = new Vector3[4];
        verts[0] = p;
        verts[1] = p;
        verts[2] = p;
        verts[3] = p;

        verts[0].z += mod.width;
        verts[0].y += mod.height;
        verts[1].z -= mod.width;
        verts[1].y += mod.height;
        verts[2].z -= mod.width;
        verts[2].y -= mod.height;
        verts[3].z += mod.width;
        verts[3].y -= mod.height;

        Handles.DrawSolidRectangleWithOutline(verts, new Color(1, 1, 1, 0.25f), new Color(0, 0, 0, 1));

        Vector3 hp  = (verts[0] + verts[1]) * 0.5f;
        Vector3 hp1 = MegaFlowHandles.FreeMoveHandle(hp, Quaternion.identity, (mod.height + mod.width) * 0.5f * 0.025f, Vector3.zero);          //, Handles.DotCap);

        if (hp1.y != hp.y)
        {
            mod.height += hp1.y - hp.y;
        }

        hp  = (verts[1] + verts[2]) * 0.5f;
        hp1 = MegaFlowHandles.FreeMoveHandle(hp, Quaternion.identity, (mod.height + mod.width) * 0.5f * 0.025f, Vector3.zero);          //, Handles.DotCap);

        if (hp1.z != hp.z)
        {
            mod.width -= hp1.z - hp.z;
        }

        hp  = (verts[2] + verts[3]) * 0.5f;
        hp1 = MegaFlowHandles.FreeMoveHandle(hp, Quaternion.identity, (mod.height + mod.width) * 0.5f * 0.025f, Vector3.zero);          //, Handles.DotCap);

        if (hp1.y != hp.y)
        {
            mod.height -= hp1.y - hp.y;
        }

        hp  = (verts[3] + verts[0]) * 0.5f;
        hp1 = MegaFlowHandles.FreeMoveHandle(hp, Quaternion.identity, (mod.height + mod.width) * 0.5f * 0.025f, Vector3.zero);          //, Handles.DotCap);

        if (hp1.z != hp.z)
        {
            mod.width += hp1.z - hp.z;
        }
    }
Esempio n. 2
0
    static void RenderGizmo(MegaFlowCreateFromSplines flow, GizmoType gizmoType)
    {
        if (!flow.shownotsel && Selection.activeGameObject != flow.gameObject)
        {
            return;
        }

        flow.DrawGizmo();

        float rng = 1.0f / (flow.maxvel - flow.minvel);

        for (int i = 0; i < flow.splines.Count; i++)
        {
            if (flow.splines[i].include)
            {
                MegaShape shape = flow.splines[i].shape;

                if (shape)
                {
                    Handles.matrix = shape.transform.localToWorldMatrix;

                    Color col = Color.green;

                    for (int s = 0; s < shape.splines.Count; s++)
                    {
                        float step = 1.0f / (float)flow.splines[i].visrings;
                        for (float j = 0.0f; j < 1.0f; j += step)
                        {
                            Vector3 p  = shape.InterpCurve3D(s, j, true);
                            Vector3 pt = shape.InterpCurve3D(s, j + 0.01f, true);

                            float dist = flow.splines[i].distcrv.Evaluate(j) * flow.splines[i].falloffdist;

                            float va = flow.splines[i].velcrv.Evaluate(j);
                            col   = flow.GetCol(va * flow.splines[i].velocity * rng);                           //flow.splines[i].velcrv.Evaluate(j));
                            col.a = flow.splines[i].ringalpha;
                            //float va = flow.splines[i].velcrv.Evaluate(j);
                            Handles.color = col;

                            Vector3 dir = (pt - p).normalized;
                            Handles.DrawWireDisc(p, dir, dist);

                            Quaternion rot = Quaternion.LookRotation(dir);
                            MegaFlowHandles.ArrowCap(0, p, rot, flow.splines[i].velocity * flow.vellen * va);
                        }
                    }
                }
            }
        }

        Handles.matrix = Matrix4x4.identity;
    }
Esempio n. 3
0
    // TODO: Blocking geom
    public void OnSceneGUI()
    {
        MegaFlowCreateFromSplines mod = (MegaFlowCreateFromSplines)target;

        Handles.matrix = mod.transform.localToWorldMatrix;

        Vector3 p = Vector3.zero;

        Vector3[] verts = new Vector3[6];
        verts[0] = p;
        verts[1] = p;
        verts[2] = p;
        verts[3] = p;
        verts[4] = p;
        verts[5] = p;

        verts[0].x -= mod.size.x * 0.5f;
        verts[1].x += mod.size.x * 0.5f;
        verts[2].y -= mod.size.y * 0.5f;
        verts[3].y += mod.size.y * 0.5f;
        verts[4].z -= mod.size.z * 0.5f;
        verts[5].z += mod.size.z * 0.5f;

        float sz = mod.size.magnitude * 0.0025f;

        Vector3 hp1 = MegaFlowHandles.FreeMoveHandle(verts[0], Quaternion.identity, sz, Vector3.zero);          //, Handles.DotCap);

        if (hp1.x != verts[0].x)
        {
            mod.size.x -= hp1.x - verts[0].x;
        }

        hp1 = MegaFlowHandles.FreeMoveHandle(verts[1], Quaternion.identity, sz, Vector3.zero);          //, Handles.DotCap);

        if (hp1.x != verts[1].x)
        {
            mod.size.x += hp1.x - verts[1].x;
        }

        hp1 = MegaFlowHandles.FreeMoveHandle(verts[2], Quaternion.identity, sz, Vector3.zero);          //, Handles.DotCap);

        if (hp1.y != verts[2].y)
        {
            mod.size.y -= hp1.y - verts[2].y;
        }

        hp1 = MegaFlowHandles.FreeMoveHandle(verts[3], Quaternion.identity, sz, Vector3.zero);          //, Handles.DotCap);

        if (hp1.y != verts[3].y)
        {
            mod.size.y += hp1.y - verts[3].y;
        }

        hp1 = MegaFlowHandles.FreeMoveHandle(verts[4], Quaternion.identity, sz, Vector3.zero);          //, Handles.DotCap);

        if (hp1.z != verts[4].z)
        {
            mod.size.z -= hp1.z - verts[4].z;
        }

        hp1 = MegaFlowHandles.FreeMoveHandle(verts[5], Quaternion.identity, sz, Vector3.zero);          //, Handles.DotCap);

        if (hp1.z != verts[5].z)
        {
            mod.size.z += hp1.z - verts[5].z;
        }

        if (mod.size.x < 0.0f)
        {
            mod.size.x = 0.0f;
        }

        if (mod.size.y < 0.0f)
        {
            mod.size.y = 0.0f;
        }

        if (mod.size.z < 0.0f)
        {
            mod.size.z = 0.0f;
        }

        if (mod.preview)
        {
            Matrix4x4 offtm = Matrix4x4.TRS(-mod.preview.flow.size * 0.5f, Quaternion.identity, Vector3.one);

            Handles.matrix = mod.transform.localToWorldMatrix * offtm;

            Handles.color = Color.green;
            switch (mod.preview.Plane)
            {
            case MegaFlowAxis.X:
                mod.preview.handlepos = MegaFlowHandles.FreeMoveHandleSphere(mod.preview.handlepos, Quaternion.identity, mod.preview.flow.spacing.x * 1.0f, Vector3.zero);                              //, Handles.SphereCap);
                mod.preview.Position  = Mathf.Clamp((int)(mod.preview.handlepos.x / mod.preview.flow.spacing.x), 0, mod.preview.flow.gridDim2[0] - 1);

                mod.preview.handlepos.y = mod.preview.flow.size.y * 0.5f;
                mod.preview.handlepos.z = mod.preview.flow.size.z * 0.5f;
                break;

            case MegaFlowAxis.Y:
                mod.preview.handlepos   = MegaFlowHandles.FreeMoveHandleSphere(mod.preview.handlepos, Quaternion.identity, mod.preview.flow.spacing.y * 1.0f, Vector3.zero);                            //, Handles.SphereCap);
                mod.preview.Position    = Mathf.Clamp((int)(mod.preview.handlepos.y / mod.preview.flow.spacing.y), 0, mod.preview.flow.gridDim2[1] - 1);
                mod.preview.handlepos.x = mod.preview.flow.size.x * 0.5f;
                mod.preview.handlepos.z = mod.preview.flow.size.z * 0.5f;
                break;

            case MegaFlowAxis.Z:
                mod.preview.handlepos   = MegaFlowHandles.FreeMoveHandleSphere(mod.preview.handlepos, Quaternion.identity, mod.preview.flow.spacing.z * 1.0f, Vector3.zero);                            //, Handles.SphereCap);
                mod.preview.Position    = Mathf.Clamp((int)(mod.preview.handlepos.z / mod.preview.flow.spacing.z), 0, mod.preview.flow.gridDim2[2] - 0);
                mod.preview.handlepos.x = mod.preview.flow.size.x * 0.5f;
                mod.preview.handlepos.y = mod.preview.flow.size.y * 0.5f;
                break;
            }

            mod.preview.handlepos.x = Mathf.Clamp(mod.preview.handlepos.x, 0.0f, mod.preview.flow.size.x);
            mod.preview.handlepos.y = Mathf.Clamp(mod.preview.handlepos.y, 0.0f, mod.preview.flow.size.y);
            mod.preview.handlepos.z = Mathf.Clamp(mod.preview.handlepos.z, 0.0f, mod.preview.flow.size.z);
        }

        Handles.matrix = Matrix4x4.identity;
    }