public SessionManager() { AnchorManager = new AnchorManager(); LightEstimateManager = new LightEstimateManager(); MotionTrackingManager = new MotionTrackingManager(); PointCloudManager = new PointCloudManager(); RaycastManager = new RaycastManager(); TrackedPlaneManager = new TrackedPlaneManager(); TangoEvents = new List <ApiTangoEvent>(); TangoClientApi.ConnectOnEventAvailable(m_eventQueue, m_eventQueueLockObject); }
public MotionTrackingManager() { ApiCoordinateFramePair[] framePairs = new ApiCoordinateFramePair[] { new ApiCoordinateFramePair() { baseFrame = ApiCoordinateFrameType.AreaDescription, targetFrame = ApiCoordinateFrameType.StartOfService, } }; TangoClientApi.ConnectOnPoseAvailable(framePairs, m_poseQueue, m_poseQueueLock); }
/// <summary> /// Get the most recent light estimate. /// </summary> /// <returns></returns> public LightEstimate GetLatestLightEstimate() { // Maintain frame consistency. if (Time.frameCount == m_latestLightEstimateFrame) { return(m_latestLightEstimate); } m_latestLightEstimateFrame = Time.frameCount; UnityTango.NativeImage nativeImage = new UnityTango.NativeImage(); if (!UnityTango.Device.TryAcquireLatestImageBuffer(ref nativeImage)) { Debug.LogError("Unable to acquire image buffer."); return(m_latestLightEstimate); } // The Y plane is always the first one. var yPlaneInfo = nativeImage.planeInfos[0]; IntPtr yPlaneStart = new IntPtr(nativeImage.planeData.ToInt64() + yPlaneInfo.offset); float intensity; ApiServiceErrorStatus status = TangoClientApi.TangoService_getPixelIntensity( yPlaneStart, (int)nativeImage.width, (int)nativeImage.height, nativeImage.planeInfos[0].rowStride, out intensity); if (status != ApiServiceErrorStatus.Success) { Debug.LogErrorFormat("Call to getPixelIntensity failed: {0}.", status); return(m_latestLightEstimate); } m_latestLightEstimate = new LightEstimate(intensity); UnityTango.Device.ReleaseImageBuffer(nativeImage); return(m_latestLightEstimate); }
private bool _UpdateMostRecentApiPlanes() { IntPtr apiPlanesPtr = IntPtr.Zero; int planeCount = 0; if (TangoClientApi.TangoService_Experimental_getPlanes(ref apiPlanesPtr, ref planeCount).IsTangoFailure()) { for (int i = 0; i < m_mostRecentApiPlanes.Count; i++) { ApiPlaneData planeData = m_mostRecentApiPlanes[i]; planeData.isValid = false; m_mostRecentApiPlanes[i] = planeData; } return(true); } // The planes api is handling a COM reset, and the current state is not available. Leave the most recent // Api planes collection unchanged. if (apiPlanesPtr == null) { return(false); } // Marshal the most recent planes returned from the Api into m_mostRecentApiPlanes. m_mostRecentApiPlanes.Clear(); MarshalingHelper.AddUnmanagedStructArrayToList <ApiPlaneData>(apiPlanesPtr, planeCount, m_mostRecentApiPlanes); if (TangoClientApi.TangoPlaneData_free(apiPlanesPtr, planeCount).IsTangoFailure()) { ARDebug.LogErrorFormat("Failed to deallocate planes from the ARCore API."); } return(false); }