Пример #1
0
 public PointCloudManager(NativeSession session)
 {
     m_NativeSession = session;
 }
Пример #2
0
 public CameraConfigApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #3
0
 public HitTestApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #4
0
        private void OnEarlyUpdate()
        {
            SetCameraTextureName();

            // Update session activity before EarlyUpdate.
            if (_haveDisableToEnableTransition)
            {
                SetSessionEnabled(false);
                SetSessionEnabled(true);
                _haveDisableToEnableTransition = false;

                // Avoid firing session enable event twice.
                if (_desiredSessionState.HasValue && _desiredSessionState.Value)
                {
                    _desiredSessionState = null;
                }
            }

            if (_desiredSessionState.HasValue)
            {
                SetSessionEnabled(_desiredSessionState.Value);
                _desiredSessionState = null;
            }

            // Perform updates before calling ArPresto_update.
            if (SessionComponent != null)
            {
                IntPtr previousSession = IntPtr.Zero;
                ExternApi.ArPresto_getSession(ref previousSession);

                if (UpdateSessionFeatures != null)
                {
                    UpdateSessionFeatures();
                }

                SetCameraDirection(SessionComponent.DeviceCameraDirection);

                IntPtr currentSession = IntPtr.Zero;
                ExternApi.ArPresto_getSession(ref currentSession);

                // Fire the session enabled event when the underlying session has been changed
                // due to session feature update(camera direction etc).
                if (previousSession != currentSession)
                {
                    FireOnSessionSetEnabled(false);
                    FireOnSessionSetEnabled(true);
                }

                // Validate and convert the SessionConfig to a Instant Preview supported config by
                // logging and disabling limited supported features.
                if (InstantPreviewManager.IsProvidingPlatform &&
                    SessionComponent.SessionConfig != null &&
                    !InstantPreviewManager.ValidateSessionConfig(SessionComponent.SessionConfig))
                {
                    // A new SessionConfig object will be created based on the original
                    // SessionConfig with all limited support features disabled.
                    SessionComponent.SessionConfig =
                        InstantPreviewManager.GenerateInstantPreviewSupportedConfig(
                            SessionComponent.SessionConfig);
                }

                UpdateConfiguration(SessionComponent.SessionConfig);
            }

            UpdateDisplayGeometry();

            // Update ArPresto and potentially ArCore.
            ExternApi.ArPresto_update();
            if (SystemInfo.graphicsMultiThreaded && !InstantPreviewManager.IsProvidingPlatform)
            {
                // Synchronize render thread with update call.
                ExternApi.ARCoreRenderingUtils_CreatePostUpdateFence();
            }

            SessionStatus previousSessionStatus = SessionStatus;

            // Get state information from ARPresto.
            ApiPrestoStatus prestoStatus = ApiPrestoStatus.Uninitialized;

            ExternApi.ArPresto_getStatus(ref prestoStatus);
            SessionStatus = prestoStatus.ToSessionStatus();

            LostTrackingReason = LostTrackingReason.None;
            if (NativeSession != null && SessionStatus == SessionStatus.LostTracking)
            {
                var cameraHandle = NativeSession.FrameApi.AcquireCamera();
                LostTrackingReason = NativeSession.CameraApi.GetLostTrackingReason(cameraHandle);
                NativeSession.CameraApi.Release(cameraHandle);
            }

            // If the current status is an error, check if the SessionStatus error state changed.
            if (SessionStatus.IsError() &&
                previousSessionStatus.IsError() != SessionStatus.IsError())
            {
                // Disable internal session bits so we properly pause the session due to error.
                FireOnSessionSetEnabled(false);
                _disabledSessionOnErrorState = true;
            }
            else if (SessionStatus.IsValid() && _disabledSessionOnErrorState)
            {
                if (SessionComponent.enabled)
                {
                    FireOnSessionSetEnabled(true);
                }

                _disabledSessionOnErrorState = false;
            }

            // Get the current session from presto and note if it has changed.
            IntPtr sessionHandle = IntPtr.Zero;

            ExternApi.ArPresto_getSession(ref sessionHandle);
            IsSessionChangedThisFrame = _cachedSessionHandle != sessionHandle;
            _cachedSessionHandle      = sessionHandle;

            ExternApi.ArPresto_getFrame(ref _cachedFrameHandle);

            // Update the native session with the newest frame.
            if (NativeSession != null)
            {
                NativeSession.OnUpdate(_cachedFrameHandle);
            }

            UpdateTextureIfNeeded();

            if (EarlyUpdate != null)
            {
                EarlyUpdate();
            }
        }
Пример #5
0
 public TrackableManager(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
     LifecycleManager.Instance.OnResetInstance += _ClearCachedTrackables;
 }
