Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        bool LoadChair()
        {
            StaticMeshScript.ClearHintLocators();

            GameObject[] chairs = StaticMeshScript.GetSemanticObjects(SceneUnderstandingObjectType.CHAIR);

            if (chairs.Length == 0)
            {
                return(false);
            }

            for (int i = 0; i < chairs.Length; i++)
            {
                GameObject go = chairs[i];
                ViveSR_Experience_Chair chair             = go.AddComponent <ViveSR_Experience_Chair>();
                ViveSR_SceneUnderstanding.SceneObject obj = ViveSR_SceneUnderstanding.GetCorrespondingSceneObject(go.name);
                if (obj.objTypeID == SceneUnderstandingObjectType.NONE)
                {
                    Debug.Log("[SemanticSegmentation] Cannot find corresponding game object.");
                    return(false);
                }
                chair.CreateChair(obj.positions[0], obj.forward); //move chair
                MR_Chairs.Add(chair);
            }

            return(true);
        }
Exemplo n.º 3
0
        private IEnumerator _ExportSemanticMesh(System.Action <int> UpdatePercentage = null, System.Action done = null)
        {
            int percentage     = 0;
            int lastPercentage = 0;

            while (percentage < 100)
            {
                percentage = ViveSR_SceneUnderstanding.GetSceneUnderstandingProgress();

                // wait until saving is really processing then we disable depth
                if (lastPercentage == 0 && percentage > 0)
                {
                    ViveSR_DualCameraImageCapture.EnableDepthProcess(false);
                }
                if (UpdatePercentage != null)
                {
                    UpdatePercentage(percentage);
                }
                yield return(new WaitForEndOfFrame());
            }

            _semanticMeshIsExporting = false;
            ViveSR_RigidReconstruction.StopScanning();
            if (done != null)
            {
                done();
            }
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        public void ExportSemanticMesh(System.Action <int> UpdatePercentage = null, System.Action done = null)
        {
            _semanticMeshIsExporting = true;

            if (!ViveSR_DualCameraImageCapture.DepthProcessing)
            {
                ViveSR_DualCameraImageCapture.EnableDepthProcess(true); // in case depth has been turned off by other process
            }
            ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(ViveSR_SceneUnderstanding.SemanticObjDir);
            StartCoroutine(_ExportSemanticMesh(UpdatePercentage, done));
        }
Exemplo n.º 6
0
        void LoadSemanticMesh_done()
        {
            if (StaticMeshScript.collisionMesh)
            {
                StaticMeshScript.collisionMesh.SetActive(false);
            }

            HintText.text  = "Mesh Loaded!";
            LoadText.color = OriginalColor;
            ViveSR_SceneUnderstanding.ShowAllSemanticBoundingBoxAndIcon();
            StaticMeshScript.ShowAllSemanticCollider();
            currentShowing = 0;
            ViveSR_Experience_ControllerDelegate.gripDelegate += HandleGrip_SemanticObjOperation;
            GripCanvas.SetActive(true);
        }
        public GameObject[] LoadSemanticColliderObjs(string dirPath)
        {
            // reset
            isAllColliderReady = false;
            totalObjNumber     = loadedObjNumber = 0;
            StopAllCoroutines();

            ViveSR_SceneUnderstanding.ImportSceneObjects(dirPath); // read data from xml

            List <GameObject> outputObjs = new List <GameObject>();
            DirectoryInfo     dir        = new DirectoryInfo(dirPath);

            if (!dir.Exists)
            {
                Debug.Log(dirPath + " does not exist.");
            }
            else
            {
                string[] fileNames = ViveSR_SceneUnderstanding.GetColliderFileNames();
                totalObjNumber = fileNames.Length;
                for (int i = 0; i < fileNames.Length; i++)
                {
                    FileInfo file = new FileInfo(dirPath + "/" + fileNames[i]);
                    //Debug.Log(file.FullName);
                    if (!file.Exists)
                    {
                        Debug.Log(file.FullName + " does not exist.");
                        if (i == fileNames.Length - 1)
                        {
                            isAllColliderReady = true;
                            return(outputObjs.ToArray());
                        }
                        else
                        {
                            continue;
                        }
                    }

                    GameObject go = OBJLoader.LoadOBJFile(file.FullName, LoadColliderDoneCallBack, file.Name);
                    go.SetActive(false);
                    outputObjs.Add(go);
                }
            }
            return(outputObjs.ToArray());
        }
        //System.Action done;

        private void LoadColliderDoneCallBack(GameObject go, string semanticFileName, bool updateIsReady)
        {
            if (ViveSR_StaticColliderPool.ProcessDataAndGenColliderInfo(go) == true)
            {
                ViveSR_StaticColliderPool cldPool = go.AddComponent <ViveSR_StaticColliderPool>();
                Rigidbody rigid = go.AddComponent <Rigidbody>();
                rigid.isKinematic = true;
                rigid.useGravity  = false;

                cldPool.OrganizeHierarchy();
                cldRnds = go.GetComponentsInChildren <MeshRenderer>(true);

                ViveSR_SceneUnderstanding.SetGameObjectByFileName(semanticFileName, go.name);
            }
            if (updateIsReady && ++loadedObjNumber == totalObjNumber)
            {
                isAllColliderReady = true;
            }
        }
Exemplo n.º 9
0
        public IEnumerator _TestSegmentationResult(System.Action <int> UpdatePercentage = null, System.Action done = null)
        {
            int percentage = 0;

            ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(semanticObj_dir);

            while (percentage < 100)
            {
                percentage = ViveSR_SceneUnderstanding.GetSceneUnderstandingProgress();
                UpdatePercentage(percentage);

                yield return(new WaitForEndOfFrame());
            }

            if (done != null)
            {
                done();
            }
        }
Exemplo n.º 10
0
        private IEnumerator _ExportSemanticMesh(System.Action <int> UpdatePercentage = null, System.Action done = null)
        {
            int percentage = 0;

            while (percentage < 100)
            {
                percentage = ViveSR_SceneUnderstanding.GetSceneUnderstandingProgress();
                if (UpdatePercentage != null)
                {
                    UpdatePercentage(percentage);
                }
                yield return(new WaitForEndOfFrame());
            }

            if (done != null)
            {
                done();
            }
        }
Exemplo n.º 11
0
        void Save()
        {
            bool allowSave = ViveSR_RigidReconstruction.IsScanning &&
                             !ViveSR_RigidReconstruction.IsExportingMesh &&
                             !StaticMeshScript.SemanticMeshIsExporting;

            if (!allowSave)
            {
                return;
            }

            LoadText.color = OriginalColor;
            ScanText.color = OriginalColor;
            StopText.color = OriginalColor;
            SaveText.color = OriginalColor;

            StaticMeshScript.SetSegmentation(false);
            ViveSR_SceneUnderstanding.SetAllCustomSceneUnderstandingConfig(10, true);

            StaticMeshScript.ExportSemanticMesh(Save_UpdatePercentage, Save_done);
        }
Exemplo n.º 12
0
        void ShowNextSemanticType()
        {
            ViveSR_SceneUnderstanding.HideAllSemanticBoundingBoxAndIcon();
            StaticMeshScript.HideAllSemanticCollider();

            int type;

            type = (int)currentShowing;
            do
            {
                type = ++type % (int)SceneUnderstandingObjectType.NumOfTypes;
                if (type == (int)SceneUnderstandingObjectType.NONE)
                {
                    ViveSR_SceneUnderstanding.ShowAllSemanticBoundingBoxAndIcon();
                    break;
                }
                else
                {
                    if (ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((SceneUnderstandingObjectType)type, true, true))
                    {
                        break;
                    }
                }
            } while (!ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((SceneUnderstandingObjectType)type, true, true));

            StaticMeshScript.ShowSemanticColliderByType((SceneUnderstandingObjectType)type);
            if (type == (int)SceneUnderstandingObjectType.NONE)
            {
                StaticMeshScript.ShowAllSemanticCollider();
            }
            currentShowing = type;
            if (currentShowing == (int)SceneUnderstandingObjectType.NONE)
            {
                HintText.text = "Showing All";
            }
            else
            {
                HintText.text = "Showing " + ViveSR_SceneUnderstanding.SemanticTypeToString((SceneUnderstandingObjectType)currentShowing);
            }
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (!Application.isPlaying)
        {
            return;
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        GUIStyle style = new GUIStyle();

        style.fontStyle = FontStyle.Bold;
        GUILayout.Label(new GUIContent("[Runtime Command]"), style);
        EditorGUILayout.Separator();

        string btnStrEnableReconstructionProcess = ViveSR_RigidReconstruction.ReconstructionProcessing ? "Disable Reconstruction Processing" : "Enable Reconstruction Processing";

        if (GUILayout.Button(btnStrEnableReconstructionProcess))
        {
            ViveSR_RigidReconstruction.EnableReconstructionProcess(!ViveSR_RigidReconstruction.ReconstructionProcessing);
        }

        if (ViveSR_RigidReconstruction.ReconstructionProcessing)
        {
            GUILayout.Label(new GUIContent("[FPS Setting]"), style);
            SetReconstructionFPS = GUILayout.Toggle(SetReconstructionFPS, "Set reconstruction FPS");
            if (SetReconstructionFPS)
            {
                GUILayout.Box("Value: " + (int)Mathf.Round(ReconstructionFPS));
                float NewReconstructionFPS = GUILayout.HorizontalSlider(ReconstructionFPS, 1.0f, 60.0f);
                if (NewReconstructionFPS != ReconstructionFPS)
                {
                    SRWorkModule_API.SetReconstructionMaxFps((int)Mathf.Round(NewReconstructionFPS));
                    ReconstructionFPS = NewReconstructionFPS;
                }
            }
            // start / stop
            GUILayout.Label(new GUIContent("--Start/Stop--"), style);
            if (!ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview || ViveSR_RigidReconstruction.IsScannedMeshPreviewCompleted)
            {
                if (GUILayout.Button("Start Reconstruction"))
                {
                    ViveSR_RigidReconstruction.StartScanning();
                }
            }

            if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview)
            {
                if (GUILayout.Button("Stop Reconstruction"))
                {
                    ViveSR_RigidReconstruction.StopScanning();
                }

                // live extraction mode
                EditorGUILayout.Separator();
                GUILayout.Label(new GUIContent("--Live Extraction--"), style);
                int curMode = (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode;
                GUILayout.BeginHorizontal();
                GUILayout.Label("Display Mode:");
                curMode = EditorGUILayout.Popup(curMode, displayMode);
                GUILayout.EndHorizontal();

                bool enableSector = GUILayout.Toggle(ViveSR_RigidReconstructionRenderer.EnableSector, "Enable Sectioned Mesh");
                if (enableSector != ViveSR_RigidReconstructionRenderer.EnableSector)
                {
                    ViveSR_RigidReconstructionRenderer.EnableSector = enableSector;
                }

                int sectorGroupNum = EditorGUILayout.IntSlider("Sectioned Mesh Limit", ViveSR_RigidReconstructionRenderer.MaxActiveGO, 50, 500);
                if (sectorGroupNum != ViveSR_RigidReconstructionRenderer.MaxActiveGO)
                {
                    ViveSR_RigidReconstructionRenderer.MaxActiveGO = sectorGroupNum;
                }

                if (curMode != (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode)
                {
                    ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode = (ReconstructionDisplayMode)curMode;
                }
                // adaptive tunning
                if (curMode == (int)ReconstructionDisplayMode.ADAPTIVE_MESH)
                {
                    EditorGUILayout.Separator();
                    GUILayout.Label(new GUIContent("--Live Adaptive Mesh Tuning--"), style);
                    DrawAdaptiveParamUI(ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres);
                    ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize = adaptiveLevel[maxSelectID];
                    ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize = adaptiveLevel[minSelectID];
                    ViveSR_RigidReconstruction.LiveAdaptiveErrorThres  = errorThres;
                }
            }

            // export
            EditorGUILayout.Separator();
            if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview)
            {
                GUILayout.Label(new GUIContent("--Export--"), style);
                bool exportAdaptive = ViveSR_RigidReconstruction.ExportAdaptiveMesh;
                ViveSR_RigidReconstruction.ExportAdaptiveMesh = GUILayout.Toggle(exportAdaptive, "Export Adaptive Model");

                if (ViveSR_RigidReconstruction.ExportAdaptiveMesh)
                {
                    // live extraction mode
                    EditorGUILayout.Separator();
                    GUILayout.Label(new GUIContent("--Export Adaptive Mesh Tuning--"), style);
                    DrawAdaptiveParamUI(ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize, ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize, ViveSR_RigidReconstruction.ExportAdaptiveErrorThres);
                    ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize = adaptiveLevel[maxSelectID];
                    ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize = adaptiveLevel[minSelectID];
                    ViveSR_RigidReconstruction.ExportAdaptiveErrorThres  = errorThres;
                }

                // only support adaptive mesh now
                if (GUILayout.Button("Preview Scanned Model"))
                {
                    ViveSR_RigidReconstruction.ExtractModelPreviewData();
                }
            }
            if (!ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview && (ViveSR_RigidReconstruction.IsScanning != ViveSR_RigidReconstruction.IsScannedMeshPreviewCompleted))
            {
                if (GUILayout.Button("Start Export Model"))
                {
                    ViveSR_RigidReconstruction.StopScanning();
                    ViveSR_RigidReconstruction.ExportModel("Model");
                }
            }

            // Scene Understanding
            // output surrounding objects of interest and their attributes
            #region Scene Understanding
            EditorGUILayout.Separator();

            GUILayout.Label(new GUIContent("--Scene Understanding--"), style);
            if (ViveSR_RigidReconstruction.IsScanning)
            {
                bool isSemanticEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding, "Enable Scene Understanding");
                if (isSemanticEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding)
                {
                    ViveSR_SceneUnderstanding.EnableSceneUnderstanding(isSemanticEnabled);
                }
            }
            if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning)
            {
                bool isSemanticRefinementEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement, "Enable Scene Understanding Refinement");
                if (isSemanticRefinementEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement)
                {
                    ViveSR_SceneUnderstanding.EnableSceneUnderstandingRefinement(isSemanticRefinementEnabled);
                }
                bool isSemanticPreviewEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView, "Enable Preview");
                if (isSemanticPreviewEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView)
                {
                    ViveSR_SceneUnderstanding.EnableSceneUnderstandingView(isSemanticPreviewEnabled);
                }
                int index = 0;
                foreach (bool toggle in SceneObjectToggle)
                {
                    bool _toggle = GUILayout.Toggle(toggle, "View/Export " + SceneObjectName[index] + " (" + ObjectColor[index] + ")");
                    if (_toggle != toggle)
                    {
                        SceneObjectToggle[index] = _toggle;
                        switch (SceneObjectName[index])
                        {
                        case "Bed":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.BED, 10, _toggle);
                            break;

                        case "Ceiling":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CEILING, 10, _toggle);
                            break;

                        case "Chair":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CHAIR, 10, _toggle);
                            break;

                        case "Floor":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.FLOOR, 10, _toggle);
                            break;

                        case "Table":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.TABLE, 10, _toggle);
                            break;

                        case "Wall":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.WALL, 10, _toggle);
                            break;

                        case "Window":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.WINDOW, 10, _toggle);
                            break;

                        case "Monitor":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.MONITOR, 10, _toggle);
                            break;

                        case "Furniture":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.FURNITURE, 10, _toggle);
                            break;

                        case "Door":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.DOOR, 10, _toggle);
                            break;

                        case "Picture":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PICTURE, 10, _toggle);
                            break;

                        case "Person":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PERSON, 10, _toggle);
                            break;
                        }
                    }
                    index++;
                }
            }
            if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning)
            {
                if (GUILayout.Button("Export SceneObjects (.xml)"))
                {
                    ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(SemanticObjDir);
                }
            }
            if (GUILayout.Button("Load & Show SceneObjects BoundingBox"))
            {
                ViveSR_SceneUnderstanding.ImportSceneObjects(ReconstructionResultDir + ReconsSceneDir + SemanticObjDir);

                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CHAIR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CEILING, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.FLOOR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.WALL, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.BED, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.TABLE, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.MONITOR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.WINDOW, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.FURNITURE, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.DOOR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PICTURE, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PERSON, true, false);
            }

            if (GUILayout.Button("Destroy All SceneObjects BoundingBox"))
            {
                ViveSR_SceneUnderstanding.DestroySceneObjects();
            }
        }
        #endregion
    }
