public static SurfaceComponentGeometry CreateDiamondCenterOctaSplitSquareGeometry( float sizeX, float sizeZ, int segmentX, int segmentZ, float diamondRatio = 0.6f, int surfaceGroup = 0, RenderGeometry.FaceType faceType = RenderGeometry.FaceType.Polygonal) { SurfaceComponentGeometry planeGeometry = SurfaceComponentGeometries.CreatePlaneGeometry(sizeX, sizeZ, segmentX, segmentZ); List <Vertex> corners = planeGeometry.corners; var structure = new StructureGeometry(planeGeometry); var edgesToMerge = new List <Halfedge>(); structure.faces.ForEach(f => { var component = CreateSingleDiamondCenterOctaSplitSquareGeometry(1, 1, diamondRatio, surfaceGroup, faceType); edgesToMerge.AddRange(component.boundaries.SelectMany(b => b).Select(e => e.opposite)); structure.SetFaceComponent(f, component, true); }); var geometry = new SurfaceComponentGeometry(structure.Build()); foreach (Halfedge edge in edgesToMerge) { if (edge.index >= 0 && !edge.opposite.isBoundary) { geometry.MergeFaces(edge); } } geometry.DefineBoundaries(corners.Select(structure.GetBuiltVertex).ToArray()); return(geometry); }
public static SurfaceComponentGeometry CreatePantagonSquareGeometry( float sizeX, float sizeZ, int segmentX, int segmentZ, float pantagonRatio = 0.3f, int surfaceGroup = 0, RenderGeometry.FaceType faceType = RenderGeometry.FaceType.Polygonal) { SurfaceComponentGeometry planeGeometry = SurfaceComponentGeometries.CreatePlaneGeometry(sizeX, sizeZ, segmentX * 2, segmentZ * 2, surfaceGroup, faceType); var originalVertexList = new List <Vertex>(planeGeometry.vertices); Vertex corner(int x, int z) => originalVertexList[x * (segmentZ * 2 + 1) + z]; float deltaX = sizeX / (segmentX * 2) * pantagonRatio; float deltaZ = sizeZ / (segmentZ * 2) * pantagonRatio; for (int x = 1; x < segmentX * 2; x++) { for (int z = 1; z < segmentZ * 2; z++) { if (x % 2 == 0 && z % 2 == 1) { corner(x, z).p += deltaX * ((x + z) % 4 == 3 ? Vector3.left : Vector3.right); } else if (x % 2 == 1 && z % 2 == 0) { corner(x, z).p += deltaZ * ((x + z) % 4 == 3 ? Vector3.forward : Vector3.back); } } } for (int x = 0; x < segmentX; x++) { for (int z = 0; z < segmentZ; z++) { if ((x + z) % 2 == 0) { planeGeometry.MergeFaces(planeGeometry.FindHalfedge(corner(x * 2 + 1, z * 2 + 1), corner(x * 2 + 1, z * 2))); planeGeometry.MergeFaces(planeGeometry.FindHalfedge(corner(x * 2 + 1, z * 2 + 1), corner(x * 2 + 1, z * 2 + 2))); } else { planeGeometry.MergeFaces(planeGeometry.FindHalfedge(corner(x * 2 + 1, z * 2 + 1), corner(x * 2, z * 2 + 1))); planeGeometry.MergeFaces(planeGeometry.FindHalfedge(corner(x * 2 + 1, z * 2 + 1), corner(x * 2 + 2, z * 2 + 1))); } } } return(planeGeometry); }