如何在 ar-core 中放置相机的 3d 对象中心位置?

How to place a 3d object center position of the camera in ar-core?

我在 android.I 中处理和分析示例 hello_ar_java 项目,想在 android.i 中将 3d 对象放置在相机的中心位置,期待答案 android 只是,我不想要统一答案,因为我不知道统一。

我无法帮助您处理 java 代码,但我已经在 Unity 中完成了,我想概念是一样的。您要做的是在 space(一个 Vector3)中创建一个始终位于相机前面的点。该点将随相机移动并始终位于相机前方。然后,您想在该 Vector3 处生成(实例化)您的对象。让我知道是否有帮助。

相机开始的点是原点。所以,只要把你的物体放在原点,一切都应该没问题。如果您希望对象随相机移动,您应该将相机的变换作为对象变换的父对象。

To place the object in the camera position,

`Frame frame = arSceneView.getArFrame();
float x = frame.getCamera().getPose().qx() ;
float y = frame.getCamera().getPose().qy();
float z = frame.getCamera().getPose().qz() ;
Node andy = new Node();
andy.setParent(arSceneView.getScene().getCamera());
andy.setLocalPosition(new Vector3(position.x, position.y, position.z));
andy.setRenderable(arrowRenderable); // your rendebrable object name`


or instead of `andy.setLocalPosition(new Vector3(position.x, position.y, position.z));`

just give 
`andy.setLocalPosition(new Vector3(0f,0,-1f)); // it will place the object in center camera`