09-21-2020, 04:26 PM
Untested code, but even if it is bugged, you get the idea.
Add this code in the CGVMesh class, and then call public method where appropriate
Add this code in the CGVMesh class, and then call public method where appropriate
Code:
public struct Edge
{
public Vector3 a;
public Vector3 b;
public Edge(Vector3 p1, Vector3 p2)
{
a = p1; b = p2;
}
}
public IEnumerable<Edge> GetHorizontalAndVerticalLines()
{
var result = new List<Edge>();
foreach (CGVSubMesh subMesh in SubMeshes)
{
for (var i = 0; i < subMesh.Triangles.Length; i++)
{
int triangleStart = subMesh.Triangles[i];
TryAddEdge(Vertex[triangleStart + 0], Vertex[triangleStart + 1], result);
TryAddEdge(Vertex[triangleStart + 1], Vertex[triangleStart + 2], result);
TryAddEdge(Vertex[triangleStart + 2], Vertex[triangleStart + 0], result);
}
}
return result;
}
private static void TryAddEdge(Vector3 position1, Vector3 position2, List<Edge> result)
{
var direction = position1 - position2;
if (Vector3.Angle(direction, Vector3.up) < 0.01f || Vector3.Angle(direction, Vector3.right) < 0.01f)
{
result.Add(new Edge(position1, position2));
}
}
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Please consider leaving a review for Curvy, this helps immensely. Thank you.