Пример #6
0
 public CameraConfigFilterApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #7
0
 public void DestroySession()
 {
     m_SessionComponent = null;
     m_NativeSession    = null;
     ExternApi.ArPresto_reset();
 }
        private ApiPrestoCallbackResult OnBeforeResumeSession(IntPtr sessionHandle)
        {
            ApiPrestoCallbackResult result = ApiPrestoCallbackResult.InvalidCameraConfig;

            if (SessionComponent == null || sessionHandle == IntPtr.Zero)
            {
                return(result);
            }

            NativeSession tempNativeSession = GetNativeSession(sessionHandle);
            var           listHandle        = tempNativeSession.CameraConfigListApi.Create();

            tempNativeSession.SessionApi.GetSupportedCameraConfigurationsWithFilter(
                SessionComponent.CameraConfigFilter,
                listHandle, _tempCameraConfigHandles, _tempCameraConfigs,
                SessionComponent.DeviceCameraDirection);

            if (_tempCameraConfigHandles.Count == 0)
            {
                Debug.LogWarning(
                    "Unable to choose a custom camera configuration because none are available.");
            }
            else
            {
                var configIndex = 0;
                if (SessionComponent.GetChooseCameraConfigurationCallback() != null)
                {
                    configIndex = SessionComponent.GetChooseCameraConfigurationCallback()(
                        _tempCameraConfigs);
                }

                if (configIndex >= 0 && configIndex < _tempCameraConfigHandles.Count)
                {
                    var status = tempNativeSession.SessionApi.SetCameraConfig(
                        _tempCameraConfigHandles[configIndex]);
                    if (status != ApiArStatus.Success)
                    {
                        Debug.LogErrorFormat(
                            "Failed to set the ARCore camera configuration: {0}", status);
                    }
                    else
                    {
                        result = ApiPrestoCallbackResult.Success;

                        // sync the session configuration with the new camera direction.
                        ExternApi.ArPresto_setConfigurationDirty();
                    }
                }

                for (int i = 0; i < _tempCameraConfigHandles.Count; i++)
                {
                    tempNativeSession.CameraConfigApi.Destroy(_tempCameraConfigHandles[i]);
                }
            }

            // clean up
            tempNativeSession.CameraConfigListApi.Destroy(listHandle);
            _tempCameraConfigHandles.Clear();
            _tempCameraConfigs.Clear();
            return(result);
        }
Пример #9
0
 public PointCloudApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #10
0
        private void _OnEarlyUpdate()
        {
            // Update session activity before EarlyUpdate.
            if (m_HaveDisableToEnableTransition)
            {
                _SetSessionEnabled(false);
                _SetSessionEnabled(true);
                m_HaveDisableToEnableTransition = false;

                // Avoid firing session enable event twice.
                if (m_DesiredSessionState.HasValue && m_DesiredSessionState.Value)
                {
                    m_DesiredSessionState = null;
                }
            }

            if (m_DesiredSessionState.HasValue)
            {
                _SetSessionEnabled(m_DesiredSessionState.Value);
                m_DesiredSessionState = null;
            }

            // Perform updates before calling ArPresto_update.
            _UpdateDisplayGeometry();
            if (SessionComponent != null)
            {
                _SetCameraDirection(SessionComponent.DeviceCameraDirection);
                _SetConfiguration(SessionComponent.SessionConfig);
            }

            // Update ArPresto and potentially ArCore.
            ExternApi.ArPresto_update();

            // Get state information from ARPresto.
            ApiPrestoStatus prestoStatus = ApiPrestoStatus.Uninitialized;

            ExternApi.ArPresto_getStatus(ref prestoStatus);
            SessionStatus = prestoStatus.ToSessionStatus();

            LostTrackingReason = LostTrackingReason.None;
            if (NativeSession != null && SessionStatus == SessionStatus.LostTracking)
            {
                var cameraHandle = NativeSession.FrameApi.AcquireCamera();
                LostTrackingReason = NativeSession.CameraApi.GetLostTrackingReason(cameraHandle);
                NativeSession.CameraApi.Release(cameraHandle);
            }

            // Get the current session from presto and note if it has changed.
            IntPtr sessionHandle = IntPtr.Zero;

            ExternApi.ArPresto_getSession(ref sessionHandle);
            IsSessionChangedThisFrame = m_CachedSessionHandle != sessionHandle;
            m_CachedSessionHandle     = sessionHandle;

            ExternApi.ArPresto_getFrame(ref m_CachedFrameHandle);

            // Update the native session with the newest frame.
            if (NativeSession != null)
            {
                NativeSession.OnUpdate(m_CachedFrameHandle);
            }

            _UpdateTextureIfNeeded();

            if (EarlyUpdate != null)
            {
                EarlyUpdate();
            }
        }
        private void _OnEarlyUpdate()
        {
            // Update session activity before EarlyUpdate.
            if (m_HaveDisableToEnableTransition)
            {
                _SetSessionEnabled(false);
                _SetSessionEnabled(true);
                m_HaveDisableToEnableTransition = false;

                // Avoid firing session enable event twice.
                if (m_DesiredSessionState.HasValue && m_DesiredSessionState.Value)
                {
                    m_DesiredSessionState = null;
                }
            }

            if (m_DesiredSessionState.HasValue)
            {
                _SetSessionEnabled(m_DesiredSessionState.Value);
                m_DesiredSessionState = null;
            }

            // Perform updates before calling ArPresto_update.
            if (SessionComponent != null)
            {
                IntPtr previousSession = IntPtr.Zero;
                ExternApi.ArPresto_getSession(ref previousSession);

                if (UpdateSessionFeatures != null)
                {
                    UpdateSessionFeatures();
                }

                _SetCameraDirection(SessionComponent.DeviceCameraDirection);

                IntPtr currentSession = IntPtr.Zero;
                ExternApi.ArPresto_getSession(ref currentSession);

                // Fire the session enabled event when the underlying session has been changed
                // due to session feature update(camera direction etc).
                if (previousSession != currentSession)
                {
                    _FireOnSessionSetEnabled(false);
                    _FireOnSessionSetEnabled(true);
                }

                _SetConfiguration(SessionComponent.SessionConfig);
            }

            _UpdateDisplayGeometry();

            // Update ArPresto and potentially ArCore.
            ExternApi.ArPresto_update();

            SessionStatus previousSessionStatus = SessionStatus;

            // Get state information from ARPresto.
            ApiPrestoStatus prestoStatus = ApiPrestoStatus.Uninitialized;

            ExternApi.ArPresto_getStatus(ref prestoStatus);
            SessionStatus = prestoStatus.ToSessionStatus();

            LostTrackingReason = LostTrackingReason.None;
            if (NativeSession != null && SessionStatus == SessionStatus.LostTracking)
            {
                var cameraHandle = NativeSession.FrameApi.AcquireCamera();
                LostTrackingReason = NativeSession.CameraApi.GetLostTrackingReason(cameraHandle);
                NativeSession.CameraApi.Release(cameraHandle);
            }

            // If the current status is an error, check if the SessionStatus error state changed.
            if (SessionStatus.IsError() &&
                previousSessionStatus.IsError() != SessionStatus.IsError())
            {
                // Disable internal session bits so we properly pause the session due to error.
                _FireOnSessionSetEnabled(false);
                m_DisabledSessionOnErrorState = true;
            }
            else if (SessionStatus.IsValid() && m_DisabledSessionOnErrorState)
            {
                if (SessionComponent.enabled)
                {
                    _FireOnSessionSetEnabled(true);
                }

                m_DisabledSessionOnErrorState = false;
            }

            // Get the current session from presto and note if it has changed.
            IntPtr sessionHandle = IntPtr.Zero;

            ExternApi.ArPresto_getSession(ref sessionHandle);
            IsSessionChangedThisFrame = m_CachedSessionHandle != sessionHandle;
            m_CachedSessionHandle     = sessionHandle;

            ExternApi.ArPresto_getFrame(ref m_CachedFrameHandle);

            // Update the native session with the newest frame.
            if (NativeSession != null)
            {
                NativeSession.OnUpdate(m_CachedFrameHandle);
            }

            _UpdateTextureIfNeeded();

            if (EarlyUpdate != null)
            {
                EarlyUpdate();
            }
        }
Пример #12
0
 public TrackDataListApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #13
0
 public AnchorApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #14
0
 public AugmentedImageApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #15
0
 public SessionConfigApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #16
0
 public PoseApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #17
0
 public PointApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #18
0
 public CameraMetadataApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #19
0
 public TrackableManager(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #20
0
 public TrackableApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #21
0
 public ImageApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #22
0
 public CameraApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #23
0
 public SessionApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #24
0
 public RecordingConfigApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
Пример #25
0
 public TrackableListApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }
 public AugmentedFaceApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #27
0
 public FrameApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #28
0
 public LightEstimateApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #29
0
 public AugmentedImageDatabaseApi(NativeSession nativeSession)
 {
     m_NativeSession = nativeSession;
 }
Пример #30
0
 public TrackApi(NativeSession nativeSession)
 {
     _nativeSession = nativeSession;
 }