投影 3D 网格的 2D 轮廓算法
给定:一个 3D 网格,由一组顶点和三角形定义,并用这些点构建网格。
问题:找到任意平面上投影的任意旋转网格的二维轮廓。
投影很容易。 挑战在于找到平面中投影三角形边的“外壳”。 我需要一些有关研究该算法的输入/指针的帮助。 为简单起见,我们可以假设 3D 边缘直接向下投影到 xy 平面上。
Given: A 3D mesh defined with a set of vertices and triangles building up the mesh with these points.
Problem: Find the 2d outline of the projected arbitrarily rotated mesh on an arbitrary plane.
The projection is easy. The challenge lies in finding the "hull" of the projected triangle edges in the plane. I need some help with input/pointers on researching this algorithm. For simplicity, we can assume the 3D edges are projected straight down onto the xy plane.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
本问题中提到的 alpha 形状技术处理顶点连接未知的一组通用点:
有没有一种有效的算法来生成2D凹壳?
但是,由于您已经知道可以通过投影保留的“面部”信息,这可能不是最好的方法。
蛮力算法可能是可行的,特别是在使用空间排序结构的情况下。 例如,对于每个面:
另一个想法,根据您所需的保真度,只需从投影法线射出一束光线平面到原始几何形状。 创建 2d 命中/未命中并使用它来确定您的范围。
The alpha shapes technique mentioned in this question handles a general set of points where the vertex connections are not known:
Is there an efficient algorithm to generate a 2D concave hull?
However, since you already know "face" information which can be preserved through the projection, it is probably not the best approach.
A brute force algorithm might feasible, especially if spatial sorting structures where used. eg for each facet:
Another idea, depending on the fidelity you require, is just shoot a bunch of rays normal from your projection plane to your original geometry. Create a 2d hit/miss and use that to determine your extents.
我只看到凸解的答案,所以这是我的非凸解的答案。
(意图是什么有点令人困惑。)
从 2D 三角形中取出所有边并将它们分组。 如果两条边共享两个端点,则它们位于同一组中。 所有只有一条边的组都是壳的一部分。
最后,您可以将壳边缘连接在一起,将它们组合成一个环。
I only see answers for convex solutions, so here is mine for non-convex.
(It was a little confusing what was the intention.)
Take all edges from your 2D-triangles and group them. If two edges share both endpoints, they are in the same group. All groups, with only one edge, is then a part of the shell.
Finally you can combine the shell-edges to one ring, by joining them together.
网格投影的 2D 轮廓是其边缘投影的子集。
利用这一观察结果,可以使用以下方法确定 2D 轮廓:
请注意,此方法将报告与投影平面正交的所有边缘,甚至是从投影平面的角度看不到的边缘。 例如,对于环面,即使环面旋转到从投影平面的角度看不到其内部孔,它也会找到内部和外部轮廓。 要确定哪些边缘可见,您将需要某种可见性测试。 如果预期用途是用于用户显示,则可以使用通过正交投影矩阵计算的深度缓冲区来从投影平面的角度渲染几何图形,并进行一些 z 测试以确定哪些边缘从平面可见。 如果需要精度,则需要执行射线/三角形相交以确定可见性。
The 2D outline of the mesh projection is a subset of the projection of its edges.
Using this observation, one can determine the 2D outline using the following method:
Note that this method will report all the edges that are orthogonal to the projection plane, even those which are not visible from the projection plane's point of view. For example, with a torus, it will find the interior and the exterior outlines, even when the torus is rotated in such a way that its interior hole isn't visible from the projection plane's point of view. To sort out which edges are visible, you will need some sort of visibility test. If the intended use is for user display, you can use a depth buffer computed with an orthogonal projection matrix to render the geometry from the projection plane's point-of-view and do some z-testing to determine which edges are visible from the plane. If you need precision, you will need to perform ray/triangle intersection to determine visibility.
edge-A
edge-B
在此处输入图像描述
观看寻找兔子轮廓的演示
这是上述算法的实现。
edge-A
edge-B
enter image description here
see a demo of finding outline for a bunny
Here is an implementation of the algorithm described above.
只是补充一下:在投影中查找边缘的一种非常直观的方法是背面剔除! 剔除面和未剔除面之间的任何边缘都应该是轮廓。 如果你想隐藏内部边缘,只需使用 z 缓冲区即可。 背面剔除只是后投影顶点顺序,计算起来非常便宜。
Just to add: A very intuitive way to find edges in a projection is back face culling! Any edge between a culled and non-culled face should be an outline. If you want to hide interior edges, just use the z-buffer. Back face culling is simply the post projection vertex order and very cheap to compute.