コード例 #1
0
        /// <summary>
        /// Wrap an ARCoreSessionConfig in an API config.
        /// </summary>
        /// <param name="config">Config to wrap.</param>
        /// <param name="handle">
        /// GCHandle pinning internal IntPtr. The caller is responsible for calling GCHandle.Free
        /// when done with this config.
        /// </param>
        public ApiPrestoConfig(ARCoreSessionConfig config, out GCHandle handle)
        {
            UpdateMode = config.MatchCameraFramerate ?
                         ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage;
            var planeFindingMode = ApiPlaneFindingMode.Disabled;

            switch (config.PlaneFindingMode)
            {
            case DetectedPlaneFindingMode.Horizontal:
                planeFindingMode = ApiPlaneFindingMode.Horizontal;
                break;

            case DetectedPlaneFindingMode.Vertical:
                planeFindingMode = ApiPlaneFindingMode.Vertical;
                break;

            case DetectedPlaneFindingMode.HorizontalAndVertical:
                planeFindingMode = ApiPlaneFindingMode.HorizontalAndVertical;
                break;

            default:
                break;
            }

            PlaneFindingMode    = planeFindingMode;
            LightEstimationMode = config.EnableLightEstimation ?
                                  ApiLightEstimationMode.AmbientIntensity : ApiLightEstimationMode.Disabled;
            CloudAnchorMode = config.EnableCloudAnchor ?
                              ApiCloudAnchorMode.Enabled : ApiCloudAnchorMode.Disabled;

            if (config.AugmentedImageDatabase != null)
            {
                byte[] rawData = config.AugmentedImageDatabase.GetRawData();
                handle = GCHandle.Alloc(rawData, GCHandleType.Pinned);
                AugmentedImageDatabaseBytes = handle.AddrOfPinnedObject();
                AugmentedImageDatabaseSize  = rawData.Length;
            }
            else
            {
                handle = new GCHandle();
                AugmentedImageDatabaseBytes = IntPtr.Zero;
                AugmentedImageDatabaseSize  = 0;
            }

            switch (config.CameraFocusMode)
            {
            case GoogleARCore.CameraFocusMode.Fixed:
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                break;

            case GoogleARCore.CameraFocusMode.Auto:
                CameraFocusMode = ApiCameraFocusMode.Auto;
                break;

            default:
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                break;
            }
        }
コード例 #2
0
        public static void UpdateApiConfigWithARCoreSessionConfig(IntPtr sessionHandle,
                                                                  IntPtr configHandle, ARCoreSessionConfig sessionConfig)
        {
            ApiLightEstimationMode lightingMode =
                sessionConfig.LightEstimationMode.ToApiLightEstimationMode();

            ExternApi.ArConfig_setLightEstimationMode(sessionHandle, configHandle, lightingMode);

            ApiPlaneFindingMode planeFindingMode =
                sessionConfig.PlaneFindingMode.ToApiPlaneFindingMode();

            ExternApi.ArConfig_setPlaneFindingMode(sessionHandle, configHandle, planeFindingMode);

            ApiUpdateMode updateMode = sessionConfig.MatchCameraFramerate ?
                                       ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage;

            ExternApi.ArConfig_setUpdateMode(sessionHandle, configHandle, updateMode);

            ApiCloudAnchorMode cloudAnchorMode =
                sessionConfig.CloudAnchorMode.ToApiCloudAnchorMode();

            ExternApi.ArConfig_setCloudAnchorMode(sessionHandle, configHandle, cloudAnchorMode);

            IntPtr augmentedImageDatabaseHandle = IntPtr.Zero;

            if (sessionConfig.AugmentedImageDatabase != null)
            {
                augmentedImageDatabaseHandle = sessionConfig.AugmentedImageDatabase._nativeHandle;
                ExternApi.ArConfig_setAugmentedImageDatabase(sessionHandle, configHandle,
                                                             augmentedImageDatabaseHandle);
            }
            else
            {
                ExternApi.ArConfig_setAugmentedImageDatabase(sessionHandle, configHandle,
                                                             IntPtr.Zero);
            }

            ApiAugmentedFaceMode augmentedFaceMode =
                sessionConfig.AugmentedFaceMode.ToApiAugmentedFaceMode();

            ExternApi.ArConfig_setAugmentedFaceMode(sessionHandle, configHandle, augmentedFaceMode);

            ApiCameraFocusMode focusMode = sessionConfig.CameraFocusMode.ToApiCameraFocusMode();

            ExternApi.ArConfig_setFocusMode(sessionHandle, configHandle, focusMode);

            if (!InstantPreviewManager.IsProvidingPlatform)
            {
                ApiDepthMode depthMode = sessionConfig.DepthMode.ToApiDepthMode();
                ExternApi.ArConfig_setDepthMode(sessionHandle, configHandle, depthMode);
            }

            if (!InstantPreviewManager.IsProvidingPlatform)
            {
                ExternApi.ArConfig_setInstantPlacementMode(sessionHandle, configHandle,
                                                           sessionConfig.InstantPlacementMode);
            }
        }
