示例#1
0
        public static void EnableSceneUnderstandingView(bool enable)
        {
            int result = 0;

            if (!ViveSR_RigidReconstruction.IsScanning)
            {
                return;
            }

            result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.SCENE_UNDERSTANDING_MACHINE_VISION, enable);
            if (result == (int)Error.WORK)
            {
                IsEnabledSceneUnderstandingView = enable;
                Debug.Log("[ViveSR] [Scene Understanding] Preview " + (enable ? "enabled" : "disabled"));

                if (IsEnabledSceneUnderstandingView)
                {
                    ViveSR_RigidReconstructionRenderer.EnableSector       = false;
                    ViveSR_RigidReconstructionRenderer.SetWireFrameOpaque = false;
                }
                else
                {
                    // ViveSR_RigidReconstructionRenderer.EnableSector = true;
                    ViveSR_RigidReconstructionRenderer.SetWireFrameOpaque = true;

                    ResetSceneUnderstandingProgress();
                }
            }
        }
示例#2
0
        public static void EnableSceneUnderstanding(bool enable)
        {
            int result;

            result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.SCENE_UNDERSTANDING_ENABLE, enable);
            if (result == (int)Error.WORK)
            {
                IsEnabledSceneUnderstanding = enable;
            }
            else
            {
                Debug.Log("[ViveSR] [Scene Understanding] Activation/Deactivation failed");
            }

            if (IsEnabledSceneUnderstanding)
            {
                result = ViveSR_Framework.RegisterCallback(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionCallback.SCENE_UNDERSTANDING_PROGRESS, Marshal.GetFunctionPointerForDelegate((ExportProgressCallback)UpdateSceneUnderstandingProgress));
                if (result != (int)Error.WORK)
                {
                    Debug.Log("[ViveSR] [Scene Understanding] Progress listener failed to register");
                }
            }
            else
            {
                EnableSceneUnderstandingView(false);
            }
        }
 private void EnableNativeMeshManipulation(bool enable)
 {
     if (CameraIndex == DualCameraIndex.LEFT)
     {
         if (IsForCalibration)
         {
             ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.ENABLE_CALIB_IMAGE_PLANE_MESH_L, enable);
         }
         else
         {
             ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.ENABLE_IMAGE_PLANE_MESH_L, enable);
         }
     }
     if (CameraIndex == DualCameraIndex.RIGHT)
     {
         if (IsForCalibration)
         {
             ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.ENABLE_CALIB_IMAGE_PLANE_MESH_R, enable);
         }
         else
         {
             ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.ENABLE_IMAGE_PLANE_MESH_R, enable);
         }
     }
 }
        private bool UpdateRuntimeParameter()
        {
            bool result = true;
            int  ret    = (int)Error.FAILED;

            // live mesh display mode
            if ((int)LiveMeshDisplayMode != LastLiveMeshDisplayMode)
            {
                HideAllLiveMeshes();
                result = SetMeshDisplayMode(LiveMeshDisplayMode) && result;
                LastLiveMeshDisplayMode = (int)LiveMeshDisplayMode;
            }

            // full scene quality
            ret = ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.CONFIG_QUALITY), (int)FullSceneQuality);
            if (LiveMeshDisplayMode == ReconstructionDisplayMode.FULL_SCENE)
            {
                LiveMeshMaterial.SetFloat("_PointSizeScaler", (FullSceneQuality == ReconstructionQuality.LOW)? 1.2f : 0.8f);
            }
            result = result && (ret == (int)Error.WORK);

            // update live adaptive param
            if (LiveMeshDisplayMode == ReconstructionDisplayMode.ADAPTIVE_MESH)
            {
                ret    = ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.ADAPTIVE_MAX_GRID, ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize * 0.01f); // cm to m
                result = result && (ret == (int)Error.WORK);
                ret    = ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.ADAPTIVE_MIN_GRID, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize * 0.01f);
                result = result && (ret == (int)Error.WORK);
                ret    = ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.ADAPTIVE_ERROR_THRES, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres);
                result = result && (ret == (int)Error.WORK);
            }

            if (EnableSector != LastEnableSector)
            {
                HideAllLiveMeshes();
                ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.ENABLE_FRUSTUM_CULLING), EnableSector);
                ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.ENABLE_SECTOR_GROUPER), EnableSector);
                ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.SECTOR_SIZE), SectorSizeInMeter);
                LastEnableSector = EnableSector;
            }

            if (SetWireFrameOpaque != LastSetWireFrameOpaque)
            {
                WireframeMaterial.SetFloat("_Opaque", SetWireFrameOpaque ? 1.0f : 0.0f);
                LastSetWireFrameOpaque = SetWireFrameOpaque;
            }

            // refresh rate
            ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.MESH_REFRESH_INTERVAL, RefreshIntervalMS);
            return(result);
        }
        public bool SetMeshDisplayMode(ReconstructionDisplayMode displayMode)
        {
            ResetData();

            int result = (int)Error.FAILED;

            if (displayMode == ReconstructionDisplayMode.FIELD_OF_VIEW)
            {
                ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.ENABLE_FRUSTUM_CULLING), false);
                ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.ENABLE_SECTOR_GROUPER), false);
                result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.LITE_POINT_CLOUD_MODE), true);
                result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.FULL_POINT_CLOUD_MODE), false);
                result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.LIVE_ADAPTIVE_MODE), false);
                LiveMeshMaterial.SetFloat("_PointSizeScaler", 1.2f);
                UsingMaterial     = LiveMeshMaterial;
                ThreadPeriod      = 15;
                BackupSectorValue = EnableSector;
                EnableSector      = false;
            }
            else if (displayMode == ReconstructionDisplayMode.FULL_SCENE)
            {
                result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.LITE_POINT_CLOUD_MODE), false);
                result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.FULL_POINT_CLOUD_MODE), true);
                result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.LIVE_ADAPTIVE_MODE), false);
                LiveMeshMaterial.SetFloat("_PointSizeScaler", (FullSceneQuality == ReconstructionQuality.LOW) ? 1.3f : 0.8f);
                UsingMaterial = LiveMeshMaterial;
                ThreadPeriod  = 300;
                EnableSector  = BackupSectorValue;
            }
            else if (displayMode == ReconstructionDisplayMode.ADAPTIVE_MESH)
            {
                result        = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.LITE_POINT_CLOUD_MODE), false);
                result        = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.FULL_POINT_CLOUD_MODE), false);
                result        = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionParam.LIVE_ADAPTIVE_MODE), true);
                UsingMaterial = WireframeMaterial;
                ThreadPeriod  = 300;
                EnableSector  = BackupSectorValue;
            }
            foreach (KeyValuePair <int, GameObject> go in ShowGameObjs)
            {
                go.Value.GetComponent <MeshRenderer>().sharedMaterial = UsingMaterial;
            }

            if (result == (int)Error.WORK)
            {
                LiveMeshDisplayMode = displayMode;
            }

            return(result == (int)Error.WORK);
        }
