我正在尝试将大型3D对象(从.obj文件生成)放置在相机前面,但无法执行此操作。以命中结果为中心放置模型。有办法完成吗?
答案 0 :(得分:2)
以下代码将在摄像机前面放置一个锚点1M-您可以根据需要调整深度:
// Place the anchor 1m in front of the camera.
Log.d(TAG,"adding Andy in fornt of camera");
Frame frame = arFragment.getArSceneView().getArFrame();
Session session = arFragment.getArSceneView().getSession();
Anchor newMarkAnchor = session.createAnchor(
frame.getCamera().getPose()
.compose(Pose.makeTranslation(0, 0, -1f))
.extractTranslation());
AnchorNode addedAnchorNode = new AnchorNode(newMarkAnchor);
addedAnchorNode.setRenderable(andyRenderable);
addedAnchorNode.setParent(arFragment.getArSceneView().getScene());
您可以在此处看到完整的工作示例-它使用按钮添加节点而不是使用点击结果,这对您也可能有用:https://github.com/mickod/LineView