public static MeshDraft Wall(Vector3 origin, Vector3 width, Vector3 height) { MeshDraft draft = MeshDraft.Quad(origin, width, height); draft.Paint(BuildingGenerator.wallColor); return(draft); }
public static MeshDraft Socle(Vector3 origin, Vector3 width, Vector3 height) { var draft = MeshDraft.Quad(origin, width, height); draft.Paint(BuildingGenerator.socleColor); return(draft); }
public override MeshDraft GetMeshDraft() { var draft = MeshDraft.Quad(origin.Value, Vector3.right * width.Value, Vector3.up * height.Value); draft.Paint(wallColor); return(draft); }
public static MeshDraft FlatRoof(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { var draft = MeshDraft.Quad(a, d, c, b); draft.Paint(BuildingGenerator.roofColor); return(draft); }
public static MeshDraft Wall(Vector3 origin, Vector3 width, Vector3 height) { MeshDraft draft = MeshDraft.Quad(origin, width, height); draft.Paint(Khrushchyovka.wallColor); return(draft); }
public static MeshDraft FlatRoof(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { var draft = MeshDraft.Quad(a, d, c, b); draft.Paint(Khrushchyovka.roofColor); return(draft); }
protected static MeshDraft Entrance(Vector3 origin, float width, float height, Color wallColor, Color doorColor) { Vector3 widthVector = Vector3.right * width; Vector3 heightVector = Vector3.up * height; Vector3 doorWidth = Vector3.right * EntranceDoorWidth; Vector3 doorHeight = Vector3.up * EntranceDoorHeight; Vector3 doorThickness = Vector3.back * EntranceDoorThickness; Vector3 doorOrigin = origin + widthVector / 2 - doorWidth / 2; var draft = Bracket(origin, widthVector, heightVector, doorOrigin, doorWidth, doorHeight); draft.Paint(wallColor); var doorFrame = MeshDraft.PartialBox(doorWidth, -doorThickness, doorHeight, Directions.All & ~Directions.ZAxis); doorFrame.Move(doorOrigin + doorWidth / 2 + doorHeight / 2 + doorThickness / 2); doorFrame.Paint(doorColor); draft.Add(doorFrame); var door = MeshDraft.Quad(doorOrigin + doorThickness, doorWidth, doorHeight); door.Paint(doorColor); draft.Add(door); return(draft); }
public static MeshDraft Socle(Vector3 origin, Vector3 width, Vector3 height) { var draft = MeshDraft.Quad(origin, width, height); draft.Paint(Khrushchyovka.socleColor); return(draft); }
protected static MeshDraft SocleWindowed(Vector3 origin, float width, float height, Color wallColor, Color glassColor) { Vector3 widthVector = Vector3.right * width; Vector3 heightVector = Vector3.up * height; Vector3 windowWidth = Vector3.right * SocleWindowWidth; Vector3 windowHeigth = Vector3.up * SocleWindowHeight; Vector3 windowDepth = Vector3.forward * SocleWindowDepth; Vector3 windowOrigin = origin + widthVector / 2 - windowWidth / 2 + Vector3.up * SocleWindowHeightOffset; Vector3 windowMax = windowOrigin + windowWidth + windowHeigth; var wall = PerforatedQuad(origin, origin + widthVector + heightVector, windowOrigin, windowMax); var frame = MeshDraft.PartialBox(windowWidth, -windowDepth, windowHeigth, Directions.All & ~Directions.ZAxis); frame.Move(windowOrigin + windowWidth / 2 + windowHeigth / 2 + windowDepth / 2); wall.Add(frame); wall.Paint(wallColor); var window = MeshDraft.Quad(windowOrigin + windowDepth / 2, windowWidth, windowHeigth); window.Paint(glassColor); wall.Add(window); return(wall); }
private static MeshDraft GenerateFlat(List <Vector2> roofPolygon, RoofConfig roofConfig) { Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 b = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 d = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness; var roofDraft = MeshDraft.Quad(a, d, c, b); return(roofDraft); }
public static MeshDraft GabledRoof(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { Vector3 ridgeHeight = Vector3.up * GabledRoofHeight; Vector3 ridge0 = (a + d) / 2 + ridgeHeight; Vector3 ridge1 = (b + c) / 2 + ridgeHeight; var draft = MeshDraft.Quad(a, ridge0, ridge1, b); draft.Add(MeshDraft.Triangle(b, ridge1, c)); draft.Add(MeshDraft.Quad(c, ridge1, ridge0, d)); draft.Add(MeshDraft.Triangle(d, ridge0, a)); draft.Paint(Khrushchyovka.roofColor); return(draft); }
public static MeshDraft HippedRoof(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { Vector3 ridgeHeight = Vector3.up * HippedRoofHeight; Vector3 ridgeOffset = (b - a).normalized * 2; Vector3 ridge0 = (a + d) / 2 + ridgeHeight + ridgeOffset; Vector3 ridge1 = (b + c) / 2 + ridgeHeight - ridgeOffset; var draft = MeshDraft.Quad(a, ridge0, ridge1, b); draft.Add(MeshDraft.Triangle(b, ridge1, c)); draft.Add(MeshDraft.Quad(c, ridge1, ridge0, d)); draft.Add(MeshDraft.Triangle(d, ridge0, a)); draft.Paint(BuildingGenerator.roofColor); return(draft); }
public static MeshDraft Entrance(Vector3 origin, Vector3 width, Vector3 height) { Vector3 doorWidth = width.normalized * EntranceDoorWidth; Vector3 doorOrigin = origin + width / 2 - doorWidth / 2; Vector3 doorHeight = Vector3.up * EntranceDoorHeight; var draft = Bracket(origin, width, height, doorOrigin, doorWidth, doorHeight); draft.Paint(Khrushchyovka.wallColor); var door = MeshDraft.Quad(doorOrigin, doorWidth, doorHeight); door.Paint(Khrushchyovka.doorColor); draft.Add(door); return(draft); }
private static MeshDraft Windowpane(Vector3 min, Vector3 max, Color frameColor, Color glassColor) { Vector3 size = max - min; Vector3 widthVector = size.OnlyXZ(); Vector3 heightVector = size.OnlyY(); Vector3 right = widthVector.normalized; Vector3 normal = Vector3.Cross(widthVector, heightVector).normalized; var draft = new MeshDraft(); int rodCount = Mathf.FloorToInt(widthVector.magnitude / WindowSegmentMinWidth); float interval = widthVector.magnitude / (rodCount + 1); Vector3 frameWidth = right * WindowFrameWidth / 2; Vector3 frameHeight = Vector3.up * WindowFrameWidth / 2; Vector3 frameLength = normal * WindowFrameWidth / 2; Vector3 startPosition = min + heightVector / 2 + frameLength / 2; for (int i = 0; i < rodCount; i++) { var frame = MeshDraft.PartialBox(frameWidth * 2, frameLength, heightVector - frameHeight * 2, Directions.Left | Directions.Back | Directions.Right); frame.Move(startPosition + right * (i + 1) * interval); draft.Add(frame); } Vector3 windowMin = min + frameWidth + frameHeight; Vector3 windowWidth = widthVector - frameWidth * 2; Vector3 windowHeight = heightVector - frameHeight * 2; Vector3 windowMax = windowMin + windowWidth + windowHeight; var window = PerforatedQuad(min, max, windowMin, windowMax); draft.Add(window); var hole = MeshDraft.PartialBox(windowWidth, frameLength, windowHeight, Directions.All & ~Directions.ZAxis); hole.Move(startPosition + widthVector / 2); hole.FlipFaces(); draft.Add(hole); draft.Paint(frameColor); var glass = MeshDraft.Quad(windowMin + frameLength, windowWidth, windowHeight); glass.Paint(glassColor); draft.Add(glass); return(draft); }
public static MeshDraft GenerateHipped(List <Vector2> roofPolygon, RoofConfig roofConfig) { Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 b = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 d = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 ridgeHeight = Vector3.up * HippedRoofHeight; Vector3 ridgeOffset = (b - a).normalized * 2; Vector3 ridge0 = (a + d) / 2 + ridgeHeight + ridgeOffset; Vector3 ridge1 = (b + c) / 2 + ridgeHeight - ridgeOffset; var roofDraft = MeshDraft.Quad(a, ridge0, ridge1, b); roofDraft.Add(MeshDraft.Triangle(b, ridge1, c)); roofDraft.Add(MeshDraft.Quad(c, ridge1, ridge0, d)); roofDraft.Add(MeshDraft.Triangle(d, ridge0, a)); return(roofDraft); }
public static MeshDraft GenerateGabled(List <Vector2> roofPolygon, RoofConfig roofConfig) { Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 b = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 d = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 ridgeHeight = Vector3.up * GabledRoofHeight; Vector3 ridge0 = (a + d) / 2 + ridgeHeight; Vector3 ridge1 = (b + c) / 2 + ridgeHeight; var roofDraft = MeshDraft.Quad(a, ridge0, ridge1, b); roofDraft.AddTriangle(b, ridge1, c); roofDraft.AddQuad(c, ridge1, ridge0, d); roofDraft.AddTriangle(d, ridge0, a); return(roofDraft); }
private static MeshDraft Windowpane(Vector3 origin, Vector3 width, Vector3 heigth) { Vector3 right = width.normalized; Vector3 normal = Vector3.Cross(width, heigth).normalized; var draft = new MeshDraft(); int rodCount = Mathf.FloorToInt(width.magnitude / WindowSegmentMinWidth); float interval = width.magnitude / (rodCount + 1); Vector3 frameWidth = right * WindowFrameWidth / 2; Vector3 frameHeight = Vector3.up * WindowFrameWidth / 2; Vector3 frameLength = normal * WindowFrameWidth / 2; Vector3 startPosition = origin + heigth / 2 + frameLength / 2; for (int i = 0; i < rodCount; i++) { var frame = MeshDraft.Hexahedron(frameWidth * 2, frameLength, heigth - frameHeight * 2, Directions.Left | Directions.Back | Directions.Right); frame.Move(startPosition + right * (i + 1) * interval); draft.Add(frame); } Vector3 windowCorner = origin + frameWidth + frameHeight; Vector3 windowWidth = width - frameWidth * 2; Vector3 windowHeigth = heigth - frameHeight * 2; var window = PerforatedQuad(origin, width, heigth, windowCorner, windowWidth, windowHeigth); draft.Add(window); var hole = MeshDraft.Hexahedron(windowWidth, frameLength, windowHeigth, Directions.All & ~Directions.ZAxis); hole.Move(startPosition + width / 2); hole.FlipFaces(); draft.Add(hole); draft.Paint(Khrushchyovka.frameColor); var glass = MeshDraft.Quad(windowCorner + frameLength, windowWidth, windowHeigth); glass.Paint(Khrushchyovka.glassColor); draft.Add(glass); return(draft); }
public static MeshDraft KhrushchyovkaDraft(float width, float length, int floorCount, bool hasAttic) { float height = FloorHeight * floorCount + SocleHeight + (hasAttic ? AtticHeight : 0); var draft = new MeshDraft { name = "Khrushchyovka" }; var corners = new Vector3[] { Vector3.left *length / 2 + Vector3.back *width / 2, Vector3.right *length / 2 + Vector3.back *width / 2, Vector3.right *length / 2 + Vector3.forward *width / 2, Vector3.left *length / 2 + Vector3.forward *width / 2 }; commonPanelConstructors[PanelType.Entrance] = panelConstructors[PanelType.Entrance].GetRandom(); commonPanelConstructors[PanelType.EntranceWall] = panelConstructors[PanelType.EntranceWall].GetRandom(); wallColor = RandomE.colorHSV.WithA(0); List <FloorPlan> facadePlan0 = FacadeGenerator(length, floorCount, hasAttic, true, true); draft.Add(Facade(corners[0], Vector3.right, facadePlan0)); List <FloorPlan> facadePlan1 = FacadeGenerator(width, floorCount, hasAttic); draft.Add(Facade(corners[1], Vector3.forward, facadePlan1)); List <FloorPlan> facadePlan2 = FacadeGenerator(length, floorCount, hasAttic, false, true); draft.Add(Facade(corners[2], Vector3.left, facadePlan2)); List <FloorPlan> facadePlan3 = FacadeGenerator(width, floorCount, hasAttic); draft.Add(Facade(corners[3], Vector3.back, facadePlan3)); draft.Add(Roof(corners[0], corners[1], corners[2], corners[3], Vector3.up * height)); var basement = MeshDraft.Quad(corners[0], corners[1], corners[2], corners[3]); basement.Paint(roofColor); draft.Add(basement); return(draft); }
protected static MeshDraft BalconyGlazed(Vector3 origin, float width, float height, Color wallColor, Color frameColor, Color glassColor, Color roofColor) { Vector3 widthVector = Vector3.right * width; Vector3 heightVector = Vector3.up * height; Vector3 balconyHeight = Vector3.up * BalconyHeight; Vector3 balconyDepth = Vector3.back * BalconyDepth; var draft = new MeshDraft(); var balcony = MeshDraft.PartialBox(widthVector, balconyDepth, balconyHeight, Directions.All & ~Directions.Up & ~Directions.Back); balcony.FlipFaces(); balcony.Move(origin + widthVector / 2 + balconyDepth / 2 + balconyHeight / 2); balcony.Paint(wallColor); draft.Add(balcony); Vector3 roof0 = origin + heightVector; Vector3 roof1 = roof0 + widthVector; Vector3 roof2 = roof1 + balconyDepth; Vector3 roof3 = roof0 + balconyDepth; var roof = MeshDraft.Quad(roof0, roof1, roof2, roof3); roof.Paint(roofColor); draft.Add(roof); Vector3 glassHeight = heightVector - balconyHeight; Vector3 glass0 = origin + balconyHeight; Vector3 glass1 = glass0 + balconyDepth; Vector3 glass2 = glass1 + widthVector; var glass = Windowpane(glass0, glass0 + balconyDepth + glassHeight, frameColor, glassColor); glass.Add(Windowpane(glass1, glass1 + widthVector + glassHeight, frameColor, glassColor)); glass.Add(Windowpane(glass2, glass2 - balconyDepth + glassHeight, frameColor, glassColor)); draft.Add(glass); return(draft); }
public static MeshDraft BalconyGlazed(Vector3 origin, Vector3 width, Vector3 height) { Vector3 balconyWidth = width; Vector3 balconyHeight = height.normalized * BalconyHeight; Vector3 balconyDepth = Vector3.Cross(height, width).normalized *BalconyDepth; var draft = new MeshDraft(); var balcony = MeshDraft.Hexahedron(balconyWidth, balconyDepth, balconyHeight, Directions.All & ~Directions.Up & ~Directions.Back); balcony.FlipFaces(); balcony.Move(origin + width / 2 + balconyDepth / 2 + balconyHeight / 2); balcony.Paint(Khrushchyovka.wallColor); draft.Add(balcony); Vector3 roof0 = origin + height; Vector3 roof1 = roof0 + balconyWidth; Vector3 roof2 = roof1 + balconyDepth; Vector3 roof3 = roof0 + balconyDepth; var roof = MeshDraft.Quad(roof0, roof1, roof2, roof3); roof.Paint(Khrushchyovka.roofColor); draft.Add(roof); Vector3 glassHeight = height - balconyHeight; Vector3 glass0 = origin + balconyHeight; Vector3 glass1 = glass0 + balconyDepth; Vector3 glass2 = glass1 + balconyWidth; var glass = Windowpane(glass0, balconyDepth, glassHeight); glass.Add(Windowpane(glass1, balconyWidth, glassHeight)); glass.Add(Windowpane(glass2, -balconyDepth, glassHeight)); draft.Add(glass); return(draft); }
public static MeshDraft SocleWindowed(Vector3 origin, Vector3 width, Vector3 height) { Vector3 right = width.normalized; Vector3 windowOrigin = origin + width / 2 - right * SocleWindowWidth / 2 + Vector3.up * SocleWindowHeightOffset; Vector3 windowWidth = right * SocleWindowWidth; Vector3 windowHeigth = Vector3.up * SocleWindowHeight; Vector3 windowDepth = Vector3.Cross(width, height).normalized *SocleWindowDepth; var draft = PerforatedQuad(origin, width, height, windowOrigin, windowWidth, windowHeigth); var frame = MeshDraft.Hexahedron(windowWidth, -windowDepth, windowHeigth, Directions.All & ~Directions.ZAxis); frame.Move(windowOrigin + windowWidth / 2 + windowHeigth / 2 + windowDepth / 2); draft.Add(frame); draft.Paint(Khrushchyovka.socleColor); var window = MeshDraft.Quad(windowOrigin + windowDepth / 2, windowWidth, windowHeigth); window.Paint(Khrushchyovka.socleWindowColor); draft.Add(window); return(draft); }