简体   繁体   English

将3D多边形绘制为网格

[英]Drawing 3D polygons as a mesh

I have a list of 3D points, forming a 3D polygon. 我有一个3D点列表,形成一个3D多边形。 They are actually N>2 lines drawn by user. 它们实际上是用户绘制的N> 2条线。

I would like to create a mesh from this polygon and draw the polygon with texture. 我想从此多边形创建一个网格并绘制带有纹理的多边形。 For this purpose, i need to create triangles from the surface formed by the polygon. 为此,我需要从多边形形成的表面创建三角形。 How i can perform this triangulation? 我如何执行此三角剖分? Are there any libraries i can use? 我可以使用任何库吗?

You should first turn the 3D problem into a 2D one by finding the plane of the face. 您首先应该通过找到人脸的平面将3D问题转换为2D问题。 You can use three vertices (forming two vectors) for this purpose (avoid taking too close or too much aligned). 为此,可以使用三个顶点(形成两个向量)(避免取得太近或太对准)。

Then you will project every vertex onto that plane. 然后,将每个顶点投影到该平面上。 This can be done by creating an orthogonal coordinates frame from the two vectors using vector calculus or equivalently Gram-Schmidt orthogonalization ( http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process ). 这可以通过使用矢量演算或等效的Gram-Schmidt正交化( http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process )从两个向量创建正交坐标框架来完成。 Perform the change of coordinates and drop Z. 执行坐标更改并放下Z。

Triangulation by "ear clipping" isn't that difficult to implement ( http://en.wikipedia.org/wiki/Polygon_triangulation ). 通过“修剪耳朵”进行三角剖分并不难实现( http://en.wikipedia.org/wiki/Polygon_triangulation )。

After 2D triangulation, you will transform the vertices back to 3D coordinates. 2D三角剖分后,您会将顶点转换回3D坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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