/// <summary> /// Gets a key that can be used to map a platform anchor to an ARReference point /// </summary> /// <param name="intPtr">The platform (ARkit or ARCore) anchor pointer</param> /// <returns>A string for the dictionary lookup</returns> static internal string GetPlatformKey(this IntPtr intPtr) { #if UNITY_IOS return(ARKitNativeHelpers.GetArkitAnchorIdFromPointer(intPtr)); #endif #if UNITY_ANDROID return(intPtr.ToString()); #endif }
/// <summary> /// Gets the anchor pose. /// </summary> /// <param name="cloudSpatialAnchor">The cloud spatial anchor.</param> /// <returns><see cref="Pose"/>.</returns> /// <exception cref="System.ArgumentNullException">cloudSpatialAnchor</exception> public static Pose GetAnchorPose(this CloudSpatialAnchor cloudSpatialAnchor) { if (cloudSpatialAnchor == null) { throw new ArgumentNullException(nameof(cloudSpatialAnchor)); } Pose anchorPose = Pose.identity; #if UNITY_IOS Matrix4x4 matrix4X4 = ARKitNativeHelpers.GetAnchorTransform(cloudSpatialAnchor.LocalAnchor).ToMatrix4x4(); anchorPose = new Pose(UnityARMatrixOps.GetPosition(matrix4X4), UnityARMatrixOps.GetRotation(matrix4X4)); #elif UNITY_ANDROID anchorPose = GoogleARCoreInternal.LifecycleManager.Instance.NativeSession.AnchorApi.GetPose(cloudSpatialAnchor.LocalAnchor); #else throw new NotSupportedException($"Platform is not supported."); #endif return(anchorPose); }