ARKit 与 SceneKit 坐标 [英] ARKit vs SceneKit coordinates

查看:32
本文介绍了ARKit 与 SceneKit 坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 ArKit 中引入的不同元素与其在 SceneKit 中可能等效的元素之间的区别:

I'm trying to understand the difference between the different element introduced in ArKit and their maybe equivalents in SceneKit:

  • SCNNode.simdTransform 对比 SCNNode.transform.在 ARKit 中,人们似乎使用 SCNNode.simdTransform 而不是 SCNNode.transform.它们有何不同?simdTransform 似乎使用列主序,而变换 (SCNMatrix4) 是行主序.我如何将一个转换为另一个?只是转置?我的印象是,如果我使用 transform 而不是 simdTransform,则跟踪效果不佳.这是预期的还是只是印象?如果我设置了一个属性,如果我再设置另一个属性会怎样?

  • SCNNode.simdTransform vs SCNNode.transform. In ARKit, it seems that people use SCNNode.simdTransform instead of SCNNode.transform. How do they differ? simdTransform seems to use column major order, while transform (SCNMatrix4) is row major. How do I convert one to the other? Just transpose? I've the impression that the tracking doesn't work as well if I use transform instead of simdTransform. Is that expected or just an impression? If I set one property, what happens if I then set the other one?

ARFrame.camera vs Scene.pointOfView:看看他们的转换,他们似乎有点不同:

ARFrame.camera vs Scene.pointOfView: Looking at their transforms, they seem to be a bit different:

.

// ARFrame.camera.transform (matrix_float4x4)
-0.01 0.99  -0.11 0.02
-0.99 0.00  0.11  0.06
0.10  0.11  0.98  0.0
0.0   0.0   0.0   1.0

// sceneView.pointOfView.transform (SCNMatrix4)
// or sceneView.pointOfView.simdTransform^T (matrix_float4x4)
0.99  0     0.11   0
0.01  0.99  -0.12  0
-0.11 0.11  0.98   0
0.03  0.6   0.0    0.99

它们相同减去一圈吗?

推荐答案

SceneKit 和 ARKit 都包含定义为 SIMD 类型的符号.由于 ARKit 导入了 SceneKit,因此两者都可以访问 SceneKit 中定义的 SIMD 符号.SIMD 类型支持并行计算,因此使用它们可以提高应用程序更新逻辑的性能.正如您所发现的,在 SIMD 类型与其旧版 SceneKit 或 Core Graphics 等效项之间进行转换并不总是一种方便的方法,因此您通常会通过尽可能一致地使用 SIMD 来获得更清晰的代码.

Both SceneKit and ARKit include symbols defined as SIMD types. Since ARKit imports SceneKit, the SIMD symbols defined in SceneKit are accessible to both. SIMD types enable parallel computation, so using them can improve the performance of your app's update logic. As you've found, there isn't always a convenient way to convert between a SIMD type and its older SceneKit or Core Graphics equivalent, so you'll usually get cleaner code by consistently using SIMD where possible.

更新任何影响节点变换的属性也会更新其其他变换属性.这也适用于本地和世界坐标.

Updating any property that affects the transform of a node also updates its other transform properties. This goes for local and world coordinates as well.

ARFramecamera 属性描述了设备的硬件相机,而不是用于渲染场景的虚拟相机.虽然我希望有密切的对应关系,但我的猜测是在渲染循环期间更新 SCNCamera 实例之前,您正在轮询 ARCamera 实例.如果可以,我建议您从适当的委托方法驱动这些更新,因为您会知道相关数据是最新的.

The camera property of ARFrame describes the device's hardware camera, not the virtual camera used to render the scene. While I would expect a close correspondence, my guess is you're polling the ARCamera instance before the SCNCamera instance has been updated during the render loop. If you can, I recommend driving those updates from the appropriate delegate methods, since you'll know the relevant data is up to date.

这篇关于ARKit 与 SceneKit 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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