Jun 24, 2015 at 11:41 AM
Edited Jun 24, 2015 at 11:49 AM

Hey there,
could you show me how to draw the triangles without drawing double lines?
When I draw every single segment of the "mesh.Triangles()" there will be overlapping lines or not?
Thanks imn advance!



Since every edge (except for the boundary) is shared by two triangles, lines will be drawn twice. But there's a simple way to prevent this:
foreach (var t in mesh.Triangles)
{
// Check the 3 neighbor triangles / edges.
for (int i = 0; i < 3; i++)
{
var n = t.GetNeighbor(i);
// Consider each edge only once.
if (n == null  t.ID < n.ID)
{
var v0 = t.GetVertex(i);
var v1 = t.GetVertex((i + 1) % 3);
DrawLine(v0, v1);
}
}
}
Or just do:
// Make sure vertices are numbered from 0 to n1.
mesh.Renumber();
var vertices = mesh.Vertices.ToArray();
foreach (var e in mesh.Edges)
{
var v0 = vertices[e.P0];
var v1 = vertices[e.P1];
DrawLine(v0, v1);
}



hey thanks for the quick answer.
The first solution doesn't work properly but the second does!






yep now the other solution is working as well =)
thanks again!

