Allow seanim to be exportable with gfbanim
This commit is contained in:
parent
9dc5b82564
commit
8ae794259c
@ -275,6 +275,7 @@ namespace FirstPlugin
|
||||
|
||||
List<string> Formats = new List<string>();
|
||||
Formats.Add("SMD (.smd)");
|
||||
Formats.Add("SEANIM (.seanim)");
|
||||
|
||||
FolderSelectDialog sfd = new FolderSelectDialog();
|
||||
|
||||
@ -292,9 +293,12 @@ namespace FirstPlugin
|
||||
continue;
|
||||
|
||||
var anim = ((IAnimationContainer)node).AnimationController;
|
||||
string name = Path.GetFileNameWithoutExtension(node.Text);
|
||||
|
||||
// if (form.Index == 0)
|
||||
SMD.Save((STSkeletonAnimation)anim, $"{folderPath}/{node.Text}.smd");
|
||||
if (form.Index == 0)
|
||||
SMD.Save((STSkeletonAnimation)anim, $"{folderPath}/{name}.smd");
|
||||
if (form.Index == 1)
|
||||
SEANIM.Save((STSkeletonAnimation)anim, $"{folderPath}/{name}.seanim");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,19 @@ namespace Toolbox.Library.Animations
|
||||
private void ExportAction(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "SMD |*.smd;";
|
||||
sfd.DefaultExt = "smd";
|
||||
sfd.Filter = "Supported Formats|*.smd; *.seanim;|" +
|
||||
"SMD |*.smd|" +
|
||||
"SEANIM |*.seanim|" +
|
||||
"All files(*.*)|*.*";
|
||||
|
||||
sfd.DefaultExt = "seanim";
|
||||
sfd.FileName = Name;
|
||||
if (sfd.ShowDialog() == DialogResult.OK) {
|
||||
SMD.Save(this, sfd.FileName);
|
||||
string ext = Utils.GetExtension(sfd.FileName);
|
||||
if (ext == ".smd")
|
||||
SMD.Save(this, sfd.FileName);
|
||||
if (ext == ".seanim")
|
||||
SEANIM.Save(this, sfd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using SELib;
|
||||
using OpenTK;
|
||||
using System.Linq;
|
||||
|
||||
namespace Toolbox.Library.Animations
|
||||
{
|
||||
@ -166,6 +167,41 @@ namespace Toolbox.Library.Animations
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(STSkeletonAnimation anim, string FileName)
|
||||
{
|
||||
STSkeleton skeleton = anim.GetActiveSkeleton();
|
||||
|
||||
SEAnim seAnim = new SEAnim();
|
||||
seAnim.Looping = anim.Loop;
|
||||
seAnim.AnimType = AnimationType.Absolute;
|
||||
|
||||
anim.SetFrame(0);
|
||||
for (int frame = 0; frame < anim.FrameCount; frame++)
|
||||
{
|
||||
anim.SetFrame(frame);
|
||||
anim.NextFrame();
|
||||
|
||||
foreach (STAnimGroup boneAnim in anim.AnimGroups)
|
||||
{
|
||||
if (boneAnim.GetTracks().Any(x => x.HasKeys))
|
||||
{
|
||||
STBone bone = skeleton.GetBone(boneAnim.Name);
|
||||
if (bone == null) continue;
|
||||
|
||||
Vector3 position = bone.GetPosition();
|
||||
Quaternion rotation = bone.GetRotation();
|
||||
Vector3 scale = bone.GetScale();
|
||||
|
||||
seAnim.AddTranslationKey(boneAnim.Name, frame, position.X, position.Y, position.Z);
|
||||
seAnim.AddRotationKey(boneAnim.Name, frame, rotation.X, rotation.Y, rotation.Z, rotation.W);
|
||||
seAnim.AddScaleKey(boneAnim.Name, frame, scale.X, scale.Y, scale.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seAnim.Write(FileName);
|
||||
}
|
||||
|
||||
public static void SaveAnimation(string FileName, Animation anim, STSkeleton skeleton)
|
||||
{
|
||||
anim.SetFrame(anim.FrameCount - 1); //from last frame
|
||||
@ -178,8 +214,6 @@ namespace Toolbox.Library.Animations
|
||||
if (anim.HasBone(b.Text))
|
||||
{
|
||||
Animation.KeyNode n = anim.GetBone(b.Text);
|
||||
|
||||
|
||||
if (n.XPOS.HasAnimation())
|
||||
WriteKey(n.XPOS);
|
||||
if (n.YPOS.HasAnimation())
|
||||
|
Loading…
Reference in New Issue
Block a user