2018-02-03 13:56:28 -06:00
|
|
|
using System.IO;
|
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
|
|
|
|
namespace ACE.DatLoader.Entity
|
|
|
|
|
{
|
2018-02-04 11:16:30 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Frame consists of a Vector3 Origin and a Quaternion Orientation
|
|
|
|
|
/// </summary>
|
2018-02-03 13:56:28 -06:00
|
|
|
public class Frame : IUnpackable
|
|
|
|
|
{
|
|
|
|
|
public Vector3 Origin { get; private set; }
|
|
|
|
|
public Quaternion Orientation { get; private set; }
|
|
|
|
|
|
2018-02-16 09:56:51 -05:00
|
|
|
public Frame()
|
|
|
|
|
{
|
2018-07-27 14:02:47 -04:00
|
|
|
Origin = Vector3.Zero;
|
|
|
|
|
Orientation = Quaternion.Identity;
|
2018-02-16 09:56:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Frame(ACE.Entity.Position position)
|
|
|
|
|
{
|
2018-07-19 19:42:07 -04:00
|
|
|
Init(position.Pos, position.Rotation);
|
2018-02-16 09:56:51 -05:00
|
|
|
}
|
|
|
|
|
|
2018-07-19 19:42:07 -04:00
|
|
|
public Frame(Vector3 origin, Quaternion orientation)
|
|
|
|
|
{
|
|
|
|
|
Init(origin, orientation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Init(Vector3 origin, Quaternion orientation)
|
|
|
|
|
{
|
2018-12-13 22:04:02 -06:00
|
|
|
Origin = origin;
|
2018-07-19 19:42:07 -04:00
|
|
|
Orientation = new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-02-03 13:56:28 -06:00
|
|
|
public void Unpack(BinaryReader reader)
|
|
|
|
|
{
|
2018-02-04 11:16:30 -06:00
|
|
|
Origin = reader.ReadVector3();
|
2018-02-03 13:56:28 -06:00
|
|
|
|
|
|
|
|
var qw = reader.ReadSingle();
|
|
|
|
|
var qx = reader.ReadSingle();
|
|
|
|
|
var qy = reader.ReadSingle();
|
|
|
|
|
var qz = reader.ReadSingle();
|
|
|
|
|
Orientation = new Quaternion(qx, qy, qz, qw);
|
|
|
|
|
}
|
2018-08-13 18:07:21 -04:00
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Origin + " " + Orientation;
|
|
|
|
|
}
|
2018-02-03 13:56:28 -06:00
|
|
|
}
|
|
|
|
|
}
|