玩转ARKit-ARConfiguration(AR配置)

2017-09-14  本文已影响354人  cmfish

上篇文章讲到ARKit中的桥梁类ARSession 没看过的可以去了解下。传送门http://www.jianshu.com/p/743ef3d6c8dd,本篇内容我们来了解下AR里面的追踪配置。


官方文档地址 :https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration

一.官文翻译

ARConfiguration

  • ARWorldTrackingConfiguration
    提供高品质的AR体验,使用后置摄像头精确跟踪设备的位置和方向,并允许平面检测和碰撞试验。
  • AROrientationTrackingConfiguration
    提供使用后置摄像头并仅跟踪设备方向的基本AR体验。
  • ARFaceTrackingConfiguration
    提供使用前置摄像头并跟踪用户脸部的移动和表情的AR体验。
其中第一个是比较常用的会话配置子类,下面2个子类只作为了解用到的时候再做详细介绍。

ARWorldTrackingConfiguration

图示1
6个自由度(6DOF)追踪维持一个AR场景不管你怎么移动或者旋转。虚拟的模型位置不会随着你设备的移动而改变。(除了特殊需求之外)


f76d63a3-7620-40d1-9e52-0d9ad6329678-1.png

如果你启用了planeDetection设置,ARKit分析场景(scene)找到真实世界的平面。 对于检测到的每个平面,ARKit会自动添加一个ARPlaneAnchor
到会话中。

二.API介绍

  

 ARWorldTrackingConfiguration 

    /**
     平面检测类型
     */
    public struct PlaneDetection : OptionSet {
        public init(rawValue: UInt)

        /** 场景中的水平平面检测 */
        public static var horizontal: ARWorldTrackingConfiguration.PlaneDetection { get }
    }
}


/**
AR会话配置的抽象基类.
 */
ARConfiguration 
    /**
     判断设备是否支持 ARConfiguration.
     */
    open class var isSupported: Bool { get }

    
    /**
    设备是否支持将真实世界的设备运动映射到3D场景坐标系中的值。
    默认ARWorldAlignmentGravity.
     */
    open var worldAlignment: ARConfiguration.WorldAlignment

    
    /**
    是否分析场景中的光照
    默认YES
     */
    open var isLightEstimationEnabled: Bool

    
    /**
    是否捕获或者提供音频
    默认NO
     */
    open var providesAudioData: Bool


/**
 一个运行全局追踪的配置.
 提供对设备6个自由度的追踪
 通过寻找场景中的特征点来,并进行全局追踪的碰撞测试来确定模型的框架.
会话暂停后追踪也就不会更新了.
 */
 ARWorldTrackingConfiguration : 

    
    /**
     平面检测的一个类型
    如果进行设置,新的平面将会持续被检测和更新, 被检测到的平面会被作为一个平面锚点添加到会话中.当两个平面合并的时候,新的平面会被移除,默认ARPlaneDetectionNone.
     */
    open var planeDetection: ARWorldTrackingConfiguration.PlaneDetection
    public init()



/**
 只追踪方向的配置
 设备沿xyz三轴移动的追踪
 
 */
AROrientationTrackingConfiguration : ARConfiguration {
 
    public init()
}
上一篇 下一篇

猜你喜欢

热点阅读