add jump to scene hierarchy

some improvements
This commit is contained in:
Perfare 2018-04-19 07:06:52 +08:00
parent 4bcc16245c
commit a3c92ddb8f
7 changed files with 186 additions and 122 deletions

View File

@ -113,6 +113,7 @@
this.exportSelectedAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportSelectedAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAnimatorwithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportAnimatorwithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportobjectswithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportobjectswithselectedAnimationClipMenuItem = 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.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -163,33 +164,33 @@
// loadFileToolStripMenuItem // loadFileToolStripMenuItem
// //
this.loadFileToolStripMenuItem.Name = "loadFileToolStripMenuItem"; this.loadFileToolStripMenuItem.Name = "loadFileToolStripMenuItem";
this.loadFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.loadFileToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.loadFileToolStripMenuItem.Text = "Load file"; this.loadFileToolStripMenuItem.Text = "Load file";
this.loadFileToolStripMenuItem.Click += new System.EventHandler(this.loadFile_Click); this.loadFileToolStripMenuItem.Click += new System.EventHandler(this.loadFile_Click);
// //
// loadFolderToolStripMenuItem // loadFolderToolStripMenuItem
// //
this.loadFolderToolStripMenuItem.Name = "loadFolderToolStripMenuItem"; this.loadFolderToolStripMenuItem.Name = "loadFolderToolStripMenuItem";
this.loadFolderToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.loadFolderToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.loadFolderToolStripMenuItem.Text = "Load folder"; this.loadFolderToolStripMenuItem.Text = "Load folder";
this.loadFolderToolStripMenuItem.Click += new System.EventHandler(this.loadFolder_Click); this.loadFolderToolStripMenuItem.Click += new System.EventHandler(this.loadFolder_Click);
// //
// toolStripMenuItem1 // toolStripMenuItem1
// //
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(177, 6); this.toolStripMenuItem1.Size = new System.Drawing.Size(151, 6);
// //
// extractFileToolStripMenuItem // extractFileToolStripMenuItem
// //
this.extractFileToolStripMenuItem.Name = "extractFileToolStripMenuItem"; this.extractFileToolStripMenuItem.Name = "extractFileToolStripMenuItem";
this.extractFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.extractFileToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.extractFileToolStripMenuItem.Text = "Extract file"; this.extractFileToolStripMenuItem.Text = "Extract file";
this.extractFileToolStripMenuItem.Click += new System.EventHandler(this.extractFileToolStripMenuItem_Click); this.extractFileToolStripMenuItem.Click += new System.EventHandler(this.extractFileToolStripMenuItem_Click);
// //
// extractFolderToolStripMenuItem // extractFolderToolStripMenuItem
// //
this.extractFolderToolStripMenuItem.Name = "extractFolderToolStripMenuItem"; this.extractFolderToolStripMenuItem.Name = "extractFolderToolStripMenuItem";
this.extractFolderToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.extractFolderToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.extractFolderToolStripMenuItem.Text = "Extract folder"; this.extractFolderToolStripMenuItem.Text = "Extract folder";
this.extractFolderToolStripMenuItem.Click += new System.EventHandler(this.extractFolderToolStripMenuItem_Click); this.extractFolderToolStripMenuItem.Click += new System.EventHandler(this.extractFolderToolStripMenuItem_Click);
// //
@ -902,9 +903,10 @@
this.exportSelectedAssetsToolStripMenuItem, this.exportSelectedAssetsToolStripMenuItem,
this.exportAnimatorwithselectedAnimationClipMenuItem, this.exportAnimatorwithselectedAnimationClipMenuItem,
this.exportobjectswithselectedAnimationClipMenuItem, this.exportobjectswithselectedAnimationClipMenuItem,
this.jumpToSceneHierarchyToolStripMenuItem,
this.showOriginalFileToolStripMenuItem}); this.showOriginalFileToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(335, 92); this.contextMenuStrip1.Size = new System.Drawing.Size(335, 136);
// //
// exportSelectedAssetsToolStripMenuItem // exportSelectedAssetsToolStripMenuItem
// //
@ -929,6 +931,14 @@
this.exportobjectswithselectedAnimationClipMenuItem.Visible = false; this.exportobjectswithselectedAnimationClipMenuItem.Visible = false;
this.exportobjectswithselectedAnimationClipMenuItem.Click += new System.EventHandler(this.exportObjectswithAnimationClipMenuItem_Click); this.exportobjectswithselectedAnimationClipMenuItem.Click += new System.EventHandler(this.exportObjectswithAnimationClipMenuItem_Click);
// //
// jumpToSceneHierarchyToolStripMenuItem
//
this.jumpToSceneHierarchyToolStripMenuItem.Name = "jumpToSceneHierarchyToolStripMenuItem";
this.jumpToSceneHierarchyToolStripMenuItem.Size = new System.Drawing.Size(334, 22);
this.jumpToSceneHierarchyToolStripMenuItem.Text = "Jump to scene hierarchy";
this.jumpToSceneHierarchyToolStripMenuItem.Visible = false;
this.jumpToSceneHierarchyToolStripMenuItem.Click += new System.EventHandler(this.jumpToSceneHierarchyToolStripMenuItem_Click);
//
// showOriginalFileToolStripMenuItem // showOriginalFileToolStripMenuItem
// //
this.showOriginalFileToolStripMenuItem.Name = "showOriginalFileToolStripMenuItem"; this.showOriginalFileToolStripMenuItem.Name = "showOriginalFileToolStripMenuItem";
@ -1068,6 +1078,7 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem exportAnimatorWithSelectedAnimationClipToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportAnimatorWithSelectedAnimationClipToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportAllObjectssplitToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem exportAllObjectssplitToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem jumpToSceneHierarchyToolStripMenuItem;
} }
} }

