private void AppearanceChanged() { var y0 = 0d; var wallBuilder = new MeshBuilder(false, false); for (int i = 0; i < this.Stories; i++) { if (i > 0 && this.FloorThickness > 0) { wallBuilder.AddBox(new Point3D(0, 0, y0 + this.FloorThickness / 2), this.Length + 0.2, this.Width + 0.2, this.FloorThickness); y0 += this.FloorThickness; } wallBuilder.AddBox(new Point3D(0, 0, y0 + this.StoryHeight / 2), this.Length, this.Width, this.StoryHeight); y0 += this.StoryHeight; } var theta = Math.PI / 180 * this.RoofAngle; var roofBuilder = new MeshBuilder(false, false); var y1 = y0 + Math.Tan(theta) * this.Width / 2; var p0 = new Point(0, y1); var p1 = new Point(this.Width / 2 + 0.2 * Math.Cos(theta), y0 - 0.2 * Math.Sin(theta)); var p2 = new Point(p1.X + this.RoofThickness * Math.Sin(theta), p1.Y + this.RoofThickness * Math.Cos(theta)); var p3 = new Point(0, y1 + this.RoofThickness / Math.Cos(theta)); var p4 = new Point(-p2.X, p2.Y); var p5 = new Point(-p1.X, p1.Y); var roofSection = new[] { p0, p1, p1, p2, p2, p3, p3, p4, p4, p5, p5, p0 }; roofBuilder.AddExtrudedSegments(roofSection, new Vector3D(0, -1, 0), new Point3D(-this.Length / 2, 0, 0), new Point3D(this.Length / 2, 0, 0)); var cap = new[] { p0, p1, p2, p3, p4, p5 }; roofBuilder.AddPolygon(cap, new Vector3D(0, -1, 0), new Vector3D(0, 0, 1), new Point3D(-this.Length / 2, 0, 0)); roofBuilder.AddPolygon(cap, new Vector3D(0, 1, 0), new Vector3D(0, 0, 1), new Point3D(this.Length / 2, 0, 0)); var p6 = new Point(this.Width / 2, y0); var p7 = new Point(-this.Width / 2, y0); wallBuilder.AddPolygon(new[] { p0, p6, p7 }, new Vector3D(0, -1, 0), new Vector3D(0, 0, 1), new Point3D(-this.Length / 2, 0, 0)); wallBuilder.AddPolygon(new[] { p0, p6, p7 }, new Vector3D(0, 1, 0), new Vector3D(0, 0, 1), new Point3D(this.Length / 2, 0, 0)); this.walls.Geometry = wallBuilder.ToMesh(true); this.roof.Geometry = roofBuilder.ToMesh(true); }