Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
        public static bool GetDepthColliderFrameInfo()
        {
            int result = (int)Error.FAILED;

            if (!InitialDepthColliderPtrSize)
            {
                result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepthCollider, DataInfoDepthCollider.Length);
                InitialDepthColliderPtrSize = (result == (int)Error.WORK);
            }

            DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoDepthCollider[(int)DepthDataMask.TIME_STP] };
            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, dataInfoFrame, dataInfoFrame.Length);
            if (result != (int)Error.WORK)
            {
                return(false);
            }

            Marshal.Copy(DataInfoDepthCollider[(int)DepthDataMask.TIME_STP].ptr, RawDepthColliderTimeIndex, 0, RawDepthColliderTimeIndex.Length);
            if (LastDepthColliderTimeIndex == DepthColliderTimeIndex)
            {
                return(false);
            }
            else
            {
                LastDepthColliderTimeIndex = DepthColliderTimeIndex;
            }
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the buffer of undistorted texture, frame index and time index.
        /// </summary>
        public static void UpdateUndistortedImage()
        {
            int result = (int)Error.FAILED;

            if (!InitialUndistortedPtrSize)
            {
                result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_SEETHROUGH, DataInfoUndistorted, DataInfoUndistorted.Length);
                InitialUndistortedPtrSize = (result == (int)Error.WORK);
            }

            DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoUndistorted[(int)SeeThroughDataMask.FRAME_SEQ] };
            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_SEETHROUGH, dataInfoFrame, dataInfoFrame.Length);
            if (result != (int)Error.WORK)
            {
                return;
            }

            Marshal.Copy(DataInfoUndistorted[(int)SeeThroughDataMask.FRAME_SEQ].ptr, RawUndistortedFrameIndex, 0, RawUndistortedFrameIndex.Length);
            if (LastUndistortedFrameIndex == UndistortedFrameIndex)
            {
                return;
            }
            else
            {
                LastUndistortedFrameIndex = UndistortedFrameIndex;
            }

            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_SEETHROUGH, DataInfoUndistorted, DataInfoUndistorted.Length);
            if (result == (int)Error.WORK)
            {
                ParseUndistortedPtrData();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Update the buffer of depth texture, frame index and time index.
        /// </summary>
        public static void UpdateDepthImage()
        {
            int result = (int)Error.FAILED;

            if (!InitialDepthPtrSize)
            {
                result = ViveSR_Framework.GetMultiDataSize(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepth, DataInfoDepth.Length);
                InitialDepthPtrSize = (result == (int)Error.WORK);
            }

            DataInfo[] dataInfoFrame = new DataInfo[] { DataInfoDepth[(int)DepthDataMask.FRAME_SEQ] };
            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, dataInfoFrame, dataInfoFrame.Length);
            if (result != (int)Error.WORK)
            {
                return;
            }

            Marshal.Copy(DataInfoDepth[(int)DepthDataMask.FRAME_SEQ].ptr, RawDepthFrameIndex, 0, RawDepthFrameIndex.Length);
            if (LastDepthFrameIndex == DepthFrameIndex)
            {
                return;
            }
            else
            {
                LastDepthFrameIndex = DepthFrameIndex;
            }

            result = ViveSR_Framework.GetMultiData(ViveSR_Framework.MODULE_ID_DEPTH, DataInfoDepth, DataInfoDepth.Length);
            if (result == (int)Error.WORK)
            {
                ParseDepthPtrData();
            }
        }
 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);
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the distorted texture, frame index, time index from current buffer.
        /// </summary>
        /// <param name="imageLeft"></param>
        /// <param name="imageRight"></param>
        /// <param name="frameIndex"></param>
        /// <param name="timeIndex"></param>
        public static void GetDistortedTexture(out Texture2D imageLeft, out Texture2D imageRight, out int frameIndex, out int timeIndex, out Matrix4x4 poseLeft, out Matrix4x4 poseRight)
        {
            // native buffer ptr method 2: get gpu texture buffer ptr directly from native(cpp)
#if USE_DISTORT_TEX_NATIVE_BUFFER
            if (TextureDistortedDeviceRaw == null)
            {
                TextureDistortedDeviceRaw = Texture2D.CreateExternalTexture(DistortedImageWidth, DistortedImageHeight * 2, TextureFormat.RGBA32, false, false, nativeTex);
            }
            else
            {
                ViveSR_Framework.GetParameterNativePtr(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.VIDEO_RES_VIEW_NATIVE_PTR, ref nativeTex);
                TextureDistortedDeviceRaw.UpdateExternalTexture(nativeTex);
            }
            imageLeft  = TextureDistortedDeviceRaw;
            imageRight = TextureDistortedDeviceRaw;
#else
            if (DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_LEFT].ptr != IntPtr.Zero && DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_RIGHT].ptr != IntPtr.Zero)
            {
                TextureDistortedLeft.LoadRawTextureData(DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_LEFT].ptr, DistortedImageWidth * DistortedImageHeight * DistortedImageChannel);
                TextureDistortedRight.LoadRawTextureData(DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_RIGHT].ptr, DistortedImageWidth * DistortedImageHeight * DistortedImageChannel);
                TextureDistortedLeft.Apply();
                TextureDistortedRight.Apply();
            }
            imageLeft  = TextureDistortedLeft;
            imageRight = TextureDistortedRight;
