void Play() { SegResults = StaticMeshScript.GetSegmentationInfo(SceneUnderstandingObjectType.CHAIR); bool allowPlay = !ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !StaticMeshScript.SemanticMeshIsExporting && !StaticMeshScript.ModelIsLoading && !StaticMeshScript.SemanticMeshIsLoading && SegResults.Count > 0; if (!allowPlay) { return; } if (StaticMeshScript.CheckModelLoaded()) { GenerateNPC(); } else if (StaticMeshScript.CheckSemanticMeshDirExist()) { LoadSemanticMesh(); } else { ScanText.color = Color_Bright; HintText.text = "Object Not Found."; } }
public void Init_Start() { GameObject attachPointCanvas = ViveSR_Experience.instance.AttachPoint.transform.GetChild(ViveSR_Experience.instance.AttachPointIndex).transform.gameObject; ScanText = attachPointCanvas.transform.Find("TouchpadCanvas/ScanText").GetComponent <Text>(); StopText = attachPointCanvas.transform.Find("TouchpadCanvas/StopText").GetComponent <Text>(); SaveText = attachPointCanvas.transform.Find("TouchpadCanvas/SaveText").GetComponent <Text>(); LoadText = attachPointCanvas.transform.Find("TouchpadCanvas/LoadText").GetComponent <Text>(); HintText = attachPointCanvas.transform.Find("HintText").GetComponent <Text>(); GripCanvas = attachPointCanvas.transform.Find("GripCanvas").gameObject; GripCanvas.SetActive(false); LoadText.color = StaticMeshScript.CheckSemanticMeshDirExist() ? BrightColor : OriginalColor; ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode = ReconstructionDisplayMode.ADAPTIVE_MESH; ViveSR_Experience_ControllerDelegate.touchpadDelegate += HandleTouchpad_MeshOperation; }
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; } } }