2017-07-15 66 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