コード例 #3
0
 public ApiPrestoConfig(ARCoreSessionConfig config)
 {
     UpdateMode = config.MatchCameraFramerate ?
                  ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage;
     PlaneFindingMode = config.EnablePlaneFinding ?
                        ApiPlaneFindingMode.Horizontal : ApiPlaneFindingMode.Disabled;
     LightEstimationMode = config.EnableLightEstimation ?
                           ApiLightEstimationMode.AmbientIntensity : ApiLightEstimationMode.Disabled;
 }
コード例 #4
0
        /// <summary>
        /// Wrap an ARCoreSessionConfig in an API config.
        /// </summary>
        /// <param name="config">Config to wrap.</param>
        public ApiPrestoConfig(ARCoreSessionConfig config)
        {
            UpdateMode = config.MatchCameraFramerate ?
                         ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage;
            var planeFindingMode = ApiPlaneFindingMode.Disabled;

            switch (config.PlaneFindingMode)
            {
            case DetectedPlaneFindingMode.Horizontal:
                planeFindingMode = ApiPlaneFindingMode.Horizontal;
                break;

            case DetectedPlaneFindingMode.Vertical:
                planeFindingMode = ApiPlaneFindingMode.Vertical;
                break;

            case DetectedPlaneFindingMode.HorizontalAndVertical:
                planeFindingMode = ApiPlaneFindingMode.HorizontalAndVertical;
                break;

            default:
                break;
            }

            PlaneFindingMode    = planeFindingMode;
            LightEstimationMode = config.EnableLightEstimation ?
                                  ApiLightEstimationMode.AmbientIntensity : ApiLightEstimationMode.Disabled;
            CloudAnchorMode = config.EnableCloudAnchor ?
                              ApiCloudAnchorMode.Enabled : ApiCloudAnchorMode.Disabled;

            if (config.AugmentedImageDatabase != null)
            {
                ArPrestoAugmentedImageDatabase = config.AugmentedImageDatabase.m_ArPrestoDatabaseHandle;
            }
            else
            {
                ArPrestoAugmentedImageDatabase = IntPtr.Zero;
            }

            switch (config.CameraFocusMode)
            {
            case GoogleARCore.CameraFocusMode.Fixed:
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                break;

            case GoogleARCore.CameraFocusMode.Auto:
                CameraFocusMode = ApiCameraFocusMode.Auto;
                break;

            default:
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                break;
            }
        }
コード例 #5
0
        internal ApiUpdate(Api api, EntitySchema entity, RecordSet records, ApiUpdateMode mode)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            _api    = api;
            Entity  = entity;
            Mode    = mode;
            Records = records ?? new RecordSet();
        }
