简体   繁体   中英

How to best group vertices that are nodes of two curves when creating triangles for a plane mesh?

I'm working on a mesh generation script in Unity3D. There are two curves in a 3D space, each curve has more than two nodes. I want to create a mesh of a plane where these two curves are two sides of the plane.

The nodes are used as vertices, and then I'll need to get the value for the mesh.triangles. Each curve may have different number of nodes (vertices), so how shall I group them into triangle int[], so that firstly, all vertices are used in order to best describe the shape, and secondly, no triangle is in overlap with another for better performance?

PS: These two curves will always be almost parallel, and they have no intersection when we see them in xy, xz, or yz planes. So we don't need to think about any complicated/special senario, eg picking vertices in different orders from two curves for different triangles.

Please see the attached picture. Thanks very much.

在此处输入图像描述

With the tip from DragonCoder on Unity forum, I figired this out.

His Tip: "As for a more focused solution: I'd imagine having a virtual train that tries to run down this track. We can say it has flexible wheels so that Its axle would be in an angle that would be the average of what angle is exactly perpendicular on either curve. Then whenever its "wheels" hit a point, you add those to a list. From that list it should not be too hard to form a set of triangles."

My reply: "I applied two rules to each vertice, if it's a beginning or an end point, it can only work with one vertice from the same curve to form a triangle, for other vertices, each one shall work with two other vertices from the same curve, unless no eligible vertice from the same curve has been passed by the train. So each time a vertice is passed by the trian, it can only form 1 triangle with existing other vertices train passed, or just wait for the trian to pass more."

DragonCoder also mentioned Apply a Delaunay triangulation (implementations on github), which is a better solution that will work for more senarios, but the math is beyond me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM