void Scan() { bool allowScan = !ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !StaticMeshScript.SemanticMeshIsExporting && !StaticMeshScript.ModelIsLoading && !StaticMeshScript.SemanticMeshIsLoading; if (!allowScan) { return; } HintText.text = ""; // Clear StaticMeshScript.LoadMesh(false); StaticMeshScript.ActivateSemanticMesh(false); StaticMeshScript.ClearHintLocators(); npcGenerator.ClearScene(); NavFloor.SetActive(false); RigidReconstruction.SRWork_Rigid_Reconstruciton.RegisterDataErrorHandler((int)Error.GPU_MEMORY_FULL, GPUMemoryFull); StaticMeshScript.EnableDepthProcessingAndScanning(true); StaticMeshScript.SetSegmentation(true); ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CHAIR, 10, true); SetColor(Color_Dark, ScanText, StopText, PlayText); SetColor(Color_Bright, SaveText, StopText); }
void Scan() { bool allowScan = !ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !StaticMeshScript.SemanticMeshIsExporting && !StaticMeshScript.ModelIsLoading && !StaticMeshScript.SemanticMeshIsLoading; if (!allowScan) { return; } ViveSR_Experience_ControllerDelegate.gripDelegate -= HandleGrip_SemanticObjOperation; GripCanvas.SetActive(false); ViveSR_SceneUnderstanding.DestroySceneObjects(); StaticMeshScript.LoadMesh(false); StaticMeshScript.ActivateSemanticMesh(false); HintText.text = "Scanning..."; RigidReconstruction.SRWork_Rigid_Reconstruciton.RegisterDataErrorHandler((int)Error.GPU_MEMORY_FULL, GPUMemoryFull); StaticMeshScript.EnableDepthProcessingAndScanning(true); StaticMeshScript.SetSegmentation(true); LoadText.color = OriginalColor; ScanText.color = OriginalColor; SaveText.color = BrightColor; StopText.color = BrightColor; }
void TestSegmentationResult_done() { List <SceneUnderstandingObjects.Element> SegResults = StaticMeshScript.GetSegmentationInfo(SceneUnderstandingObjectType.CHAIR); StaticMeshScript.GenerateHintLocators(SegResults); chairNum = StaticMeshScript.GetSegmentationInfo(SceneUnderstandingObjectType.CHAIR).Count; ViveSR_Experience_Demo.instance.ButtonScripts[MenuButton.Segmentation].EnableButton(chairNum > 0); StaticMeshScript.SetSegmentation(false); StaticMeshScript.ExportModel(UpdatePercentage_Mesh, ExportModel_done); }
private void HandleTouchpad_MeshOperation(ButtonStage buttonStage, Vector2 axis) { if (!isTriggerDown) { switch (buttonStage) { case ButtonStage.PressDown: TouchpadDirection touchpadDirection = ViveSR_Experience_ControllerDelegate.GetTouchpadDirection(axis, false); if (touchpadDirection == TouchpadDirection.Up) //[Scan] { if (!ViveSR_RigidReconstruction.IsScanning && !StaticMeshScript.ModelIsLoading && !StaticMeshScript.SemanticMeshIsLoading) { //SemanticDrawer.DestroyAllObjects(); if (StaticMeshScript.CheckModelLoaded()) { StaticMeshScript.LoadMesh(false); } StaticMeshScript.ActivateSemanticMesh(false); DartText.text = ""; HintText.text = ""; GripText.text = ""; //ViveSR_Experience_ControllerDelegate.gripDelegate -= HandleGrip_SwitchMode; StaticMeshScript.SetScanning(true); StaticMeshScript.SetSegmentation(true); LoadText.color = Color.gray; ScanText.color = Color.gray; SaveText.color = Color.white; StopText.color = Color.white; } } else if (touchpadDirection == TouchpadDirection.Left) //[Stop] { if (ViveSR_RigidReconstruction.IsScanning) { StaticMeshScript.SetScanning(false); StaticMeshScript.SetSegmentation(false); if (StaticMeshScript.CheckModelLoaded()) { StaticMeshScript.LoadMesh(true); } if (StaticMeshScript.SemanticMeshIsLoaded) { StaticMeshScript.ActivateSemanticMesh(true); } SetStaticMeshUI(); //ViveSR_Experience_ControllerDelegate.gripDelegate += HandleGrip_SwitchMode; } } else if (touchpadDirection == TouchpadDirection.Right) // [Save] { if (ViveSR_RigidReconstruction.IsScanning) { StaticMeshScript.UnloadSemanticMesh(); LoadText.color = Color.grey; ScanText.color = Color.grey; StopText.color = Color.grey; SaveText.color = Color.grey; ViveSR_Experience_ControllerDelegate.touchpadDelegate -= HandleTouchpad_MeshOperation; ViveSR_SceneUnderstanding.SetAllCustomSceneUnderstandingConfig(10, true); StaticMeshScript.SetSegmentation(false); StaticMeshScript.ExportSemanticMesh(UpdateSegmentationPercentage, () => { StaticMeshScript.ExportModel(UpdateModelPercentage, () => { DartText.text = ""; HintText.text = "Mesh Saved!"; ScanText.color = Color.white; LoadText.color = Color.white; ViveSR_Experience_ControllerDelegate.touchpadDelegate += HandleTouchpad_MeshOperation; } ); } ); } } else if (touchpadDirection == TouchpadDirection.Down) //[Load] { if (!ViveSR_RigidReconstruction.IsScanning && StaticMeshScript.CheckModelExist() && !StaticMeshScript.CheckModelLoaded()) { //ViveSR_Experience_ControllerDelegate.gripDelegate -= HandleGrip_SwitchMode; StaticMeshScript.LoadMesh( true, () => { // step 1 ScanText.color = Color.grey; LoadText.color = Color.grey; HintText.text = "Loading Scene..."; DartText.text = ""; }, () => { // step 2 if (StaticMeshScript.CheckSemanticMeshDirExist()) { LoadSemanticMesh(); StaticMeshScript.collisionMesh.SetActive(false); } else { ScanText.color = Color.white; HintText.text = "No Object is Found.\nPlease Rescan!"; } } ); } } break; } } }