Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mesh Lines - Horizontal and Vertical Edges
#15
(09-21-2020, 04:26 PM)_Aka_ Wrote: 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));
            }
        }

Thank you for the code, will try it. 
Cheers
Reply


Messages In This Thread
RE: Mesh Lines - Horizontal and Vertical Edges - by Krypton - 09-23-2020, 02:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Adjust radius of generated mesh via script? Shackman 1 4 03-26-2024, 01:12 PM
Last Post: _Aka_
  Not seeing mesh extended after following YT PaulM 1 3 02-02-2024, 12:01 PM
Last Post: _Aka_
  Trigger Zones along Spline Mesh dlees9191 1 5 01-05-2024, 10:18 AM
Last Post: _Aka_

Forum Jump: