Export objects with Animation

This commit is contained in:
Perfare
2018-04-11 15:52:37 +08:00
parent 8031d1a03f
commit af80b270cf
4 changed files with 70 additions and 19 deletions
+16 -13
View File
@@ -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
+7
View File
@@ -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();
}
}
}