コード例 #6
0
        public static void UpdateApiConfigWithARCoreSessionConfig(IntPtr sessionHandle,
                                                                  IntPtr configHandle, ARCoreSessionConfig sessionConfig)
        {
            ApiLightEstimationMode lightingMode =
                sessionConfig.LightEstimationMode.ToApiLightEstimationMode();

            ExternApi.ArConfig_setLightEstimationMode(sessionHandle, configHandle, lightingMode);

            ApiPlaneFindingMode planeFindingMode =
                sessionConfig.PlaneFindingMode.ToApiPlaneFindingMode();

            ExternApi.ArConfig_setPlaneFindingMode(sessionHandle, configHandle, planeFindingMode);

            ApiUpdateMode updateMode = sessionConfig.MatchCameraFramerate ?
                                       ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage;

            ExternApi.ArConfig_setUpdateMode(sessionHandle, configHandle, updateMode);

            ApiCloudAnchorMode cloudAnchorMode = sessionConfig.EnableCloudAnchor ?
                                                 ApiCloudAnchorMode.Enabled : ApiCloudAnchorMode.Disabled;

            ExternApi.ArConfig_setCloudAnchorMode(sessionHandle, configHandle, cloudAnchorMode);

            IntPtr augmentedImageDatabaseHandle = IntPtr.Zero;

            if (sessionConfig.AugmentedImageDatabase != null)
            {
                augmentedImageDatabaseHandle = sessionConfig.AugmentedImageDatabase.NativeHandle;
                ExternApi.ArConfig_setAugmentedImageDatabase(sessionHandle, configHandle,
                                                             augmentedImageDatabaseHandle);
            }

            ApiAugmentedFaceMode augmentedFaceMode =
                sessionConfig.AugmentedFaceMode.ToApiAugmentedFaceMode();

            ExternApi.ArConfig_setAugmentedFaceMode(sessionHandle, configHandle, augmentedFaceMode);

            ApiCameraFocusMode focusMode = sessionConfig.CameraFocusMode.ToApiCameraFocusMode();

            ExternApi.ArConfig_setFocusMode(sessionHandle, configHandle, focusMode);
        }
コード例 #7
0
 public static extern void ArConfig_setUpdateMode(
     IntPtr session, IntPtr config, ApiUpdateMode update_mode);
コード例 #8
0
        /// <summary>
        /// Wrap an ARCoreSessionConfig in an API config.
        /// </summary>
        /// <param name="config">Config to wrap.</param>
        public ApiPrestoConfig(ARCoreSessionConfig config)
        {
            UpdateMode = config.MatchCameraFramerate ?
                         ApiUpdateMode.Blocking : ApiUpdateMode.LatestCameraImage;
            var planeFindingMode = ApiPlaneFindingMode.Disabled;

            switch (config.PlaneFindingMode)
            {
            case DetectedPlaneFindingMode.Horizontal:
                planeFindingMode = ApiPlaneFindingMode.Horizontal;
                break;

            case DetectedPlaneFindingMode.Vertical:
                planeFindingMode = ApiPlaneFindingMode.Vertical;
                break;

            case DetectedPlaneFindingMode.HorizontalAndVertical:
                planeFindingMode = ApiPlaneFindingMode.HorizontalAndVertical;
                break;

            default:
                break;
            }

            PlaneFindingMode    = planeFindingMode;
            LightEstimationMode = config.EnableLightEstimation ?
                                  ApiLightEstimationMode.AmbientIntensity : ApiLightEstimationMode.Disabled;
            CloudAnchorMode = config.EnableCloudAnchor ?
                              ApiCloudAnchorMode.Enabled : ApiCloudAnchorMode.Disabled;

            if (config.AugmentedImageDatabase != null)
            {
                ArPrestoAugmentedImageDatabase = config.AugmentedImageDatabase.m_ArPrestoDatabaseHandle;
            }
            else
            {
                ArPrestoAugmentedImageDatabase = IntPtr.Zero;
            }

            switch (config.CameraFocusMode)
            {
            case GoogleARCore.CameraFocusMode.Fixed:
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                break;

            case GoogleARCore.CameraFocusMode.Auto:
#if UNITY_EDITOR
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                UnityEngine.Debug.LogWarningFormat(
                    "Camera focus mode '{0}' not supported in editor.\n" +
                    "Using camera focus mode '{1}' instead.", config.CameraFocusMode, CameraFocusMode);
#else
                CameraFocusMode = ApiCameraFocusMode.Auto;
#endif
                break;

            default:
                CameraFocusMode = ApiCameraFocusMode.Fixed;
                break;
            }
        }