/// <summary> /// Constructor for a new PointCloud wrapping <c>rawPointCloud</c>. /// </summary> /// <param name="rawPointCloud">The raw point cloud to wrap. If <c>rawPointCloud</c> is null, the /// resulting PointCloud will have <c>IsValid</c> set to false.</param> public PointCloud(UnityTango.PointCloudData?rawPointCloud) { if (rawPointCloud == null) { IsValid = false; m_rawPointCloud = new UnityTango.PointCloudData(); Pose = new Pose(); m_unityWorldTDepthCamera = Matrix4x4.identity; return; } IsValid = true; m_rawPointCloud = rawPointCloud.Value; Pose = new Pose(); m_unityWorldTDepthCamera = Matrix4x4.identity; ApiPoseData apiPoseData = new ApiPoseData(); if (ExternApi.TangoService_getPoseAtTime(m_rawPointCloud.timestamp, new ApiCoordinateFramePair(Constants.START_SERVICE_T_DEPTH_FRAME_PAIR), ref apiPoseData) == ApiServiceErrorStatus.Success) { Matrix4x4 ss_T_depth = Matrix4x4.TRS(apiPoseData.translation.ToVector3(), apiPoseData.orientation.ToQuaternion(), Vector3.one); m_unityWorldTDepthCamera = Constants.UNITY_WORLD_T_START_SERVICE * ss_T_depth; Vector3 translation = m_unityWorldTDepthCamera.GetColumn(3); Quaternion rotation = Quaternion.LookRotation(m_unityWorldTDepthCamera.GetColumn(2), m_unityWorldTDepthCamera.GetColumn(1)); Pose = new Pose(translation, rotation); } else { ARDebug.LogError("Could not retrieve a pose for the point cloud."); Pose = new Pose(); m_unityWorldTDepthCamera = Matrix4x4.identity; } }
public static extern ApiServiceErrorStatus TangoService_getPoseAtTime(double timestamp, ApiCoordinateFramePair framePair, ref ApiPoseData poseData);