GFBANM : Support vector3 byte keyframe types

This commit is contained in:
KillzXGaming 2022-05-25 16:35:59 -04:00
parent 857476e92b
commit 6fe6dfed37
2 changed files with 86 additions and 32 deletions

View file

@ -22,7 +22,8 @@ namespace Gfbanim
NONE = 0,
FixedVectorTrack = 1,
DynamicVectorTrack = 2,
FramedVectorTrack = 3,
FramedVectorTrack16 = 3,
FramedVectorTrack8 = 4,
};
public enum QuatTrack : byte
@ -862,14 +863,14 @@ namespace Gfbanim
}
};
public struct FramedVectorTrack : IFlatbufferObject
public struct FramedVectorTrack16 : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static FramedVectorTrack GetRootAsFramedVectorTrack(ByteBuffer _bb) { return GetRootAsFramedVectorTrack(_bb, new FramedVectorTrack()); }
public static FramedVectorTrack GetRootAsFramedVectorTrack(ByteBuffer _bb, FramedVectorTrack obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static FramedVectorTrack16 GetRootAsFramedVectorTrack(ByteBuffer _bb) { return GetRootAsFramedVectorTrack(_bb, new FramedVectorTrack16()); }
public static FramedVectorTrack16 GetRootAsFramedVectorTrack(ByteBuffer _bb, FramedVectorTrack16 obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public FramedVectorTrack __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public FramedVectorTrack16 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public ushort Frames(int j) { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUshort(__p.__vector(o) + j * 2) : (ushort)0; }
public int FramesLength { get { int o = __p.__offset(4); return o != 0 ? __p.__vector_len(o) : 0; } }
@ -882,14 +883,14 @@ namespace Gfbanim
public Vector3? Values(int j) { int o = __p.__offset(6); return o != 0 ? (Vector3?)(new Vector3()).__assign(__p.__vector(o) + j * 12, __p.bb) : null; }
public int ValuesLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
public static Offset<FramedVectorTrack> CreateFramedVectorTrack(FlatBufferBuilder builder,
public static Offset<FramedVectorTrack16> CreateFramedVectorTrack(FlatBufferBuilder builder,
VectorOffset FramesOffset = default(VectorOffset),
VectorOffset ValuesOffset = default(VectorOffset))
{
builder.StartObject(2);
FramedVectorTrack.AddValues(builder, ValuesOffset);
FramedVectorTrack.AddFrames(builder, FramesOffset);
return FramedVectorTrack.EndFramedVectorTrack(builder);
FramedVectorTrack16.AddValues(builder, ValuesOffset);
FramedVectorTrack16.AddFrames(builder, FramesOffset);
return FramedVectorTrack16.EndFramedVectorTrack(builder);
}
public static void StartFramedVectorTrack(FlatBufferBuilder builder) { builder.StartObject(2); }
@ -899,10 +900,54 @@ namespace Gfbanim
public static void StartFramesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(2, numElems, 2); }
public static void AddValues(FlatBufferBuilder builder, VectorOffset ValuesOffset) { builder.AddOffset(1, ValuesOffset.Value, 0); }
public static void StartValuesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(12, numElems, 4); }
public static Offset<FramedVectorTrack> EndFramedVectorTrack(FlatBufferBuilder builder)
public static Offset<FramedVectorTrack16> EndFramedVectorTrack(FlatBufferBuilder builder)
{
int o = builder.EndObject();
return new Offset<FramedVectorTrack>(o);
return new Offset<FramedVectorTrack16>(o);
}
};
public struct FramedVectorTrack8 : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static FramedVectorTrack8 GetRootAsFramedVectorTrack(ByteBuffer _bb) { return GetRootAsFramedVectorTrack(_bb, new FramedVectorTrack8()); }
public static FramedVectorTrack8 GetRootAsFramedVectorTrack(ByteBuffer _bb, FramedVectorTrack8 obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public FramedVectorTrack8 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public byte Frames(int j) { int o = __p.__offset(4); return o != 0 ? __p.bb.Get(__p.__vector(o) + j * 2) : (byte)0; }
public int FramesLength { get { int o = __p.__offset(4); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
public Span<byte> GetFramesBytes() { return __p.__vector_as_span(4); }
#else
public ArraySegment<byte>? GetFramesBytes() { return __p.__vector_as_arraysegment(4); }
#endif
public byte[] GetFramesArray() { return __p.__vector_as_array<byte>(4); }
public Vector3? Values(int j) { int o = __p.__offset(6); return o != 0 ? (Vector3?)(new Vector3()).__assign(__p.__vector(o) + j * 12, __p.bb) : null; }
public int ValuesLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
public static Offset<FramedVectorTrack8> CreateFramedVectorTrack(FlatBufferBuilder builder,
VectorOffset FramesOffset = default(VectorOffset),
VectorOffset ValuesOffset = default(VectorOffset))
{
builder.StartObject(2);
FramedVectorTrack8.AddValues(builder, ValuesOffset);
FramedVectorTrack8.AddFrames(builder, FramesOffset);
return FramedVectorTrack8.EndFramedVectorTrack(builder);
}
public static void StartFramedVectorTrack(FlatBufferBuilder builder) { builder.StartObject(2); }
public static void AddFrames(FlatBufferBuilder builder, VectorOffset FramesOffset) { builder.AddOffset(0, FramesOffset.Value, 0); }
public static VectorOffset CreateFramesVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateFramesVectorBlock(FlatBufferBuilder builder, ushort[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
public static void StartFramesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
public static void AddValues(FlatBufferBuilder builder, VectorOffset ValuesOffset) { builder.AddOffset(1, ValuesOffset.Value, 0); }
public static void StartValuesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(12, numElems, 4); }
public static Offset<FramedVectorTrack8> EndFramedVectorTrack(FlatBufferBuilder builder)
{
int o = builder.EndObject();
return new Offset<FramedVectorTrack8>(o);
}
};
@ -1009,7 +1054,7 @@ namespace Gfbanim
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public FramedQuatTrack8 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public sbyte Frames(int j) { int o = __p.__offset(4); return o != 0 ? __p.bb.GetSbyte(__p.__vector(o) + j * 2) : (sbyte)0; }
public byte Frames(int j) { int o = __p.__offset(4); return o != 0 ? __p.bb.Get(__p.__vector(o) + j * 2) : (byte)0; }
public int FramesLength { get { int o = __p.__offset(4); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
public Span<byte> GetFramesBytes() { return __p.__vector_as_span(4); }

View file

@ -414,21 +414,6 @@ namespace FirstPlugin
break;
}
switch (boneAnim.ScaleType)
{
case Gfbanim.VectorTrack.FixedVectorTrack:
{
var scale = boneAnim.Scale<Gfbanim.FixedVectorTrack>();
if (scale.HasValue)
{
var vec = scale.Value.Value.Value;
groupAnim.ScaleX.KeyFrames.Add(new STKeyFrame(0, vec.X));
groupAnim.ScaleY.KeyFrames.Add(new STKeyFrame(0, vec.Y));
groupAnim.ScaleZ.KeyFrames.Add(new STKeyFrame(0, vec.Z));
}
}
break;
}
switch (boneAnim.ScaleType)
{
case Gfbanim.VectorTrack.DynamicVectorTrack:
{
@ -441,10 +426,22 @@ namespace FirstPlugin
groupAnim.ScaleZ = values[2];
}
}
break;
case Gfbanim.VectorTrack.FramedVectorTrack:
break;
case Gfbanim.VectorTrack.FramedVectorTrack16:
{
var scale = boneAnim.Scale<Gfbanim.FramedVectorTrack>();
var scale = boneAnim.Scale<Gfbanim.FramedVectorTrack16>();
if (scale.HasValue)
{
var values = GfbanimKeyFrameLoader.LoadVectorTrack(scale.Value);
groupAnim.ScaleX = values[0];
groupAnim.ScaleY = values[1];
groupAnim.ScaleZ = values[2];
}
}
break;
case Gfbanim.VectorTrack.FramedVectorTrack8:
{
var scale = boneAnim.Scale<Gfbanim.FramedVectorTrack8>();
if (scale.HasValue)
{
var values = GfbanimKeyFrameLoader.LoadVectorTrack(scale.Value);
@ -481,9 +478,21 @@ namespace FirstPlugin
}
}
break;
case Gfbanim.VectorTrack.FramedVectorTrack:
case Gfbanim.VectorTrack.FramedVectorTrack16:
{
var trans = boneAnim.Translate<Gfbanim.FramedVectorTrack>();
var trans = boneAnim.Translate<Gfbanim.FramedVectorTrack16>();
if (trans.HasValue)
{
var values = GfbanimKeyFrameLoader.LoadVectorTrack(trans.Value);
groupAnim.TranslateX = values[0];
groupAnim.TranslateY = values[1];
groupAnim.TranslateZ = values[2];
}
}
break;
case Gfbanim.VectorTrack.FramedVectorTrack8:
{
var trans = boneAnim.Translate<Gfbanim.FramedVectorTrack8>();
if (trans.HasValue)
{
var values = GfbanimKeyFrameLoader.LoadVectorTrack(trans.Value);