From e7c5976f7cf1c340dc7d75c389d1c95be16a1684 Mon Sep 17 00:00:00 2001 From: Perfare Date: Tue, 13 Nov 2018 01:07:24 +0800 Subject: [PATCH] Add scaleFactor option --- AssetStudio/ExportOptions.Designer.cs | 80 +++++++++++++++------ AssetStudio/ExportOptions.cs | 6 +- AssetStudio/Properties/Settings.Designer.cs | 18 ++++- AssetStudio/Properties/Settings.settings | 5 +- AssetStudio/StudioClasses/Exporter.cs | 5 +- AssetStudio/app.config | 5 +- AssetStudioFBX/AssetStudioFBX.h | 10 +-- AssetStudioFBX/AssetStudioFBXExporter.cpp | 27 +++---- 8 files changed, 107 insertions(+), 49 deletions(-) diff --git a/AssetStudio/ExportOptions.Designer.cs b/AssetStudio/ExportOptions.Designer.cs index f2190d5..692e0e6 100644 --- a/AssetStudio/ExportOptions.Designer.cs +++ b/AssetStudio/ExportOptions.Designer.cs @@ -38,6 +38,8 @@ this.tobmp = new System.Windows.Forms.RadioButton(); this.converttexture = new System.Windows.Forms.CheckBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.scaleFactor = new System.Windows.Forms.NumericUpDown(); + this.label5 = new System.Windows.Forms.Label(); this.fbxFormat = new System.Windows.Forms.ComboBox(); this.label4 = new System.Windows.Forms.Label(); this.fbxVersion = new System.Windows.Forms.ComboBox(); @@ -50,17 +52,18 @@ this.filterPrecision = new System.Windows.Forms.NumericUpDown(); this.allBones = new System.Windows.Forms.CheckBox(); this.allFrames = new System.Windows.Forms.CheckBox(); - this.EulerFilter = new System.Windows.Forms.CheckBox(); + this.eulerFilter = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.scaleFactor)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.boneSize)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.filterPrecision)).BeginInit(); this.SuspendLayout(); // // OKbutton // - this.OKbutton.Location = new System.Drawing.Point(321, 240); + this.OKbutton.Location = new System.Drawing.Point(321, 267); this.OKbutton.Name = "OKbutton"; this.OKbutton.Size = new System.Drawing.Size(75, 21); this.OKbutton.TabIndex = 6; @@ -71,7 +74,7 @@ // Cancel // this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(402, 240); + this.Cancel.Location = new System.Drawing.Point(402, 267); this.Cancel.Name = "Cancel"; this.Cancel.Size = new System.Drawing.Size(75, 21); this.Cancel.TabIndex = 7; @@ -161,6 +164,8 @@ // groupBox2 // this.groupBox2.AutoSize = true; + this.groupBox2.Controls.Add(this.scaleFactor); + this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.fbxFormat); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.fbxVersion); @@ -173,14 +178,42 @@ this.groupBox2.Controls.Add(this.filterPrecision); this.groupBox2.Controls.Add(this.allBones); this.groupBox2.Controls.Add(this.allFrames); - this.groupBox2.Controls.Add(this.EulerFilter); + this.groupBox2.Controls.Add(this.eulerFilter); this.groupBox2.Location = new System.Drawing.Point(12, 12); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(214, 249); + this.groupBox2.Size = new System.Drawing.Size(214, 276); this.groupBox2.TabIndex = 11; this.groupBox2.TabStop = false; this.groupBox2.Text = "Fbx"; // + // scaleFactor + // + this.scaleFactor.DecimalPlaces = 2; + this.scaleFactor.Increment = new decimal(new int[] { + 1, + 0, + 0, + 131072}); + this.scaleFactor.Location = new System.Drawing.Point(83, 155); + this.scaleFactor.Name = "scaleFactor"; + this.scaleFactor.Size = new System.Drawing.Size(60, 21); + this.scaleFactor.TabIndex = 20; + this.scaleFactor.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.scaleFactor.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 157); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(71, 12); + this.label5.TabIndex = 19; + this.label5.Text = "ScaleFactor"; + // // fbxFormat // this.fbxFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -188,7 +221,7 @@ this.fbxFormat.Items.AddRange(new object[] { "Binary", "Ascii"}); - this.fbxFormat.Location = new System.Drawing.Point(75, 180); + this.fbxFormat.Location = new System.Drawing.Point(75, 207); this.fbxFormat.Name = "fbxFormat"; this.fbxFormat.Size = new System.Drawing.Size(61, 20); this.fbxFormat.TabIndex = 18; @@ -196,7 +229,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(4, 183); + this.label4.Location = new System.Drawing.Point(4, 210); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(59, 12); this.label4.TabIndex = 17; @@ -213,7 +246,7 @@ "7.3", "7.4", "7.5"}); - this.fbxVersion.Location = new System.Drawing.Point(75, 209); + this.fbxVersion.Location = new System.Drawing.Point(75, 236); this.fbxVersion.Name = "fbxVersion"; this.fbxVersion.Size = new System.Drawing.Size(47, 20); this.fbxVersion.TabIndex = 16; @@ -221,7 +254,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(4, 212); + this.label3.Location = new System.Drawing.Point(4, 239); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(65, 12); this.label3.TabIndex = 15; @@ -230,7 +263,7 @@ // flatInbetween // this.flatInbetween.AutoSize = true; - this.flatInbetween.Location = new System.Drawing.Point(6, 155); + this.flatInbetween.Location = new System.Drawing.Point(6, 182); this.flatInbetween.Name = "flatInbetween"; this.flatInbetween.Size = new System.Drawing.Size(102, 16); this.flatInbetween.TabIndex = 12; @@ -319,17 +352,17 @@ this.allFrames.Text = "AllFrames"; this.allFrames.UseVisualStyleBackColor = true; // - // EulerFilter + // eulerFilter // - this.EulerFilter.AutoSize = true; - this.EulerFilter.Checked = true; - this.EulerFilter.CheckState = System.Windows.Forms.CheckState.Checked; - this.EulerFilter.Location = new System.Drawing.Point(6, 20); - this.EulerFilter.Name = "EulerFilter"; - this.EulerFilter.Size = new System.Drawing.Size(90, 16); - this.EulerFilter.TabIndex = 3; - this.EulerFilter.Text = "EulerFilter"; - this.EulerFilter.UseVisualStyleBackColor = true; + this.eulerFilter.AutoSize = true; + this.eulerFilter.Checked = true; + this.eulerFilter.CheckState = System.Windows.Forms.CheckState.Checked; + this.eulerFilter.Location = new System.Drawing.Point(6, 20); + this.eulerFilter.Name = "eulerFilter"; + this.eulerFilter.Size = new System.Drawing.Size(90, 16); + this.eulerFilter.TabIndex = 3; + this.eulerFilter.Text = "EulerFilter"; + this.eulerFilter.UseVisualStyleBackColor = true; // // ExportOptions // @@ -337,7 +370,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(490, 275); + this.ClientSize = new System.Drawing.Size(490, 301); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.Cancel); @@ -356,6 +389,7 @@ this.panel1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.scaleFactor)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.boneSize)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.filterPrecision)).EndInit(); this.ResumeLayout(false); @@ -382,10 +416,12 @@ private System.Windows.Forms.NumericUpDown filterPrecision; private System.Windows.Forms.CheckBox allBones; private System.Windows.Forms.CheckBox allFrames; - private System.Windows.Forms.CheckBox EulerFilter; + private System.Windows.Forms.CheckBox eulerFilter; private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox fbxVersion; private System.Windows.Forms.ComboBox fbxFormat; private System.Windows.Forms.Label label4; + private System.Windows.Forms.NumericUpDown scaleFactor; + private System.Windows.Forms.Label label5; } } \ No newline at end of file diff --git a/AssetStudio/ExportOptions.cs b/AssetStudio/ExportOptions.cs index a3af436..2b6ef08 100644 --- a/AssetStudio/ExportOptions.cs +++ b/AssetStudio/ExportOptions.cs @@ -26,12 +26,13 @@ namespace AssetStudio break; } } - EulerFilter.Checked = (bool)Properties.Settings.Default["EulerFilter"]; + eulerFilter.Checked = (bool)Properties.Settings.Default["eulerFilter"]; filterPrecision.Value = (decimal)Properties.Settings.Default["filterPrecision"]; allFrames.Checked = (bool)Properties.Settings.Default["allFrames"]; allBones.Checked = (bool)Properties.Settings.Default["allBones"]; skins.Checked = (bool)Properties.Settings.Default["skins"]; boneSize.Value = (decimal)Properties.Settings.Default["boneSize"]; + scaleFactor.Value = (decimal)Properties.Settings.Default["scaleFactor"]; flatInbetween.Checked = (bool)Properties.Settings.Default["flatInbetween"]; fbxVersion.SelectedIndex = (int)Properties.Settings.Default["fbxVersion"]; fbxFormat.SelectedIndex = (int)Properties.Settings.Default["fbxFormat"]; @@ -55,12 +56,13 @@ namespace AssetStudio break; } } - Properties.Settings.Default["EulerFilter"] = EulerFilter.Checked; + Properties.Settings.Default["eulerFilter"] = eulerFilter.Checked; Properties.Settings.Default["filterPrecision"] = filterPrecision.Value; Properties.Settings.Default["allFrames"] = allFrames.Checked; Properties.Settings.Default["allBones"] = allBones.Checked; Properties.Settings.Default["skins"] = skins.Checked; Properties.Settings.Default["boneSize"] = boneSize.Value; + Properties.Settings.Default["scaleFactor"] = scaleFactor.Value; Properties.Settings.Default["flatInbetween"] = flatInbetween.Checked; Properties.Settings.Default["fbxVersion"] = fbxVersion.SelectedIndex; Properties.Settings.Default["fbxFormat"] = fbxFormat.SelectedIndex; diff --git a/AssetStudio/Properties/Settings.Designer.cs b/AssetStudio/Properties/Settings.Designer.cs index ba9219b..7563169 100644 --- a/AssetStudio/Properties/Settings.Designer.cs +++ b/AssetStudio/Properties/Settings.Designer.cs @@ -134,12 +134,12 @@ namespace AssetStudio.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool EulerFilter { + public bool eulerFilter { get { - return ((bool)(this["EulerFilter"])); + return ((bool)(this["eulerFilter"])); } set { - this["EulerFilter"] = value; + this["eulerFilter"] = value; } } @@ -238,5 +238,17 @@ namespace AssetStudio.Properties { this["fbxFormat"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1")] + public decimal scaleFactor { + get { + return ((decimal)(this["scaleFactor"])); + } + set { + this["scaleFactor"] = value; + } + } } } diff --git a/AssetStudio/Properties/Settings.settings b/AssetStudio/Properties/Settings.settings index 72c57e6..e5d5fa9 100644 --- a/AssetStudio/Properties/Settings.settings +++ b/AssetStudio/Properties/Settings.settings @@ -29,7 +29,7 @@ False - + True @@ -56,5 +56,8 @@ 0 + + 1 + \ No newline at end of file diff --git a/AssetStudio/StudioClasses/Exporter.cs b/AssetStudio/StudioClasses/Exporter.cs index 7c8ccc0..72d48d4 100644 --- a/AssetStudio/StudioClasses/Exporter.cs +++ b/AssetStudio/StudioClasses/Exporter.cs @@ -308,16 +308,17 @@ namespace AssetStudio private static bool ModelConverter(ModelConverter convert, string exportPath) { - var EulerFilter = (bool)Properties.Settings.Default["EulerFilter"]; + var eulerFilter = (bool)Properties.Settings.Default["eulerFilter"]; var filterPrecision = (float)(decimal)Properties.Settings.Default["filterPrecision"]; var allFrames = (bool)Properties.Settings.Default["allFrames"]; var allBones = (bool)Properties.Settings.Default["allBones"]; var skins = (bool)Properties.Settings.Default["skins"]; var boneSize = (int)(decimal)Properties.Settings.Default["boneSize"]; + var scaleFactor = (float)(decimal)Properties.Settings.Default["scaleFactor"]; var flatInbetween = (bool)Properties.Settings.Default["flatInbetween"]; var fbxVersion = (int)Properties.Settings.Default["fbxVersion"]; var fbxFormat = (int)Properties.Settings.Default["fbxFormat"]; - Fbx.Exporter.Export(exportPath, convert, EulerFilter, filterPrecision, allFrames, allBones, skins, boneSize, flatInbetween, fbxVersion, fbxFormat == 1); + Fbx.Exporter.Export(exportPath, convert, eulerFilter, filterPrecision, allFrames, allBones, skins, boneSize, scaleFactor, flatInbetween, fbxVersion, fbxFormat == 1); return true; } } diff --git a/AssetStudio/app.config b/AssetStudio/app.config index 9e7a7fd..0ca6853 100644 --- a/AssetStudio/app.config +++ b/AssetStudio/app.config @@ -34,7 +34,7 @@ False - + True @@ -61,6 +61,9 @@ 0 + + 1 + \ No newline at end of file diff --git a/AssetStudioFBX/AssetStudioFBX.h b/AssetStudioFBX/AssetStudioFBX.h index f3db69e..160b61c 100644 --- a/AssetStudioFBX/AssetStudioFBX.h +++ b/AssetStudioFBX/AssetStudioFBX.h @@ -48,8 +48,8 @@ namespace AssetStudio { ref class Exporter { public: - static void Export(String^ path, IImported^ imported, bool EulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, bool flatInbetween, int versionIndex, bool isAscii); - static void ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, int versionIndex, bool isAscii); + static void Export(String^ path, IImported^ imported, bool eulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, bool flatInbetween, int versionIndex, bool isAscii); + static void ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, float scaleFactor, int versionIndex, bool isAscii); private: HashSet^ frameNames; @@ -66,7 +66,7 @@ namespace AssetStudio { FbxArray* pTextures; FbxArray* pMeshNodes; - Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, int versionIndex, bool isAscii, bool normals); + Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, int versionIndex, bool isAscii, bool normals); ~Exporter(); void Exporter::LinkTexture(ImportedMaterial^ mat, int attIndex, FbxFileTexture* pTexture, FbxProperty& prop); @@ -77,8 +77,8 @@ namespace AssetStudio { void ExportFrame(FbxNode* pParentNode, ImportedFrame^ frame); void ExportMesh(FbxNode* pFrameNode, ImportedMesh^ meshList, bool normals); FbxFileTexture* ExportTexture(ImportedTexture^ matTex, FbxMesh* pMesh); - void ExportAnimations(bool EulerFilter, float filterValue, bool flatInbetween); - void ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* EulerFilter, float filterPrecision, bool flatInbetween); + void ExportAnimations(bool eulerFilter, float filterValue, bool flatInbetween); + void ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* eulerFilter, float filterPrecision, bool flatInbetween); void ExportMorphs(IImported^ imported, bool morphMask, bool flatInbetween); }; }; diff --git a/AssetStudioFBX/AssetStudioFBXExporter.cpp b/AssetStudioFBX/AssetStudioFBXExporter.cpp index 00d40dd..78a0120 100644 --- a/AssetStudioFBX/AssetStudioFBXExporter.cpp +++ b/AssetStudioFBX/AssetStudioFBXExporter.cpp @@ -4,7 +4,7 @@ namespace AssetStudio { - void Fbx::Exporter::Export(String^ path, IImported^ imported, bool EulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, bool flatInbetween, int versionIndex, bool isAscii) + void Fbx::Exporter::Export(String^ path, IImported^ imported, bool eulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, bool flatInbetween, int versionIndex, bool isAscii) { FileInfo^ file = gcnew FileInfo(path); DirectoryInfo^ dir = file->Directory; @@ -16,16 +16,16 @@ namespace AssetStudio Directory::SetCurrentDirectory(dir->FullName); path = Path::GetFileName(path); - Exporter^ exporter = gcnew Exporter(path, imported, allFrames, allBones, skins, boneSize, versionIndex, isAscii, true); + Exporter^ exporter = gcnew Exporter(path, imported, allFrames, allBones, skins, boneSize, scaleFactor, versionIndex, isAscii, true); exporter->ExportMorphs(imported, false, flatInbetween); - exporter->ExportAnimations(EulerFilter, filterPrecision, flatInbetween); + exporter->ExportAnimations(eulerFilter, filterPrecision, flatInbetween); exporter->pExporter->Export(exporter->pScene); delete exporter; Directory::SetCurrentDirectory(currentDir); } - void Fbx::Exporter::ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, int versionIndex, bool isAscii) + void Fbx::Exporter::ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, float scaleFactor, int versionIndex, bool isAscii) { FileInfo^ file = gcnew FileInfo(path); DirectoryInfo^ dir = file->Directory; @@ -37,7 +37,7 @@ namespace AssetStudio Directory::SetCurrentDirectory(dir->FullName); path = Path::GetFileName(path); - Exporter^ exporter = gcnew Exporter(path, imported, false, true, skins, boneSize, versionIndex, isAscii, false); + Exporter^ exporter = gcnew Exporter(path, imported, false, true, skins, boneSize, scaleFactor, versionIndex, isAscii, false); exporter->ExportMorphs(imported, morphMask, flatInbetween); exporter->pExporter->Export(exporter->pScene); delete exporter; @@ -45,7 +45,7 @@ namespace AssetStudio Directory::SetCurrentDirectory(currentDir); } - Fbx::Exporter::Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, int versionIndex, bool isAscii, bool normals) + Fbx::Exporter::Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, int versionIndex, bool isAscii, bool normals) { this->imported = imported; exportSkins = skins; @@ -72,6 +72,7 @@ namespace AssetStudio IOS_REF.SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, true); FbxGlobalSettings& globalSettings = pScene->GetGlobalSettings(); + globalSettings.SetSystemUnit(FbxSystemUnit(scaleFactor)); cDest = StringToCharArray(path); pExporter = FbxExporter::Create(pScene, ""); @@ -707,7 +708,7 @@ namespace AssetStudio prop.ConnectSrcObject(pTexture); } - void Fbx::Exporter::ExportAnimations(bool EulerFilter, float filterPrecision, bool flatInbetween) + void Fbx::Exporter::ExportAnimations(bool eulerFilter, float filterPrecision, bool flatInbetween) { auto importedAnimationList = imported->AnimationList; if (importedAnimationList == nullptr) @@ -715,7 +716,7 @@ namespace AssetStudio return; } - FbxAnimCurveFilterUnroll* lFilter = EulerFilter ? new FbxAnimCurveFilterUnroll() : NULL; + FbxAnimCurveFilterUnroll* lFilter = eulerFilter ? new FbxAnimCurveFilterUnroll() : NULL; for (int i = 0; i < importedAnimationList->Count; i++) { @@ -738,7 +739,7 @@ namespace AssetStudio } } - void Fbx::Exporter::ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* EulerFilter, float filterPrecision, bool flatInbetween) + void Fbx::Exporter::ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* eulerFilter, float filterPrecision, bool flatInbetween) { List^ pAnimationList = parser->TrackList; @@ -828,15 +829,15 @@ namespace AssetStudio lCurveTY->KeyModifyEnd(); lCurveTZ->KeyModifyEnd(); - if (EulerFilter) + if (eulerFilter) { FbxAnimCurve* lCurve[3]; lCurve[0] = lCurveRX; lCurve[1] = lCurveRY; lCurve[2] = lCurveRZ; - EulerFilter->Reset(); - EulerFilter->SetQualityTolerance(filterPrecision); - EulerFilter->Apply(lCurve, 3); + eulerFilter->Reset(); + eulerFilter->SetQualityTolerance(filterPrecision); + eulerFilter->Apply(lCurve, 3); } if (keyframeList->Curve->Count > 0)