Skip to main content
 首页 » 编程设计

c#之检查屏幕上是否显示 Vector3

2024年02月13日14EasonJim

我想知道是否有一种方法可以检查相机是否正在查看 3D 空间中的 Vector3 点,或者检查该点是否显示在屏幕上。

请您参考如下方法:

是的,只需将您的 View 和投影矩阵输入到这样的边界平截头体中即可:

//class scope variables 
BoundingFrustum boundingFrustum; 
 
//in the init method 
boundingFrustum = new BoundingFrustum(); 
 
//In the Update method or wherever you need to run a check check 
boundingFrustum.Matrix = view * projection; 
 
bool isPointInView = boundingFrustum.Contains(Vector3ToTest);