More progress on seanim importing
This commit is contained in:
parent
d73c607f15
commit
9b0883150a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,6 +9,86 @@ namespace Switch_Toolbox.Library.Animations
|
||||
{
|
||||
Animation anim = new Animation();
|
||||
var seanim = SEAnim.Read(FileName);
|
||||
anim.FrameCount = seanim.FrameCount;
|
||||
anim.CanLoop = seanim.Looping;
|
||||
|
||||
foreach (var bone in seanim.Bones)
|
||||
{
|
||||
var boneAnim = new Animation.KeyNode(bone);
|
||||
anim.Bones.Add(boneAnim);
|
||||
|
||||
if (seanim.AnimationPositionKeys.ContainsKey(bone))
|
||||
{
|
||||
var translationKeys = seanim.AnimationPositionKeys[bone];
|
||||
foreach (SEAnimFrame animFrame in translationKeys)
|
||||
{
|
||||
boneAnim.XPOS.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = (float)((SELib.Utilities.Vector3)animFrame.Data).X,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
boneAnim.YPOS.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = (float)((SELib.Utilities.Vector3)animFrame.Data).Y,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
boneAnim.ZPOS.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = (float)((SELib.Utilities.Vector3)animFrame.Data).Z,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (seanim.AnimationRotationKeys.ContainsKey(bone))
|
||||
{
|
||||
var rotationnKeys = seanim.AnimationRotationKeys[bone];
|
||||
foreach (SEAnimFrame animFrame in rotationnKeys)
|
||||
{
|
||||
boneAnim.XROT.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = (float)((SELib.Utilities.Vector3)animFrame.Data).X,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
boneAnim.YROT.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = (float)((SELib.Utilities.Vector3)animFrame.Data).Y,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
boneAnim.ZROT.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = (float)((SELib.Utilities.Vector3)animFrame.Data).Z,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (seanim.AnimationScaleKeys.ContainsKey(bone))
|
||||
{
|
||||
var scaleKeys = seanim.AnimationRotationKeys[bone];
|
||||
foreach (SEAnimFrame animFrame in scaleKeys)
|
||||
{
|
||||
var quat = ((SELib.Utilities.Quaternion)animFrame.Data);
|
||||
var euler = STMath.ToEulerAngles(quat.X, quat.Y, quat.Z, quat.W);
|
||||
|
||||
boneAnim.XSCA.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = euler.X,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
boneAnim.YSCA.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = euler.Y,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
boneAnim.ZSCA.Keys.Add(new Animation.KeyFrame()
|
||||
{
|
||||
Value = euler.Z,
|
||||
Frame = animFrame.Frame,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
@ -40,6 +40,14 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
//From https://github.com/Ploaj/SSBHLib/blob/e37b0d83cd088090f7802be19b1d05ec998f2b6a/CrossMod/Tools/CrossMath.cs#L42
|
||||
//Seems to give good results
|
||||
public static Vector3 ToEulerAngles(double X, double Y, double Z, double W) {
|
||||
return ToEulerAngles(new Quaternion((float)X, (float)Y, (float)Z, (float)W));
|
||||
}
|
||||
|
||||
public static Vector3 ToEulerAngles(float X, float Y, float Z, float W) {
|
||||
return ToEulerAngles(new Quaternion(X, Y, Z, W));
|
||||
}
|
||||
|
||||
public static Vector3 ToEulerAngles(Quaternion q)
|
||||
{
|
||||
Matrix4 mat = Matrix4.CreateFromQuaternion(q);
|
||||
|
Loading…
Reference in New Issue
Block a user