Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mesh Lines - Horizontal and Vertical Edges
#13
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
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.
Reply


Messages In This Thread
RE: Mesh Lines - Horizontal and Vertical Edges - by _Aka_ - 09-21-2020, 04:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace deform mesh on volume spots Kokoriko49 1 2,070 06-09-2025, 06:49 PM
Last Post: _Aka_
  Mesh Generation between two splines vatan 4 3,151 02-14-2025, 07:11 AM
Last Post: vatan
  Maintaining vertical orientation of extruded meshes rickgplus 3 2,127 01-24-2025, 09:24 PM
Last Post: _Aka_
  Create Mesh Node, Make Static Options rickgplus 1 1,626 01-23-2025, 10:12 AM
Last Post: _Aka_

Forum Jump: