From 9660ef79fc94be22c36bd1ef717b00b5a98854d8 Mon Sep 17 00:00:00 2001 From: elpie89 Date: Mon, 20 May 2019 18:20:28 +0200 Subject: [PATCH 1/6] export gltf with texture specification --- 3ds Max/Max2Babylon/ExportParameters.cs | 1 + .../Exporter/BabylonExporter.ExportItem.cs | 1 + .../BabylonExporter.GLTFExporter.Texture.cs | 24 ++- .../Max2Babylon/Exporter/BabylonExporter.cs | 9 +- .../Forms/ExporterForm.Designer.cs | 159 +++++++++++------- 3ds Max/Max2Babylon/Forms/ExporterForm.cs | 64 +++++-- 3ds Max/Max2Babylon/Forms/ExporterForm.resx | 3 + 3ds Max/Max2Babylon/Tools/Tools.cs | 19 +++ 8 files changed, 206 insertions(+), 74 deletions(-) diff --git a/3ds Max/Max2Babylon/ExportParameters.cs b/3ds Max/Max2Babylon/ExportParameters.cs index 43d88da8..77bc3866 100644 --- a/3ds Max/Max2Babylon/ExportParameters.cs +++ b/3ds Max/Max2Babylon/ExportParameters.cs @@ -4,6 +4,7 @@ public class ExportParameters { public string outputPath; public string outputFormat; + public string textureFolder; public string scaleFactor = "1"; public bool writeTextures = true; public bool overwriteTextures = true; diff --git a/3ds Max/Max2Babylon/Exporter/BabylonExporter.ExportItem.cs b/3ds Max/Max2Babylon/Exporter/BabylonExporter.ExportItem.cs index 5adf3f4d..611fd19c 100644 --- a/3ds Max/Max2Babylon/Exporter/BabylonExporter.ExportItem.cs +++ b/3ds Max/Max2Babylon/Exporter/BabylonExporter.ExportItem.cs @@ -79,6 +79,7 @@ public bool Selected private bool selected = true; private string exportPathRelative = ""; private string exportPathAbsolute = ""; + private string exportTextureFolderPathRelative = ""; public ExportItem(string outputFileExt) { this.outputFileExt = outputFileExt; } diff --git a/3ds Max/Max2Babylon/Exporter/BabylonExporter.GLTFExporter.Texture.cs b/3ds Max/Max2Babylon/Exporter/BabylonExporter.GLTFExporter.Texture.cs index e51ab116..8ad48a94 100644 --- a/3ds Max/Max2Babylon/Exporter/BabylonExporter.GLTFExporter.Texture.cs +++ b/3ds Max/Max2Babylon/Exporter/BabylonExporter.GLTFExporter.Texture.cs @@ -15,7 +15,7 @@ partial class BabylonExporter public const string KHR_texture_transform = "KHR_texture_transform"; // Name of the extension private Dictionary glTFTextureInfoMap = new Dictionary(); private Dictionary glTFImageMap = new Dictionary(); - + public string relativeTextureFolder = ""; /// /// Export the texture using the parameters of babylonTexture except its name. /// Write the bitmap file @@ -62,6 +62,21 @@ private GLTFTextureInfo ExportTexture(BabylonTexture babylonTexture, GLTF gltf) () => { return TryWriteImage(gltf, babylonTexture.originalPath, babylonTexture.name); }); } + private bool ExtensionIsValidGLTFTexture(string _extension) + { + if (_extension.StartsWith(".")) + { + _extension = _extension.Replace(".", ""); + } + + if (validGltfFormats.Contains(_extension)) + { + return true; + } + + return false; + } + private string TryWriteImage(GLTF gltf, string sourcePath, string textureName) { if (sourcePath == null || sourcePath == "") @@ -157,9 +172,14 @@ private GLTFTextureInfo ExportTexture(BabylonTexture babylonTexture, GLTF gltf, } else { + string textureUri = name; + if (!string.IsNullOrWhiteSpace(relativeTextureFolder)) + { + textureUri = relativeTextureFolder + "/"+ name; + } gltfImage = new GLTFImage { - uri = name + uri = textureUri }; gltfImage.index = gltf.ImagesList.Count; gltf.ImagesList.Add(gltfImage); diff --git a/3ds Max/Max2Babylon/Exporter/BabylonExporter.cs b/3ds Max/Max2Babylon/Exporter/BabylonExporter.cs index 81cbba26..d894955f 100644 --- a/3ds Max/Max2Babylon/Exporter/BabylonExporter.cs +++ b/3ds Max/Max2Babylon/Exporter/BabylonExporter.cs @@ -144,6 +144,7 @@ public void Export(ExportParameters exportParameters) string tempOutputDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); string outputDirectory = Path.GetDirectoryName(exportParameters.outputPath); + string folderOuputDirectory = exportParameters.textureFolder; string outputFileName = Path.GetFileName(exportParameters.outputPath); // Check directory exists @@ -557,6 +558,7 @@ public void Export(ExportParameters exportParameters) var tempFilePath = Path.Combine(tempOutputDirectory, file); var outputFile = Path.Combine(outputDirectory, file); + IUTF8Str maxNotification = GlobalInterface.Instance.UTF8Str.Create(outputFile); Loader.Global.BroadcastNotification(SystemNotificationCode.PreExport, maxNotification); moveFileToOutputDirectory(tempFilePath, outputFile, exportParameters); @@ -571,8 +573,13 @@ public void Export(ExportParameters exportParameters) foreach (var filePath in filePaths) { var file = Path.GetFileName(filePath); - var outputPath = Path.Combine(outputDirectory, file); + string ext = Path.GetExtension(file); var tempFilePath = Path.Combine(tempOutputDirectory, file); + var outputPath = Path.Combine(outputDirectory, file); + if (!string.IsNullOrWhiteSpace(exportParameters.textureFolder) && ExtensionIsValidGLTFTexture(ext)) + { + outputPath = Path.Combine(exportParameters.textureFolder, file); + } IUTF8Str maxNotification = GlobalInterface.Instance.UTF8Str.Create(outputPath); Loader.Global.BroadcastNotification(SystemNotificationCode.PreExport, maxNotification); diff --git a/3ds Max/Max2Babylon/Forms/ExporterForm.Designer.cs b/3ds Max/Max2Babylon/Forms/ExporterForm.Designer.cs index 1b337aaa..eb6db127 100644 --- a/3ds Max/Max2Babylon/Forms/ExporterForm.Designer.cs +++ b/3ds Max/Max2Babylon/Forms/ExporterForm.Designer.cs @@ -31,8 +31,8 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); this.butExport = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); - this.txtFilename = new System.Windows.Forms.TextBox(); - this.butBrowse = new System.Windows.Forms.Button(); + this.txtModelName = new System.Windows.Forms.TextBox(); + this.butModelBrowse = new System.Windows.Forms.Button(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.progressBar = new System.Windows.Forms.ProgressBar(); this.treeView = new System.Windows.Forms.TreeView(); @@ -42,6 +42,9 @@ private void InitializeComponent() this.label2 = new System.Windows.Forms.Label(); this.chkWriteTextures = new System.Windows.Forms.CheckBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.textureLabel = new System.Windows.Forms.Label(); + this.txtTextureName = new System.Windows.Forms.TextBox(); + this.btnTxtBrowse = new System.Windows.Forms.Button(); this.chkExportMaterials = new System.Windows.Forms.CheckBox(); this.chkKHRMaterialsUnlit = new System.Windows.Forms.CheckBox(); this.chkKHRTextureTransform = new System.Windows.Forms.CheckBox(); @@ -63,6 +66,7 @@ private void InitializeComponent() this.butClose = new System.Windows.Forms.Button(); this.toolTipDracoCompression = new System.Windows.Forms.ToolTip(this.components); this.butMultiExport = new System.Windows.Forms.Button(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); @@ -72,7 +76,7 @@ private void InitializeComponent() this.butExport.Anchor = System.Windows.Forms.AnchorStyles.Top; this.butExport.Enabled = false; this.butExport.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.butExport.Location = new System.Drawing.Point(115, 245); + this.butExport.Location = new System.Drawing.Point(114, 261); this.butExport.Name = "butExport"; this.butExport.Size = new System.Drawing.Size(197, 27); this.butExport.TabIndex = 100; @@ -86,33 +90,33 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 17); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.Size = new System.Drawing.Size(68, 13); this.label1.TabIndex = 1; - this.label1.Text = "File name:"; + this.label1.Text = "Model name:"; // - // txtFilename + // txtModelName // - this.txtFilename.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.txtModelName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.txtFilename.Location = new System.Drawing.Point(18, 34); - this.txtFilename.Name = "txtFilename"; - this.txtFilename.Size = new System.Drawing.Size(377, 20); - this.txtFilename.TabIndex = 2; - this.txtFilename.TextChanged += new System.EventHandler(this.txtFilename_TextChanged); - this.txtFilename.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExporterForm_KeyDown); - // - // butBrowse - // - this.butBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.butBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.butBrowse.Location = new System.Drawing.Point(401, 32); - this.butBrowse.Name = "butBrowse"; - this.butBrowse.Size = new System.Drawing.Size(43, 23); - this.butBrowse.TabIndex = 3; - this.butBrowse.Text = "..."; - this.butBrowse.UseVisualStyleBackColor = true; - this.butBrowse.Click += new System.EventHandler(this.butBrowse_Click); - this.butBrowse.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExporterForm_KeyDown); + this.txtModelName.Location = new System.Drawing.Point(86, 14); + this.txtModelName.Name = "txtModelName"; + this.txtModelName.Size = new System.Drawing.Size(324, 20); + this.txtModelName.TabIndex = 2; + this.txtModelName.TextChanged += new System.EventHandler(this.txtFilename_TextChanged); + this.txtModelName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExporterForm_KeyDown); + // + // butModelBrowse + // + this.butModelBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.butModelBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.butModelBrowse.Location = new System.Drawing.Point(416, 12); + this.butModelBrowse.Name = "butModelBrowse"; + this.butModelBrowse.Size = new System.Drawing.Size(28, 23); + this.butModelBrowse.TabIndex = 3; + this.butModelBrowse.Text = "..."; + this.butModelBrowse.UseVisualStyleBackColor = true; + this.butModelBrowse.Click += new System.EventHandler(this.butModelBrowse_Click); + this.butModelBrowse.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExporterForm_KeyDown); // // saveFileDialog // @@ -124,7 +128,7 @@ private void InitializeComponent() // this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar.Location = new System.Drawing.Point(12, 526); + this.progressBar.Location = new System.Drawing.Point(12, 581); this.progressBar.Name = "progressBar"; this.progressBar.Size = new System.Drawing.Size(638, 23); this.progressBar.TabIndex = 104; @@ -134,9 +138,9 @@ private void InitializeComponent() this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.treeView.Location = new System.Drawing.Point(12, 278); + this.treeView.Location = new System.Drawing.Point(12, 294); this.treeView.Name = "treeView"; - this.treeView.Size = new System.Drawing.Size(810, 242); + this.treeView.Size = new System.Drawing.Size(810, 281); this.treeView.TabIndex = 103; this.treeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExporterForm_KeyDown); // @@ -145,7 +149,7 @@ private void InitializeComponent() this.butCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.butCancel.Enabled = false; this.butCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.butCancel.Location = new System.Drawing.Point(656, 526); + this.butCancel.Location = new System.Drawing.Point(656, 581); this.butCancel.Name = "butCancel"; this.butCancel.Size = new System.Drawing.Size(80, 23); this.butCancel.TabIndex = 105; @@ -169,7 +173,7 @@ private void InitializeComponent() // this.chkManifest.AutoSize = true; this.chkManifest.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkManifest.Location = new System.Drawing.Point(320, 163); + this.chkManifest.Location = new System.Drawing.Point(320, 171); this.chkManifest.Name = "chkManifest"; this.chkManifest.Size = new System.Drawing.Size(112, 17); this.chkManifest.TabIndex = 14; @@ -180,7 +184,7 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 98); + this.label2.Location = new System.Drawing.Point(6, 106); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(46, 13); this.label2.TabIndex = 10; @@ -192,7 +196,7 @@ private void InitializeComponent() this.chkWriteTextures.Checked = true; this.chkWriteTextures.CheckState = System.Windows.Forms.CheckState.Checked; this.chkWriteTextures.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkWriteTextures.Location = new System.Drawing.Point(18, 117); + this.chkWriteTextures.Location = new System.Drawing.Point(18, 125); this.chkWriteTextures.Name = "chkWriteTextures"; this.chkWriteTextures.Size = new System.Drawing.Size(92, 17); this.chkWriteTextures.TabIndex = 11; @@ -204,6 +208,9 @@ private void InitializeComponent() // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.textureLabel); + this.groupBox1.Controls.Add(this.txtTextureName); + this.groupBox1.Controls.Add(this.btnTxtBrowse); this.groupBox1.Controls.Add(this.chkExportMaterials); this.groupBox1.Controls.Add(this.chkKHRMaterialsUnlit); this.groupBox1.Controls.Add(this.chkKHRTextureTransform); @@ -223,23 +230,53 @@ private void InitializeComponent() this.groupBox1.Controls.Add(this.chkHidden); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.chkWriteTextures); - this.groupBox1.Controls.Add(this.txtFilename); + this.groupBox1.Controls.Add(this.txtModelName); this.groupBox1.Controls.Add(this.chkManifest); - this.groupBox1.Controls.Add(this.butBrowse); + this.groupBox1.Controls.Add(this.butModelBrowse); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Location = new System.Drawing.Point(12, 6); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(450, 233); + this.groupBox1.Size = new System.Drawing.Size(450, 249); this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; // + // textureLabel + // + this.textureLabel.AutoSize = true; + this.textureLabel.Location = new System.Drawing.Point(6, 43); + this.textureLabel.Name = "textureLabel"; + this.textureLabel.Size = new System.Drawing.Size(75, 13); + this.textureLabel.TabIndex = 24; + this.textureLabel.Text = "Texture folder:"; + // + // txtTextureName + // + this.txtTextureName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtTextureName.Location = new System.Drawing.Point(86, 40); + this.txtTextureName.Name = "txtTextureName"; + this.txtTextureName.Size = new System.Drawing.Size(324, 20); + this.txtTextureName.TabIndex = 25; + // + // btnTxtBrowse + // + this.btnTxtBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnTxtBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnTxtBrowse.Location = new System.Drawing.Point(416, 38); + this.btnTxtBrowse.Name = "btnTxtBrowse"; + this.btnTxtBrowse.Size = new System.Drawing.Size(28, 23); + this.btnTxtBrowse.TabIndex = 26; + this.btnTxtBrowse.Text = "..."; + this.btnTxtBrowse.UseVisualStyleBackColor = true; + this.btnTxtBrowse.Click += new System.EventHandler(this.btnTextureBrowse_Click); + // // chkExportMaterials // this.chkExportMaterials.AutoSize = true; this.chkExportMaterials.Checked = true; this.chkExportMaterials.CheckState = System.Windows.Forms.CheckState.Checked; this.chkExportMaterials.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkExportMaterials.Location = new System.Drawing.Point(18, 187); + this.chkExportMaterials.Location = new System.Drawing.Point(18, 195); this.chkExportMaterials.Name = "chkExportMaterials"; this.chkExportMaterials.Size = new System.Drawing.Size(98, 17); this.chkExportMaterials.TabIndex = 23; @@ -250,7 +287,7 @@ private void InitializeComponent() // this.chkKHRMaterialsUnlit.AutoSize = true; this.chkKHRMaterialsUnlit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkKHRMaterialsUnlit.Location = new System.Drawing.Point(317, 210); + this.chkKHRMaterialsUnlit.Location = new System.Drawing.Point(317, 218); this.chkKHRMaterialsUnlit.Name = "chkKHRMaterialsUnlit"; this.chkKHRMaterialsUnlit.Size = new System.Drawing.Size(118, 17); this.chkKHRMaterialsUnlit.TabIndex = 22; @@ -261,7 +298,7 @@ private void InitializeComponent() // this.chkKHRTextureTransform.AutoSize = true; this.chkKHRTextureTransform.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkKHRTextureTransform.Location = new System.Drawing.Point(166, 210); + this.chkKHRTextureTransform.Location = new System.Drawing.Point(166, 218); this.chkKHRTextureTransform.Name = "chkKHRTextureTransform"; this.chkKHRTextureTransform.Size = new System.Drawing.Size(133, 17); this.chkKHRTextureTransform.TabIndex = 21; @@ -272,7 +309,7 @@ private void InitializeComponent() // this.chkKHRLightsPunctual.AutoSize = true; this.chkKHRLightsPunctual.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkKHRLightsPunctual.Location = new System.Drawing.Point(18, 210); + this.chkKHRLightsPunctual.Location = new System.Drawing.Point(18, 218); this.chkKHRLightsPunctual.Name = "chkKHRLightsPunctual"; this.chkKHRLightsPunctual.Size = new System.Drawing.Size(123, 17); this.chkKHRLightsPunctual.TabIndex = 20; @@ -285,7 +322,7 @@ private void InitializeComponent() this.chkOverwriteTextures.Checked = true; this.chkOverwriteTextures.CheckState = System.Windows.Forms.CheckState.Checked; this.chkOverwriteTextures.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkOverwriteTextures.Location = new System.Drawing.Point(18, 141); + this.chkOverwriteTextures.Location = new System.Drawing.Point(18, 149); this.chkOverwriteTextures.Name = "chkOverwriteTextures"; this.chkOverwriteTextures.Size = new System.Drawing.Size(112, 17); this.chkOverwriteTextures.TabIndex = 19; @@ -296,7 +333,7 @@ private void InitializeComponent() // this.chkDracoCompression.AutoSize = true; this.chkDracoCompression.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkDracoCompression.Location = new System.Drawing.Point(166, 163); + this.chkDracoCompression.Location = new System.Drawing.Point(166, 171); this.chkDracoCompression.Name = "chkDracoCompression"; this.chkDracoCompression.Size = new System.Drawing.Size(136, 17); this.chkDracoCompression.TabIndex = 18; @@ -310,7 +347,7 @@ private void InitializeComponent() this.chkMergeAOwithMR.Checked = true; this.chkMergeAOwithMR.CheckState = System.Windows.Forms.CheckState.Checked; this.chkMergeAOwithMR.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkMergeAOwithMR.Location = new System.Drawing.Point(18, 163); + this.chkMergeAOwithMR.Location = new System.Drawing.Point(18, 171); this.chkMergeAOwithMR.Name = "chkMergeAOwithMR"; this.chkMergeAOwithMR.Size = new System.Drawing.Size(94, 17); this.chkMergeAOwithMR.TabIndex = 17; @@ -320,7 +357,7 @@ private void InitializeComponent() // // txtQuality // - this.txtQuality.Location = new System.Drawing.Point(401, 90); + this.txtQuality.Location = new System.Drawing.Point(401, 98); this.txtQuality.Name = "txtQuality"; this.txtQuality.Size = new System.Drawing.Size(43, 20); this.txtQuality.TabIndex = 9; @@ -331,7 +368,7 @@ private void InitializeComponent() // labelQuality // this.labelQuality.AutoSize = true; - this.labelQuality.Location = new System.Drawing.Point(317, 93); + this.labelQuality.Location = new System.Drawing.Point(317, 101); this.labelQuality.Name = "labelQuality"; this.labelQuality.Size = new System.Drawing.Size(79, 13); this.labelQuality.TabIndex = 8; @@ -343,7 +380,7 @@ private void InitializeComponent() this.chkExportTangents.Checked = true; this.chkExportTangents.CheckState = System.Windows.Forms.CheckState.Checked; this.chkExportTangents.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkExportTangents.Location = new System.Drawing.Point(320, 140); + this.chkExportTangents.Location = new System.Drawing.Point(320, 148); this.chkExportTangents.Name = "chkExportTangents"; this.chkExportTangents.Size = new System.Drawing.Size(97, 17); this.chkExportTangents.TabIndex = 16; @@ -354,7 +391,7 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(329, 69); + this.label4.Location = new System.Drawing.Point(329, 77); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(67, 13); this.label4.TabIndex = 6; @@ -362,7 +399,7 @@ private void InitializeComponent() // // txtScaleFactor // - this.txtScaleFactor.Location = new System.Drawing.Point(402, 66); + this.txtScaleFactor.Location = new System.Drawing.Point(402, 74); this.txtScaleFactor.Name = "txtScaleFactor"; this.txtScaleFactor.Size = new System.Drawing.Size(42, 20); this.txtScaleFactor.TabIndex = 7; @@ -373,7 +410,7 @@ private void InitializeComponent() // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 69); + this.label3.Location = new System.Drawing.Point(6, 77); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(74, 13); this.label3.TabIndex = 4; @@ -387,7 +424,7 @@ private void InitializeComponent() "binary babylon", "gltf", "glb"}); - this.comboOutputFormat.Location = new System.Drawing.Point(86, 66); + this.comboOutputFormat.Location = new System.Drawing.Point(86, 74); this.comboOutputFormat.Name = "comboOutputFormat"; this.comboOutputFormat.Size = new System.Drawing.Size(121, 21); this.comboOutputFormat.TabIndex = 5; @@ -398,7 +435,7 @@ private void InitializeComponent() // this.chkOnlySelected.AutoSize = true; this.chkOnlySelected.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkOnlySelected.Location = new System.Drawing.Point(320, 117); + this.chkOnlySelected.Location = new System.Drawing.Point(320, 125); this.chkOnlySelected.Name = "chkOnlySelected"; this.chkOnlySelected.Size = new System.Drawing.Size(118, 17); this.chkOnlySelected.TabIndex = 13; @@ -410,7 +447,7 @@ private void InitializeComponent() // this.chkAutoSave.AutoSize = true; this.chkAutoSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkAutoSave.Location = new System.Drawing.Point(166, 140); + this.chkAutoSave.Location = new System.Drawing.Point(166, 148); this.chkAutoSave.Name = "chkAutoSave"; this.chkAutoSave.Size = new System.Drawing.Size(130, 17); this.chkAutoSave.TabIndex = 15; @@ -422,7 +459,7 @@ private void InitializeComponent() // this.chkHidden.AutoSize = true; this.chkHidden.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.chkHidden.Location = new System.Drawing.Point(166, 117); + this.chkHidden.Location = new System.Drawing.Point(166, 125); this.chkHidden.Name = "chkHidden"; this.chkHidden.Size = new System.Drawing.Size(125, 17); this.chkHidden.TabIndex = 12; @@ -435,7 +472,7 @@ private void InitializeComponent() this.butExportAndRun.Anchor = System.Windows.Forms.AnchorStyles.Top; this.butExportAndRun.Enabled = false; this.butExportAndRun.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.butExportAndRun.Location = new System.Drawing.Point(318, 245); + this.butExportAndRun.Location = new System.Drawing.Point(317, 261); this.butExportAndRun.Name = "butExportAndRun"; this.butExportAndRun.Size = new System.Drawing.Size(197, 27); this.butExportAndRun.TabIndex = 102; @@ -448,7 +485,7 @@ private void InitializeComponent() // this.butClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.butClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.butClose.Location = new System.Drawing.Point(742, 526); + this.butClose.Location = new System.Drawing.Point(742, 581); this.butClose.Name = "butClose"; this.butClose.Size = new System.Drawing.Size(80, 23); this.butClose.TabIndex = 106; @@ -465,7 +502,7 @@ private void InitializeComponent() // this.butMultiExport.Anchor = System.Windows.Forms.AnchorStyles.Top; this.butMultiExport.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.butMultiExport.Location = new System.Drawing.Point(521, 245); + this.butMultiExport.Location = new System.Drawing.Point(520, 261); this.butMultiExport.Name = "butMultiExport"; this.butMultiExport.Size = new System.Drawing.Size(197, 27); this.butMultiExport.TabIndex = 109; @@ -477,7 +514,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(834, 561); + this.ClientSize = new System.Drawing.Size(834, 616); this.Controls.Add(this.butMultiExport); this.Controls.Add(this.butExportAndRun); this.Controls.Add(this.groupBox1); @@ -508,8 +545,8 @@ private void InitializeComponent() private System.Windows.Forms.Button butExport; private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtFilename; - private System.Windows.Forms.Button butBrowse; + private System.Windows.Forms.TextBox txtModelName; + private System.Windows.Forms.Button butModelBrowse; private System.Windows.Forms.SaveFileDialog saveFileDialog; private System.Windows.Forms.ProgressBar progressBar; private System.Windows.Forms.TreeView treeView; @@ -540,5 +577,9 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox chkKHRTextureTransform; private System.Windows.Forms.CheckBox chkKHRMaterialsUnlit; private System.Windows.Forms.CheckBox chkExportMaterials; + private System.Windows.Forms.Label textureLabel; + private System.Windows.Forms.TextBox txtTextureName; + private System.Windows.Forms.Button btnTxtBrowse; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; } } \ No newline at end of file diff --git a/3ds Max/Max2Babylon/Forms/ExporterForm.cs b/3ds Max/Max2Babylon/Forms/ExporterForm.cs index 5040aa78..c611419f 100644 --- a/3ds Max/Max2Babylon/Forms/ExporterForm.cs +++ b/3ds Max/Max2Babylon/Forms/ExporterForm.cs @@ -51,8 +51,12 @@ public ExporterForm(BabylonExportActionItem babylonExportAction) private void ExporterForm_Load(object sender, EventArgs e) { string userRelativePath = Tools.ResolveRelativePath(Loader.Core.RootNode.GetLocalData()); - txtFilename.Text = userRelativePath; - singleExportItem = new ExportItem(Tools.UnformatPath(txtFilename.Text)); + txtModelName.Text = userRelativePath; + string absoluteModelPath = Tools.UnformatPath(txtModelName.Text); + singleExportItem = new ExportItem(absoluteModelPath); + + string formatedFolderPath = Tools.ResolveRelativePath(Loader.Core.RootNode.GetLocalData()); + txtTextureName.Text = formatedFolderPath; Tools.PrepareCheckBox(chkManifest, Loader.Core.RootNode, "babylonjs_generatemanifest"); Tools.PrepareCheckBox(chkWriteTextures, Loader.Core.RootNode, "babylonjs_writetextures", 1); @@ -78,12 +82,33 @@ private void ExporterForm_Load(object sender, EventArgs e) } } - private void butBrowse_Click(object sender, EventArgs e) + private void butModelBrowse_Click(object sender, EventArgs e) { if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { - txtFilename.Text = Tools.FormatPath(saveFileDialog.FileName); - + txtModelName.Text = Tools.FormatPath(saveFileDialog.FileName); + } + } + + + private void btnTextureBrowse_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(txtModelName.Text)) + { + MessageBox.Show("Select model file path first"); + return; + } + + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) + { + string selectedFolderPath = folderBrowserDialog1.SelectedPath; + string absoluteModelPath = Tools.UnformatPath(txtModelName.Text); + if (!Tools.IsBelowModelPath(selectedFolderPath, absoluteModelPath)) + { + MessageBox.Show("WARNING: folderPath should be below model file path"); + } + + txtTextureName.Text = Tools.FormatPath(folderBrowserDialog1.SelectedPath); } } @@ -129,12 +154,17 @@ private async Task DoExport(ExportItem exportItem, bool clearLogs = true) Tools.UpdateCheckBox(chkKHRMaterialsUnlit, Loader.Core.RootNode, "babylonjs_khr_materials_unlit"); Tools.UpdateCheckBox(chkExportMaterials, Loader.Core.RootNode, "babylonjs_export_materials"); - string unformattedPath = Tools.UnformatPath(txtFilename.Text); + string unformattedPath = Tools.UnformatPath(txtModelName.Text); Loader.Core.RootNode.SetLocalData(Tools.RelativePathStore(unformattedPath)); + string unformattedTextureFolderPath = Tools.UnformatPath(txtTextureName.Text); + Loader.Core.RootNode.SetLocalData(Tools.RelativePathStore(unformattedTextureFolderPath)); + exporter = new BabylonExporter(); + exporter.relativeTextureFolder = Tools.GetPathRelativeToModel(Tools.UnformatPath(txtTextureName.Text), Tools.UnformatPath(txtModelName.Text)); + - if(clearLogs) + if (clearLogs) treeView.Nodes.Clear(); exporter.OnImportProgressChanged += progress => @@ -196,7 +226,8 @@ private async Task DoExport(ExportItem exportItem, bool clearLogs = true) { ExportParameters exportParameters = new ExportParameters { - outputPath = Tools.UnformatPath(txtFilename.Text), + outputPath = Tools.UnformatPath(txtModelName.Text), + textureFolder = Tools.UnformatPath(txtTextureName.Text), outputFormat = comboOutputFormat.SelectedItem.ToString(), scaleFactor = txtScaleFactor.Text, writeTextures = chkWriteTextures.Checked, @@ -296,7 +327,7 @@ private void ExporterForm_FormClosed(object sender, FormClosedEventArgs e) private void txtFilename_TextChanged(object sender, EventArgs e) { - butExport.Enabled = !string.IsNullOrEmpty(txtFilename.Text.Trim()); + butExport.Enabled = !string.IsNullOrEmpty(txtModelName.Text.Trim()); butExportAndRun.Enabled = butExport.Enabled && WebServer.IsSupported; } @@ -319,8 +350,8 @@ private async void butExportAndRun_Click(object sender, EventArgs e) { if (await DoExport(singleExportItem)) { - WebServer.SceneFilename = Path.GetFileName(Tools.UnformatPath(txtFilename.Text)); - WebServer.SceneFolder = Path.GetDirectoryName(Tools.UnformatPath(txtFilename.Text)); + WebServer.SceneFilename = Path.GetFileName(Tools.UnformatPath(txtModelName.Text)); + WebServer.SceneFolder = Path.GetDirectoryName(Tools.UnformatPath(txtModelName.Text)); Process.Start(WebServer.url + WebServer.SceneFilename); @@ -346,6 +377,9 @@ private void comboOutputFormat_SelectedIndexChanged(object sender, EventArgs e) chkDracoCompression.Enabled = false; chkWriteTextures.Enabled = true; chkOverwriteTextures.Enabled = true; + txtTextureName.Enabled = false; + textureLabel.Enabled = false; + btnTxtBrowse.Enabled = false; break; case "gltf": this.saveFileDialog.DefaultExt = "gltf"; @@ -353,6 +387,9 @@ private void comboOutputFormat_SelectedIndexChanged(object sender, EventArgs e) chkDracoCompression.Enabled = gltfPipelineInstalled; chkWriteTextures.Enabled = true; chkOverwriteTextures.Enabled = true; + txtTextureName.Enabled = true; + textureLabel.Enabled = true; + btnTxtBrowse.Enabled = true; break; case "glb": this.saveFileDialog.DefaultExt = "glb"; @@ -362,9 +399,12 @@ private void comboOutputFormat_SelectedIndexChanged(object sender, EventArgs e) chkWriteTextures.Enabled = false; chkOverwriteTextures.Checked = true; chkOverwriteTextures.Enabled = false; + txtTextureName.Enabled = false; + textureLabel.Enabled = false; + btnTxtBrowse.Enabled = false; break; } - this.txtFilename.Text = Path.ChangeExtension(txtFilename.Text, this.saveFileDialog.DefaultExt); + this.txtModelName.Text = Path.ChangeExtension(txtModelName.Text, this.saveFileDialog.DefaultExt); } /// diff --git a/3ds Max/Max2Babylon/Forms/ExporterForm.resx b/3ds Max/Max2Babylon/Forms/ExporterForm.resx index b9b0366d..69bd488e 100644 --- a/3ds Max/Max2Babylon/Forms/ExporterForm.resx +++ b/3ds Max/Max2Babylon/Forms/ExporterForm.resx @@ -123,4 +123,7 @@ 146, 17 + + 339, 17 + \ No newline at end of file diff --git a/3ds Max/Max2Babylon/Tools/Tools.cs b/3ds Max/Max2Babylon/Tools/Tools.cs index 539d0f13..585a83a8 100644 --- a/3ds Max/Max2Babylon/Tools/Tools.cs +++ b/3ds Max/Max2Babylon/Tools/Tools.cs @@ -1194,6 +1194,25 @@ public static string ResolveRelativePath(string path) return string.Format("({0})\\{1}", dirName, path); } + public static bool IsBelowModelPath(string folderPath,string modelPath) + { + string modelFolderPath = Path.GetDirectoryName(modelPath); + if (folderPath.StartsWith(modelFolderPath)) + { + return true; + } + + return false; + } + + public static string GetPathRelativeToModel(string folderPath, string modelPath) + { + Uri path1 = new Uri(modelPath); + Uri path2 = new Uri(folderPath); + Uri diff = path1.MakeRelativeUri(path2); + return diff.OriginalString; + } + #endregion } From a277773b30f5740ed7ef0758fe2dd02fa0f92393 Mon Sep 17 00:00:00 2001 From: elpie89 Date: Tue, 21 May 2019 11:41:56 +0200 Subject: [PATCH 2/6] relative file path features adapted to texture folder specification check if task is running before to kill it on pre build event --- 3ds Max/Max2Babylon/Forms/ExporterForm.cs | 23 ++++++++++++++++------- 3ds Max/Max2Babylon/OnPreBuild.bat | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/3ds Max/Max2Babylon/Forms/ExporterForm.cs b/3ds Max/Max2Babylon/Forms/ExporterForm.cs index c611419f..bba7bccc 100644 --- a/3ds Max/Max2Babylon/Forms/ExporterForm.cs +++ b/3ds Max/Max2Babylon/Forms/ExporterForm.cs @@ -11,6 +11,9 @@ namespace Max2Babylon { public partial class ExporterForm : Form { + private const string ModelFilePathProperty = "modelFilePathProperty"; + private const string TextureFolderPathProperty = "textureFolderPathProperty"; + private readonly BabylonExportActionItem babylonExportAction; private BabylonExporter exporter; private bool gltfPipelineInstalled = true; // true if the gltf-pipeline is installed and runnable. @@ -50,12 +53,14 @@ public ExporterForm(BabylonExportActionItem babylonExportAction) private void ExporterForm_Load(object sender, EventArgs e) { - string userRelativePath = Tools.ResolveRelativePath(Loader.Core.RootNode.GetLocalData()); + string storedModelPath = Loader.Core.RootNode.GetStringProperty(ModelFilePathProperty,string.Empty); + string userRelativePath = Tools.ResolveRelativePath(storedModelPath); txtModelName.Text = userRelativePath; string absoluteModelPath = Tools.UnformatPath(txtModelName.Text); singleExportItem = new ExportItem(absoluteModelPath); - string formatedFolderPath = Tools.ResolveRelativePath(Loader.Core.RootNode.GetLocalData()); + string storedFolderPath = Loader.Core.RootNode.GetStringProperty(TextureFolderPathProperty, string.Empty); + string formatedFolderPath = Tools.ResolveRelativePath(storedFolderPath); txtTextureName.Text = formatedFolderPath; Tools.PrepareCheckBox(chkManifest, Loader.Core.RootNode, "babylonjs_generatemanifest"); @@ -108,7 +113,7 @@ private void btnTextureBrowse_Click(object sender, EventArgs e) MessageBox.Show("WARNING: folderPath should be below model file path"); } - txtTextureName.Text = Tools.FormatPath(folderBrowserDialog1.SelectedPath); + txtTextureName.Text = Tools.FormatPath(folderBrowserDialog1.SelectedPath + "\\"); } } @@ -155,14 +160,16 @@ private async Task DoExport(ExportItem exportItem, bool clearLogs = true) Tools.UpdateCheckBox(chkExportMaterials, Loader.Core.RootNode, "babylonjs_export_materials"); string unformattedPath = Tools.UnformatPath(txtModelName.Text); - Loader.Core.RootNode.SetLocalData(Tools.RelativePathStore(unformattedPath)); + Loader.Core.RootNode.SetStringProperty(ModelFilePathProperty, Tools.RelativePathStore(unformattedPath)); string unformattedTextureFolderPath = Tools.UnformatPath(txtTextureName.Text); - Loader.Core.RootNode.SetLocalData(Tools.RelativePathStore(unformattedTextureFolderPath)); + Loader.Core.RootNode.SetStringProperty(TextureFolderPathProperty,Tools.RelativePathStore(unformattedTextureFolderPath)); exporter = new BabylonExporter(); - exporter.relativeTextureFolder = Tools.GetPathRelativeToModel(Tools.UnformatPath(txtTextureName.Text), Tools.UnformatPath(txtModelName.Text)); - + if (!string.IsNullOrWhiteSpace(txtTextureName.Text)) + { + exporter.relativeTextureFolder = Tools.GetPathRelativeToModel(Tools.UnformatPath(txtTextureName.Text), Tools.UnformatPath(txtModelName.Text)); + } if (clearLogs) treeView.Nodes.Clear(); @@ -377,6 +384,7 @@ private void comboOutputFormat_SelectedIndexChanged(object sender, EventArgs e) chkDracoCompression.Enabled = false; chkWriteTextures.Enabled = true; chkOverwriteTextures.Enabled = true; + txtTextureName.Text = string.Empty; txtTextureName.Enabled = false; textureLabel.Enabled = false; btnTxtBrowse.Enabled = false; @@ -399,6 +407,7 @@ private void comboOutputFormat_SelectedIndexChanged(object sender, EventArgs e) chkWriteTextures.Enabled = false; chkOverwriteTextures.Checked = true; chkOverwriteTextures.Enabled = false; + txtTextureName.Text = string.Empty; txtTextureName.Enabled = false; textureLabel.Enabled = false; btnTxtBrowse.Enabled = false; diff --git a/3ds Max/Max2Babylon/OnPreBuild.bat b/3ds Max/Max2Babylon/OnPreBuild.bat index a0b84e1d..120a82c7 100644 --- a/3ds Max/Max2Babylon/OnPreBuild.bat +++ b/3ds Max/Max2Babylon/OnPreBuild.bat @@ -6,7 +6,7 @@ ECHO %configurationName% IF "%configurationName%"=="Debug" GOTO OnDebug :OnDebug -taskkill /f /fi "pid gt 0" /im 3dsmax.exe +taskkill /im 3dsmax.exe /f /fi "STATUS eq RUNNING" pause From 587c394168be3dc284e66872daacefc5d4d53bdf Mon Sep 17 00:00:00 2001 From: elpie89 Date: Tue, 21 May 2019 11:54:22 +0200 Subject: [PATCH 3/6] last backslash added if need during export, to avoid manual user error when the path is written manually --- 3ds Max/Max2Babylon/Forms/ExporterForm.cs | 3 ++- 3ds Max/Max2Babylon/Tools/Tools.cs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/3ds Max/Max2Babylon/Forms/ExporterForm.cs b/3ds Max/Max2Babylon/Forms/ExporterForm.cs index bba7bccc..a3a02dcb 100644 --- a/3ds Max/Max2Babylon/Forms/ExporterForm.cs +++ b/3ds Max/Max2Babylon/Forms/ExporterForm.cs @@ -113,7 +113,8 @@ private void btnTextureBrowse_Click(object sender, EventArgs e) MessageBox.Show("WARNING: folderPath should be below model file path"); } - txtTextureName.Text = Tools.FormatPath(folderBrowserDialog1.SelectedPath + "\\"); + txtTextureName.Text = Tools.FormatPath(folderBrowserDialog1.SelectedPath); + } } diff --git a/3ds Max/Max2Babylon/Tools/Tools.cs b/3ds Max/Max2Babylon/Tools/Tools.cs index 585a83a8..103881ef 100644 --- a/3ds Max/Max2Babylon/Tools/Tools.cs +++ b/3ds Max/Max2Babylon/Tools/Tools.cs @@ -1208,6 +1208,12 @@ public static bool IsBelowModelPath(string folderPath,string modelPath) public static string GetPathRelativeToModel(string folderPath, string modelPath) { Uri path1 = new Uri(modelPath); + + if (!folderPath.EndsWith("\\")) + { + folderPath += "\\"; + } + Uri path2 = new Uri(folderPath); Uri diff = path1.MakeRelativeUri(path2); return diff.OriginalString; From 9eca45c3503e341b5f087c7fc0a8608d779071b0 Mon Sep 17 00:00:00 2001 From: elpie89 Date: Thu, 23 May 2019 16:29:47 +0200 Subject: [PATCH 4/6] fix file path --- 3ds Max/Max2Babylon/Tools/Tools.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/3ds Max/Max2Babylon/Tools/Tools.cs b/3ds Max/Max2Babylon/Tools/Tools.cs index 103881ef..2a585c70 100644 --- a/3ds Max/Max2Babylon/Tools/Tools.cs +++ b/3ds Max/Max2Babylon/Tools/Tools.cs @@ -1155,7 +1155,8 @@ public static string FormatPath(string absolutePath) } //wrap the part of path relative to user project folder around () - return string.Format("({0})\\{1}",dirName, absolutePath.TrimStart(dirName.ToCharArray())); + string relativePath = absolutePath.Remove(0, dirName.Length); + return string.Format(@"({0}){1}",dirName, relativePath); } public static string RelativePathStore(string path) @@ -1173,7 +1174,7 @@ public static string RelativePathStore(string path) return path; } - return path.TrimStart(dirName.ToCharArray()); + return path.Remove(0,dirName.Length); } public static string ResolveRelativePath(string path) From 7986b065954531b9e4034dc3d44392c5a5255b96 Mon Sep 17 00:00:00 2001 From: elpie89 Date: Thu, 23 May 2019 18:51:48 +0200 Subject: [PATCH 5/6] is path rooted removed to custom control --- 3ds Max/Max2Babylon/Tools/Tools.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3ds Max/Max2Babylon/Tools/Tools.cs b/3ds Max/Max2Babylon/Tools/Tools.cs index 2a585c70..1f80d908 100644 --- a/3ds Max/Max2Babylon/Tools/Tools.cs +++ b/3ds Max/Max2Babylon/Tools/Tools.cs @@ -1179,7 +1179,7 @@ public static string RelativePathStore(string path) public static string ResolveRelativePath(string path) { - if (string.IsNullOrWhiteSpace(Loader.Core.CurFilePath)) + if (string.IsNullOrEmpty(Loader.Core.CurFilePath)) { return path; } @@ -1187,12 +1187,12 @@ public static string ResolveRelativePath(string path) string dirName = Loader.Core.GetDir((int)MaxDirectory.ProjectFolder); - if(Path.IsPathRooted(path)) + if(!path.StartsWith("\\")) { return path; } - return string.Format("({0})\\{1}", dirName, path); + return string.Format(@"({0}){1}", dirName, path); } public static bool IsBelowModelPath(string folderPath,string modelPath) From 593c0a598dec5447b9b7972f3296faa292e10efc Mon Sep 17 00:00:00 2001 From: elpie89 Date: Wed, 5 Jun 2019 15:20:02 +0200 Subject: [PATCH 6/6] resolved conflct on exportitem with multiexport button a warnign message prevent user that texture cannot be exported with multiexport button --- 3ds Max/Max2Babylon/Forms/ExporterForm.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/3ds Max/Max2Babylon/Forms/ExporterForm.cs b/3ds Max/Max2Babylon/Forms/ExporterForm.cs index a3a02dcb..f8859f98 100644 --- a/3ds Max/Max2Babylon/Forms/ExporterForm.cs +++ b/3ds Max/Max2Babylon/Forms/ExporterForm.cs @@ -132,7 +132,7 @@ private async Task DoExport(ExportItemList exportItemList) { if (!item.Selected) continue; - allSucceeded = allSucceeded && await DoExport(item, false); + allSucceeded = allSucceeded && await DoExport(item,true, false); if (exporter.IsCancelled) break; @@ -141,7 +141,7 @@ private async Task DoExport(ExportItemList exportItemList) return allSucceeded; } - private async Task DoExport(ExportItem exportItem, bool clearLogs = true) + private async Task DoExport(ExportItem exportItem, bool multiExport = false,bool clearLogs = true) { Tools.UpdateCheckBox(chkManifest, Loader.Core.RootNode, "babylonjs_generatemanifest"); Tools.UpdateCheckBox(chkWriteTextures, Loader.Core.RootNode, "babylonjs_writetextures"); @@ -232,9 +232,10 @@ private async Task DoExport(ExportItem exportItem, bool clearLogs = true) bool success = true; try { + string modelAbsolutePath = multiExport ? exportItem.ExportFilePathAbsolute : Tools.UnformatPath(txtModelName.Text); ExportParameters exportParameters = new ExportParameters { - outputPath = Tools.UnformatPath(txtModelName.Text), + outputPath = modelAbsolutePath, textureFolder = Tools.UnformatPath(txtTextureName.Text), outputFormat = comboOutputFormat.SelectedItem.ToString(), scaleFactor = txtScaleFactor.Text, @@ -479,6 +480,12 @@ private async void butMultiExport_Click(object sender, EventArgs e) } else if(numLoadedItems > 0) { + if (chkWriteTextures.Checked || chkOverwriteTextures.Checked) + { + MessageBox.Show("Cannot write textures with Multi-File Export"); + return; + } + await DoExport(exportItemList); } }