盒子背面剔除 [英] Box backface culling

查看:21
本文介绍了盒子背面剔除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个由其位置和方向定义的相机,以及一个由其中心和范围定义的框(从框中心到面中心的三个正交向量).人脸外表面面向相机时可见,内表面面向时不可见.

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.

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

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.

推荐答案

我相信您描述的方法是执行此操作的常规方法.这是一个非常快的计算,所以你不应该太担心速度.这与他们用于减少光线三角形相交算法的计算次数的方法相同.如果面的正面不可见,则该方法不会继续计算该面.有关该算法的 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

这篇关于盒子背面剔除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