2017-07-15 69 views
1

我真的在xCode上开发AR应用程序,ARKitARKit:在摄像机视图上翻译3D对象

我有我的iPad是在一个特定的方向,当我添加一个SCNode(0,0,0)到我的SCNScene与ARWorldTrackingSessionConfiguration它出现在相机的前面,当iPad垂直于地面所以: The iPad is perpendicular to the ground and the 3D object is at (0,0,0)

iPad是垂直于地面和3D物体在(0,0,0)

我想有我SCNode到直接显示上日ËiPad的屏幕,当我启动ARScene这样的:

The iPad is oriented in direction to the flower pot and i had to set the coordinates manually

,iPad是用方向面向花盆,我不得不手动设置的坐标

如何我可以那样做吗? 我想我将不得不做一些事情,如坐标翻译,但我不知道该怎么做。 如果它可以帮助,我可以有相机和花盆之间的距离

在此先感谢! :)

回答

1

您需要通过物体的坐标在SCNMatrix4形式如下:

let translationMatrix = SCNMatrix4Translate(theNode.worldTransform, 0.1, 0.1, 0.1) //tx, ty, tz are translations in each axis i 然后theNode.transform = translation matrix