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

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

问题描述

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

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

  • SCNNode.simdTransformSCNNode.transform.在ARKit中,人们似乎使用SCNNode.simdTransform而不是SCNNode.transform.它们有何不同? simdTransform似乎使用列主要顺序,而transform(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.cameraScene.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

它们是相同的减去一转吗?

Are they the same minus one rotation?

推荐答案

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 vs SceneKit坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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