mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 14:30:26 +00:00
Add gfbanm exporting as smd
This commit is contained in:
parent
8a8ac6830e
commit
d971b03a17
7 changed files with 87 additions and 7 deletions
|
@ -141,6 +141,13 @@ namespace FirstPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override STSkeleton GetActiveSkeleton()
|
||||||
|
{
|
||||||
|
if (ActiveModel == null) return null;
|
||||||
|
|
||||||
|
return ActiveModel.Model.Skeleton;
|
||||||
|
}
|
||||||
|
|
||||||
public override void NextFrame()
|
public override void NextFrame()
|
||||||
{
|
{
|
||||||
if (Frame > FrameCount || ActiveModel == null) return;
|
if (Frame > FrameCount || ActiveModel == null) return;
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
||||||
|
using Toolbox.Library.Forms;
|
||||||
|
|
||||||
namespace Toolbox.Library.Animations
|
namespace Toolbox.Library.Animations
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Toolbox.Library.Animations
|
namespace Toolbox.Library.Animations
|
||||||
{
|
{
|
||||||
public class STSkeletonAnimation : STAnimation
|
public class STSkeletonAnimation : STAnimation, IContextMenuNode
|
||||||
{
|
{
|
||||||
public virtual STSkeleton GetActiveSkeleton()
|
public virtual STSkeleton GetActiveSkeleton()
|
||||||
{
|
{
|
||||||
|
@ -20,5 +20,27 @@ namespace Toolbox.Library.Animations
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ToolStripItem[] GetContextMenuItems()
|
||||||
|
{
|
||||||
|
bool hasBones = GetActiveSkeleton() != null;
|
||||||
|
|
||||||
|
List<ToolStripItem> Items = new List<ToolStripItem>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,6 +281,51 @@ namespace Toolbox.Library.Animations
|
||||||
return a;
|
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)
|
public static void Save(Animation anim, STSkeleton Skeleton, String Fname)
|
||||||
{
|
{
|
||||||
System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
|
System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
|
||||||
|
|
|
@ -157,6 +157,7 @@
|
||||||
//
|
//
|
||||||
// stToolStrip1
|
// stToolStrip1
|
||||||
//
|
//
|
||||||
|
this.stToolStrip1.HighlightSelectedTab = false;
|
||||||
this.stToolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.stToolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.toolStripButton1,
|
this.toolStripButton1,
|
||||||
this.searchFormToolStrip});
|
this.searchFormToolStrip});
|
||||||
|
@ -224,6 +225,7 @@
|
||||||
// objectEditorMenu
|
// objectEditorMenu
|
||||||
//
|
//
|
||||||
this.objectEditorMenu.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.objectEditorMenu.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.objectEditorMenu.HighlightSelectedTab = false;
|
||||||
this.objectEditorMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.objectEditorMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.fileToolStripMenuItem,
|
this.fileToolStripMenuItem,
|
||||||
this.viewToolStripMenuItem});
|
this.viewToolStripMenuItem});
|
||||||
|
|
|
@ -406,6 +406,12 @@ namespace Toolbox.Library.Forms
|
||||||
node = (IContextMenuNode)e.Node.Tag;
|
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 (node != null)
|
||||||
{
|
{
|
||||||
if (IsRoot)
|
if (IsRoot)
|
||||||
|
|
|
@ -123,9 +123,6 @@
|
||||||
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="treeNodeContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="treeNodeContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>166, 17</value>
|
<value>166, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|
Loading…
Reference in a new issue