Add scaleFactor option

This commit is contained in:
Perfare 2018-11-13 01:07:24 +08:00
parent 798a63e33c
commit e7c5976f7c
8 changed files with 107 additions and 49 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}
}
}
}

View File

@ -29,7 +29,7 @@
<Setting Name="displayOriginalName" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="EulerFilter" Type="System.Boolean" Scope="User">
<Setting Name="eulerFilter" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="filterPrecision" Type="System.Decimal" Scope="User">
@ -56,5 +56,8 @@
<Setting Name="fbxFormat" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="scaleFactor" Type="System.Decimal" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -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;
}
}

View File

@ -34,7 +34,7 @@
<setting name="displayOriginalName" serializeAs="String">
<value>False</value>
</setting>
<setting name="EulerFilter" serializeAs="String">
<setting name="eulerFilter" serializeAs="String">
<value>True</value>
</setting>
<setting name="filterPrecision" serializeAs="String">
@ -61,6 +61,9 @@
<setting name="fbxFormat" serializeAs="String">
<value>0</value>
</setting>
<setting name="scaleFactor" serializeAs="String">
<value>1</value>
</setting>
</AssetStudio.Properties.Settings>
</userSettings>
</configuration>

View File

@ -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<String^>^ frameNames;
@ -66,7 +66,7 @@ namespace AssetStudio {
FbxArray<FbxFileTexture*>* pTextures;
FbxArray<FbxNode*>* 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);
};
};

View File

@ -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<ImportedAnimationKeyframedTrack^>^ 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)