本文介绍了如何监视我在ARCore和Sceneform中的当前位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有ARCore和Sceneform的应用程序中,我需要以某种方式监视我在ARCore空间中的(设备,实际上是)移动吗?

In application with ARCore and Sceneform I need somehow monitor my (device, really) movement in ARCore space?

因此,我想从选定点(Anchor/AnchorNode)到当前位置绘制射线,或计算从选定点到此处的距离,并在移动过程中对其进行更新.我有想法,如何计算或绘制,但是如何获取更新?

As result I want to draw a ray from selected point (Anchor/AnchorNode) through my current position, or to calculate distance from selected point to here, and update them during movement. I have ideas, how to calculate or draw, but how to get updates?

推荐答案

首先设置On Update侦听器

First setup an On Update listener

fragment.getArSceneView().getScene().addOnUpdateListener(frameTime -> {
        fragment.onUpdate(frameTime);
        onUpdate();
    });

在OnUpdate()中,调用Camera.getDisplayOrientedPose()

In OnUpdate() call Camera.getDisplayOrientedPose()

Frame frame = fragment.getArSceneView().getArFrame();

    Camera camera = frame.getCamera();

    if (camera.getTrackingState() == TrackingState.TRACKING){
        Pose CameraPose = camera.getDisplayOrientedPose();
    }

随着相机姿势的移动,将不断更新.

As you move around your Camera Pose will keep getting updated.

这篇关于如何监视我在ARCore和Sceneform中的当前位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 05:39