Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GeometryUtility.TestPlanesAABB 测试平面
# [GeometryUtility](GeometryUtility.html).TestPlanesAABB 测试平面 static function *TestPlanesAABB* (*planes* : [Plane](../Plane/Plane.html)[], *bounds* : [Bounds](../Bounds/Bounds.html)) : bool *Description* 描述 Returns true if bounds are inside the plane array. 如果包围盒在平面数组内部返回 true。 Will return true if the bounding box is inside the planes or intersects any of the planes. 如果包围盒在平面数组内部或和任意平面相交,返回 true。 The TestPlanesAABB function uses the Plane array to test whether a bounding box is in the frustum or not. You can use this function with CalculateFrustrumPlanes to test whether a camera's view contains an object regardless of whether it is rendered or not. TestPlanesAABB 函数使用 Plane 数组来测试包围盒是否在视景体。你可以使用这个函数用 CalculateFrustrumPlanes 去测试相机视图是否包含一个物体,无论它是否被渲染。 参考:[GeometryUtility.CalculateFrustumPlanes](GeometryUtility.CalculateFrustumPlanes.html). * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public GameObject anObject; private Camera cam; private Plane[] planes; void Start() { cam = Camera.main; planes = GeometryUtility.CalculateFrustumPlanes(cam); } void Update() { if (GeometryUtility.TestPlanesAABB(planes, anObject.collider.bounds)) Debug.Log(anObject.name + " has been detected!"); else Debug.Log("Nothing has been detected"); } } ``` ``` // Detects manually if anObject is being seen by the main camera //手工检测,如果一个物体由主摄像机看到 var anObject : GameObject; private var cam : Camera; private var planes : Plane[]; function Start() { cam = Camera.main; planes = GeometryUtility.CalculateFrustumPlanes(cam); } function Update() { if(GeometryUtility.TestPlanesAABB(planes,anObject.collider.bounds)) Debug.Log(anObject.name + " has been detected!"); else Debug.Log("Nothing has been detected"); } ```
da
2022年5月20日 23:03
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码