示例#6
0
        public static void EnableSceneUnderstandingRefinement(bool enable)
        {
            int result;

            result = ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.SCENE_UNDERSTANDING_REFINEMENT, enable);
            if (result == (int)Error.WORK)
            {
                IsEnabledSceneUnderstandingRefinement = enable;
                //Debug.Log("[ViveSR] [Scene Understanding] Refinement " + (enable ? "enabled" : "disabled"));
            }
            else
            {
                Debug.Log("[ViveSR] [Scene Understanding] Setting Refinement failed");
            }
        }
示例#7
0
        public static void ExportModel(string filename)
        {
            ExportStage      = 0;
            ExportPercentage = 0;
            IsExportingMesh  = true;

            ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.EXPORT_ADAPTIVE_MODEL, ExportAdaptiveMesh);
            if (ExportAdaptiveMesh)
            {
                ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.ADAPTIVE_MAX_GRID, ExportAdaptiveMaxGridSize * 0.01f);   // cm to m
                ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.ADAPTIVE_MIN_GRID, ExportAdaptiveMinGridSize * 0.01f);
                ViveSR_Framework.SetParameterFloat(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.ADAPTIVE_ERROR_THRES, ExportAdaptiveErrorThres);
            }
            ViveSR_Framework.RegisterCallback(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionCallback.EXPORT_PROGRESS, Marshal.GetFunctionPointerForDelegate((ExportProgressCallback)UpdateExportProgress));
            ViveSR_Framework.SetCommandString(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionCmd.EXPORT_MODEL_FOR_UNITY), filename);
        }