private bool DoExport() { BabylonExporter babylonExporter = new BabylonExporter(); // Display logs to console // TODO - Display logs to custom frame with ranks babylonExporter.OnWarning += (warning, rank) => { MGlobal.displayInfo("[WARNING] " + warning); }; babylonExporter.OnError += (error, rank) => { MGlobal.displayInfo("[ERROR] " + error); }; babylonExporter.OnMessage += (message, color, rank, emphasis) => { MGlobal.displayInfo("[MESSAGE] " + message); }; // For debug purpose babylonExporter.OnVerbose += (message, color, rank, emphasis) => { MGlobal.displayInfo("[VERBOSE] " + message); }; babylonExporter.OnExportProgressChanged += (progress) => { // TODO - Add progress bar //progressBar.Value = progress; //Application.DoEvents(); MGlobal.displayInfo("[PROGRESS] " + progress + "%"); }; // TODO - Retreive export parameters string outputDirectory = @"C:\"; string outputFileName = "MyFirstExportToBabylon"; string outputFormat = "babylon"; bool generateManifest = false; bool onlySelected = false; bool autoSaveMayaFile = false; bool exportHiddenObjects = false; bool copyTexturesToOutput = true; bool success = true; try { babylonExporter.Export(outputDirectory, outputFileName, outputFormat, generateManifest, onlySelected, autoSaveMayaFile, exportHiddenObjects, copyTexturesToOutput); } catch (OperationCanceledException) { success = false; } catch (Exception ex) { MGlobal.displayInfo("Exportation cancelled: " + ex.Message); success = false; } return(success); }
/// <summary> /// Write "ScriptToBabylon" in the Maya console to export with MEL /// </summary> /// <param name="argl"></param> /// public override void doIt(MArgList argl) { uint index = 1; MStringArray argExportParameters = argl.asStringArray(ref index); string errorMessage = null; for (var i = 0; i < argExportParameters.length; i++) { switch (i) { case 0: if (argExportParameters[i] != "") { ScriptExportParameters.outputPath = argExportParameters[i]; } else { errorMessage = "The specified path is not valid"; } break; case 1: if (argExportParameters[i] != "babylon" || argExportParameters[i] != "gltf" || argExportParameters[i] != "glb" || argExportParameters[i] != "binary babylon") { ScriptExportParameters.outputFormat = argExportParameters[i]; } else { errorMessage = "The specified output format is not valid"; } break; case 2: ScriptExportParameters.textureFolder = argExportParameters[i]; break; case 3: ScriptExportParameters.scaleFactor = float.Parse(argExportParameters[i]); break; case 4: ScriptExportParameters.writeTextures = bool.Parse(argExportParameters[i]); break; case 5: ScriptExportParameters.overwriteTextures = bool.Parse(argExportParameters[i]); break; case 6: ScriptExportParameters.exportHiddenObjects = bool.Parse(argExportParameters[i]); break; case 7: ScriptExportParameters.exportMaterials = bool.Parse(argExportParameters[i]); break; case 8: ScriptExportParameters.exportOnlySelected = bool.Parse(argExportParameters[i]); break; case 9: ScriptExportParameters.bakeAnimationFrames = bool.Parse(argExportParameters[i]); break; case 10: ScriptExportParameters.optimizeAnimations = bool.Parse(argExportParameters[i]); break; case 11: ScriptExportParameters.optimizeVertices = bool.Parse(argExportParameters[i]); break; case 12: ScriptExportParameters.animgroupExportNonAnimated = bool.Parse(argExportParameters[i]); break; case 13: ScriptExportParameters.generateManifest = bool.Parse(argExportParameters[i]); break; case 14: ScriptExportParameters.autoSaveSceneFile = bool.Parse(argExportParameters[i]); break; case 15: ScriptExportParameters.exportTangents = bool.Parse(argExportParameters[i]); break; case 16: ScriptExportParameters.exportSkins = bool.Parse(argExportParameters[i]); break; case 17: ScriptExportParameters.exportMorphTangents = bool.Parse(argExportParameters[i]); break; case 18: ScriptExportParameters.exportMorphNormals = bool.Parse(argExportParameters[i]); break; case 19: ScriptExportParameters.txtQuality = long.Parse(argExportParameters[i]); break; case 20: ScriptExportParameters.mergeAOwithMR = bool.Parse(argExportParameters[i]); break; case 21: ScriptExportParameters.dracoCompression = bool.Parse(argExportParameters[i]); break; case 22: ScriptExportParameters.enableKHRLightsPunctual = bool.Parse(argExportParameters[i]); break; case 23: ScriptExportParameters.enableKHRTextureTransform = bool.Parse(argExportParameters[i]); break; case 24: ScriptExportParameters.enableKHRMaterialsUnlit = bool.Parse(argExportParameters[i]); break; case 25: ScriptExportParameters.pbrFull = bool.Parse(argExportParameters[i]); break; case 26: ScriptExportParameters.pbrNoLight = bool.Parse(argExportParameters[i]); break; case 27: ScriptExportParameters.createDefaultSkybox = bool.Parse(argExportParameters[i]); break; case 28: ScriptExportParameters.pbrEnvironment = argExportParameters[i]; break; } } if (errorMessage == null) { try { BabylonExporter exporterInstance = new BabylonExporter(); exporterInstance.OnError += (error, rank) => { try { displayError(error); } catch { } Application.DoEvents(); }; exporterInstance.OnWarning += (error, rank) => { try { displayWarning(error); } catch { } Application.DoEvents(); }; exporterInstance.OnMessage += (message, color, rank, emphasis) => { try { displayInfo(message); } catch { } Application.DoEvents(); }; exporterInstance.Export(ScriptExportParameters); } catch (Exception ex) { displayError("Export cancelled: " + ex.Message); } } else { displayError(errorMessage); } }