Exemple #1
0
        public Pose ExtractPoseValue(IntPtr poseHandle)
        {
            ApiPoseData poseValue = new ApiPoseData(Pose.identity);

            ExternApi.ArPose_getPoseRaw(_nativeSession.SessionHandle, poseHandle, ref poseValue);
            return(poseValue.ToUnityPose());
        }
Exemple #2
0
 private static void _OnPoseAvailableAsync(IntPtr callbackContext, ref ApiPoseData pose)
 {
     lock (m_poseQueueLock)
     {
         m_poseQueue.Enqueue(pose);
     }
 }
Exemple #3
0
        public IntPtr Create(Pose pose)
        {
            ApiPoseData rawPose    = new ApiPoseData(pose);
            IntPtr      poseHandle = IntPtr.Zero;

            ExternApi.ArPose_create(m_NativeSession.SessionHandle, ref rawPose, ref poseHandle);
            return(poseHandle);
        }
        public static void ApiPoseToUnityPose(ApiPoseData apiPose, out Pose unityPose)
        {
            Matrix4x4 glWorld_T_glLocal = Matrix4x4.TRS(new Vector3(apiPose.X, apiPose.Y, apiPose.Z),
                                                        new Quaternion(apiPose.Qx, apiPose.Qy, apiPose.Qz, apiPose.Qw), Vector3.one);
            Matrix4x4  unityWorld_T_glWorld    = Matrix4x4.Scale(new Vector3(1, 1, -1));
            Matrix4x4  unityWorld_T_unityLocal = unityWorld_T_glWorld * glWorld_T_glLocal * unityWorld_T_glWorld.inverse;
            Vector3    position = unityWorld_T_unityLocal.GetColumn(3);
            Quaternion rotation = Quaternion.LookRotation(unityWorld_T_unityLocal.GetColumn(2),
                                                          unityWorld_T_unityLocal.GetColumn(1));

            unityPose = new Pose(position, rotation);
        }
 public void EarlyUpdate()
 {
     lock (m_poseQueueLock)
     {
         while (m_poseQueue.Count > 0)
         {
             ApiPoseData pose = m_poseQueue.Dequeue();
             if (pose.framePair.baseFrame == ApiCoordinateFrameType.AreaDescription &&
                 pose.framePair.targetFrame == ApiCoordinateFrameType.StartOfService)
             {
                 IsLocalized = pose.statusCode == ApiPoseStatusType.Valid;
             }
         }
     }
 }
        public static void UnityPoseToApiPose(Pose unityPose, out ApiPoseData apiPose)
        {
            Matrix4x4  glWorld_T_glLocal       = Matrix4x4.TRS(unityPose.position, unityPose.rotation, Vector3.one);
            Matrix4x4  unityWorld_T_glWorld    = Matrix4x4.Scale(new Vector3(1, 1, -1));
            Matrix4x4  unityWorld_T_unityLocal = unityWorld_T_glWorld * glWorld_T_glLocal * unityWorld_T_glWorld.inverse;
            Vector3    position = unityWorld_T_unityLocal.GetColumn(3);
            Quaternion rotation = Quaternion.LookRotation(unityWorld_T_unityLocal.GetColumn(2),
                                                          unityWorld_T_unityLocal.GetColumn(1));

            apiPose.X  = position.x;
            apiPose.Y  = position.y;
            apiPose.Z  = position.z;
            apiPose.Qx = rotation.x;
            apiPose.Qy = rotation.y;
            apiPose.Qz = rotation.z;
            apiPose.Qw = rotation.w;
        }
Exemple #7
0
 public static extern void ArPose_getPoseRaw(
     IntPtr sessionHandle, IntPtr poseHandle, ref ApiPoseData rawPose);
Exemple #8
0
 public static extern void ArPose_create(
     IntPtr session, ref ApiPoseData rawPose, ref IntPtr poseHandle);