/// <summary> /// Enables the user to convert the .PLY mesh file to .OBJ via Blender. /// </summary> public void SubsectionConvertPLYtoOBJ() { EditorGUILayout.Space(); string inputFilePath = Path.Combine(_meshWorkspace, COLMAPConnector.delaunayFileName); string outputFilePath = Path.Combine(_meshWorkspace, BlenderConnector.convertPLYtoOBJOutputFileName); string label = "Convert .PLY mesh to .OBJ file."; string tooltip = "File " + GeneralToolkit.FormatPathForCommand(inputFilePath) + " will be converted to file " + GeneralToolkit.FormatPathForCommand(outputFilePath) + "."; // Check if this option is available. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && File.Exists(inputFilePath) && Application.isPlaying; GeneralToolkit.EditorRequirePlayMode(ref tooltip); // Display a button to launch the helper method. bool hasPressed = GeneralToolkit.EditorWordWrapLeftButton(new GUIContent("Run", tooltip), new GUIContent(label, tooltip)); if (hasPressed) { StartCoroutine(BlenderConnector.RunConvertPLYtoOBJCoroutine(processingCaller, inputFilePath, outputFilePath, ReadMeshFaceCount)); } // Reset the GUI. GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
/// <summary> /// Enables the user to UV-map the given .OBJ mesh using Blender's Smart UV Project algorithm. /// </summary> public void SubsectionSmartUVProjectOBJ() { EditorGUILayout.Space(); string inputFilePath = Path.Combine(_meshWorkspace, BlenderConnector.convertPLYtoOBJOutputFileName); string outputFilePath = inputFilePath; string label = "UV-map .OBJ file."; string tooltip = "Mesh in file " + GeneralToolkit.FormatPathForCommand(inputFilePath) + " will be UV-mapped using Blender's Smart UV Project algorithm."; // Check if this option is available. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && File.Exists(inputFilePath) && Application.isPlaying; GeneralToolkit.EditorRequirePlayMode(ref tooltip); // Display a button to launch the helper method. bool hasPressed = GeneralToolkit.EditorWordWrapLeftButton(new GUIContent("Run", tooltip), new GUIContent(label, tooltip)); if (hasPressed) { StartCoroutine(BlenderConnector.RunSmartUVProjectOBJCoroutine(this, inputFilePath, outputFilePath)); } // Reset the GUI. GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
/// <summary> /// Enables the user to simplify the .OBJ mesh via Blender. /// </summary> /// <param name="serializedObject"></param> The serialized object to modify. public void SubsectionSimplifyOBJ(SerializedObject serializedObject) { EditorGUILayout.Space(); string inputFilePath = Path.Combine(_meshWorkspace, BlenderConnector.convertPLYtoOBJOutputFileName); string outputFilePath = inputFilePath; string label = "Simplify .OBJ mesh."; string tooltip = "Mesh in file " + GeneralToolkit.FormatPathForCommand(inputFilePath) + " will be simplified, reducing its face count."; // Check if this option is available. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && File.Exists(inputFilePath) && Application.isPlaying; GeneralToolkit.EditorRequirePlayMode(ref tooltip); // Display a button to launch the helper method. bool hasPressed = GeneralToolkit.EditorWordWrapLeftButton(new GUIContent("Run", tooltip), new GUIContent(label, tooltip)); // If the button is pressed, launch the method. if (hasPressed) { StartCoroutine(BlenderConnector.RunSimplifyOBJCoroutine(this, inputFilePath, outputFilePath, ReadMeshFaceCount)); } // Reset the GUI. GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
/// <summary> /// Checks the number of faces on the current .OBJ mesh. /// </summary> /// <param name="workspace"></param> The workspace from which to perform this method. public void CheckOBJMeshInfo(string workspace) { string inputFilePath = Path.Combine(workspace, BlenderConnector.convertPLYtoOBJOutputFileName); StartCoroutine(BlenderConnector.RunCheckOBJMeshInfoCoroutine(this, inputFilePath, ReadMeshFaceCount)); }