public static MeshDraft GenerateGabled(List <Vector2> roofPolygon, RoofConfig roofConfig) { Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 b = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 d = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 ridgeHeight = Vector3.up * GabledRoofHeight; Vector3 ridge0 = (a + d) / 2 + ridgeHeight; Vector3 ridge1 = (b + c) / 2 + ridgeHeight; var roofDraft = new MeshDraft(); roofDraft.AddQuad(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 GenerateFlat(List <Vector2> roofPolygon, RoofConfig roofConfig) { Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 b = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness; Vector3 d = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness; var roofDraft = new MeshDraft(); roofDraft.AddQuad(a, d, c, b, Vector3.up); return(roofDraft); }
public static MeshDraft CubeOpenTop(Vector3 width, Vector3 length, Vector3 height, bool generateUV = true) { Vector3 v000 = -width / 2 - length / 2 - height / 2; Vector3 v001 = v000 + height; Vector3 v010 = v000 + width; Vector3 v011 = v000 + width + height; Vector3 v100 = v000 + length; Vector3 v101 = v000 + length + height; Vector3 v110 = v000 + width + length; Vector3 v111 = v000 + width + length + height; var draft = new MeshDraft { name = "Hexahedron" }; if (generateUV) { Vector2 uv0 = new Vector2(0, 0); Vector2 uv1 = new Vector2(0, 1); Vector2 uv2 = new Vector2(1, 1); Vector2 uv3 = new Vector2(1, 0); draft.AddQuad(v100, v101, v001, v000, Vector3.left, uv0, uv1, uv2, uv3) .AddQuad(v010, v011, v111, v110, Vector3.right, uv0, uv1, uv2, uv3) // .AddQuad(v010, v110, v100, v000, Vector3.down, uv0, uv1, uv2, uv3) .AddQuad(v111, v011, v001, v101, Vector3.up, uv0, uv1, uv2, uv3) .AddQuad(v000, v001, v011, v010, Vector3.back, uv0, uv1, uv2, uv3) .AddQuad(v110, v111, v101, v100, Vector3.forward, uv0, uv1, uv2, uv3); } else { draft.AddQuad(v100, v101, v001, v000, Vector3.left) .AddQuad(v010, v011, v111, v110, Vector3.right) // .AddQuad(v010, v110, v100, v000, Vector3.down) .AddQuad(v111, v011, v001, v101, Vector3.up) .AddQuad(v000, v001, v011, v010, Vector3.back) .AddQuad(v110, v111, v101, v100, Vector3.forward); } return(draft); }
private void AddLeftHalf(int x, int y) { Vector2 bottomLeft = GetBottomLeftPosition(x, y); if (contours.useInterpolation) { draft.AddQuad( bottomLeft, bottomLeft + Vector2.up * squareSize, bottomLeft + Vector2.right * contours.GetTopSide(x, y) * squareSize + Vector2.up * squareSize, bottomLeft + Vector2.right * contours.GetBottomSide(x, y) * squareSize, normal); } else { draft.AddQuad( bottomLeft, bottomLeft + Vector2.up * squareSize, bottomLeft + Vector2.right * cornerWeight * squareSize + Vector2.up * squareSize, bottomLeft + Vector2.right * cornerWeight * squareSize, normal); } }