protected override void BuildMeshComponents() { var points = CatmullRomSpline.GetPoints(MeshHelper.ConvertVec2ToVec3(SplinePoints), Resolution); if (MinArea.HasValue) { points = SplineSimplification.Simplify(points, MinArea.Value, true, false); } Vertices = points.ToArray(); CenterShift = MeshHelper.GetCenter(Vertices); for (int i = 0; i < Vertices.Length; i++) { Vertices[i] -= CenterShift; } Triangles = new int[Vertices.Length * 3]; for (int i = 0; i < Vertices.Length; i++) { Triangles[i * 3 + 0] = 0; Triangles[i * 3 + 1] = i; Triangles[i * 3 + 2] = (i + 1) % Vertices.Length; } UVs = MeshHelper.UVUnwrap(Vertices); }
protected override void BuildMeshComponents() { Vector2 center = MeshHelper.GetCenter(SplinePoints); for (int i = 0; i < SplinePoints.Length; i++) { SplinePoints[i] -= center; } var points = CatmullRomSpline.GetPoints(MeshHelper.ConvertVec2ToVec3(SplinePoints), Resolution); if (MinArea.HasValue) { points = SplineSimplification.Simplify(points, MinArea.Value, true, false); } Vertices = points.ToArray(); var connections = Triangulation.TriangulationToInt3(new List <Vector2>(MeshHelper.ConvertVec3ToVec2(Vertices))); Triangles = new int[connections.Count * 3]; for (int i = 0; i < connections.Count; i++) { Triangles[i * 3 + 0] = connections[i].A; Triangles[i * 3 + 1] = connections[i].B; Triangles[i * 3 + 2] = connections[i].C; } UVs = MeshHelper.UVUnwrap(Vertices); }
protected override void BuildMeshComponents() { BaseVertices = ConvexVertices; Vertices = MeshHelper.ConvertVec2ToVec3(ConvexHull.QuickHull(MeshHelper.ConvertVec3ToVec2(ConvexVertices)).ToArray()); // oh no Triangles = new int[Vertices.Length * 3]; for (int i = 1; i < Vertices.Length - 1; i++) { Triangles[i * 3 + 0] = 0; Triangles[i * 3 + 1] = i; Triangles[i * 3 + 2] = i + 1; } UVs = MeshHelper.UVUnwrap(Vertices); }