View File

@ -170,6 +170,12 @@ namespace AssetStudio
private void BuildAssetStrucutres() private void BuildAssetStrucutres()
{ {
if (assetsfileList.Count == 0)
{
StatusStripUpdate("No file was loaded.");
return;
}
bool optionLoadAssetsMenuItem = !dontLoadAssetsMenuItem.Checked; bool optionLoadAssetsMenuItem = !dontLoadAssetsMenuItem.Checked;
bool optionDisplayAll = displayAll.Checked; bool optionDisplayAll = displayAll.Checked;
bool optionBuildHierarchyMenuItem = !dontBuildHierarchyMenuItem.Checked; bool optionBuildHierarchyMenuItem = !dontBuildHierarchyMenuItem.Checked;
@ -231,7 +237,7 @@ namespace AssetStudio
showTypeToolStripMenuItem.DropDownItems.Add(typeItem); showTypeToolStripMenuItem.DropDownItems.Add(typeItem);
} }
allToolStripMenuItem.Checked = true; allToolStripMenuItem.Checked = true;
StatusStripUpdate(assetsfileList.Count == 0 ? "No file was loaded." : $"Finished loading {assetsfileList.Count} files with {assetListView.Items.Count} exportable assets."); StatusStripUpdate($"Finished loading {assetsfileList.Count} files with {assetListView.Items.Count} exportable assets.");
treeSearch.Select(); treeSearch.Select();
})); }));
} }
@ -1350,10 +1356,8 @@ namespace AssetStudio
var savePath = saveFolderDialog1.Folder + "\\"; var savePath = saveFolderDialog1.Folder + "\\";
progressBar1.Value = 0; progressBar1.Value = 0;
progressBar1.Maximum = sceneTreeView.Nodes.Count; progressBar1.Maximum = sceneTreeView.Nodes.Count;
ExportSplitObjects(savePath, sceneTreeView.Nodes);
ThreadPool.QueueUserWorkItem(state => ExportSplitObjects(savePath, sceneTreeView.Nodes));
} }
} }
else else
{ {
@ -1734,12 +1738,14 @@ namespace AssetStudio
{ {
if (e.Button == MouseButtons.Right && assetListView.SelectedIndices.Count > 0) if (e.Button == MouseButtons.Right && assetListView.SelectedIndices.Count > 0)
{ {
jumpToSceneHierarchyToolStripMenuItem.Visible = false;
showOriginalFileToolStripMenuItem.Visible = false; showOriginalFileToolStripMenuItem.Visible = false;
exportAnimatorwithselectedAnimationClipMenuItem.Visible = false; exportAnimatorwithselectedAnimationClipMenuItem.Visible = false;
exportobjectswithselectedAnimationClipMenuItem.Visible = false; exportobjectswithselectedAnimationClipMenuItem.Visible = false;
if (assetListView.SelectedIndices.Count == 1) if (assetListView.SelectedIndices.Count == 1)
{ {
jumpToSceneHierarchyToolStripMenuItem.Visible = true;
showOriginalFileToolStripMenuItem.Visible = true; showOriginalFileToolStripMenuItem.Visible = true;
} }
if (assetListView.SelectedIndices.Count >= 1) if (assetListView.SelectedIndices.Count >= 1)
@ -1808,12 +1814,46 @@ namespace AssetStudio
} }
private void exportSelectedObjectsToolStripMenuItem_Click(object sender, EventArgs e) private void exportSelectedObjectsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (sceneTreeView.Nodes.Count > 0)
{ {
var saveFolderDialog1 = new OpenFolderDialog(); var saveFolderDialog1 = new OpenFolderDialog();
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK) if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{ {
var exportPath = saveFolderDialog1.Folder + "\\GameObject\\"; var exportPath = saveFolderDialog1.Folder + "\\GameObject\\";
ThreadPool.QueueUserWorkItem(state => ForeachTreeNodes(sceneTreeView.Nodes, exportPath, o => { ExportObjectsWithAnimationClip(o, exportPath); })); ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes);
}
}
else
{
StatusStripUpdate("No Objects available for export");
}
}
private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventArgs e)
{
if (sceneTreeView.Nodes.Count > 0)
{
var saveFolderDialog1 = new OpenFolderDialog();
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
var exportPath = saveFolderDialog1.Folder + "\\GameObject\\";
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, GetSelectedAssets());
}
}
else
{
StatusStripUpdate("No Objects available for export");
}
}
private void jumpToSceneHierarchyToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectasset = (AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]];
if (selectasset.gameObject != null)
{
sceneTreeView.SelectedNode = selectasset.gameObject;
tabControl1.SelectedTab = tabPage1;
} }
} }
@ -1827,8 +1867,7 @@ namespace AssetStudio
var savePath = saveFolderDialog1.Folder + "\\"; var savePath = saveFolderDialog1.Folder + "\\";
progressBar1.Value = 0; progressBar1.Value = 0;
progressBar1.Maximum = sceneTreeView.Nodes.Count; progressBar1.Maximum = sceneTreeView.Nodes.Count;
ExportSplitObjectsNew(savePath, sceneTreeView.Nodes);
ThreadPool.QueueUserWorkItem(state => ExportSplitObjectsNew(savePath, sceneTreeView.Nodes));
} }
} }
else else
@ -1837,17 +1876,6 @@ namespace AssetStudio
} }
} }
private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventArgs e)
{
var selectedAssets = GetSelectedAssets();
var saveFolderDialog1 = new OpenFolderDialog();
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
var exportPath = saveFolderDialog1.Folder + "\\GameObject\\";
ThreadPool.QueueUserWorkItem(state => ForeachTreeNodes(sceneTreeView.Nodes, exportPath, o => { ExportObjectsWithAnimationClip(o, exportPath, selectedAssets); }));
}
}
private List<AssetPreloadData> GetSelectedAssets() private List<AssetPreloadData> GetSelectedAssets()
{ {
var selectedAssets = new List<AssetPreloadData>(); var selectedAssets = new List<AssetPreloadData>();

View File

@ -21,6 +21,7 @@ namespace AssetStudio
public string extension; public string extension;
public AssetsFile sourceFile; public AssetsFile sourceFile;
public GameObject gameObject;
public string uniqueID; public string uniqueID;
public EndianBinaryReader InitReader() public EndianBinaryReader InitReader()

View File

@ -30,10 +30,20 @@ namespace AssetStudio
var animator = new Animator(m_Animator); var animator = new Animator(m_Animator);
InitWithAnimator(animator); InitWithAnimator(animator);
CollectAnimationClip(animator); CollectAnimationClip(animator);
ConvertAnimations();
} }
else else
InitWithGameObject(m_GameObject); InitWithGameObject(m_GameObject);
ConvertAnimations();
}
public ModelConverter(GameObject m_GameObject, List<AssetPreloadData> animationList)
{
InitWithGameObject(m_GameObject);
foreach (var assetPreloadData in animationList)
{
animationClipHashSet.Add(assetPreloadData);
}
ConvertAnimations();
} }
public ModelConverter(Animator m_Animator) public ModelConverter(Animator m_Animator)
@ -53,16 +63,6 @@ namespace AssetStudio
ConvertAnimations(); ConvertAnimations();
} }
public ModelConverter(GameObject m_GameObject, List<AssetPreloadData> animationList)
{
InitWithGameObject(m_GameObject);
foreach (var assetPreloadData in animationList)
{
animationClipHashSet.Add(assetPreloadData);
}
ConvertAnimations();
}
private void InitWithAnimator(Animator m_Animator) private void InitWithAnimator(Animator m_Animator)
{ {
//In fact, doesn't need this. //In fact, doesn't need this.

View File

@ -328,9 +328,8 @@ namespace AssetStudio
fileNodes = new List<GameObject>(); fileNodes = new List<GameObject>();
if (buildHierarchyMenuItem) if (buildHierarchyMenuItem)
{ {
SetProgressBarMaximum(1); SetProgressBarValue(0);
SetProgressBarValue(1); SetProgressBarMaximum(assetsfileList.Sum(x => x.GameObjectList.Values.Count));
SetProgressBarMaximum(assetsfileList.Sum(x => x.GameObjectList.Values.Count) + 1);
StatusStripUpdate("Building tree structure..."); StatusStripUpdate("Building tree structure...");
foreach (var assetsFile in assetsfileList) foreach (var assetsFile in assetsfileList)
@ -341,7 +340,6 @@ namespace AssetStudio
foreach (var m_GameObject in assetsFile.GameObjectList.Values) foreach (var m_GameObject in assetsFile.GameObjectList.Values)
{ {
//ParseGameObject
foreach (var m_Component in m_GameObject.m_Components) foreach (var m_Component in m_GameObject.m_Components)
{ {
if (m_Component.m_FileID >= 0 && m_Component.m_FileID < assetsfileList.Count) if (m_Component.m_FileID >= 0 && m_Component.m_FileID < assetsfileList.Count)
@ -364,11 +362,27 @@ namespace AssetStudio
case ClassIDReference.MeshFilter: case ClassIDReference.MeshFilter:
{ {
m_GameObject.m_MeshFilter = m_Component; m_GameObject.m_MeshFilter = m_Component;
if (assetsfileList.TryGetPD(m_Component, out var assetPreloadData))
{
var m_MeshFilter = new MeshFilter(assetPreloadData);
if (assetsfileList.TryGetPD(m_MeshFilter.m_Mesh, out assetPreloadData))
{
assetPreloadData.gameObject = m_GameObject;
}
}
break; break;
} }
case ClassIDReference.SkinnedMeshRenderer: case ClassIDReference.SkinnedMeshRenderer:
{ {
m_GameObject.m_SkinnedMeshRenderer = m_Component; m_GameObject.m_SkinnedMeshRenderer = m_Component;
if (assetsfileList.TryGetPD(m_Component, out var assetPreloadData))
{
var m_SkinnedMeshRenderer = new SkinnedMeshRenderer(assetPreloadData);
if (assetsfileList.TryGetPD(m_SkinnedMeshRenderer.m_Mesh, out assetPreloadData))
{
assetPreloadData.gameObject = m_GameObject;
}
}
break; break;
} }
case ClassIDReference.Animator: case ClassIDReference.Animator:
@ -381,7 +395,6 @@ namespace AssetStudio
} }
} }
} }
//
var parentNode = fileNode; var parentNode = fileNode;
@ -413,10 +426,10 @@ namespace AssetStudio
{ {
string matLine; string matLine;
using (StreamReader reader = File.OpenText(mainPath + "\\materials.json")) using (StreamReader reader = File.OpenText(mainPath + "\\materials.json"))
{ matLine = reader.ReadToEnd(); } {
matLine = reader.ReadToEnd();
}
jsonMats = new JavaScriptSerializer().Deserialize<Dictionary<string, Dictionary<string, string>>>(matLine); jsonMats = new JavaScriptSerializer().Deserialize<Dictionary<string, Dictionary<string, string>>>(matLine);
//var jsonMats = new JavaScriptSerializer().DeserializeObject(matLine);
} }
} }
#endregion #endregion
@ -585,6 +598,8 @@ namespace AssetStudio
} }
public static void ExportSplitObjects(string savePath, TreeNodeCollection nodes) public static void ExportSplitObjects(string savePath, TreeNodeCollection nodes)
{
ThreadPool.QueueUserWorkItem(state =>
{ {
foreach (TreeNode node in nodes) foreach (TreeNode node in nodes)
{ {
@ -621,9 +636,12 @@ namespace AssetStudio
} }
ProgressBarPerformStep(); ProgressBarPerformStep();
} }
});
} }
public static void ExportSplitObjectsNew(string savePath, TreeNodeCollection nodes) public static void ExportSplitObjectsNew(string savePath, TreeNodeCollection nodes)
{
ThreadPool.QueueUserWorkItem(state =>
{ {
foreach (TreeNode node in nodes) foreach (TreeNode node in nodes)
{ {
@ -660,6 +678,7 @@ namespace AssetStudio
} }
ProgressBarPerformStep(); ProgressBarPerformStep();
} }
});
} }
private static void CollectNode(TreeNode node, List<GameObject> gameObjects) private static void CollectNode(TreeNode node, List<GameObject> gameObjects)
@ -690,7 +709,15 @@ namespace AssetStudio
}); });
} }
public static void ExportObjectsWithAnimationClip(GameObject gameObject, string exportPath, List<AssetPreloadData> animationList = null) public static void ExportObjectsWithAnimationClip(string exportPath, TreeNodeCollection nodes, List<AssetPreloadData> animationList = null)
{
ThreadPool.QueueUserWorkItem(state =>
{
var gameObjects = new List<GameObject>();
GetSelectedParentNode(nodes, gameObjects);
SetProgressBarValue(0);
SetProgressBarMaximum(gameObjects.Count);
foreach (var gameObject in gameObjects)
{ {
StatusStripUpdate($"Exporting {gameObject.Text}"); StatusStripUpdate($"Exporting {gameObject.Text}");
try try
@ -703,19 +730,22 @@ namespace AssetStudio
MessageBox.Show($"{ex.Message}\r\n{ex.StackTrace}"); MessageBox.Show($"{ex.Message}\r\n{ex.StackTrace}");
StatusStripUpdate("Error in export"); StatusStripUpdate("Error in export");
} }
ProgressBarPerformStep();
}
});
} }
public static void ForeachTreeNodes(TreeNodeCollection nodes, string exportPath, Action<GameObject> action) private static void GetSelectedParentNode(TreeNodeCollection nodes, List<GameObject> gameObjects)
{ {
foreach (TreeNode i in nodes) foreach (TreeNode i in nodes)
{ {
if (i.Checked) if (i.Checked)
{ {
action((GameObject)i); gameObjects.Add((GameObject)i);
} }
else else
{ {
ForeachTreeNodes(i.Nodes, exportPath, action); GetSelectedParentNode(i.Nodes, gameObjects);
} }
} }
} }

View File

@ -47,7 +47,6 @@ namespace AssetStudio {
IImported^ imported; IImported^ imported;
char* cDest; char* cDest;
char* cFormat;
FbxManager* pSdkManager; FbxManager* pSdkManager;
FbxScene* pScene; FbxScene* pScene;
FbxExporter* pExporter; FbxExporter* pExporter;

View File

@ -52,7 +52,6 @@ namespace AssetStudio
this->boneSize = boneSize; this->boneSize = boneSize;
cDest = NULL; cDest = NULL;
cFormat = NULL;
pSdkManager = NULL; pSdkManager = NULL;
pScene = NULL; pScene = NULL;
pExporter = NULL; pExporter = NULL;
@ -166,10 +165,6 @@ namespace AssetStudio
{ {
pSdkManager->Destroy(); pSdkManager->Destroy();
} }
if (cFormat != NULL)
{
Marshal::FreeHGlobal((IntPtr)cFormat);
}
if (cDest != NULL) if (cDest != NULL)
{ {
Marshal::FreeHGlobal((IntPtr)cDest); Marshal::FreeHGlobal((IntPtr)cDest);