This commit is contained in:
Perfare 2018-09-13 20:52:17 +08:00
parent a233af5b8f
commit 310c165824
11 changed files with 103 additions and 90 deletions

View File

@ -46,6 +46,7 @@
this.assetGroupOptions = new System.Windows.Forms.ToolStripComboBox(); this.assetGroupOptions = new System.Windows.Forms.ToolStripComboBox();
this.showExpOpt = new System.Windows.Forms.ToolStripMenuItem(); this.showExpOpt = new System.Windows.Forms.ToolStripMenuItem();
this.modelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.modelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.exportallobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportallobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportallobjectssplitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportallobjectssplitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportselectedobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportselectedobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -113,7 +114,6 @@
this.exportobjectswithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportobjectswithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.jumpToSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.jumpToSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
@ -263,7 +263,7 @@
// assetGroupOptions // assetGroupOptions
// //
this.assetGroupOptions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.assetGroupOptions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.assetGroupOptions.FlatStyle = System.Windows.Forms.FlatStyle.System; this.assetGroupOptions.FlatStyle = System.Windows.Forms.FlatStyle.Standard;
this.assetGroupOptions.Items.AddRange(new object[] { this.assetGroupOptions.Items.AddRange(new object[] {
"Group by type", "Group by type",
"Group by source file", "Group by source file",
@ -294,24 +294,31 @@
this.modelToolStripMenuItem.Size = new System.Drawing.Size(58, 21); this.modelToolStripMenuItem.Size = new System.Drawing.Size(58, 21);
this.modelToolStripMenuItem.Text = "Model"; this.modelToolStripMenuItem.Text = "Model";
// //
// toolStripMenuItem3
//
this.toolStripMenuItem3.Enabled = false;
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(332, 22);
this.toolStripMenuItem3.Text = "-----------------------Ascii-----------------------";
//
// exportallobjectsMenuItem // exportallobjectsMenuItem
// //
this.exportallobjectsMenuItem.Name = "exportallobjectsMenuItem"; this.exportallobjectsMenuItem.Name = "exportallobjectsMenuItem";
this.exportallobjectsMenuItem.Size = new System.Drawing.Size(323, 22); this.exportallobjectsMenuItem.Size = new System.Drawing.Size(332, 22);
this.exportallobjectsMenuItem.Text = "Export all objects"; this.exportallobjectsMenuItem.Text = "Export all objects";
this.exportallobjectsMenuItem.Click += new System.EventHandler(this.ExportObjects_Click); this.exportallobjectsMenuItem.Click += new System.EventHandler(this.ExportObjects_Click);
// //
// exportallobjectssplitToolStripMenuItem // exportallobjectssplitToolStripMenuItem
// //
this.exportallobjectssplitToolStripMenuItem.Name = "exportallobjectssplitToolStripMenuItem"; this.exportallobjectssplitToolStripMenuItem.Name = "exportallobjectssplitToolStripMenuItem";
this.exportallobjectssplitToolStripMenuItem.Size = new System.Drawing.Size(323, 22); this.exportallobjectssplitToolStripMenuItem.Size = new System.Drawing.Size(332, 22);
this.exportallobjectssplitToolStripMenuItem.Text = "Export all objects (split)"; this.exportallobjectssplitToolStripMenuItem.Text = "Export all objects (split)";
this.exportallobjectssplitToolStripMenuItem.Click += new System.EventHandler(this.exportallobjectssplitToolStripMenuItem_Click); this.exportallobjectssplitToolStripMenuItem.Click += new System.EventHandler(this.exportallobjectssplitToolStripMenuItem_Click);
// //
// exportselectedobjectsMenuItem // exportselectedobjectsMenuItem
// //
this.exportselectedobjectsMenuItem.Name = "exportselectedobjectsMenuItem"; this.exportselectedobjectsMenuItem.Name = "exportselectedobjectsMenuItem";
this.exportselectedobjectsMenuItem.Size = new System.Drawing.Size(323, 22); this.exportselectedobjectsMenuItem.Size = new System.Drawing.Size(332, 22);
this.exportselectedobjectsMenuItem.Text = "Export selected objects"; this.exportselectedobjectsMenuItem.Text = "Export selected objects";
this.exportselectedobjectsMenuItem.Click += new System.EventHandler(this.ExportObjects_Click); this.exportselectedobjectsMenuItem.Click += new System.EventHandler(this.ExportObjects_Click);
// //
@ -325,21 +332,21 @@
// exportAllObjectssplitToolStripMenuItem1 // exportAllObjectssplitToolStripMenuItem1
// //
this.exportAllObjectssplitToolStripMenuItem1.Name = "exportAllObjectssplitToolStripMenuItem1"; this.exportAllObjectssplitToolStripMenuItem1.Name = "exportAllObjectssplitToolStripMenuItem1";
this.exportAllObjectssplitToolStripMenuItem1.Size = new System.Drawing.Size(323, 22); this.exportAllObjectssplitToolStripMenuItem1.Size = new System.Drawing.Size(332, 22);
this.exportAllObjectssplitToolStripMenuItem1.Text = "Export all objects (split)"; this.exportAllObjectssplitToolStripMenuItem1.Text = "Export all objects (split)";
this.exportAllObjectssplitToolStripMenuItem1.Click += new System.EventHandler(this.exportAllObjectssplitToolStripMenuItem1_Click); this.exportAllObjectssplitToolStripMenuItem1.Click += new System.EventHandler(this.exportAllObjectssplitToolStripMenuItem1_Click);
// //
// exportSelectedObjectsToolStripMenuItem // exportSelectedObjectsToolStripMenuItem
// //
this.exportSelectedObjectsToolStripMenuItem.Name = "exportSelectedObjectsToolStripMenuItem"; this.exportSelectedObjectsToolStripMenuItem.Name = "exportSelectedObjectsToolStripMenuItem";
this.exportSelectedObjectsToolStripMenuItem.Size = new System.Drawing.Size(323, 22); this.exportSelectedObjectsToolStripMenuItem.Size = new System.Drawing.Size(332, 22);
this.exportSelectedObjectsToolStripMenuItem.Text = "Export selected objects"; this.exportSelectedObjectsToolStripMenuItem.Text = "Export selected objects";
this.exportSelectedObjectsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedObjectsToolStripMenuItem_Click); this.exportSelectedObjectsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedObjectsToolStripMenuItem_Click);
// //
// exportSelectedObjectsWithAnimationClipToolStripMenuItem // exportSelectedObjectsWithAnimationClipToolStripMenuItem
// //
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Name = "exportSelectedObjectsWithAnimationClipToolStripMenuItem"; this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Name = "exportSelectedObjectsWithAnimationClipToolStripMenuItem";
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(323, 22); this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(332, 22);
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Text = "Export selected objects with AnimationClip"; this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Text = "Export selected objects with AnimationClip";
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportObjectswithAnimationClipMenuItem_Click); this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportObjectswithAnimationClipMenuItem_Click);
// //
@ -951,13 +958,6 @@
this.showOriginalFileToolStripMenuItem.Visible = false; this.showOriginalFileToolStripMenuItem.Visible = false;
this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click); this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click);
// //
// toolStripMenuItem3
//
this.toolStripMenuItem3.Enabled = false;
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(332, 22);
this.toolStripMenuItem3.Text = "-----------------------Ascii-----------------------";
//
// AssetStudioForm // AssetStudioForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

View File

@ -120,9 +120,6 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>312, 17</value> <value>312, 17</value>
</metadata> </metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>432, 17</value>
</metadata>
<data name="fontPreviewBox.Text" xml:space="preserve"> <data name="fontPreviewBox.Text" xml:space="preserve">
<value>abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ <value>abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ
1234567890.:,;'\"(!?)+-*/= 1234567890.:,;'\"(!?)+-*/=
@ -141,6 +138,9 @@ The quick brown fox jumps over the lazy dog. 1234567890
The quick brown fox jumps over the lazy dog. 1234567890</value> The quick brown fox jumps over the lazy dog. 1234567890</value>
</data> </data>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>432, 17</value>
</metadata>
<metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>553, 17</value> <value>553, 17</value>
</metadata> </metadata>

View File

@ -48,8 +48,9 @@
this.tobmp = new System.Windows.Forms.RadioButton(); this.tobmp = new System.Windows.Forms.RadioButton();
this.converttexture = new System.Windows.Forms.CheckBox(); this.converttexture = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.fbxVersion = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.FixRotation = new System.Windows.Forms.CheckBox(); this.FixRotation = new System.Windows.Forms.CheckBox();
this.compatibility = new System.Windows.Forms.CheckBox();
this.flatInbetween = new System.Windows.Forms.CheckBox(); this.flatInbetween = new System.Windows.Forms.CheckBox();
this.boneSize = new System.Windows.Forms.NumericUpDown(); this.boneSize = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
@ -300,8 +301,9 @@
// groupBox2 // groupBox2
// //
this.groupBox2.AutoSize = true; this.groupBox2.AutoSize = true;
this.groupBox2.Controls.Add(this.fbxVersion);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.FixRotation); this.groupBox2.Controls.Add(this.FixRotation);
this.groupBox2.Controls.Add(this.compatibility);
this.groupBox2.Controls.Add(this.flatInbetween); this.groupBox2.Controls.Add(this.flatInbetween);
this.groupBox2.Controls.Add(this.boneSize); this.groupBox2.Controls.Add(this.boneSize);
this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.label2);
@ -313,11 +315,35 @@
this.groupBox2.Controls.Add(this.EulerFilter); this.groupBox2.Controls.Add(this.EulerFilter);
this.groupBox2.Location = new System.Drawing.Point(265, 12); this.groupBox2.Location = new System.Drawing.Point(265, 12);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(214, 235); this.groupBox2.Size = new System.Drawing.Size(214, 240);
this.groupBox2.TabIndex = 11; this.groupBox2.TabIndex = 11;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Fbx Binary"; this.groupBox2.Text = "Fbx Binary";
// //
// fbxVersion
//
this.fbxVersion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.fbxVersion.FormattingEnabled = true;
this.fbxVersion.Items.AddRange(new object[] {
"6.1",
"7.1",
"7.2",
"7.3",
"7.4"});
this.fbxVersion.Location = new System.Drawing.Point(77, 200);
this.fbxVersion.Name = "fbxVersion";
this.fbxVersion.Size = new System.Drawing.Size(47, 20);
this.fbxVersion.TabIndex = 16;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 203);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 12);
this.label3.TabIndex = 15;
this.label3.Text = "FBXVersion";
//
// FixRotation // FixRotation
// //
this.FixRotation.AutoSize = true; this.FixRotation.AutoSize = true;
@ -330,16 +356,6 @@
this.FixRotation.Text = "FixRotation"; this.FixRotation.Text = "FixRotation";
this.FixRotation.UseVisualStyleBackColor = true; this.FixRotation.UseVisualStyleBackColor = true;
// //
// compatibility
//
this.compatibility.AutoSize = true;
this.compatibility.Location = new System.Drawing.Point(6, 199);
this.compatibility.Name = "compatibility";
this.compatibility.Size = new System.Drawing.Size(138, 16);
this.compatibility.TabIndex = 13;
this.compatibility.Text = "Compatibility (6.1)";
this.compatibility.UseVisualStyleBackColor = true;
//
// flatInbetween // flatInbetween
// //
this.flatInbetween.AutoSize = true; this.flatInbetween.AutoSize = true;
@ -502,7 +518,6 @@
private System.Windows.Forms.CheckBox convertAudio; private System.Windows.Forms.CheckBox convertAudio;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.CheckBox compatibility;
private System.Windows.Forms.CheckBox flatInbetween; private System.Windows.Forms.CheckBox flatInbetween;
private System.Windows.Forms.NumericUpDown boneSize; private System.Windows.Forms.NumericUpDown boneSize;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
@ -513,5 +528,7 @@
private System.Windows.Forms.CheckBox allFrames; private System.Windows.Forms.CheckBox allFrames;
private System.Windows.Forms.CheckBox EulerFilter; private System.Windows.Forms.CheckBox EulerFilter;
private System.Windows.Forms.CheckBox FixRotation; private System.Windows.Forms.CheckBox FixRotation;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox fbxVersion;
} }
} }

View File

@ -42,7 +42,7 @@ namespace AssetStudio
skins.Checked = (bool)Properties.Settings.Default["skins"]; skins.Checked = (bool)Properties.Settings.Default["skins"];
boneSize.Value = (decimal)Properties.Settings.Default["boneSize"]; boneSize.Value = (decimal)Properties.Settings.Default["boneSize"];
flatInbetween.Checked = (bool)Properties.Settings.Default["flatInbetween"]; flatInbetween.Checked = (bool)Properties.Settings.Default["flatInbetween"];
compatibility.Checked = (bool)Properties.Settings.Default["compatibility"]; fbxVersion.SelectedIndex = (int)Properties.Settings.Default["fbxVersion"];
} }
private void exportOpnions_CheckedChanged(object sender, EventArgs e) private void exportOpnions_CheckedChanged(object sender, EventArgs e)
@ -77,7 +77,7 @@ namespace AssetStudio
Properties.Settings.Default["skins"] = skins.Checked; Properties.Settings.Default["skins"] = skins.Checked;
Properties.Settings.Default["boneSize"] = boneSize.Value; Properties.Settings.Default["boneSize"] = boneSize.Value;
Properties.Settings.Default["flatInbetween"] = flatInbetween.Checked; Properties.Settings.Default["flatInbetween"] = flatInbetween.Checked;
Properties.Settings.Default["compatibility"] = compatibility.Checked; Properties.Settings.Default["fbxVersion"] = fbxVersion.SelectedIndex;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();

View File

@ -301,13 +301,13 @@ namespace AssetStudio.Properties {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")] [global::System.Configuration.DefaultSettingValueAttribute("3")]
public bool compatibility { public int fbxVersion {
get { get {
return ((bool)(this["compatibility"])); return ((int)(this["fbxVersion"]));
} }
set { set {
this["compatibility"] = value; this["fbxVersion"] = value;
} }
} }

View File

@ -71,8 +71,8 @@
<Setting Name="flatInbetween" Type="System.Boolean" Scope="User"> <Setting Name="flatInbetween" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="compatibility" Type="System.Boolean" Scope="User"> <Setting Name="fbxVersion" Type="System.Int32" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">3</Value>
</Setting> </Setting>
<Setting Name="FixRotation" Type="System.Boolean" Scope="User"> <Setting Name="FixRotation" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>

View File

@ -353,8 +353,8 @@ namespace AssetStudio
var skins = (bool)Properties.Settings.Default["skins"]; var skins = (bool)Properties.Settings.Default["skins"];
var boneSize = (int)(decimal)Properties.Settings.Default["boneSize"]; var boneSize = (int)(decimal)Properties.Settings.Default["boneSize"];
var flatInbetween = (bool)Properties.Settings.Default["flatInbetween"]; var flatInbetween = (bool)Properties.Settings.Default["flatInbetween"];
var compatibility = (bool)Properties.Settings.Default["compatibility"]; var fbxVersion = (int)Properties.Settings.Default["fbxVersion"];
Fbx.Exporter.Export(exportPath, convert, EulerFilter, filterPrecision, allFrames, allBones, skins, boneSize, flatInbetween, compatibility); Fbx.Exporter.Export(exportPath, convert, EulerFilter, filterPrecision, allFrames, allBones, skins, boneSize, flatInbetween, fbxVersion);
return true; return true;
} }
} }

View File

