// Update is called once per frame void Update() { Mesh m1 = SphereScript.BuildMesh(Vector3.zero, 0.2f, 32, Color.white); Mesh m2 = SphereScript.BuildMesh(TestVector, 0.2f, 32, Color.white); Mesh m3 = SphereScript.BuildMesh(Quaternion.Euler(RotationVector) * TestVector, 0.2f, 32, Color.white); filter.mesh = m1; filter2.mesh = m2; filter3.mesh = m3; }
public static void BuildMesh(Transform parent, LinePoints[] curves, Material material, float lineRadius, int sphereIterations, int cylinderCapSegments, Color vertexColor) { DeleteChildObjects(parent, "Curve"); for (int z = 0; z < curves.Length; z++) { for (int v = 0; v < curves[z].Points.Length; v++) { Mesh m = SphereScript.BuildMesh(curves[z].Points[v], lineRadius, sphereIterations, vertexColor); m = NormalSolver.RecalculateNormals(m, 75f); CreateChildObject(parent, "Curve_" + z + "_Sphere_" + v, m, material); if (v < curves[z].Points.Length - 1) { Mesh m2 = CylinderScript.BuildMesh(curves[z].Points[v], curves[z].Points[v + 1], lineRadius, lineRadius, vertexColor, new Vector3(0f, 90f, 0f), cylinderCapSegments, true); m2 = NormalSolver.RecalculateNormals(m2, 75f); CreateChildObject(parent, "Curve_" + z + "_Cylinder_" + v, m2, material); } } if (curves[z].ArrowAtStart) { Vector3 p0 = curves[z].Points[0]; Vector3 p1 = curves[z].Points[1]; Vector3 parrow = (p0 - p1).normalized * curves[z].ArrowLength + p0; Mesh m = CylinderScript.BuildMesh(p0, parrow, curves[z].ArrowRadius, 0f, vertexColor, new Vector3(0f, 90f, 0f), cylinderCapSegments, true); m = NormalSolver.RecalculateNormals(m, 75f); CreateChildObject(parent, "Curve_" + z + "_ArrowStart", m, material); } if (curves[z].ArrowAtEnd) { Vector3 p0 = curves[z].Points[curves[z].Points.Length - 1]; Vector3 p1 = curves[z].Points[curves[z].Points.Length - 2]; Vector3 parrow = (p0 - p1).normalized * curves[z].ArrowLength + p0; Mesh m = CylinderScript.BuildMesh(p0, parrow, curves[z].ArrowRadius, 0f, vertexColor, new Vector3(0f, 90f, 0f), cylinderCapSegments, true); m = NormalSolver.RecalculateNormals(m, 75f); CreateChildObject(parent, "Curve_" + z + "_ArrowEnd", m, material); } } }