MeshData GetLineMeshData(Vector2[] line) { MeshData meshData = new MeshData(); if (additional.isAdditionalMode) { MeshData lineMesh = LineDrawer.GetMeshDataMk2(line, width, additional.materialLeft, material, additional.materialRight, zValue); meshData = MeshData.Marge(meshData, lineMesh); } else { MeshData lineMesh = LineDrawer.GetMeshData(line, width, material, zValue); meshData = MeshData.Marge(meshData, lineMesh); } if (make3D.is3DMode) { List <Vector2> linepadData = LineDrawer.GetMainLineData(line, Mathf.Max(0.001f, make3D.padding))[0]; for (int i = linepadData.Count - 1; i >= 0; i--) { if (i >= 2 && i % 2 == 1) { linepadData.RemoveAt(i); } } for (int i = 0; i < linepadData.Count - 1; i++) { var topMesh = PolygonGetter.GetSidePolygon(linepadData[i], linepadData[i + 1], 1.0f, make3D.front, make3D.back, make3D.topMaterial); meshData = MeshData.Marge(meshData, topMesh); } } return(meshData); }
public MeshData GetMeshData(Vector2[] p) { Vector2[] nextPoints = new Vector2[p.Length + 2]; int maxp = 0; for (int i = 0; i < p.Length - 1; i++) { if ((p[maxp + 1] - p[maxp]).magnitude <= (p[i + 1] - p[i]).magnitude) { maxp = i; } } Vector2 st = (p[maxp + 1] + p[maxp]) / 2; nextPoints[0] = st; nextPoints[nextPoints.Length - 1] = st; if (p.Length == 0) { return(null); } for (int i = 0; i < p.Length; i++) { nextPoints[i + 1] = p[(i + maxp + 1) % p.Length]; } return(LineDrawer.GetMeshData(nextPoints, width, material, zValue)); }
void MakeMesh() { MeshData meshData; if (additional.isAdditional) { meshData = LineDrawer.GetMeshDataMk2(edgeCollider.points, width, additional.materialLeft, materialNum, additional.materialRight, 0); } else { meshData = LineDrawer.GetMeshData(edgeCollider.points, width, materialNum, 0); } Mesh mesh = meshData.GetMesh(meshRenderer.sharedMaterials.Length); if (meshFilter.sharedMesh != null) { DestroyImmediate(meshFilter.sharedMesh); } meshFilter.mesh = mesh; }