盒子背面剔除

发布于 2024-10-23 12:42:14 字数 243 浏览 1 评论 0原文

假设我有一个由其位置和方向定义的相机,以及一个由其中心和范围定义的盒子(从盒子中心到面中心的三个正交向量)。当其外表面面向相机时,面部可见;而当其内表面面向相机时,面部不可见。

显然,根据盒子的位置和方向,盒子可能有 1-3 个面可见。有没有一些聪明的方法来确定哪些面孔是可见的?一个明显的解决方案是计算每张脸的脸法线与脸相机向量的 6 个点积。有更好的办法吗?

注意:将使用透视投影,但我认为这并不重要,“面向相机”的属性似乎与投影无关。

Assume I have a camera defined by its position and direction, and a box defined by its center and extents (three orthogonal vectors from the box center to face centers). Face is visible when its outer surface is facing the camera and invisible when its inner surface is facing it.

It seems obvious that depending on box position and orientation there may be 1-3 faces of the box visible. Is there some clever way how to determine which faces are visible? An obvious solution would be to compute 6 dot-products of the face normal against the face-camera vector for each face. Is there a better way?

Note: perspective projection will be used, but I do not think it matters, the property of "facing camera" seems independent to a projecting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

灯下孤影 2024-10-30 12:42:14

我相信您描述的方法是执行此操作的正常方法。这是一个非常快的计算,因此您不必太担心速度。这与他们用来减少射线-三角形相交算法的计算次数的方法相同。如果该面的正面不可见,则该方法不会继续对该面进行计算。有关该算法的 C++ 实现,请参阅本文。这是计算的前半部分。 http://jgt.akpeters.com/papers/MollerTrumbore97/code.html

I believe the method you described is the normal way to do this. It's a very fast calculation so you shouldn't be worried too much about speed. This is the same method they use to reduce the number of calculations for ray-triangle intersection algorithms. If the front of the face isn't visible, the method doesn't continue calculations for that face. See this paper for a c++ implementation of this algorithm. It's in the first half of the calculations. http://jgt.akpeters.com/papers/MollerTrumbore97/code.html

肤浅与狂妄 2024-10-30 12:42:14

唯一的聪明之处在于,如果立方体的一个面是可见的,那么相反的面肯定是不可见的。至少在常规透视投影中是这样。

请注意,相反的情况可能并非如此:如果一个面不可见,则另一面也可能不可见。这是因为投影类型确实很重要。想象一下立方体非常靠近相机,相机直视一张脸。然后稍微旋转立方体,当使用平行投影时,另一个面会立即变得可见,而在透视投影中不会发生这种情况。

The only cleverness is that if a face of the cube is visible, the opposing face definitely isn't. At least in a regular perspective projection.

Note that the opposite might not be true: if a face is invisible, the opposing face might be invisible too. This is because the type of projection does matter. Imagine the cube being really up close to the camera, which is looking straight at one face. Then rotate the cube slightly, and while with a parallel projection, another face would immediately become visible, in a perspective projection this doesn't happen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文