diff --git a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBANIM/GFBANM.cs b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBANIM/GFBANM.cs
index 3c447ecb..42e9f70b 100644
--- a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBANIM/GFBANM.cs
+++ b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBANIM/GFBANM.cs
@@ -141,6 +141,13 @@ namespace FirstPlugin
}
}
+ public override STSkeleton GetActiveSkeleton()
+ {
+ if (ActiveModel == null) return null;
+
+ return ActiveModel.Model.Skeleton;
+ }
+
public override void NextFrame()
{
if (Frame > FrameCount || ActiveModel == null) return;
diff --git a/Switch_Toolbox_Library/Animations/AnimationRewrite/STAnimation.cs b/Switch_Toolbox_Library/Animations/AnimationRewrite/STAnimation.cs
index a4708416..8e6ce130 100644
--- a/Switch_Toolbox_Library/Animations/AnimationRewrite/STAnimation.cs
+++ b/Switch_Toolbox_Library/Animations/AnimationRewrite/STAnimation.cs
@@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using System.Threading.Tasks;
+using System.Windows.Forms;
+using Toolbox.Library.Forms;
namespace Toolbox.Library.Animations
{
@@ -31,7 +32,7 @@ namespace Toolbox.Library.Animations
///
/// Represents a class for animating
///
- public class STAnimation
+ public class STAnimation
{
///
/// The name of the animation.
diff --git a/Switch_Toolbox_Library/Animations/AnimationRewrite/STSkeletonAnimation.cs b/Switch_Toolbox_Library/Animations/AnimationRewrite/STSkeletonAnimation.cs
index 2c74d36a..8446a2ee 100644
--- a/Switch_Toolbox_Library/Animations/AnimationRewrite/STSkeletonAnimation.cs
+++ b/Switch_Toolbox_Library/Animations/AnimationRewrite/STSkeletonAnimation.cs
@@ -2,11 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using System.Threading.Tasks;
+using System.Windows.Forms;
namespace Toolbox.Library.Animations
{
- public class STSkeletonAnimation : STAnimation
+ public class STSkeletonAnimation : STAnimation, IContextMenuNode
{
public virtual STSkeleton GetActiveSkeleton()
{
@@ -20,5 +20,27 @@ namespace Toolbox.Library.Animations
return null;
}
+
+ public ToolStripItem[] GetContextMenuItems()
+ {
+ bool hasBones = GetActiveSkeleton() != null;
+
+ List Items = new List();
+ Items.Add(new ToolStripMenuItem("Export Animation", null, ExportAction, Keys.Control | Keys.E)
+ { Enabled = hasBones });
+
+ return Items.ToArray();
+ }
+
+ private void ExportAction(object sender, EventArgs e)
+ {
+ SaveFileDialog sfd = new SaveFileDialog();
+ sfd.Filter = "SMD |*.smd;";
+ sfd.DefaultExt = "smd";
+ sfd.FileName = Name;
+ if (sfd.ShowDialog() == DialogResult.OK) {
+ SMD.Save(this, sfd.FileName);
+ }
+ }
}
}
diff --git a/Switch_Toolbox_Library/FileFormats/Animation/SMD.cs b/Switch_Toolbox_Library/FileFormats/Animation/SMD.cs
index 276af792..6476da74 100644
--- a/Switch_Toolbox_Library/FileFormats/Animation/SMD.cs
+++ b/Switch_Toolbox_Library/FileFormats/Animation/SMD.cs
@@ -281,6 +281,51 @@ namespace Toolbox.Library.Animations
return a;
}
+ public static void Save(STSkeletonAnimation anim, String Fname)
+ {
+ System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
+ customCulture.NumberFormat.NumberDecimalSeparator = ".";
+
+ STSkeleton Skeleton = anim.GetActiveSkeleton();
+
+ using (System.IO.StreamWriter file = new System.IO.StreamWriter(@Fname))
+ {
+ file.WriteLine("version 1");
+
+ file.WriteLine("nodes");
+ foreach (STBone b in Skeleton.bones)
+ {
+ file.WriteLine(Skeleton.bones.IndexOf(b) + " \"" + b.Text + "\" " + b.parentIndex);
+ }
+ file.WriteLine("end");
+
+ file.WriteLine("skeleton");
+ anim.SetFrame(0);
+ for (int i = 0; i <= anim.FrameCount; i++)
+ {
+ anim.SetFrame(i);
+ anim.NextFrame();
+
+ file.WriteLine($"time {i}");
+
+ foreach (var sb in anim.AnimGroups)
+ {
+ STBone b = Skeleton.GetBone(sb.Name);
+ if (b == null) continue;
+ Vector3 eul = STMath.ToEulerAngles(b.rot);
+ Vector3 scale = b.GetScale();
+ Vector3 translate = b.GetPosition();
+
+ file.WriteLine($"{ Skeleton.bones.IndexOf(b)} {translate.X} {translate.Y} {translate.Z} {eul.X} {eul.Y} {eul.Z}");
+ }
+
+ }
+ file.WriteLine("end");
+
+ file.Close();
+ }
+ }
+
public static void Save(Animation anim, STSkeleton Skeleton, String Fname)
{
System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs
index 64fe588a..3e5f8e3b 100644
--- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs
+++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.Designer.cs
@@ -157,6 +157,7 @@
//
// stToolStrip1
//
+ this.stToolStrip1.HighlightSelectedTab = false;
this.stToolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton1,
this.searchFormToolStrip});
@@ -224,6 +225,7 @@
// objectEditorMenu
//
this.objectEditorMenu.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.objectEditorMenu.HighlightSelectedTab = false;
this.objectEditorMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.viewToolStripMenuItem});
diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs
index 027629b0..84dd5417 100644
--- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs
+++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs
@@ -406,6 +406,12 @@ namespace Toolbox.Library.Forms
node = (IContextMenuNode)e.Node.Tag;
}
+ if (e.Node is IAnimationContainer) {
+ var anim = ((IAnimationContainer)e.Node).AnimationController;
+ if (anim is IContextMenuNode)
+ node = (IContextMenuNode)anim;
+ }
+
if (node != null)
{
if (IsRoot)
diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx
index 22477dcd..b3ccea75 100644
--- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx
+++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.resx
@@ -123,9 +123,6 @@
17, 17
-
- 17, 17
-
166, 17