@ -39,7 +39,13 @@ namespace AssetStudio
public ModelConverter(GameObject m_GameObject, List<AssetPreloadData> animationList) public ModelConverter(GameObject m_GameObject, List<AssetPreloadData> animationList)
{ {
InitWithGameObject(m_GameObject); if (assetsfileList.TryGetPD(m_GameObject.m_Animator, out var m_Animator))
{
var animator = new Animator(m_Animator);
InitWithAnimator(animator);
}
else
InitWithGameObject(m_GameObject);
foreach (var assetPreloadData in animationList) foreach (var assetPreloadData in animationList)
{ {
animationClipHashSet.Add(assetPreloadData); animationClipHashSet.Add(assetPreloadData);

View File

@ -76,8 +76,8 @@
<setting name="flatInbetween" serializeAs="String"> <setting name="flatInbetween" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="compatibility" serializeAs="String"> <setting name="fbxVersion" serializeAs="String">
<value>False</value> <value>3</value>
</setting> </setting>
<setting name="FixRotation" serializeAs="String"> <setting name="FixRotation" serializeAs="String">
<value>True</value> <value>True</value>

View File

@ -25,6 +25,15 @@ using namespace SharpDX;
} \ } \
} }
static char* FBXVersion[] =
{
FBX_2010_00_COMPATIBLE,
FBX_2011_00_COMPATIBLE,
FBX_2012_00_COMPATIBLE,
FBX_2013_00_COMPATIBLE,
FBX_2014_00_COMPATIBLE
};
namespace AssetStudio { namespace AssetStudio {
public ref class Fbx public ref class Fbx
@ -32,12 +41,14 @@ namespace AssetStudio {
public: public:
static Vector3 QuaternionToEuler(Quaternion q); static Vector3 QuaternionToEuler(Quaternion q);
static Quaternion EulerToQuaternion(Vector3 v); static Quaternion EulerToQuaternion(Vector3 v);
static char* StringToCharArray(String^ s);
static void Init(FbxManager** pSdkManager, FbxScene** pScene);
ref class Exporter ref class Exporter
{ {
public: public:
static void Export(String^ path, IImported^ imported, bool EulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, bool flatInbetween, bool compatibility); static void Export(String^ path, IImported^ imported, bool EulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, bool flatInbetween, int versionIndex);
static void ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, bool compatibility); static void ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, int versionIndex);
private: private:
HashSet<String^>^ frameNames; HashSet<String^>^ frameNames;
@ -54,11 +65,11 @@ namespace AssetStudio {
FbxArray<FbxFileTexture*>* pTextures; FbxArray<FbxFileTexture*>* pTextures;
FbxArray<FbxNode*>* pMeshNodes; FbxArray<FbxNode*>* pMeshNodes;
Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, int versionIndex, bool normals);
~Exporter(); ~Exporter();
void Fbx::Exporter::LinkTexture(ImportedMaterial^ mat, int attIndex, FbxFileTexture* pTexture, FbxProperty& prop);
void SetJointsNode(FbxNode* pNode, HashSet<String^>^ boneNames, bool allBones);
Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, bool compatibility, bool normals); void Exporter::LinkTexture(ImportedMaterial^ mat, int attIndex, FbxFileTexture* pTexture, FbxProperty& prop);
void SetJointsNode(FbxNode* pNode, HashSet<String^>^ boneNames, bool allBones);
HashSet<String^>^ SearchHierarchy(); HashSet<String^>^ SearchHierarchy();
void SearchHierarchy(ImportedFrame^ frame, HashSet<String^>^ exportFrames); void SearchHierarchy(ImportedFrame^ frame, HashSet<String^>^ exportFrames);
void SetJointsFromImportedMeshes(bool allBones); void SetJointsFromImportedMeshes(bool allBones);
@ -69,8 +80,5 @@ namespace AssetStudio {
void ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* EulerFilter, float filterPrecision, bool flatInbetween); void ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* EulerFilter, float filterPrecision, bool flatInbetween);
void ExportMorphs(IImported^ imported, bool morphMask, bool flatInbetween); void ExportMorphs(IImported^ imported, bool morphMask, bool flatInbetween);
}; };
static char* StringToCharArray(String^ s);
static void Init(FbxManager** pSdkManager, FbxScene** pScene);
}; };
} }

View File

