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

            ExternApi.arPoseGetPoseRaw(poseHandle, ref poseValue);
            return(poseValue.ToUnityPose());
        }
Esempio n. 2
0
        public IntPtr Create(Pose pose)
        {
            ApiPoseData rawPose = new ApiPoseData(pose);

            IntPtr poseHandle = IntPtr.Zero;

            ExternApi.arPoseCreate(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 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;
        }
Esempio n. 5
0
 public static extern void arPoseGetPoseRaw(IntPtr poseHandle,
                                            ref ApiPoseData rawPose);
Esempio n. 6
0
 public static extern void arPoseCreate(ref ApiPoseData rawPose, ref IntPtr poseHandle);