mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Export objects with Animation
This commit is contained in:
parent
8031d1a03f
commit
af80b270cf
@ -1757,10 +1757,10 @@ namespace AssetStudio
|
||||
exportAnimatorwithAnimationClipMenuItem.Visible = true;
|
||||
|
||||
}
|
||||
/*else if (selectedAssets.All(x => x.Type == ClassIDReference.AnimationClip))
|
||||
else if (selectedAssets.All(x => x.Type == ClassIDReference.AnimationClip))
|
||||
{
|
||||
exportObjectswithAnimationClipMenuItem.Visible = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
contextMenuStrip1.Show(assetListView, e.X, e.Y);
|
||||
@ -1779,7 +1779,7 @@ namespace AssetStudio
|
||||
|
||||
private void showOriginalFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectasset = (AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]];
|
||||
var selectasset = selectedAssets[0];
|
||||
var args = $"/select, {selectasset.sourceFile.parentPath ?? selectasset.sourceFile.filePath}";
|
||||
var pfi = new ProcessStartInfo("explorer.exe", args);
|
||||
Process.Start(pfi);
|
||||
@ -1806,17 +1806,37 @@ namespace AssetStudio
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var exportpath = saveFolderDialog1.Folder + "\\Animator\\";
|
||||
var exportPath = saveFolderDialog1.Folder + "\\Animator\\";
|
||||
progressBar1.Value = 0;
|
||||
progressBar1.Maximum = 1;
|
||||
ExportAnimatorWithAnimationClip(animator, animationList, exportpath);
|
||||
ExportAnimatorWithAnimationClip(animator, animationList, exportPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//TODO
|
||||
var saveFolderDialog1 = new OpenFolderDialog();
|
||||
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
var exportPath = saveFolderDialog1.Folder + "\\Animator\\";
|
||||
ThreadPool.QueueUserWorkItem(state => ForeachTreeNodes(sceneTreeView.Nodes, exportPath));
|
||||
}
|
||||
}
|
||||
|
||||
private void ForeachTreeNodes(TreeNodeCollection nodes, string exportPath)
|
||||
{
|
||||
foreach (TreeNode i in nodes)
|
||||
{
|
||||
if (i.Checked)
|
||||
{
|
||||
ExportObjectsWithAnimationClip((GameObject)i, selectedAssets, exportPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ForeachTreeNodes(i.Nodes, exportPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -319,22 +319,28 @@ namespace AssetStudio
|
||||
|
||||
public static bool ExportAnimator(AssetPreloadData animator, string exportPath)
|
||||
{
|
||||
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 flatInbetween = (bool)Properties.Settings.Default["flatInbetween"];
|
||||
var compatibility = (bool)Properties.Settings.Default["compatibility"];
|
||||
var m_Animator = new Animator(animator);
|
||||
var convert = new ModelConverter(m_Animator);
|
||||
exportPath = exportPath + Studio.FixFileName(animator.Text) + ".fbx";
|
||||
Fbx.Exporter.Export(exportPath, convert, EulerFilter, filterPrecision, ".fbx", allFrames, allBones, skins, boneSize, flatInbetween, compatibility);
|
||||
return true;
|
||||
return ModelConverter(convert, exportPath);
|
||||
}
|
||||
|
||||
public static bool ExportAnimator(AssetPreloadData animator, List<AssetPreloadData> animationList, string exportPath)
|
||||
{
|
||||
var m_Animator = new Animator(animator);
|
||||
var convert = new ModelConverter(m_Animator, animationList);
|
||||
exportPath = exportPath + Studio.FixFileName(animator.Text) + ".fbx";
|
||||
return ModelConverter(convert, exportPath);
|
||||
}
|
||||
|
||||
public static bool ExportGameObject(GameObject gameObject, List<AssetPreloadData> animationList, string exportPath)
|
||||
{
|
||||
var convert = new ModelConverter(gameObject, animationList);
|
||||
exportPath = exportPath + Studio.FixFileName(gameObject.Text) + ".fbx";
|
||||
return ModelConverter(convert, exportPath);
|
||||
}
|
||||
|
||||
private static bool ModelConverter(ModelConverter convert, string exportPath)
|
||||
{
|
||||
var EulerFilter = (bool)Properties.Settings.Default["EulerFilter"];
|
||||
var filterPrecision = (float)(decimal)Properties.Settings.Default["filterPrecision"];
|
||||
@ -344,9 +350,6 @@ namespace AssetStudio
|
||||
var boneSize = (int)(decimal)Properties.Settings.Default["boneSize"];
|
||||
var flatInbetween = (bool)Properties.Settings.Default["flatInbetween"];
|
||||
var compatibility = (bool)Properties.Settings.Default["compatibility"];
|
||||
var m_Animator = new Animator(animator);
|
||||
var convert = new ModelConverter(m_Animator, animationList);
|
||||
exportPath = exportPath + Studio.FixFileName(animator.Text) + ".fbx";
|
||||
Fbx.Exporter.Export(exportPath, convert, EulerFilter, filterPrecision, ".fbx", allFrames, allBones, skins, boneSize, flatInbetween, compatibility);
|
||||
return true;
|
||||
}
|
||||
|
@ -27,6 +27,11 @@ namespace AssetStudio
|
||||
private HashSet<AssetPreloadData> animationClipHashSet = new HashSet<AssetPreloadData>();
|
||||
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
||||
|
||||
public ModelConverter(GameObject m_GameObject)
|
||||
{
|
||||
InitWithGameObject(m_GameObject);
|
||||
}
|
||||
|
||||
public ModelConverter(Animator m_Animator)
|
||||
{
|
||||
InitWithAnimator(m_Animator);
|
||||
@ -44,6 +49,16 @@ namespace AssetStudio
|
||||
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)
|
||||
{
|
||||
//In fact, doesn't need this.
|
||||
@ -51,6 +66,12 @@ namespace AssetStudio
|
||||
avatar = new Avatar(m_Avatar);
|
||||
|
||||
assetsfileList.TryGetGameObject(m_Animator.m_GameObject, out var m_GameObject);
|
||||
InitWithGameObject(m_GameObject);
|
||||
}
|
||||
|
||||
|
||||
private void InitWithGameObject(GameObject m_GameObject)
|
||||
{
|
||||
assetsfileList.TryGetTransform(m_GameObject.m_Transform, out var m_Transform);
|
||||
var rootTransform = m_Transform;
|
||||
while (assetsfileList.TryGetTransform(rootTransform.m_Father, out var m_Father))//Get Root Transform
|
||||
|
@ -523,5 +523,12 @@ namespace AssetStudio
|
||||
ProgressBarPerformStep();
|
||||
});
|
||||
}
|
||||
|
||||
public static void ExportObjectsWithAnimationClip(GameObject gameObject, List<AssetPreloadData> animationList, string exportPath)
|
||||
{
|
||||
var result = ExportGameObject(gameObject, animationList, exportPath);
|
||||
StatusStripUpdate(result ? "Successfully exported" : "Nothing exported.");
|
||||
ProgressBarPerformStep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user