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

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

            IntPtr poseHandle = IntPtr.Zero;

            ExternApi.arPoseCreate(ref rawPose, ref poseHandle);
            return(poseHandle);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
        }
예제 #5
0
 public static extern void arPoseGetPoseRaw(IntPtr poseHandle,
                                            ref ApiPoseData rawPose);
예제 #6
0
 public static extern void arPoseCreate(ref ApiPoseData rawPose, ref IntPtr poseHandle);