public BuildingMesh(Building parent, BuildingLot lot)
        {
            this.parent = parent;
            name = "neo_building_mesh";
            var list = MaterialManager.Instance.GetCollection("mat_walls");
            material = list[Random.Range(0, list.Count)];

            parent.AddCombinable(material.name, this);

            if (parent.floorHeight <= 0f)
              floorHeight = Random.Range(3.8f, 4f);
            else
              floorHeight = parent.floorHeight;

            if (parent.floorCount <= 0)
              floorCount = Util.RollDice(new float[] {0.15f, 0.7f, 0.15f});
            else
              floorCount = parent.floorCount;

            FindMeshOrigin(lot.edges[0].start, lot.edges[2].start,
                   lot.edges[1].start, lot.edges[3].start);

            boundaries = new Vector3[8];
            boundaries[0] = lot.edges[0].start - meshOrigin;
            boundaries[1] = lot.edges[1].start - meshOrigin;
            boundaries[2] = lot.edges[2].start - meshOrigin;
            boundaries[3] = lot.edges[3].start - meshOrigin;

            for (int i = 0; i < 4; ++i)
              boundaries[i + 4] = boundaries[i] + height * Vector3.up;

            ConstructFaces(lot);
            ConstructFaceComponents();
            ConstructRoof();
        }
 public void Build(BuildingLot lot)
 {
     var n = new Building(lot);
     n.buildingMesh.FindVertices();
     n.buildingMesh.FindTriangles();
     n.buildingMesh.Draw();
     n.CombineSubmeshes();
     n.gameObject.SetActiveRecursively(true);
     _buildings.Add(n);
 }
 public void Build(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4)
 {
     var n = new Building(p1, p2, p3, p4);
     n.buildingMesh.FindVertices();
     n.buildingMesh.FindTriangles();
     n.buildingMesh.Draw();
     n.CombineSubmeshes();
     n.gameObject.SetActiveRecursively(true);
     _buildings.Add(n);
 }
 public void Build(BuildingLot lot)
 {
     var n = new Building(lot);
     n.buildingMesh.FindVertices();
     n.buildingMesh.FindTriangles();
     n.buildingMesh.Draw();
     n.CombineSubmeshes();
     n.gameObject.SetActive(true);
     foreach (Transform t in n.gameObject.transform) {
       t.gameObject.SetActive(true);
     }
     _buildings.Add(n);
 }
 public void Build(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4)
 {
     var n = new Building(p1, p2, p3, p4);
     n.buildingMesh.FindVertices();
     n.buildingMesh.FindTriangles();
     n.buildingMesh.Draw();
     n.CombineSubmeshes();
     n.gameObject.SetActive(true);
     foreach (Transform t in n.gameObject.transform) {
       t.gameObject.SetActive(true);
     }
     _buildings.Add(n);
 }