#endif
            frameIndex = DistortedFrameIndex;
            timeIndex  = DistortedTimeIndex;
            poseLeft   = DistortedPoseLeft;
            poseRight  = DistortedPoseRight;
        }
Ejemplo n.º 8
0
 private static void DepthDataCallback(int key)
 {
     for (int i = 0; i < DataInfoDepth.Length; i++)
     {
         ViveSR_Framework.GetPointer(key, i, ref DataInfoDepth[i].ptr);
     }
     ParseDepthPtrData();
 }
Ejemplo n.º 9
0
 private static void UndistortedDataCallback(int key)
 {
     for (int i = 0; i < DataInfoUndistorted.Length; i++)
     {
         ViveSR_Framework.GetPointer(key, i, ref DataInfoUndistorted[i].ptr);
     }
     ParseUndistortedPtrData();
 }
Ejemplo n.º 10
0
        public static void GetSceneUnderstandingConfig(ref SceneUnderstandingConfig config)
        {
            IntPtr pointer = Marshal.AllocCoTaskMem(Marshal.SizeOf(config));

            ViveSR_Framework.GetParameterStruct(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.SCENE_UNDERSTANDING_CONFIG, ref pointer);
            config = (SceneUnderstandingConfig)Marshal.PtrToStructure(pointer, typeof(SceneUnderstandingConfig));
            Marshal.FreeCoTaskMem(pointer);
        }
Ejemplo n.º 11
0
 private static void ReconstructionDataCallback(int key)
 {
     for (int i = 0; i < DataInfoPointCloud.Length; i++)
     {
         ViveSR_Framework.GetPointer(key, i, ref DataInfoPointCloud[i].ptr);
     }
     ParseReconstructionPtrData();
 }
Ejemplo n.º 12
0
        public static void SetSceneUnderstandingConfig(SceneUnderstandingConfig config)
        {
            IntPtr pointer = Marshal.AllocCoTaskMem(Marshal.SizeOf(config));

            Marshal.StructureToPtr(config, pointer, true);
            ViveSR_Framework.SetParameterStruct(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.SCENE_UNDERSTANDING_CONFIG, pointer);
            Marshal.FreeCoTaskMem(pointer);
        }
Ejemplo n.º 13
0
        public static int SetDefaultDepthCase(DepthCase depthCase)
        {
            int result = ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthParam.DEPTH_USING_CASE, (int)depthCase);

            if (result == (int)Error.WORK)
            {
                DepthCase = depthCase;
            }
            return(result);
        }
Ejemplo n.º 14
0
        public static int  EnableDepthProcess(bool active)
        {
            int result = ViveSR_Framework.ChangeModuleLinkStatus(ViveSR_Framework.MODULE_ID_SEETHROUGH, ViveSR_Framework.MODULE_ID_DEPTH, active ? (int)WorkLinkMethod.ACTIVE : (int)WorkLinkMethod.NONE);

            if (result == (int)Error.WORK)
            {
                DepthProcessing = active;
            }
            return(result);
        }
Ejemplo n.º 15
0
        public static int EnableDepthRefinement(bool active)
        {
            int result = ViveSR_Framework.SetCommandBool(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthCmd.ENABLE_REFINEMENT, active);

            if (result == (int)Error.WORK)
            {
                _DepthRefinement = active;
            }
            return(result);
        }
Ejemplo n.º 16
0
        public static int EnableDepthEdgeEnhance(bool active)
        {
            int result = ViveSR_Framework.SetCommandBool(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthCmd.ENABLE_EDGE_ENHANCE, active);

            if (result == (int)Error.WORK)
            {
                _DepthEdgeEnhance = active;
            }
            return(result);
        }
Ejemplo n.º 17
0
        public static int ChangeDepthCase(DepthCase depthCase)
        {
            int result = ViveSR_Framework.SetCommandInt(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthCmd.CHANGE_DEPTH_CASE, (int)depthCase);

            if (result == (int)Error.WORK)
            {
                DepthCase = depthCase;
            }
            return(result);
        }
