public Pose GetPoseValue(IntPtr poseHandle)
        {
            NDKPoseData poseValue = new NDKPoseData(Pose.identity);

            NDKAPI.HwArPose_getPoseRaw(m_ndkSession.SessionHandle, poseHandle, ref poseValue);
            return(poseValue.ToUnityPose());
        }
        public IntPtr Create(Pose pose)
        {
            NDKPoseData nDKPoseData = new NDKPoseData(pose);
            IntPtr      poseHandle  = IntPtr.Zero;

            NDKAPI.HwArPose_create(m_ndkSession.SessionHandle, ref nDKPoseData, ref poseHandle);
            return(poseHandle);
        }
Beispiel #3
0
        public static void NDKPoseData2UnityPose(NDKPoseData poseData, out Pose pose)
        {
            Matrix4x4 glWorld2glLocal = Matrix4x4.TRS(new Vector3(poseData.Tx, poseData.Ty, poseData.Tz),
                                                      new Quaternion(poseData.Qx, poseData.Qy, poseData.Qz, poseData.Qw), Vector3.one);
            Matrix4x4 unityWorld2glWorld    = Matrix4x4.Scale(new Vector3(1, 1, -1));
            Matrix4x4 unityWorld2unityLocal = unityWorld2glWorld * glWorld2glLocal * unityWorld2glWorld.inverse;

            Vector3    position   = unityWorld2unityLocal.GetColumn(3);
            Quaternion quaternion = Quaternion.LookRotation(unityWorld2unityLocal.GetColumn(2),
                                                            unityWorld2unityLocal.GetColumn(1));

            pose = new Pose(position, quaternion);
        }
Beispiel #4
0
        public static void UnityPose2NDKPoseData(Pose pose, out NDKPoseData poseData)
        {
            Matrix4x4  unityWorld2unityLocal = Matrix4x4.TRS(pose.position, pose.rotation, Vector3.one);
            Matrix4x4  glWorld2unityWorld    = Matrix4x4.Scale(new Vector3(1, 1, -1));
            Matrix4x4  glWorld2glLocal       = glWorld2unityWorld * unityWorld2unityLocal * glWorld2unityWorld.inverse;
            Vector3    position   = glWorld2glLocal.GetColumn(3);
            Quaternion quaternion = Quaternion.LookRotation(glWorld2glLocal.GetColumn(2),
                                                            glWorld2glLocal.GetColumn(1));

            poseData.Tx = position.x;
            poseData.Ty = position.y;
            poseData.Tz = position.z;

            poseData.Qw = quaternion.w;
            poseData.Qx = quaternion.x;
            poseData.Qy = quaternion.y;
            poseData.Qz = quaternion.z;
        }
 public static extern void HwArPose_getPoseRaw(IntPtr sessionHandle, IntPtr poseHandle,
                                               ref NDKPoseData outPoseRaw);
 public static extern void HwArPose_create(IntPtr sessionHandle,
                                           ref NDKPoseData poseRaw, ref IntPtr outPoseHandle);