void Stop()
        {
            if (!ViveSR_RigidReconstruction.IsScanning)
            {
                return;
            }

            if (StaticMeshScript.CheckModelLoaded())
            {
                ViveSR_Experience_ControllerDelegate.gripDelegate += HandleGrip_SwitchMode;
            }
            StaticMeshScript.EnableDepthProcessingAndScanning(false);

            TriggerCanvas.SetActive(StaticMeshScript.CheckModelLoaded());
            GripCanvas.SetActive(StaticMeshScript.CheckModelLoaded());

            if (StaticMeshScript.CheckModelLoaded())
            {
                // show loaded mesh
                StaticMeshScript.LoadMesh(true);
            }
            else if (StaticMeshScript.CheckModelFileExist())
            {
                LoadText.color = BrightColor;
            }

            ScanText.color = BrightColor;
            StopText.color = OriginalColor;
            SaveText.color = OriginalColor;
            LoadText.color = StaticMeshScript.CheckModelFileExist() ? BrightColor : OriginalColor;
        }
Beispiel #2
0
        void Scan()
        {
            bool allowScan = !ViveSR_RigidReconstruction.IsScanning &&
                             !ViveSR_RigidReconstruction.IsExportingMesh &&
                             !StaticMeshScript.ModelIsLoading;

            if (!allowScan)
            {
                return;
            }

            SwitchMeshDisplayMode(0);
            dartGeneratorMgr.DestroyObjs();

            if (StaticMeshScript.CheckModelLoaded())
            {
                StaticMeshScript.LoadMesh(false);
                LoadText.color = BrightColor;
            }

            GripCanvas.SetActive(false);
            TriggerCanvas.SetActive(false);
            HintText.text = "";

            RigidReconstruction.SRWork_Rigid_Reconstruciton.RegisterDataErrorHandler((int)Error.GPU_MEMORY_FULL, GPUMemoryFull);
            StaticMeshScript.EnableDepthProcessingAndScanning(true);

            LoadText.color = OriginalColor;
            ScanText.color = OriginalColor;
            SaveText.color = BrightColor;
            StopText.color = BrightColor;
        }
Beispiel #3
0
        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.";
            }
        }
Beispiel #4
0
        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;
                }
            }
        }