Ejemplo n.º 18
0
        //public static void InitRigidReconstructionParam()
        //{
        //    this function is not called in current version, keep this API on, we can allow user to adjust some default setting
        //    ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_DATA_SOURCE, (int)ViveSR_RigidReconstructionConfig.ReconstructionDataSource);
        //    ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_DATASET_FRAME_NUM, (int)ViveSR_RigidReconstructionConfig.NumDatasetFrame);
        //    ViveSR_Framework.SetParameterString(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_DATASET_PATH, ViveSR_RigidReconstructionConfig.DatasetPath);
        //    ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_EXPORT_COLLIDER, ViveSR_RigidReconstructionConfig.ExportCollider);
        //    ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_EXPORT_TEXTURE, true);
        //    ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_QUALITY, (int)ViveSR_RigidReconstructionConfig.Quality);
        //}

        public static int GetRigidReconstructionIntParameter(int type)
        {
            int ret = -1;

            if (ViveSR_Framework.GetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, type, ref ret) != (int)Error.WORK)
            {
                Debug.Log("[ViveSR] [RigidReconstruction] GetRigidReconstructionIntParameter Failed");
            }

            return(ret);
        }
Ejemplo n.º 19
0
 public static void ExportSceneUnderstandingInfo(string filename)
 {
     ResetSceneUnderstandingProgress();
     ViveSR_RigidReconstructionRenderer.EnableSector = false;
     if (IsEnabledSceneUnderstandingView)
     {
         EnableSceneUnderstandingView(false);
     }
     ViveSR_Framework.SetCommandString(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)(ReconstructionCmd.EXPORT_SCENE_UNDERSTANDING_FOR_UNITY), filename);
     IsExportingSceneUnderstandingInfo = true;
 }
        private static bool SetColliderRangeEnable(bool value)
        {
            int result = ViveSR_Framework.SetCommandBool(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthCmd.ENABLE_SELECT_MESH_DISTANCE_RANGE, value);

            if (result == (int)Error.WORK)
            {
                _UpdateDepthColliderRange = value;
                return(true);
            }

            return(false);
        }
        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 static bool SetQualityScale(int value)
        {
            int result = ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthParam.COLLIDER_QUALITY, value);

            if (result == (int)Error.WORK)
            {
                QualityScale = value;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static bool SetDepthColliderHoleFillingEnable(bool value)
        {
            int result = ViveSR_Framework.SetCommandBool(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthCmd.ENABLE_DEPTH_MESH_HOLE_FILLING, value);

            if (result == (int)Error.WORK)
            {
                _UpdateDepthColliderHoleFilling = value;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        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);
        }
        public static bool GetQualityScale(out int value)
        {
            int result = ViveSR_Framework.GetParameterInt(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthParam.COLLIDER_QUALITY, ref QualityScale);

            if (result == (int)Error.WORK)
            {
                value = QualityScale;
                return(true);
            }
            else
            {
                value = -1;
                return(false);
            }
        }
Ejemplo n.º 26
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");
            }
        }
        private static bool SetDepthColliderFarDistance(double value)
        {
            value = (value < _ColliderNearDistance) ? _ColliderNearDistance : value;
            int result = ViveSR_Framework.SetParameterDouble(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthParam.MESH_FAR_DISTANCE, value);

            if (result == (int)Error.WORK)
            {
                _ColliderFarDistance = value;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private static bool SetColliderProcessEnable(bool value)
        {
            int result = ViveSR_Framework.SetCommandBool(ViveSR_Framework.MODULE_ID_DEPTH, (int)DepthCmd.EXTRACT_DEPTH_MESH, value);

            if (result == (int)Error.WORK)
            {
                _UpdateDepthCollider = value;
            }
            if (_UpdateDepthCollider == false)
            {
                ColliderMeshes.sharedMesh.Clear();
                ColliderMeshVisibility = false;
            }

            return(true);
        }
Ejemplo n.º 29
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);
        }
        // set self-setting to the static param
        public override bool RightBeforeStartModule()
        {
            bool result = ViveSR_RigidReconstruction.InitRigidReconstructionParamFromFile(ConfigFilePath);

            if (!result)
            {
                Debug.Log("[ViveSR] [RigidReconstruction] Set Config By Config File");
            }
            else
            {
                Debug.Log("[ViveSR] [RigidReconstruction] Config File Not Found, Set Config From GameObject");
                ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_QUALITY, (int)FullSceneQuality);
                //ViveSR_RigidReconstruction.InitRigidReconstructionParam();
            }

            WireframeMaterial.SetFloat("_Opaque", SetWireFrameOpaque ? 1.0f : 0.0f);
            return(true);
        }