public FlatRoof (BuildingMesh parent) : base(parent) { width = 0.1f; height = 0.05f; boundaries = new Vector3[8]; for (int i = 0; i < 4; ++i) { boundaries[i] = parentMesh.roofBase.boundaries[i + 4] + width * parentMesh.faces[i].normal + width * parentMesh.faces[(i + 3) % 4].normal; boundaries[i + 4] = boundaries[i] + height * Vector3.up; } decor = new RoofDecoration(this); if (parentMesh.parent.roofDecorMaterial == null) { var list = MaterialManager.Instance.GetCollection("mat_roof_decor"); decor.material = list[Random.Range(0, list.Count)]; } else decor.material = parentMesh.parent.roofDecorMaterial; parentMesh.parent.AddCombinable(decor.material.name, decor); }
public void CreateBuilding () { if (startingPoints == null) { startingPoints = new Vector3[4]; if (width0 == 0f || width1 == 0f) { startingPoints[0] = new Vector3(); startingPoints[1] = new Vector3(0f, 0f, 11f); startingPoints[2] = new Vector3(8f, 0f, 11f); startingPoints[3] = new Vector3(8f, 0f, 0f); } else { startingPoints[0] = new Vector3(); startingPoints[1] = Vector3.forward * width0; startingPoints[3] = Vector3.right * width1; startingPoints[2] = startingPoints[1] + startingPoints[3]; } } buildingMesh = new BuildingMesh(this, startingPoints[0], startingPoints[1], startingPoints[2], startingPoints[3]); gameObject = new GameObject("Neoclassical"); gameObject.transform.position = buildingMesh.meshOrigin; }
public FlatRoof(BuildingMesh parent) : base(parent) { width = 0.1f; height = 0.05f; boundaries = new Vector3[8]; for (int i = 0; i < 4; ++i) { boundaries[i] = parentMesh.roofBase.boundaries[i + 4] + width * parentMesh.faces[i].normal + width * parentMesh.faces[(i + 3) % 4].normal; boundaries[i + 4] = boundaries[i] + height * Vector3.up; } decor = new RoofDecoration(this); if (parentMesh.parent.roofDecorMaterial == null) { var list = MaterialManager.Instance.GetCollection("mat_roof_decor"); decor.material = list[Random.Range(0, list.Count)]; } else decor.material = parentMesh.parent.roofDecorMaterial; parentMesh.parent.AddCombinable(decor.material.name, decor); }
public Building (BuildingLot lot) { Init(); // must be _after_ the initialization of this object buildingMesh = new BuildingMesh(this, lot); gameObject = new GameObject("Neoclassical"); gameObject.transform.position = buildingMesh.meshOrigin; }
public Building (Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) { Init(); // must be _after_ the initialization of this object buildingMesh = new BuildingMesh(this, p1, p2, p3, p4); gameObject = new GameObject("Neoclassical"); gameObject.transform.position = buildingMesh.meshOrigin; }
public Building(BuildingLot lot) { Init(); // must be _after_ the initialization of this object buildingMesh = new BuildingMesh(this, lot); gameObject = new GameObject("Neoclassical"); gameObject.transform.position = buildingMesh.meshOrigin; }
public Building(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) { Init(); // must be _after_ the initialization of this object buildingMesh = new BuildingMesh(this, p1, p2, p3, p4); gameObject = new GameObject("Neoclassical"); gameObject.transform.position = buildingMesh.meshOrigin; }
public DoublePeakRoof (BuildingMesh parent) : base(parent) { width = 0.2f; boundaries = new Vector3[6]; for (int i = 0; i < 4; ++i) boundaries[i] = parentMesh.roofBase.boundaries[i + 4]+ width * parentMesh.faces[i].normal + width * parentMesh.faces[(i + 3) % 4].normal; FindMeshOrigin(boundaries[0], boundaries[2], boundaries[1], boundaries[3]); int index = Mathf.Max(parentMesh.sortedFaces[2], parentMesh.sortedFaces[3]); Face face = parentMesh.faces[index]; height = 0.2f * face.width; var bi0 = (parentMesh.faces[(index + 3) % 4].right - face.right).normalized; var bi1 = (face.right - parentMesh.faces[(index + 1) % 4].right).normalized; var p = Util.IntersectionPoint(face.boundaries[0], bi0, face.boundaries[1], bi1); boundaries[4] = new Vector3(p.x, boundaries[0].y + height, p.z); index = Mathf.Min(parentMesh.sortedFaces[2], parentMesh.sortedFaces[3]); face = parentMesh.faces[index]; bi0 = (parentMesh.faces[(index + 3) % 4].right - face.right).normalized; bi1 = (face.right - parentMesh.faces[(index + 1) % 4].right).normalized; p = Util.IntersectionPoint(face.boundaries[0], bi0, face.boundaries[1], bi1); boundaries[5] = new Vector3(p.x, boundaries[0].y + height, p.z); if ((boundaries[0] - boundaries[4]).magnitude < (boundaries[0] - boundaries[5]).magnitude) { _type = _Type.four; _widthBig = (boundaries[0] - boundaries[1]).magnitude; _widthSmall = (boundaries[1] - boundaries[2]).magnitude; _heightSmall = ((boundaries[1] + boundaries[2]) / 2 - boundaries[5]).magnitude; } else { _type = _Type.five; _widthBig = (boundaries[1] - boundaries[2]).magnitude; _widthSmall = (boundaries[1] - boundaries[0]).magnitude; _heightSmall = ((boundaries[1] + boundaries[0]) / 2 - boundaries[5]).magnitude; } _heightBig = Mathf.Sqrt(Mathf.Pow(_widthSmall / 2, 2) + Mathf.Pow(height, 2)); }
/*************** CONSTRUCTORS ***************/ public RoofBase(BuildingMesh parent) { parentMesh = parent; height = 0.6f; boundaries = new Vector3[8]; for (int i = 0; i < 4; ++i) { boundaries[i] = parentMesh.boundaries[i + 4]; boundaries[i + 4] = boundaries[i] + height * Vector3.up; } }
/*************** CONSTRUCTORS ***************/ public RoofBase (BuildingMesh parent) { parentMesh = parent; height = 0.6f; boundaries = new Vector3[8]; for (int i = 0; i < 4; ++i) { boundaries[i] = parentMesh.boundaries[i + 4]; boundaries[i + 4] = boundaries[i] + height * Vector3.up; } }
/*************** CONSTRUCTORS ***************/ /// <summary> /// Initializes a new instance of the <see cref="Face"/> class from the given points, /// in clockwise order. The clockwise order is required so that the normal of this face /// is properly calculated. /// </summary> public Face(BuildingMesh parent, Vector3 dr, Vector3 dl, bool isFree = true) { parentBuilding = parent; _isFree = isFree; boundaries = new Vector3[4]; boundaries[0] = dr; boundaries[1] = dl; boundaries[2] = new Vector3(dl.x, dl.y + parentBuilding.height, dl.z); boundaries[3] = new Vector3(dr.x, dr.y + parentBuilding.height, dr.z); right = new Vector3(boundaries[0].x - boundaries[1].x, 0f, boundaries[0].z - boundaries[1].z); width = right.magnitude; normal = Vector3.Cross(Vector3.up, right); right.Normalize(); normal.Normalize(); }
/*************** CONSTRUCTORS ***************/ /// <summary> /// Initializes a new instance of the <see cref="Face"/> class from the given points, /// in clockwise order. The clockwise order is required so that the normal of this face /// is properly calculated. /// </summary> public Face (BuildingMesh parent, Vector3 dr, Vector3 dl, bool isFree = true) { parentBuilding = parent; _isFree = isFree; boundaries = new Vector3[4]; boundaries[0] = dr; boundaries[1] = dl; boundaries[2] = new Vector3(dl.x, dl.y + parentBuilding.height, dl.z); boundaries[3] = new Vector3(dr.x, dr.y + parentBuilding.height, dr.z); right = new Vector3(boundaries[0].x - boundaries[1].x, 0f, boundaries[0].z - boundaries[1].z); width = right.magnitude; normal = Vector3.Cross(Vector3.up, right); right.Normalize(); normal.Normalize(); }
public SinglePeakRoof(BuildingMesh parent) : base(parent) { height = 1f; width = 0.2f; boundaries = new Vector3[5]; for (int i = 0; i < 4; ++i) boundaries[i] = parentMesh.roofBase.boundaries[i + 4] + width * parentMesh.faces[i].normal + width * parentMesh.faces[(i + 3) % 4].normal; FindMeshOrigin(boundaries[0], boundaries[2], boundaries[1], boundaries[3]); boundaries[4] = new Vector3(meshOrigin.x, boundaries[0].y + height, meshOrigin.z); }
public SinglePeakRoof(BuildingMesh parent) : base(parent) { height = 1f; width = 0.2f; boundaries = new Vector3[5]; for (int i = 0; i < 4; ++i) { boundaries[i] = parentMesh.roofBase.boundaries[i + 4] + width * parentMesh.faces[i].normal + width * parentMesh.faces[(i + 3) % 4].normal; } FindMeshOrigin(boundaries[0], boundaries[2], boundaries[1], boundaries[3]); boundaries[4] = new Vector3(meshOrigin.x, boundaries[0].y + height, meshOrigin.z); }
public void CreateBuilding() { if (startingPoints == null) { startingPoints = new Vector3[4]; if (width0 == 0f || width1 == 0f) { startingPoints[0] = new Vector3(); startingPoints[1] = new Vector3(0f, 0f, 11f); startingPoints[2] = new Vector3(8f, 0f, 11f); startingPoints[3] = new Vector3(8f, 0f, 0f); } else { startingPoints[0] = new Vector3(); startingPoints[1] = Vector3.forward * width0; startingPoints[3] = Vector3.right * width1; startingPoints[2] = startingPoints[1] + startingPoints[3]; } } buildingMesh = new BuildingMesh(this, startingPoints[0], startingPoints[1], startingPoints[2], startingPoints[3]); gameObject = new GameObject("Neoclassical"); gameObject.transform.position = buildingMesh.meshOrigin; }
public Roof (BuildingMesh parent) { parentMesh = parent; decor = null; }