Exemplo n.º 14
0
 public void SetChairSegmentationConfig(bool isOn)
 {
     #region Set SceneUnderstandingConfig for Chair
     ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.CHAIR, 5, isOn);
     #endregion
 }
Exemplo n.º 15
0
        //public void SetColliderForNavigation(List<ViveSR_Experience_Chair> Chairs, System.Action done)
        //{
        //    cldPool = collisionMesh.GetComponent<ViveSR_StaticColliderPool>();
        //    if (cldPool == null) WaitForCldPool(() => _SetColliderForNavigation(Chairs, done));
        //    else _SetColliderForNavigation(Chairs, done);
        //}
        //public void _SetColliderForNavigation(List<ViveSR_Experience_Chair> Chairs, System.Action done)
        //{
        //    Debug.Log("SetColliderForNavigation");
        //    ViveSR_StaticColliderInfo[] clds = cldPool.GetColliderByHeightRange(ColliderShapeType.MESH_SHAPE, 0.3f, 0.8f);
        //    foreach (ViveSR_StaticColliderInfo cld in clds)
        //    {
        //        if (cld.ApproxArea < 0.01f) continue;

        //        bool createObstacle = true;

        //        Vector3 cld_center = cld.transform.TransformPoint(cld.GetComponent<MeshFilter>().mesh.bounds.center);

        //        foreach (ViveSR_Experience_Chair chair in Chairs)
        //        {
        //            float dist = Vector3.Distance(cld_center, chair.transform.position);
        //            Vector3 dir = (cld_center - chair.transform.position) / dist;

        //            if (dist < 1f || (dist < 1.5f && Vector3.Angle(chair.transform.forward, dir) < 60f))
        //                createObstacle = false;
        //        }

        //        if (!createObstacle) continue;

        //        NavMeshObstacle obstacle;

        //        if (!cld.gameObject.GetComponent<NavMeshObstacle>())
        //        {
        //            obstacle = cld.gameObject.AddComponent<NavMeshObstacle>();
        //            obstacle.carving = true;
        //        }

        //        cld.GetComponent<MeshRenderer>().enabled = true;
        //    }
        //    if (done != null) done();
        //}

        public void SetSegmentation(bool isOn)
        {
            ViveSR_SceneUnderstanding.EnableSceneUnderstanding(isOn);
        }