@ -4,7 +4,7 @@
namespace AssetStudio namespace AssetStudio
{ {
void Fbx::Exporter::Export(String^ path, IImported^ imported, bool EulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, bool flatInbetween, bool compatibility) void Fbx::Exporter::Export(String^ path, IImported^ imported, bool EulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, bool flatInbetween, int versionIndex)
{ {
FileInfo^ file = gcnew FileInfo(path); FileInfo^ file = gcnew FileInfo(path);
DirectoryInfo^ dir = file->Directory; DirectoryInfo^ dir = file->Directory;
@ -16,7 +16,7 @@ namespace AssetStudio
Directory::SetCurrentDirectory(dir->FullName); Directory::SetCurrentDirectory(dir->FullName);
path = Path::GetFileName(path); path = Path::GetFileName(path);
Exporter^ exporter = gcnew Exporter(path, imported, allFrames, allBones, skins, boneSize, compatibility, true); Exporter^ exporter = gcnew Exporter(path, imported, allFrames, allBones, skins, boneSize, versionIndex, true);
exporter->ExportMorphs(imported, false, flatInbetween); exporter->ExportMorphs(imported, false, flatInbetween);
exporter->ExportAnimations(EulerFilter, filterPrecision, flatInbetween); exporter->ExportAnimations(EulerFilter, filterPrecision, flatInbetween);
exporter->pExporter->Export(exporter->pScene); exporter->pExporter->Export(exporter->pScene);
@ -25,7 +25,7 @@ namespace AssetStudio
Directory::SetCurrentDirectory(currentDir); Directory::SetCurrentDirectory(currentDir);
} }
void Fbx::Exporter::ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, bool compatibility) void Fbx::Exporter::ExportMorph(String^ path, IImported^ imported, bool morphMask, bool flatInbetween, bool skins, float boneSize, int versionIndex)
{ {
FileInfo^ file = gcnew FileInfo(path); FileInfo^ file = gcnew FileInfo(path);
DirectoryInfo^ dir = file->Directory; DirectoryInfo^ dir = file->Directory;
@ -37,7 +37,7 @@ namespace AssetStudio
Directory::SetCurrentDirectory(dir->FullName); Directory::SetCurrentDirectory(dir->FullName);
path = Path::GetFileName(path); path = Path::GetFileName(path);
Exporter^ exporter = gcnew Exporter(path, imported, false, true, skins, boneSize, compatibility, false); Exporter^ exporter = gcnew Exporter(path, imported, false, true, skins, boneSize, versionIndex, false);
exporter->ExportMorphs(imported, morphMask, flatInbetween); exporter->ExportMorphs(imported, morphMask, flatInbetween);
exporter->pExporter->Export(exporter->pScene); exporter->pExporter->Export(exporter->pScene);
delete exporter; delete exporter;
@ -45,7 +45,7 @@ namespace AssetStudio
Directory::SetCurrentDirectory(currentDir); Directory::SetCurrentDirectory(currentDir);
} }
Fbx::Exporter::Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, bool compatibility, bool normals) Fbx::Exporter::Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, int versionIndex, bool normals)
{ {
this->imported = imported; this->imported = imported;
exportSkins = skins; exportSkins = skins;
@ -63,24 +63,6 @@ namespace AssetStudio
pin_ptr<FbxScene*> pScenePin = &pScene; pin_ptr<FbxScene*> pScenePin = &pScene;
Init(pSdkManagerPin, pScenePin); Init(pSdkManagerPin, pScenePin);
cDest = Fbx::StringToCharArray(path);
pExporter = FbxExporter::Create(pScene, "");
int lFormatIndex, lFormatCount = pSdkManager->GetIOPluginRegistry()->GetWriterFormatCount();
for (lFormatIndex = 0; lFormatIndex < lFormatCount; lFormatIndex++)
{
if (pSdkManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex))
{
FbxString lDesc = FbxString(pSdkManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex));
if (lDesc.Find("binary") >= 0)
{
if (!compatibility || lDesc.Find("6.") >= 0)
{
break;
}
}
}
}
IOS_REF.SetBoolProp(EXP_FBX_MATERIAL, true); IOS_REF.SetBoolProp(EXP_FBX_MATERIAL, true);
IOS_REF.SetBoolProp(EXP_FBX_TEXTURE, true); IOS_REF.SetBoolProp(EXP_FBX_TEXTURE, true);
IOS_REF.SetBoolProp(EXP_FBX_EMBEDDED, false); IOS_REF.SetBoolProp(EXP_FBX_EMBEDDED, false);
@ -91,10 +73,13 @@ namespace AssetStudio
FbxGlobalSettings& globalSettings = pScene->GetGlobalSettings(); FbxGlobalSettings& globalSettings = pScene->GetGlobalSettings();
if (!pExporter->Initialize(cDest, lFormatIndex, pSdkManager->GetIOSettings())) cDest = StringToCharArray(path);
pExporter = FbxExporter::Create(pScene, "");
if (!pExporter->Initialize(cDest, 0, pSdkManager->GetIOSettings()))
{ {
throw gcnew Exception(gcnew String("Failed to initialize FbxExporter: ") + gcnew String(pExporter->GetStatus().GetErrorString())); throw gcnew Exception(gcnew String("Failed to initialize FbxExporter: ") + gcnew String(pExporter->GetStatus().GetErrorString()));
} }
pExporter->SetFileExportVersion(FBXVersion[versionIndex], FbxSceneRenamer::ERenamingMode::eNone);
frameNames = nullptr; frameNames = nullptr;
if (!allFrames) if (!allFrames)
@ -128,7 +113,7 @@ namespace AssetStudio
meshPath = gcnew String(rootNode->GetName()) + "/" + meshPath; meshPath = gcnew String(rootNode->GetName()) + "/" + meshPath;
} }
ImportedMesh^ mesh = ImportedHelpers::FindMesh(meshPath, imported->MeshList); ImportedMesh^ mesh = ImportedHelpers::FindMesh(meshPath, imported->MeshList);
ExportMesh(meshNode, mesh, normals); ExportMesh(meshNode, mesh, normals);
} }
} }
else else
@ -543,7 +528,8 @@ namespace AssetStudio
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(normal.X, normal.Y, normal.Z, 0)); lGeometryElementNormal->GetDirectArray().Add(FbxVector4(normal.X, normal.Y, normal.Z, 0));
} }
array<float>^ uv = vertex->UV; array<float>^ uv = vertex->UV;
lGeometryElementUV->GetDirectArray().Add(FbxVector2(uv[0], -uv[1])); if (uv != nullptr)
lGeometryElementUV->GetDirectArray().Add(FbxVector2(uv[0], -uv[1]));
if (normals) if (normals)
{ {
Vector4 tangent = vertex->Tangent; Vector4 tangent = vertex->Tangent;
@ -568,13 +554,10 @@ namespace AssetStudio
for (int j = 0; j < faceList->Count; j++) for (int j = 0; j < faceList->Count; j++)
{ {
ImportedFace^ face = faceList[j]; ImportedFace^ face = faceList[j];
unsigned short v1 = (unsigned short)face->VertexIndices[0]; pMesh->BeginPolygon(0);
unsigned short v2 = (unsigned short)face->VertexIndices[1]; pMesh->AddPolygon(face->VertexIndices[0]);
unsigned short v3 = (unsigned short)face->VertexIndices[2]; pMesh->AddPolygon(face->VertexIndices[1]);
pMesh->BeginPolygon(false); pMesh->AddPolygon(face->VertexIndices[2]);
pMesh->AddPolygon(v1);
pMesh->AddPolygon(v2);
pMesh->AddPolygon(v3);
pMesh->EndPolygon(); pMesh->EndPolygon();
} }
@ -586,7 +569,6 @@ namespace AssetStudio
FbxCluster* pCluster = pClusterArray->GetAt(j); FbxCluster* pCluster = pClusterArray->GetAt(j);
if (pCluster->GetControlPointIndicesCount() > 0) if (pCluster->GetControlPointIndicesCount() > 0)
{ {
FbxNode* pBoneNode = pBoneNodeList->GetAt(j);
auto boneMatrix = boneList[j]->Matrix; auto boneMatrix = boneList[j]->Matrix;
FbxAMatrix lBoneMatrix; FbxAMatrix lBoneMatrix;
for (int m = 0; m < 4; m++) for (int m = 0; m < 4; m++)
@ -618,7 +600,7 @@ namespace AssetStudio
{ {
delete pClusterArray; delete pClusterArray;
} }
Marshal::FreeHGlobal((IntPtr)pName); Marshal::FreeHGlobal((IntPtr)pName);
} }
} }
} }
@ -762,7 +744,7 @@ namespace AssetStudio
char* pName = NULL; char* pName = NULL;
try try
{ {
pName = Fbx::StringToCharArray(name); pName = StringToCharArray(name);
pNode = pScene->GetRootNode()->FindChild(pName); pNode = pScene->GetRootNode()->FindChild(pName);
} }
finally finally
@ -976,7 +958,7 @@ namespace AssetStudio
} }
int meshVertexIndex = 0; int meshVertexIndex = 0;
for (int meshObjIdx = 0; meshObjIdx < meshList->SubmeshList->Count; meshObjIdx++) for (int meshObjIdx = pBaseNode->GetChildCount() - meshList->SubmeshList->Count; meshObjIdx < meshList->SubmeshList->Count; meshObjIdx++)
{ {
List<ImportedVertex^>^ vertList = meshList->SubmeshList[meshObjIdx]->VertexList; List<ImportedVertex^>^ vertList = meshList->SubmeshList[meshObjIdx]->VertexList;
FbxNode* pBaseMeshNode = pBaseNode->GetChild(meshObjIdx); FbxNode* pBaseMeshNode = pBaseNode->GetChild(meshObjIdx);