private static void ExportBrushStrokesFbx() { var current = SaveLoadScript.m_Instance.SceneFile; string basename = (current.Valid) ? Path.GetFileNameWithoutExtension(current.FullPath).Replace(" ", "_") : "Untitled"; string directoryName = FileUtils.GenerateNonexistentFilename( App.UserExportPath(), basename, ""); if (!FileUtils.InitializeDirectoryWithUserError(directoryName, "Failed to export")) { return; } string fbxName = Path.Combine(directoryName, basename + ".fbx"); ExportFbx.Export(fbxName, ExportFbx.kFbxAscii); }
public static string ExportScene() { var current = SaveLoadScript.m_Instance.SceneFile; string safeHumanName = FileUtils.SanitizeFilename(current.HumanName); string basename = FileUtils.SanitizeFilename( (current.Valid && (safeHumanName != "")) ? safeHumanName : "Untitled"); string parent = FileUtils.GenerateNonexistentFilename(App.UserExportPath(), basename, ""); if (!FileUtils.InitializeDirectoryWithUserError( parent, "Failed to create export directory")) { return(""); } // Set up progress bar. var progress = new Progress(); if (App.PlatformConfig.EnableExportJson) { progress.SetWork("json"); } #if FBX_SUPPORTED if (App.PlatformConfig.EnableExportFbx) { progress.SetWork("fbx"); } #endif #if USD_SUPPORTED if (App.PlatformConfig.EnableExportUsd) { progress.SetWork("usd"); } #endif #if (UNITY_EDITOR || EXPERIMENTAL_ENABLED) if (Config.IsExperimental) { progress.SetWork("wrl"); progress.SetWork("stl"); #if FBX_SUPPORTED progress.SetWork("obj"); #endif } #endif if (App.PlatformConfig.EnableExportGlb) { progress.SetWork("glb"); } string filename; if (App.PlatformConfig.EnableExportJson && (filename = MakeExportPath(parent, basename, "json")) != null) { using (var unused = new AutoTimer("raw export")) { OverlayManager.m_Instance.UpdateProgress(0.1f); ExportRaw.Export(filename); } } progress.CompleteWork("json"); #if FBX_SUPPORTED if (App.PlatformConfig.EnableExportFbx && (filename = MakeExportPath(parent, basename, "fbx")) != null) { using (var unused = new AutoTimer("fbx export")) { OverlayManager.m_Instance.UpdateProgress(0.3f); ExportFbx.Export(filename, App.UserConfig.Export.ExportBinaryFbx ? ExportFbx.kFbxBinary : ExportFbx.kFbxAscii, App.UserConfig.Export.ExportFbxVersion); OverlayManager.m_Instance.UpdateProgress(0.5f); } } progress.CompleteWork("fbx"); #endif #if USD_SUPPORTED if (App.PlatformConfig.EnableExportUsd && (filename = MakeExportPath(parent, basename, "usd")) != null) { using (var unused = new AutoTimer("usd export")) { ExportUsd.ExportPayload(filename); } } progress.CompleteWork("usd"); #endif #if (UNITY_EDITOR || EXPERIMENTAL_ENABLED) if (Config.IsExperimental && (filename = MakeExportPath(parent, basename, "wrl")) != null) { ExportVrml.Export(filename); progress.CompleteWork("wrl"); } if (Config.IsExperimental && (filename = MakeExportPath(parent, basename, "stl")) != null) { ExportStl.Export(filename); progress.CompleteWork("stl"); } #if FBX_SUPPORTED if (Config.IsExperimental && App.PlatformConfig.EnableExportFbx && (filename = MakeExportPath(parent, basename, "obj")) != null) { // This has never been tested with the new fbx export style and may not work ExportFbx.Export(filename, ExportFbx.kObj); progress.CompleteWork("obj"); } #endif #endif var results = new ExportGlTF.ExportResults(); if (App.PlatformConfig.EnableExportGlb) { string extension = App.Config.m_EnableGlbVersion2 ? "glb" : "glb1"; int gltfVersion = App.Config.m_EnableGlbVersion2 ? 2 : 1; filename = MakeExportPath(parent, basename, extension); if (filename != null) { using (var unused = new AutoTimer("glb export")) { OverlayManager.m_Instance.UpdateProgress(0.7f); var exporter = new ExportGlTF(); // TBT doesn't need (or want) brush textures in the output because it replaces all // the materials, so it's fine to keep those http:. However, Sketchfab doesn't support // http textures so if uploaded, this glb will have missing textures. results = exporter.ExportBrushStrokes( filename, AxisConvention.kGltf2, binary: true, doExtras: false, includeLocalMediaContent: true, gltfVersion: gltfVersion); progress.CompleteWork("glb"); } } } OutputWindowScript.m_Instance.CreateInfoCardAtController( InputManager.ControllerName.Brush, basename + " exported! Your download will begin in 5 seconds."); ControllerConsoleScript.m_Instance.AddNewLine("Located in " + App.UserExportPath()); string readmeFilename = Path.Combine(App.UserExportPath(), kExportReadmeName); if (!File.Exists(readmeFilename) && !Directory.Exists(readmeFilename)) { File.WriteAllText(readmeFilename, kExportReadmeBody); } return(results.exportedFiles[0]); }