Skip to content

Commit

Permalink
add experimental support for exporting model animations (#72)
Browse files Browse the repository at this point in the history
* add experimental support for exporting model animations

* spacing
  • Loading branch information
gmriggs authored Jul 15, 2023
1 parent 55271a5 commit abd020a
Show file tree
Hide file tree
Showing 8 changed files with 798 additions and 20 deletions.
8 changes: 4 additions & 4 deletions ACViewer/ACE.Server/Entity/GeneratorProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ public bool Spawn_Specific(WorldObject obj)
// offset from generator location
else
{
if (/*PropertyManager.GetBool("use_generator_rotation_offset").Item*/true)
{
/*if (PropertyManager.GetBool("use_generator_rotation_offset").Item)
{*/
var offset = Vector3.Transform(new Vector3(Biota.OriginX ?? 0, Biota.OriginY ?? 0, Biota.OriginZ ?? 0), Generator.Location.Rotation);

if (Generator.GeneratorType == GeneratorType.Relative)
Expand All @@ -337,9 +337,9 @@ public bool Spawn_Specific(WorldObject obj)
}
else
obj.Location = new ACE.Entity.Position(Generator.Location.Cell, Generator.Location.PositionX + offset.X, Generator.Location.PositionY + offset.Y, Generator.Location.PositionZ + offset.Z, Biota.AnglesX ?? 0, Biota.AnglesY ?? 0, Biota.AnglesZ ?? 0, Biota.AnglesW ?? 0);
}
/*}
else
obj.Location = new ACE.Entity.Position(Generator.Location.Cell, Generator.Location.PositionX + Biota.OriginX ?? 0, Generator.Location.PositionY + Biota.OriginY ?? 0, Generator.Location.PositionZ + Biota.OriginZ ?? 0, Biota.AnglesX ?? 0, Biota.AnglesY ?? 0, Biota.AnglesZ ?? 0, Biota.AnglesW ?? 0);
obj.Location = new ACE.Entity.Position(Generator.Location.Cell, Generator.Location.PositionX + Biota.OriginX ?? 0, Generator.Location.PositionY + Biota.OriginY ?? 0, Generator.Location.PositionZ + Biota.OriginZ ?? 0, Biota.AnglesX ?? 0, Biota.AnglesY ?? 0, Biota.AnglesZ ?? 0, Biota.AnglesW ?? 0);*/
}

if (!VerifyLandblock(obj) || !VerifyWalkableSlope(obj))
Expand Down
2 changes: 2 additions & 0 deletions ACViewer/ACViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AssimpNet" Version="5.0.0-beta1" />
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Framework.WpfInterop" Version="1.9.2" />
<PackageReference Include="UkooLabs.FbxSharpie" Version="1.0.99" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions ACViewer/ActionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public bool CanExecute(object parameter)
return true;
}

public event EventHandler CanExecuteChanged;
}
public event EventHandler CanExecuteChanged { add {} remove {} }
}
39 changes: 35 additions & 4 deletions ACViewer/Extensions/QuaternionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
namespace ACViewer
using System;
using System.Numerics;

namespace ACViewer
{
public static class QuaternionExtensions
{
public static System.Numerics.Quaternion ToNumerics(this Microsoft.Xna.Framework.Quaternion q)
public static Quaternion ToNumerics(this Microsoft.Xna.Framework.Quaternion q)
{
return new System.Numerics.Quaternion(q.X, q.Y, q.Z, q.W);
return new Quaternion(q.X, q.Y, q.Z, q.W);
}

public static Microsoft.Xna.Framework.Quaternion ToXna(this System.Numerics.Quaternion q)
public static Microsoft.Xna.Framework.Quaternion ToXna(this Quaternion q)
{
return new Microsoft.Xna.Framework.Quaternion(q.X, q.Y, q.Z, q.W);
}

public static Vector3 ToEulerAngles(this Quaternion q)
{
var angles = Vector3.Zero;

// roll / x
double sinr_cosp = 2 * (q.W * q.X + q.Y * q.Z);
double cosr_cosp = 1 - 2 * (q.X * q.X + q.Y * q.Y);
angles.X = (float)Math.Atan2(sinr_cosp, cosr_cosp);

// pitch / y
double sinp = 2 * (q.W * q.Y - q.Z * q.X);
if (Math.Abs(sinp) >= 1)
{
angles.Y = (float)Math.CopySign(Math.PI / 2, sinp);
}
else
{
angles.Y = (float)Math.Asin(sinp);
}

// yaw / z
double siny_cosp = 2 * (q.W * q.Z + q.X * q.Y);
double cosy_cosp = 1 - 2 * (q.Y * q.Y + q.Z * q.Z);
angles.Z = (float)Math.Atan2(siny_cosp, cosy_cosp);

return angles;
}
}
}
Loading

0 comments on commit abd020a

Please sign in to comment.