Oscar
Oscar

Reputation: 35

Order of vertices in Geometry

In my program I have created a Geometry from the vertices of an intersection between a plane and a mesh. I use this Geometry to create a LineSegments object and it works perfectly. I would like to use the vertices in a couple of other ways as well, but the array of vertices in the Geometry is not in the correct order (the order that LineSegments draws them). I am unable to find where the information is stored that allows LineSegments to draw lines between the vertices in the correct order. The link below shows the problem:

https://gamedev.stackexchange.com/questions/99353/vertex-ordering-with-threejss-exporter

There is only one answer that suggests that you check the faces for more information, but from what I can see there is no information about the faces in my Geometry, it only contains the vertices that I put in there.

Any help would be much appreciated!

Upvotes: 0

Views: 1254

Answers (1)

user1196549
user1196549

Reputation:

In a watertight and topologically correct mesh, every edge is shared by exactly two faces. When you cut by a plane, the two faces generate two edges that meet at a vertex, where the common edge pierces the plane.

So if you have a model such that you can reliably pair the edges of the faces (or if the edges are listed uniquely), you can obtain a list of section edges where the vertices are shared by two edges, and describe a closed polygon (unless the surface itself is open).

You can reconstruct this polygon by going from edge to edge, through the common vertices.

For instance, consider the cube below and assume that its faces are labeled left, right, front, back, top, bottom.

The section is made of five edges that can be labeled lt-rt, rt-rf, rf-bf, bf-lb, lb-lt.

enter image description here

Upvotes: 1

Related Questions