ARKit - Position of ARCamera

I am trying to use ARKit and my question is very simple. How can I get the camera position?

I know that if I'm SCNNodein the ( 0, 0, 0) and my ARCamera, for example, looks at the ground, I have to look up to see the 3D-object. This means that the position and orientation of the device’s camera must be accessible.

So how do I know, where the camera isand where she is looking to?

Thanks in advance.

+6
source share
2 answers

ARCamera.transform . ARKit WWDC 2017, , , . , 10 .

:

var translation = matrix_identity_float4x4
translation.columns.3.z = -0.1 // Translate 10 cm in front of the camera
node.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)

Objective-C

matrix_float4x4 translation = matrix_identity_float4x4;
translation.columns[3][2] = -0.1; // Translate 10 cm in front of the camera
node.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)
+12

X, Y Z :

var translation = matrix_identity_float4x4

translation.columns.3 = simd_float4(0, 0.2, -0.5, 1)      // x, y, z, HC

aNode.simdTransform = matrix_multiply(translation, 
                                      currentFrame.camera.transform)

columns.3 - , 1.

.

0

Source: https://habr.com/ru/post/1681521/


All Articles