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

问题描述 投票:0回答:3

我已经在android中工作和分析样本hello_ar_java项目。我想在android.i中期望将一个3d对象放在相机的中心位置。我只期待安卓的答案,我不想要统一回答,因为我不知道团结。

android arcore
3个回答
0
投票

相机启动的点是原点。所以,只需将对象放在原点,一切都应该没问题。如果您希望对象随相机移动,则应将相机的变换作为对象变换的父变换。


0
投票

我无法帮助你使用java代码,但我在Unity中完成了这个,我想这个概念是一样的。你想要做的是在空间(Vector3)中创建一个始终位于相机前面的点。这一点将与相机一起移动并始终位于其前方。然后,您希望在该Vector3上生成(实例化)您的对象。如果有帮助,请告诉我。


0
投票
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`
© www.soinside.com 2019 - 2024. All rights reserved.