//Display a MeshProfile at a certain InterpolationTransform public static void DisplayMeshProfile(MeshProfile profile, InterpolationTransform transform, float profileScale) { //Display the points //Convert all vertices from 2d to 3d in global space //List<MyVector3> positions_3d = profile.vertices.Select(s => // testTrans.LocalToWorld(new MyVector3(s.point.x, s.point.y, 0f) * profileScale) //).ToList(); List <Vector3> positions_3d = new List <Vector3>(); foreach (Vertex v in profile.vertices) { MyVector2 localPos2d = v.point; MyVector3 localPos = new MyVector3(localPos2d.x, localPos2d.y, 0f); MyVector3 pos = transform.LocalToWorld_Pos(localPos * profileScale); positions_3d.Add(pos.ToVector3()); } DisplayPoints(positions_3d); //Display how the points are connected with lines Gizmos.color = Color.white; for (int i = 0; i < profile.lineIndices.Length; i++) { Vector3 pos_1 = positions_3d[profile.lineIndices[i].x]; Vector3 pos_2 = positions_3d[profile.lineIndices[i].y]; Gizmos.DrawLine(pos_1, pos_2); } //Display normals at each point Gizmos.color = Color.blue; //Convert all normals from 2d to 3d in global space List <Vector3> normals_3d = new List <Vector3>(); foreach (Vertex v in profile.vertices) { MyVector2 normal2d = v.normal; MyVector3 normal = new MyVector3(normal2d.x, normal2d.y, 0f); MyVector3 worldNormal = transform.LocalToWorld_Dir(normal); normals_3d.Add(worldNormal.ToVector3()); } DisplayDirections(positions_3d, normals_3d, 0.5f, Color.magenta); }
//Display mesh extruded along a curve public static void DisplayExtrudedMesh(List <InterpolationTransform> transforms, MeshProfile profile) { Mesh mesh = ExtrudeMeshAlongCurve.GenerateMesh(transforms, profile, 0.25f); if (mesh == null) { return; } //Gizmos.DrawMesh(mesh); Gizmos.DrawWireMesh(mesh); //TestAlgorithmsHelpMethods.DisplayMesh(mesh, Color.green); //TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(mesh, 0); //Graphics.DrawMeshNow(mesh, Vector3.zero, Quaternion.identity); }