Exemplo n.º 16
0
 public void ExportSemanticMesh(System.Action <int> UpdatePercentage = null, System.Action done = null)
 {
     ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(ViveSR_SceneUnderstanding.SemanticObjDir);
     StartCoroutine(_ExportSemanticMesh(UpdatePercentage, done));
 }
Exemplo n.º 17
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;
                }
            }
        }
Exemplo n.º 18
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (!Application.isPlaying)
        {
            return;
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        GUIStyle style = new GUIStyle();

        style.fontStyle = FontStyle.Bold;
        GUILayout.Label(new GUIContent("[Runtime Command]"), style);
        EditorGUILayout.Separator();

        // start / stop
        GUILayout.Label(new GUIContent("--Start/Stop--"), style);
        if (!ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh)
        {
            if (GUILayout.Button("Start Reconstruction"))
            {
                ViveSR_RigidReconstruction.StartScanning();
            }
        }
        if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh)
        {
            if (GUILayout.Button("Stop Reconstruction"))
            {
                ViveSR_RigidReconstruction.StopScanning();
            }

            // live extraction mode
            EditorGUILayout.Separator();
            GUILayout.Label(new GUIContent("--Live Extraction--"), style);
            int curMode = (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Display Mode:");
            curMode = EditorGUILayout.Popup(curMode, displayMode);
            GUILayout.EndHorizontal();

            bool enableSector = GUILayout.Toggle(ViveSR_RigidReconstructionRenderer.EnableSector, "Enable Sectioned Mesh");
            if (enableSector != ViveSR_RigidReconstructionRenderer.EnableSector)
            {
                ViveSR_RigidReconstructionRenderer.EnableSector = enableSector;
            }

            int sectorGroupNum = EditorGUILayout.IntSlider("Sectioned Mesh Limit", ViveSR_RigidReconstructionRenderer.MaxActiveGO, 50, 500);
            if (sectorGroupNum != ViveSR_RigidReconstructionRenderer.MaxActiveGO)
            {
                ViveSR_RigidReconstructionRenderer.MaxActiveGO = sectorGroupNum;
            }

            if (curMode != (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode)
            {
                ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode = (ReconstructionDisplayMode)curMode;
            }
            // adaptive tunning
            if (curMode == (int)ReconstructionDisplayMode.ADAPTIVE_MESH)
            {
                EditorGUILayout.Separator();
                GUILayout.Label(new GUIContent("--Live Adaptive Mesh Tuning--"), style);
                DrawAdaptiveParamUI(ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres);
                ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize = adaptiveLevel[maxSelectID];
                ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize = adaptiveLevel[minSelectID];
                ViveSR_RigidReconstruction.LiveAdaptiveErrorThres  = errorThres;
            }
        }

        // export
        EditorGUILayout.Separator();
        if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh)
        {
            GUILayout.Label(new GUIContent("--Export--"), style);
            bool exportAdaptive = ViveSR_RigidReconstruction.ExportAdaptiveMesh;
            ViveSR_RigidReconstruction.ExportAdaptiveMesh = GUILayout.Toggle(exportAdaptive, "Export Adaptive Model");

            if (ViveSR_RigidReconstruction.ExportAdaptiveMesh)
            {
                // live extraction mode
                EditorGUILayout.Separator();
                GUILayout.Label(new GUIContent("--Export Adaptive Mesh Tuning--"), style);
                DrawAdaptiveParamUI(ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize, ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize, ViveSR_RigidReconstruction.ExportAdaptiveErrorThres);
                ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize = adaptiveLevel[maxSelectID];
                ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize = adaptiveLevel[minSelectID];
                ViveSR_RigidReconstruction.ExportAdaptiveErrorThres  = errorThres;
            }

            if (GUILayout.Button("Start Export Model"))
            {
                ViveSR_RigidReconstruction.ExportModel("Model");
            }
        }

        // Scene Understanding
        // output surrounding objects of interest and their attributes
        EditorGUILayout.Separator();

        GUILayout.Label(new GUIContent("--Scene Understanding--"), style);
        if (ViveSR_RigidReconstruction.IsScanning)
        {
            bool isSemanticEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding, "Enable Scene Understanding");
            if (isSemanticEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding)
            {
                ViveSR_SceneUnderstanding.EnableSceneUnderstanding(isSemanticEnabled);
            }
        }
        if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning)
        {
            bool isSemanticRefinementEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement, "Enable Scene Understanding Refinement");
            if (isSemanticRefinementEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement)
            {
                ViveSR_SceneUnderstanding.EnableSceneUnderstandingRefinement(isSemanticRefinementEnabled);
            }
            bool isSemanticPreviewEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView, "Enable Preview");
            if (isSemanticPreviewEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView)
            {
                ViveSR_SceneUnderstanding.EnableSceneUnderstandingView(isSemanticPreviewEnabled);
            }
            int index = 0;
            foreach (bool toggle in SceneObjectToggle)
            {
                bool _toggle = GUILayout.Toggle(toggle, "View/Export " + SceneObjectName[index]);
                if (_toggle != toggle)
                {
                    SceneObjectToggle[index] = _toggle;
                    switch (SceneObjectName[index])
                    {
                    case "Bed":
                        ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.BED, 5, _toggle);
                        break;

                    case "Ceiling":
                        ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.CEILING, 5, _toggle);
                        break;

                    case "Chair":
                        ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.CHAIR, 5, _toggle);
                        break;

                    case "Floor":
                        ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.FLOOR, 5, _toggle);
                        break;

                    case "Table":
                        ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.TABLE, 5, _toggle);
                        break;

                    case "Wall":
                        ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.WALL, 5, _toggle);
                        break;
                    }
                }
                index++;
            }
        }
        if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning)
        {
            if (GUILayout.Button("Export SceneObjects (.xml)"))
            {
                ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(SemanticObjDir);
            }
        }

        if (GUILayout.Button("Load & Show SceneObjects BoundingBox"))
        {
            ViveSR_SceneUnderstanding.ImportSceneObjects(ReconsSceneDir + SemanticObjDir);
            //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.CHAIR);
            //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.CEILING);
            //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.FLOOR);
            //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.WALL);
            //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.BED);
            //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.TABLE);
            ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.CHAIR, true, false);
            ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.CEILING, true, false);
            ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.FLOOR, true, false);
            ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.WALL, true, false);
            ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.BED, true, false);
            ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.TABLE, true, false);

            //ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxWithId((int)SceneUnderstandingObjectType.CHAIR, 0, false, true);
        }
    }
