gpt4 book ai didi

ios - SceneKit 计算可见边界?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:18 26 4
gpt4 key购买 nike

所以根据标题,我试图弄清楚是否有一种计算场景边界的好方法,因为通常的框架/边界属性在上下文中并不真正起作用。

我基本上需要一种方法来根据 xFov/yFov/zNear/zFar 的相机设置检查对象是否已移出可视屏幕。到目前为止,我还没有真正找到这样做的好方法。我是否忽略了此处的任何 API 方法,还是需要手动计算?

我希望我在这里说得有道理,如果没有请告诉我,我会进一步澄清。

最佳答案

SCNView 符合 SCNSceneRenderer,后者又具有一个名为 isNodeInsideFrustum:withPointOfView: 的方法,这就是您要寻找的方法。根据the documentation ,它返回:

YES if the bounding box of the tested node intersects the view frustum defined by the pointOfView node; otherwise, NO.


使用它看起来像这样:

BOOL isInside = [sceneView isNodeInsideFrustum:nodeToTest
withPointOfView:sceneView.pointOfView];
if (!isInside) {
// the bounding box of nodeToTest is not in the viewport ...
}

关于ios - SceneKit 计算可见边界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24562613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com