v1.00.00
This commit is contained in:
27
AssetStudio/Math/Float.cs
Normal file
27
AssetStudio/Math/Float.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace AssetStudio
|
||||
{
|
||||
public struct Float : IYAMLExportable
|
||||
{
|
||||
public float Value;
|
||||
|
||||
public Float(float value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public static implicit operator Float(float value)
|
||||
{
|
||||
return new Float(value);
|
||||
}
|
||||
|
||||
public static implicit operator float(Float value)
|
||||
{
|
||||
return value.Value;
|
||||
}
|
||||
|
||||
public YAMLNode ExportYAML(int[] version)
|
||||
{
|
||||
return new YAMLScalarNode(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||
namespace AssetStudio
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct Quaternion : IEquatable<Quaternion>
|
||||
public struct Quaternion : IEquatable<Quaternion>, IYAMLExportable
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
@@ -83,6 +83,16 @@ namespace AssetStudio
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
public YAMLNode ExportYAML(int[] version)
|
||||
{
|
||||
var node = new YAMLMappingNode();
|
||||
node.Style = MappingStyle.Flow;
|
||||
node.Add("x", X);
|
||||
node.Add("y", Y);
|
||||
node.Add("z", Z);
|
||||
node.Add("w", W);
|
||||
return node;
|
||||
}
|
||||
|
||||
private const float kEpsilon = 0.000001F;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||
namespace AssetStudio
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct Vector3 : IEquatable<Vector3>
|
||||
public struct Vector3 : IEquatable<Vector3>, IYAMLExportable
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
@@ -87,6 +87,16 @@ namespace AssetStudio
|
||||
return X * X + Y * Y + Z * Z;
|
||||
}
|
||||
|
||||
public YAMLNode ExportYAML(int[] version)
|
||||
{
|
||||
var node = new YAMLMappingNode();
|
||||
node.Style = MappingStyle.Flow;
|
||||
node.Add("x", X);
|
||||
node.Add("y", Y);
|
||||
node.Add("z", Z);
|
||||
return node;
|
||||
}
|
||||
|
||||
public static Vector3 Zero => new Vector3();
|
||||
|
||||
public static Vector3 One => new Vector3(1.0f, 1.0f, 1.0f);
|
||||
|
||||
71
AssetStudio/Math/XForm.cs
Normal file
71
AssetStudio/Math/XForm.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct XForm : IEquatable<XForm>
|
||||
{
|
||||
public Vector3 t;
|
||||
public Quaternion q;
|
||||
public Vector3 s;
|
||||
|
||||
public XForm(Vector3 t, Quaternion q, Vector3 s)
|
||||
{
|
||||
this.t = t;
|
||||
this.q = q;
|
||||
this.s = s;
|
||||
}
|
||||
public float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return t.X;
|
||||
case 1: return t.Y;
|
||||
case 2: return t.Z;
|
||||
case 3: return q.X;
|
||||
case 4: return q.Y;
|
||||
case 5: return q.Z;
|
||||
case 6: return q.W;
|
||||
case 7: return s.X;
|
||||
case 8: return s.Y;
|
||||
case 9: return s.Z;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid xform index!");
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: t.X = value; break;
|
||||
case 1: t.Y = value; break;
|
||||
case 2: t.Z = value; break;
|
||||
case 3: q.X = value; break;
|
||||
case 4: q.Y = value; break;
|
||||
case 5: q.Z = value; break;
|
||||
case 6: q.W = value; break;
|
||||
case 7: s.X = value; break;
|
||||
case 8: s.Y = value; break;
|
||||
case 9: s.Z = value; break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(index), "Invalid xform index!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return t.GetHashCode() ^ (q.GetHashCode() << 2) ^ (s.GetHashCode() >> 2);
|
||||
}
|
||||
|
||||
bool IEquatable<XForm>.Equals(XForm other)
|
||||
{
|
||||
return t.Equals(other.t) && q.Equals(other.q) && s.Equals(other.s);
|
||||
}
|
||||
|
||||
public static XForm Zero => new XForm(Vector3.Zero, Quaternion.Zero, Vector3.One);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user