/**************************************************************************** * Copyright 2019 Nreal Techonology Limited. All rights reserved. * * This file is part of NRSDK. * * https://www.nreal.ai/ * *****************************************************************************/ namespace NRKernal { using System; using UnityEngine; /// /// A Trackable in the real world detected by NRInternel. The base class of TrackablePlane and /// TrackableImage.Through this class, application can get the infomation of a trackable object. public abstract class NRTrackable { /// Handle of the trackable native. internal UInt64 TrackableNativeHandle = 0; private NRTrackableSubsystem m_TrackableSubsystem; internal NRTrackableSubsystem TrackableSubsystem { get { if (m_TrackableSubsystem == null) { m_TrackableSubsystem = NRSessionManager.Instance.TrackableFactory.TrackableSubsystem; } return m_TrackableSubsystem; } } /// Constructor. /// Handle of the trackable native. /// The nativeinterface. internal NRTrackable(UInt64 trackableNativeHandle) { TrackableNativeHandle = trackableNativeHandle; } /// Get the id of trackable. /// The data base index. public int GetDataBaseIndex() { UInt32 identify = TrackableSubsystem.GetIdentify(TrackableNativeHandle); identify &= 0X0000FFFF; return (int)identify; } /// Get the tracking state of current trackable. /// The tracking state. public TrackingState GetTrackingState() { if (NRFrame.SessionStatus != SessionState.Running) { return TrackingState.Stopped; } return TrackableSubsystem.GetTrackingState(TrackableNativeHandle); } /// Type of the trackable. TrackableType trackableType; /// Get the tracking type of current trackable. /// The trackable type. public TrackableType GetTrackableType() { if (NRFrame.SessionStatus != SessionState.Running) { return trackableType; } trackableType = TrackableSubsystem.GetTrackableType(TrackableNativeHandle); return trackableType; } /// Get the center pose of current trackable. /// The center pose. public virtual Pose GetCenterPose() { return Pose.identity; } /// Creates an anchor attached to current trackable at given pose. /// The new anchor. public NRAnchor CreateAnchor() { return NRAnchor.Factory(this); } } }