Exemplo n.º 19
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (!Application.isPlaying)
        {
            return;
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        GUIStyle style = new GUIStyle();

        style.fontStyle = FontStyle.Bold;
        GUILayout.Label(new GUIContent("[Runtime Command]"), style);
        EditorGUILayout.Separator();

        string btn_str_enable_reconstruction_process = ViveSR_RigidReconstruction.ReconstructionProcessing ? "Disable Reconstruction Processing" : "Enable Reconstruction Processing";

        if (GUILayout.Button(btn_str_enable_reconstruction_process))
        {
            ViveSR_RigidReconstruction.EnableReconstructionProcess(!ViveSR_RigidReconstruction.ReconstructionProcessing);
        }

        if (ViveSR_RigidReconstruction.ReconstructionProcessing)
        {
            GUILayout.Label(new GUIContent("[FPS Setting]"), style);
            set_reconstruction_fps = GUILayout.Toggle(set_reconstruction_fps, "Set Reconstruction FPS");
            if (set_reconstruction_fps)
            {
                GUILayout.Box("Value: " + (int)Mathf.Round(reconstruction_fps));
                float NewReconstructionFPS = GUILayout.HorizontalSlider(reconstruction_fps, 1.0f, 60.0f);
                if (NewReconstructionFPS != reconstruction_fps)
                {
                    SRWorkModule_API.SetReconstructionMaxFps((int)Mathf.Round(NewReconstructionFPS));
                    reconstruction_fps = NewReconstructionFPS;
                }
            }

            // Quality setting
            if (!ViveSR_RigidReconstruction.IsScanning)
            {
                set_voxel_size = GUILayout.Toggle(set_voxel_size, "Set Voxel Size");
                if (set_voxel_size)
                {
                    selectQuality = EditorGUILayout.Popup(selectQuality, qualityList);
                    ViveSR_RigidReconstruction.SetReconstructionUpdateQuality(selectQuality);

                    geometrySize = ViveSR_RigidReconstruction.GetReconstructionGeometrySize();
                    GUILayout.Label("Geometry resolution: " + geometrySize * 100 + " cm");
                    float NewGeometrySize = GUILayout.HorizontalSlider(geometrySize, 0.005f, 0.16f);
                    ViveSR_RigidReconstruction.SetReconstructionGeometrySize(NewGeometrySize);

                    colorSize = ViveSR_RigidReconstruction.GetReconstructionColorSize();
                    GUILayout.Label("Color resolution: " + colorSize * 100 + " cm");
                    float NewColorSize = GUILayout.HorizontalSlider(colorSize, 0.005f, 0.16f);
                    ViveSR_RigidReconstruction.SetReconstructionColorSize(NewColorSize);
                }
            }

            // start / stop
            GUILayout.Label(new GUIContent("--Start/Stop--"), style);
            if (!ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExporting && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview || ViveSR_RigidReconstruction.IsScannedMeshPreviewCompleted)
            {
                if (GUILayout.Button("Start Reconstruction"))
                {
                    ViveSR_RigidReconstruction.StartScanning();
                }
            }

            if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExporting && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview)
            {
                if (GUILayout.Button("Stop Reconstruction"))
                {
                    ViveSR_RigidReconstruction.StopScanning();
                }

                // live extraction mode
                EditorGUILayout.Separator();
                GUILayout.Label(new GUIContent("--Live Extraction--"), style);
                int cur_mode = (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode;
                GUILayout.BeginHorizontal();
                GUILayout.Label("Display Mode:");
                cur_mode = EditorGUILayout.Popup(cur_mode, display_mode);
                GUILayout.EndHorizontal();

                bool enableSector = GUILayout.Toggle(ViveSR_RigidReconstructionRenderer.EnableSector, "Enable Sectioned Mesh");
                if (enableSector != ViveSR_RigidReconstructionRenderer.EnableSector)
                {
                    ViveSR_RigidReconstructionRenderer.EnableSector = enableSector;
                }

                int sectorGroupNum = EditorGUILayout.IntSlider("Sectioned Mesh Limit", ViveSR_RigidReconstructionRenderer.MaxActiveGO, 50, 500);
                if (sectorGroupNum != ViveSR_RigidReconstructionRenderer.MaxActiveGO)
                {
                    ViveSR_RigidReconstructionRenderer.MaxActiveGO = sectorGroupNum;
                }

                if (cur_mode != (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode)
                {
                    ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode = (ReconstructionDisplayMode)cur_mode;
                }
                // adaptive tunning
                if (cur_mode == (int)ReconstructionDisplayMode.ADAPTIVE_MESH)
                {
                    EditorGUILayout.Separator();
                    GUILayout.Label(new GUIContent("--Live Adaptive Mesh Tuning--"), style);
                    DrawAdaptiveParamUI(ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres);
                    ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize = adaptive_level[max_select_id];
                    ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize = adaptive_level[min_select_id];
                    ViveSR_RigidReconstruction.LiveAdaptiveErrorThres  = error_thres;
                }
            }

            // export
            EditorGUILayout.Separator();
            if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExporting && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview)
            {
                GUILayout.Label(new GUIContent("--Export--"), style);
                bool export_adaptive = ViveSR_RigidReconstruction.ExportAdaptiveMesh;
                ViveSR_RigidReconstruction.ExportAdaptiveMesh = GUILayout.Toggle(export_adaptive, "Export Adaptive Model");

                if (ViveSR_RigidReconstruction.ExportAdaptiveMesh)
                {
                    // live extraction mode
                    EditorGUILayout.Separator();
                    GUILayout.Label(new GUIContent("--Export Adaptive Mesh Tuning--"), style);
                    DrawAdaptiveParamUI(ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize, ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize, ViveSR_RigidReconstruction.ExportAdaptiveErrorThres);
                    ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize = adaptive_level[max_select_id];
                    ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize = adaptive_level[min_select_id];
                    ViveSR_RigidReconstruction.ExportAdaptiveErrorThres  = error_thres;
                }

                // only support adaptive mesh now
                if (GUILayout.Button("Preview Scanned Model"))
                {
                    ViveSR_RigidReconstruction.ExtractModelPreviewData();
                }
            }
            if (!ViveSR_RigidReconstruction.IsExporting && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview && (ViveSR_RigidReconstruction.IsScanning != ViveSR_RigidReconstruction.IsScannedMeshPreviewCompleted))
            {
                if (GUILayout.Button("Start Export Model"))
                {
                    ViveSR_RigidReconstruction.StopScanning();
                    ViveSR_RigidReconstruction.StartExporting("Model");
                }
            }

            // Scene Understanding
            // output surrounding objects of interest and their attributes
            #region Scene Understanding
            EditorGUILayout.Separator();

            GUILayout.Label(new GUIContent("--Scene Understanding--"), style);
            if (ViveSR_RigidReconstruction.IsScanning)
            {
                bool isSemanticEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding, "Enable Scene Understanding");
                if (isSemanticEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding)
                {
                    ViveSR_SceneUnderstanding.EnableSceneUnderstanding(isSemanticEnabled, false);
                }
            }
            if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning)
            {
                bool isSemanticRefinementEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement, "Enable Scene Understanding Refinement");
                if (isSemanticRefinementEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement)
                {
                    ViveSR_SceneUnderstanding.EnableSceneUnderstandingRefinement(isSemanticRefinementEnabled);
                }
                bool isSemanticPreviewEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView, "Enable Preview");
                if (isSemanticPreviewEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView)
                {
                    ViveSR_SceneUnderstanding.EnableSceneUnderstandingView(isSemanticPreviewEnabled);
                }
                int index = 0;
                foreach (bool toggle in scene_object_toggle)
                {
                    bool _toggle = GUILayout.Toggle(toggle, "View/Export " + scene_object_name[index] + " (" + object_color[index] + ")");
                    if (_toggle != toggle)
                    {
                        scene_object_toggle[index] = _toggle;
                        switch (scene_object_name[index])
                        {
                        case "Bed":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.BED, 10, _toggle);
                            break;

                        case "Ceiling":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CEILING, 10, _toggle);
                            break;

                        case "Chair":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CHAIR, 10, _toggle);
                            break;

                        case "Floor":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.FLOOR, 10, _toggle);
                            break;

                        case "Table":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.TABLE, 10, _toggle);
                            break;

                        case "Wall":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.WALL, 10, _toggle);
                            break;

                        case "Window":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.WINDOW, 10, _toggle);
                            break;

                        case "Monitor":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.MONITOR, 10, _toggle);
                            break;

                        case "Furniture":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.FURNITURE, 10, _toggle);
                            break;

                        case "Door":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.DOOR, 10, _toggle);
                            break;

                        case "Picture":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PICTURE, 10, _toggle);
                            break;

                        case "Person":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PERSON, 10, _toggle);
                            break;

                        case "Light":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.LIGHT, 10, _toggle);
                            break;

                        case "Plant":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PLANT, 10, _toggle);
                            break;

                        case "Curtain":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CURTAIN, 10, _toggle);
                            break;

                        case "Pillow":
                            ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PILLOW, 10, _toggle);
                            break;
                        }
                    }
                    index++;
                }
            }
            if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning)
            {
                if (GUILayout.Button("Export SceneObjects (.xml)"))
                {
                    ViveSR_SceneUnderstanding.StartExporting(semantic_obj_dir);
                }
            }
            if (GUILayout.Button("Load & Show SceneObjects BoundingBox"))
            {
                ViveSR_SceneUnderstanding.ImportSceneObjects(reconstruction_result_dir + recons_scene_dir + semantic_obj_dir);

                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CHAIR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CEILING, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.FLOOR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.WALL, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.BED, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.TABLE, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.MONITOR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.WINDOW, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.FURNITURE, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.DOOR, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PICTURE, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PERSON, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.LIGHT, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PLANT, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CURTAIN, true, false);
                ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PILLOW, true, false);
            }

            if (GUILayout.Button("Destroy All SceneObjects BoundingBox"))
            {
                ViveSR_SceneUnderstanding.DestroySceneObjects();
            }
        }
        #endregion
        if (ViveSR_RigidReconstruction.IsExporting || ViveSR_SceneUnderstanding.IsExportingSceneUnderstandingInfo)
        {
            if (ViveSR_RigidReconstruction.IsExporting)
            {
                GUILayout.Label(new GUIContent("Exporting reconstruction model..."), style);
            }
            if (ViveSR_SceneUnderstanding.IsExportingSceneUnderstandingInfo)
            {
                GUILayout.Label(new GUIContent("Exporting scene understanding model..."), style);
            }
            if (GUILayout.Button("Stop Export All Model"))
            {
                ViveSR_RigidReconstruction.TerminateExporting();
                ViveSR_RigidReconstruction.ResetReconstructionModule();
            }
        }
    }
Exemplo n.º 20
0
 private void Update()
 {
     ViveSR_SceneUnderstanding.SetIconLookAtPlayer(ViveSR_Experience.instance.PlayerHeadCollision.transform);
 }