SurfaceTracking¶
演示如何使用表面跟踪。
用法¶

单指延表面移动,双指捏合可以放大缩小Cube,双指同时水平移动可以水平旋转Cube。
详解¶
设置被跟踪的SurfaceTarget¶
SurfaceTrackerFrameFilter只能跟踪一个surface。这个surface可以在场景中事先创建并设置。

SurfaceTarget一般不需要太多配置,需要在surface上显示的物体应放在SurfaceTarget下面。

开关跟踪¶
SurfaceTrackerFrameFilter.enabled 可以控制图像跟踪功能的开关。可以在不需要的时候关闭跟踪来节省资源。跟踪关闭的时候不会对camera或其它跟踪功能产生影响。


在surface上移动物体¶
可以将物体放在 SurfaceTracker 可以持续跟踪的点上。如果放在其它地方,跟踪可能会不正常。
当需要将物体移动到surface的其他地方的时候,可以使用 SurfaceTracker.alignTargetToCameraImagePoint 修改 SurfaceTracker 跟踪的点的位置。通过这种方法,可以看到物体在surface上移动。不过camera不会以连续方式移动,因此surface节点外的物体可能会忽大忽小,因为surface tracking 不会保持真实世界尺度。
SurfaceTracker 设计并不是一个 VIO 系统,因此如果你发现物体或camera表现比较奇怪,可以看一下 MotionTracking sample,它与 ARCore 和 ARKit的行为一致。
var viewPoint = new Vector2(touch.position.x / Screen.width, touch.position.y / Screen.height);
var coord = Session.ImageCoordinatesFromScreenCoordinates(viewPoint);
if (tracker && tracker.Tracker != null && coord.OnSome)
{
tracker.Tracker.alignTargetToCameraImagePoint(coord.Value.ToEasyARVector());
}
中心模式¶
在 ARSession.ARCenterMode.SessionOrigin 模式中,camera会在设备运动时自动移动,而SessionOrigin不会动。在 ARSession.ARCenterMode.Camera 模式中,设备运动时camera不会自动移动。其它模式可参考 中心模式。