private void Start() { GlobalScript globals = GameObject.Find("Globals").GetComponent <GlobalScript>(); resolution_preset = globals.resolution_preset; range_preset = globals.range_preset; isFilteringEnable = globals.isFilteringEnable; isTextured = globals.isTextured; manager = GameObject.FindObjectOfType(typeof(ZEDManager)) as ZEDManager; spatialMapping = new ZEDSpatialMapping(transform, sl.ZEDCamera.GetInstance(), manager); }
public void SetResolution(int val) { switch (val) { case 0: resolution_preset = ZEDSpatialMapping.RESOLUTION.LOW; break; case 1: resolution_preset = ZEDSpatialMapping.RESOLUTION.MEDIUM; break; case 2: resolution_preset = ZEDSpatialMapping.RESOLUTION.HIGH; break; } }
public override void OnInspectorGUI() { bool cameraIsReady = sl.ZEDCamera.GetInstance().IsCameraReady; displayText = ZEDSpatialMapping.display ? "Hide Mesh" : "Display Mesh"; serializedObject.Update(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Mesh Parameters", EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); ZEDSpatialMapping.RESOLUTION newResolution = (ZEDSpatialMapping.RESOLUTION)EditorGUILayout.EnumPopup("Resolution", spatialMapping.resolution_preset); if (newResolution != spatialMapping.resolution_preset) { resolution.enumValueIndex = (int)newResolution; serializedObject.ApplyModifiedProperties(); } ZEDSpatialMapping.RANGE newRange = (ZEDSpatialMapping.RANGE)EditorGUILayout.EnumPopup("Range", spatialMapping.range_preset); if (newRange != spatialMapping.range_preset) { range.enumValueIndex = (int)newRange; serializedObject.ApplyModifiedProperties(); } EditorGUILayout.BeginHorizontal(); filterParameters.enumValueIndex = (int)(sl.FILTER)EditorGUILayout.EnumPopup("Mesh Filtering", (sl.FILTER)filterParameters.enumValueIndex); isFilteringEnable.boolValue = true; EditorGUILayout.EndHorizontal(); GUI.enabled = !spatialMapping.IsRunning; isTextured.boolValue = EditorGUILayout.Toggle("Texturing", isTextured.boolValue); GUI.enabled = cameraIsReady; EditorGUILayout.BeginHorizontal(); if (!spatialMapping.IsRunning) { if (GUILayout.Button("Start Spatial Mapping")) { if (!ZEDSpatialMapping.display) { spatialMapping.SwitchDisplayMeshState(true); } spatialMapping.StartSpatialMapping(); } } else { if (spatialMapping.IsRunning && !spatialMapping.IsUpdateThreadRunning || spatialMapping.IsRunning && spatialMapping.IsTexturingRunning) { GUILayout.FlexibleSpace(); GUILayout.Label("Spatial mapping is finishing"); Repaint(); GUILayout.FlexibleSpace(); } else { if (GUILayout.Button("Stop Spatial Mapping")) { spatialMapping.StopSpatialMapping(); } } } EditorGUILayout.EndHorizontal(); GUI.enabled = cameraIsReady; if (GUILayout.Button(displayText)) { spatialMapping.SwitchDisplayMeshState(!ZEDSpatialMapping.display); } GUI.enabled = true; GUILayout.Label("Mesh Storage", EditorStyles.boldLabel); saveWhenOver.boolValue = EditorGUILayout.Toggle("Save Mesh (when stop)", saveWhenOver.boolValue); EditorGUILayout.BeginHorizontal(); meshPath.stringValue = EditorGUILayout.TextField("Mesh Path", meshPath.stringValue); if (GUILayout.Button("...", optionsButtonBrowse)) { meshPath.stringValue = EditorUtility.OpenFilePanel("Mesh file", "", "ply,obj,bin"); serializedObject.ApplyModifiedProperties(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); //GUI.enabled = cameraIsReady; GUILayout.FlexibleSpace(); GUI.enabled = System.IO.File.Exists(meshPath.stringValue) && cameraIsReady; if (GUILayout.Button("Load")) { spatialMapping.LoadMesh(meshPath.stringValue); } EditorGUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); if (!cameraIsReady) { Repaint(); } }
public override void OnInspectorGUI() { bool cameraIsReady = sl.ZEDCamera.GetInstance().IsCameraReady; displayText = ZEDSpatialMapping.display ? "Hide Mesh" : "Display Mesh"; serializedObject.Update(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Mesh Parameters", EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUIContent resolutionlabel = new GUIContent("Resolution", "Resolution setting for the scan. " + "A higher resolution creates more submeshes and uses more memory, but is more accurate."); ZEDSpatialMapping.RESOLUTION newResolution = (ZEDSpatialMapping.RESOLUTION)EditorGUILayout.EnumPopup(resolutionlabel, spatialMapping.resolution_preset); if (newResolution != spatialMapping.resolution_preset) { resolution.enumValueIndex = (int)newResolution; serializedObject.ApplyModifiedProperties(); } GUIContent rangelabel = new GUIContent("Range", "Maximum distance geometry can be from the camera to be scanned. " + "Geometry scanned from farther away will be less accurate."); ZEDSpatialMapping.RANGE newRange = (ZEDSpatialMapping.RANGE)EditorGUILayout.EnumPopup(rangelabel, spatialMapping.range_preset); if (newRange != spatialMapping.range_preset) { range.enumValueIndex = (int)newRange; serializedObject.ApplyModifiedProperties(); } EditorGUILayout.BeginHorizontal(); GUIContent filteringlabel = new GUIContent("Mesh Filtering", "Whether mesh filtering is needed."); filterParameters.enumValueIndex = (int)(sl.FILTER)EditorGUILayout.EnumPopup(filteringlabel, (sl.FILTER)filterParameters.enumValueIndex); isFilteringEnable.boolValue = true; EditorGUILayout.EndHorizontal(); GUI.enabled = !spatialMapping.IsRunning; //Don't allow changing the texturing setting while the scan is running. GUIContent texturedlabel = new GUIContent("Texturing", "Whether surface textures will be scanned and applied. " + "Note that texturing will add further delay to the post-scan finalizing period."); isTextured.boolValue = EditorGUILayout.Toggle(texturedlabel, isTextured.boolValue); GUI.enabled = cameraIsReady; //Gray out below elements if the ZED hasn't been initialized as you can't yet start a scan. EditorGUILayout.BeginHorizontal(); if (!spatialMapping.IsRunning) { GUIContent startmappinglabel = new GUIContent("Start Spatial Mapping", "Begin the spatial mapping process."); if (GUILayout.Button(startmappinglabel)) { if (!ZEDSpatialMapping.display) { spatialMapping.SwitchDisplayMeshState(true); } spatialMapping.StartSpatialMapping(); } } else { if (spatialMapping.IsRunning && !spatialMapping.IsUpdateThreadRunning || spatialMapping.IsRunning && spatialMapping.IsTexturingRunning) { GUILayout.FlexibleSpace(); GUIContent finishinglabel = new GUIContent("Spatial mapping is finishing", "Please wait - the mesh is being processed."); GUILayout.Label(finishinglabel); Repaint(); GUILayout.FlexibleSpace(); } else { GUIContent stopmappinglabel = new GUIContent("Stop Spatial Mapping", "Ends spatial mapping and begins processing the final mesh."); if (GUILayout.Button(stopmappinglabel)) { spatialMapping.StopSpatialMapping(); } } } EditorGUILayout.EndHorizontal(); GUI.enabled = cameraIsReady; string displaytooltip = ZEDSpatialMapping.display ? "Hide the mesh from view." : "Display the hidden mesh."; GUIContent displaylabel = new GUIContent(displayText, displaytooltip); if (GUILayout.Button(displayText)) { spatialMapping.SwitchDisplayMeshState(!ZEDSpatialMapping.display); } GUI.enabled = true; GUILayout.Label("Mesh Storage", EditorStyles.boldLabel); GUIContent savelabel = new GUIContent("Save Mesh (when finished)", "Whether to save the mesh and .area file when finished scanning."); saveWhenOver.boolValue = EditorGUILayout.Toggle(savelabel, saveWhenOver.boolValue); EditorGUILayout.BeginHorizontal(); GUIContent pathlabel = new GUIContent("Mesh Path", "Path where the mesh is saved/loaded from. Valid file types are .obj, .ply and .bin."); meshPath.stringValue = EditorGUILayout.TextField(pathlabel, meshPath.stringValue); GUIContent findfilelabel = new GUIContent("...", "Browse for an existing .obj, .ply or .bin file."); if (GUILayout.Button(findfilelabel, optionsButtonBrowse)) { meshPath.stringValue = EditorUtility.OpenFilePanel("Mesh file", "", "ply,obj,bin"); serializedObject.ApplyModifiedProperties(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = System.IO.File.Exists(meshPath.stringValue) && cameraIsReady; GUIContent loadlabel = new GUIContent("Load", "Load an existing mesh and .area file into the scene."); if (GUILayout.Button(loadlabel)) { spatialMapping.LoadMesh(meshPath.stringValue); } EditorGUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); if (!cameraIsReady) { Repaint(); } }