示例#1
0
    public void Start()
    {
        UiManager.Instance.Subscribe(this);

        if (SpbFrame == null)
        {
            SpbFrame = Images.LoadImage("graphics/interface/spellbook.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (SpbPlaceholder == null)
        {
            SpbPlaceholder = Images.LoadImage("graphics/interface/spellback.bmp", 0, Images.ImageType.AllodsBMP);
        }

        //
        Renderer = gameObject.AddComponent <MeshRenderer>();
        Filter   = gameObject.AddComponent <MeshFilter>();

        Renderer.materials = new Material[] { new Material(MainCamera.MainShader), new Material(MainCamera.MainShader) };
        Renderer.materials[0].mainTexture = SpbFrame;
        Renderer.materials[1].mainTexture = SpbPlaceholder;

        // generate mesh.
        Builder = new Utils.MeshBuilder();
        UpdateMesh();

        transform.localScale = new Vector3(1, 1, 0.01f);
    }
示例#2
0
    public void UpdateMesh()
    {
        if (Filter.mesh != null && LastWidth == Width && LastHeight == Height && LastClicked == _Clicked && LastChecked == Checked)
        {
            return;
        }

        LastChecked = Checked;
        LastClicked = _Clicked;
        LastWidth   = Width;
        LastHeight  = Height;

        if (Builder == null)
        {
            Builder = new Utils.MeshBuilder();
        }

        //
        Color col_inactive = new Color(1, 1, 1, 1);
        Color col_active   = new Color(1, 1, 1, 0);

        if (_Clicked)
        {
            col_active = new Color(1, 1, 1, 0.5f);
        }
        else if (Checked)
        {
            col_active   = new Color(1, 1, 1, 1);
            col_inactive = new Color(0, 0, 0, 1);
        }

        Builder.AddQuad(0, 0, 0, imgRadiob.Sprites[2].rect.width, imgRadiob.Sprites[2].rect.height, imgRadiob.AtlasRects[2], col_inactive); // disabled
        Builder.AddQuad(0, 0, 0, imgRadiob.Sprites[3].rect.width, imgRadiob.Sprites[3].rect.height, imgRadiob.AtlasRects[3], col_active);   // disabled

        Filter.mesh = Builder.ToMesh(MeshTopology.Quads);
    }
示例#3
0
    public void Start()
    {
        UiManager.Instance.Subscribe(this);

        if (InvFrame == null)
        {
            InvFrame = Images.LoadImage("graphics/interface/invframe.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow1 == null)
        {
            InvArrow1 = Images.LoadImage("graphics/interface/invarrow1.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow2 == null)
        {
            InvArrow2 = Images.LoadImage("graphics/interface/invarrow2.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow3 == null)
        {
            InvArrow3 = Images.LoadImage("graphics/interface/invarrow3.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow4 == null)
        {
            InvArrow4 = Images.LoadImage("graphics/interface/invarrow4.bmp", 0, Images.ImageType.AllodsBMP);
        }

        //
        Renderer = gameObject.AddComponent <MeshRenderer>();
        Filter   = gameObject.AddComponent <MeshFilter>();

        Renderer.materials = new Material[] { new Material(MainCamera.MainShader), new Material(MainCamera.MainShader), new Material(MainCamera.MainShader) };
        Renderer.materials[0].mainTexture = InvFrame;
        Renderer.materials[1].color       = Renderer.materials[2].color = new Color(0, 0, 0, 0);

        // generate mesh.
        Utils.MeshBuilder mb = new Utils.MeshBuilder();
        // 3 submeshes: left arrow, right arrow, and background. I'm NOT using the full original inventory view.
        for (int i = 0; i < View.InvWidth; i++)
        {
            int internalPosition;
            if (i == 0)
            {
                internalPosition = 0;
            }
            else if (i == View.InvWidth - 1)
            {
                internalPosition = 4;
            }
            else
            {
                internalPosition = (i % 3) + 1;
            }
            Rect internalRect = Utils.DivRect(new Rect(32 + internalPosition * 80, 0, 80, 90), new Vector2(InvFrame.width, InvFrame.height));
            mb.AddQuad(0, 32 + i * 80, 0, 80, 90, internalRect);
        }

        // add two quads for unpressed buttons
        mb.AddQuad(0, 0, 0, 32, 90, Utils.DivRect(new Rect(0, 0, 32, 90), new Vector2(InvFrame.width, InvFrame.height)));
        mb.AddQuad(0, 32 + View.InvWidth * 80, 0, 32, 90, Utils.DivRect(new Rect(432, 0, 32, 90), new Vector2(InvFrame.width, InvFrame.height)));

        mb.AddQuad(1, 0, 2, 32, 88);
        mb.AddQuad(2, 32 + View.InvWidth * 80, 2, 32, 88);

        Filter.mesh = mb.ToMesh(MeshTopology.Quads, MeshTopology.Quads, MeshTopology.Quads);

        transform.localScale    = new Vector3(1, 1, 0.01f);
        transform.localPosition = new Vector3((Screen.width - 176) / 2 - (View.InvWidth * 80 + 64) / 2, Screen.height - 90, MainCamera.InterfaceZ + 0.99f); // on this layer all map UI is drawn
    }
示例#4
0
    public void Start()
    {
        UiManager.Instance.Subscribe(this);

        if (CrystalL == null)
        {
            CrystalL = Images.LoadImage("graphics/interface/crystall.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (CrystalR == null)
        {
            CrystalR = Images.LoadImage("graphics/interface/crystalr.bmp", Images.ImageType.AllodsBMP);
        }
        transform.localScale    = new Vector3(1, 1, 0.01f);
        transform.localPosition = new Vector3(MainCamera.Width - 176, 0, MainCamera.InterfaceZ + 0.99f); // on this layer all map UI is drawn

        CrystalLObject   = Utils.CreatePrimitive(PrimitiveType.Quad);
        CrystalLRenderer = CrystalLObject.GetComponent <MeshRenderer>();
        CrystalLObject.transform.parent        = transform;
        CrystalLObject.transform.localScale    = new Vector3(CrystalL.width, CrystalL.height, 1);
        CrystalLObject.transform.localPosition = new Vector3(CrystalL.width / 2, CrystalL.height / 2, 0);
        CrystalLRenderer.material             = new Material(MainCamera.MainShader);
        CrystalLRenderer.material.mainTexture = CrystalL;

        CrystalRObject   = Utils.CreatePrimitive(PrimitiveType.Quad);
        CrystalRRenderer = CrystalRObject.GetComponent <MeshRenderer>();
        CrystalRObject.transform.parent        = transform;
        CrystalRObject.transform.localScale    = new Vector3(CrystalR.width, CrystalR.height, 1);
        CrystalRObject.transform.localPosition = new Vector3(CrystalL.width + CrystalR.width / 2, CrystalR.height / 2, 0);
        CrystalRRenderer.material             = new Material(MainCamera.MainShader);
        CrystalRRenderer.material.mainTexture = CrystalR;

        TexObject   = Utils.CreatePrimitive(PrimitiveType.Quad);
        TexRenderer = TexObject.GetComponent <MeshRenderer>();
        TexObject.transform.parent        = transform;
        TexObject.transform.localPosition = new Vector3(CrystalL.width + CrystalR.width / 2, CrystalR.height / 2, 0);
        TexRenderer.material             = new Material(MainCamera.MainShader);
        TexRenderer.material.mainTexture = MapTexture;
        TexRenderer.enabled = false;

        if (MiniMapData == null)
        {
            Texture2D mmData = Images.LoadImage("graphics/interface/minimapdata.bmp", Images.ImageType.AllodsBMP);
            MiniMapData = mmData.GetPixels();
            DestroyImmediate(mmData);
        }

        // update bounds object
        Utils.MeshBuilder mb = new Utils.MeshBuilder();

        mb.CurrentPosition = new Vector2(-0.00390625f, 0);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();
        mb.CurrentPosition = new Vector2(1, 0);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();

        mb.CurrentPosition = new Vector2(1, 0);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();
        mb.CurrentPosition = new Vector2(1, 1);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();

        mb.CurrentPosition = new Vector2(1, 1);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();
        mb.CurrentPosition = new Vector2(0, 1);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();

        mb.CurrentPosition = new Vector2(0, 1);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();
        mb.CurrentPosition = new Vector2(0, -0.00390625f);
        mb.CurrentColor    = new Color(1, 1, 1, 1);
        mb.NextVertex();

        Mesh boundsMesh = mb.ToMesh(MeshTopology.Lines);

        BoundsObject                         = new GameObject();
        BoundsObject.name                    = "ScreenBounds";
        BoundsObject.transform.parent        = transform;
        BoundsObject.transform.localPosition = new Vector3(0, 0, -2f);
        BoundsObject.transform.localScale    = new Vector2(0, 0);
        MeshFilter boundsFilter = BoundsObject.AddComponent <MeshFilter>();

        boundsFilter.mesh       = boundsMesh;
        BoundsRenderer          = BoundsObject.AddComponent <MeshRenderer>();
        BoundsRenderer.material = new Material(MainCamera.MainShader);
        BoundsRenderer.enabled  = false;
    }
示例#5
0
    public void Start()
    {
        ItemCount      = (MainCamera.Width - 176 - 64) / 80; // each arrow is 32 in width
        View.InvScale  = 1;
        View.InvWidth  = (int)(ItemCount / View.InvScale);
        View.InvHeight = (int)(1 / View.InvScale);
        View.ShowMoney = true;

        if (InvFrame == null)
        {
            InvFrame = Images.LoadImage("graphics/interface/invframe.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow1 == null)
        {
            InvArrow1 = Images.LoadImage("graphics/interface/invarrow1.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow2 == null)
        {
            InvArrow2 = Images.LoadImage("graphics/interface/invarrow2.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow3 == null)
        {
            InvArrow3 = Images.LoadImage("graphics/interface/invarrow3.bmp", 0, Images.ImageType.AllodsBMP);
        }
        if (InvArrow4 == null)
        {
            InvArrow4 = Images.LoadImage("graphics/interface/invarrow4.bmp", 0, Images.ImageType.AllodsBMP);
        }

        //
        Renderer = gameObject.AddComponent <MeshRenderer>();
        Filter   = gameObject.AddComponent <MeshFilter>();

        Renderer.materials = new Material[] { new Material(MainCamera.MainShader), new Material(MainCamera.MainShader), new Material(MainCamera.MainShader) };
        Renderer.materials[0].mainTexture = InvFrame;
        Renderer.materials[1].color       = Renderer.materials[2].color = new Color(0, 0, 0, 0);

        // generate mesh.
        Utils.MeshBuilder mb = new Utils.MeshBuilder();
        // 3 submeshes: left arrow, right arrow, and background. I'm NOT using the full original inventory view.
        for (int j = 1; j >= 0; j--)
        {
            for (int i = 0; i < View.InvWidth; i++)
            {
                int internalPosition;
                if (i == 0)
                {
                    internalPosition = 0;
                }
                else if (i == View.InvWidth - 1)
                {
                    internalPosition = 4;
                }
                else
                {
                    internalPosition = (i % 3) + 1;
                }
                int yoffs = 0;
                if (View.InvScale < 1)
                {
                    yoffs = (int)(1.5f / View.InvScale);
                }
                Rect internalRect = Utils.DivRect(new Rect(32 + internalPosition * 80, 0, 80, 90), new Vector2(InvFrame.width, InvFrame.height));
                mb.AddQuad(0, 32 + i * 80 * View.InvScale, j * 80 * View.InvScale + yoffs, 80 * View.InvScale, 90 * View.InvScale, internalRect);
            }
        }

        // add two quads for unpressed buttons
        mb.AddQuad(0, 0, 0, 32, 90, Utils.DivRect(new Rect(0, 0, 32, 90), new Vector2(InvFrame.width, InvFrame.height)));
        mb.AddQuad(0, 32 + View.InvWidth * 80 * View.InvScale, 0, 32, 90, Utils.DivRect(new Rect(432, 0, 32, 90), new Vector2(InvFrame.width, InvFrame.height)));

        mb.AddQuad(1, 0, 2, 32, 88);
        mb.AddQuad(2, 32 + View.InvWidth * 80 * View.InvScale, 2, 32, 88);

        Filter.mesh = mb.ToMesh(MeshTopology.Quads, MeshTopology.Quads, MeshTopology.Quads);

        transform.localScale    = new Vector3(1, 1, 0.01f);
        transform.localPosition = new Vector3((MainCamera.Width - 176) / 2 - (View.InvWidth * 80 * View.InvScale + 64) / 2, MainCamera.Height - 90, MainCamera.InterfaceZ + 0.99f); // on this layer all map UI is drawn
    }
示例#6
0
    void SetMesh()
    {
        if (Filter.mesh)
        {
            Destroy(Filter.mesh);
        }

        List <Material>     materials = new List <Material>();
        List <MeshTopology> topos     = new List <MeshTopology>();

        materials.Add(new Material(MainCamera.MainShader)); // this is for outlines
        topos.Add(MeshTopology.Lines);
        //Renderer.materials = new Material[] { new Material(MainCamera.MainShader), new Material(MainCamera.MainShader) };

        Utils.MeshBuilder mb = new Utils.MeshBuilder();
        for (int i = 0; i < CurrentLevel.Sectors.Count; i++)
        {
            LevelSector sec = CurrentLevel.Sectors[i];

            if (drawAfter >= 0 && i < drawAfter)
            {
                continue;
            }

            int planemesh = mb.CurrentMesh + 1;
            mb.CurrentMesh = 0;
            //if (sec.Walls.Count > 1) Debug.LogFormat("sector {0} has walls", i);
            for (int j = 0; j < sec.Walls.Count; j++)
            {
                LevelWall wall = sec.Walls[j];

                //if (j != 0) continue;

                if (wall.V1.X < 0 || wall.V1.Y < 0 ||
                    wall.V2.X < 0 || wall.V2.Y < 0)
                {
                    continue;
                }

                Color color = new Color(1, 0, 0, 1);
                if (wall.Back != null)
                {
                    color.r = 0;
                    color.g = 1f;
                }

                //if (i == 0) color.g = color.b = 0;
                //else if (i == 10) color.g = color.r = 0;

                // sector 0 = 0
                // sector 10 = +8 (-8) floor height

                float TopFZ1 = wall.Front.Sector.Floor.ZatPoint(wall.V1.X, wall.V1.Y);
                if (wall.Back != null)
                {
                    TopFZ1 = Mathf.Max(TopFZ1, wall.Back.Sector.Floor.ZatPoint(wall.V1.X, wall.V1.Y)); // top point at v1
                }
                float BottomFZ1 = wall.Front.Sector.Floor.ZatPoint(wall.V1.X, wall.V1.Y);
                if (wall.Back != null)
                {
                    BottomFZ1 = Mathf.Min(BottomFZ1, wall.Back.Sector.Floor.ZatPoint(wall.V1.X, wall.V1.Y));
                }
                float TopFZ2 = wall.Front.Sector.Floor.ZatPoint(wall.V2.X, wall.V2.Y);
                if (wall.Back != null)
                {
                    TopFZ2 = Mathf.Max(TopFZ2, wall.Back.Sector.Floor.ZatPoint(wall.V2.X, wall.V2.Y)); // top point at v2
                }
                float BottomFZ2 = wall.Front.Sector.Floor.ZatPoint(wall.V2.X, wall.V2.Y);
                if (wall.Back != null)
                {
                    BottomFZ2 = Mathf.Min(BottomFZ2, wall.Back.Sector.Floor.ZatPoint(wall.V2.X, wall.V2.Y));
                }

                float TopCZ1 = wall.Front.Sector.Ceiling.ZatPoint(wall.V1.X, wall.V1.Y);
                if (wall.Back != null)
                {
                    TopCZ1 = Mathf.Max(TopCZ1, wall.Back.Sector.Ceiling.ZatPoint(wall.V1.X, wall.V1.Y)); // top point at v1
                }
                float BottomCZ1 = wall.Front.Sector.Ceiling.ZatPoint(wall.V1.X, wall.V1.Y);
                if (wall.Back != null)
                {
                    BottomCZ1 = Mathf.Min(BottomCZ1, wall.Back.Sector.Ceiling.ZatPoint(wall.V1.X, wall.V1.Y));
                }
                float TopCZ2 = wall.Front.Sector.Ceiling.ZatPoint(wall.V2.X, wall.V2.Y);
                if (wall.Back != null)
                {
                    TopCZ2 = Mathf.Max(TopCZ2, wall.Back.Sector.Ceiling.ZatPoint(wall.V2.X, wall.V2.Y)); // top point at v2
                }
                float BottomCZ2 = wall.Front.Sector.Ceiling.ZatPoint(wall.V2.X, wall.V2.Y);
                if (wall.Back != null)
                {
                    BottomCZ2 = Mathf.Min(BottomCZ2, wall.Back.Sector.Ceiling.ZatPoint(wall.V2.X, wall.V2.Y));
                }

                if (wall.Back != null)
                {
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopFZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopFZ2);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopCZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopCZ2);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, BottomFZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, BottomFZ2);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, BottomCZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, BottomCZ2);
                    mb.NextVertex();
                }
                else
                {
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopFZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopFZ2);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopCZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopCZ2);
                    mb.NextVertex();
                }

                // vertical lines
                if (wall.Back != null)
                {
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopFZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, BottomFZ1);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopFZ2);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, BottomFZ2);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopCZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, BottomCZ1);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopCZ2);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, BottomCZ2);
                    mb.NextVertex();
                }
                else
                {
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, TopFZ1);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V1.X, wall.V1.Y, BottomCZ1);
                    mb.NextVertex();

                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, TopFZ2);
                    mb.NextVertex();
                    mb.CurrentColor    = color;
                    mb.CurrentPosition = new Vector3(wall.V2.X, wall.V2.Y, BottomCZ2);
                    mb.NextVertex();
                }
            }

            // draw floor
            Material    texfloor    = new Material(MainCamera.MainShader);
            RadixBitmap bitmapfloor = TextureManager.GetTextureById(sec.Floor.Texture);
            Vector2     texmul      = new Vector2(bitmapfloor.Width, bitmapfloor.Height);
            if (bitmapfloor != null)
            {
                texfloor.mainTexture = bitmapfloor.Texture;
            }

            Material    texceiling    = new Material(MainCamera.MainShader);
            RadixBitmap bitmapceiling = TextureManager.GetTextureById(sec.Ceiling.Texture);
            Vector2     texmul2       = new Vector2(bitmapceiling.Width, bitmapceiling.Height);
            if (bitmapceiling != null)
            {
                texceiling.mainTexture = bitmapceiling.Texture;
            }

            materials.Add(texfloor);
            materials.Add(texceiling);
            topos.Add(MeshTopology.Triangles);
            topos.Add(MeshTopology.Triangles);

            for (int p = 0; p < 2; p++)
            {
                mb.CurrentMesh = planemesh + p;
                LevelSector.Plane plane = p == 0 ? sec.Floor : sec.Ceiling;
                for (int j = 0; j < sec.Triangles.Count; j++)
                {
                    LevelSector.Triangle tri = sec.Triangles[j];

                    Color color = new Color(0.5f, 0.5f, 0.5f, 1);

                    if (tri.Points.Count != 3)
                    {
                        // now, we know that this mesh is NOT actual triangle list, it consists of points around the sector.
                        Vector2 center = tri.Center;

                        for (int k = 0; k < tri.Points.Count; k++)
                        {
                            // add center point
                            mb.CurrentColor    = color;
                            mb.CurrentPosition = new Vector3(center.x, center.y, plane.ZatPoint(center.x, center.y));
                            mb.CurrentUV1      = new Vector2(center.x / texmul.x, center.y / texmul.y);
                            mb.NextVertex();

                            // add current point
                            int cIndex = k % tri.Points.Count;
                            mb.CurrentColor    = color;
                            mb.CurrentPosition = new Vector3(tri.Points[cIndex].x, tri.Points[cIndex].y, plane.ZatPoint(tri.Points[cIndex].x, tri.Points[cIndex].y));
                            mb.CurrentUV1      = new Vector2(tri.Points[cIndex].x / texmul.x, tri.Points[cIndex].y / texmul.y);
                            mb.NextVertex();

                            // add next point
                            int nIndex = (k + 1) % tri.Points.Count;
                            mb.CurrentColor    = color;
                            mb.CurrentPosition = new Vector3(tri.Points[nIndex].x, tri.Points[nIndex].y, plane.ZatPoint(tri.Points[nIndex].x, tri.Points[nIndex].y));
                            mb.CurrentUV1      = new Vector2(tri.Points[nIndex].x / texmul.x, tri.Points[nIndex].y / texmul.y);
                            mb.NextVertex();
                        }
                    }
                    else // it's a legit triangle, don't overcomplicate
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            mb.CurrentColor    = color;
                            mb.CurrentPosition = new Vector3(tri.Points[k].x, tri.Points[k].y, plane.ZatPoint(tri.Points[k].x, tri.Points[k].y));
                            mb.CurrentUV1      = new Vector2(tri.Points[k].x / texmul.x, tri.Points[k].y / texmul.y);
                            mb.NextVertex();
                        }
                    }
                }
            }

            if (drawAfter >= 0 && i >= drawAfter && sec.Walls.Count > 0)
            {
                Debug.LogFormat("stopped rendering at {0}", i);
                break;
            }
        }

        Filter.mesh        = mb.ToMesh(topos.ToArray());
        Renderer.materials = materials.ToArray();
    }