1
0
mirror of synced 2024-11-12 02:00:50 +01:00

Improve bin.gz endianness detection

This commit is contained in:
KillzXGaming 2020-02-06 21:05:35 -05:00
parent d991a23980
commit 0b27e890be
4 changed files with 58 additions and 21 deletions

View File

@ -64,7 +64,7 @@ namespace FirstPlugin
entry.FileName = $"file {i}";
entry.Read(reader);
if (entry.Size != 0 && entry.CompFlags == 0)
if (entry.CompFlags != 0)
files.Add(entry);
}
@ -82,11 +82,12 @@ namespace FirstPlugin
{
DataReader.SeekBegin(files[i].Offset);
var magicCheck = DataReader.ReadString(4);
Console.WriteLine("MAGIC=" + magicCheck);
if (magicCheck == "SARC")
files[i].FileName = $"Layout/{files[i].FileName}.szs";
else if (magicCheck == "SPKG")
files[i].FileName = $"ShaderPackage/{files[i].FileName}.spkg";
else if (files[i].CompFlags != 0)
files[i].FileName = $"CompressedFiles/{files[i].FileName}.bin.gz";
else
files[i].FileName = $"UnknownTypes/{files[i].FileName}.bin";
}

View File

@ -22,5 +22,47 @@ namespace Toolbox.Library.Animations
return Result;
}
public static float HermiteInterpolate(float frame, float frame1, float frame2,
float inSlope, float outSlope, float p0, float p1)
{
if (frame == frame1) return p0;
if (frame == frame2) return p1;
float t = (frame - frame1) / (frame2 - frame1);
return GetPointHermite(p0, p1, outSlope, inSlope, t);
}
private static float GetPointHermite(float p0, float p1, float s0, float s1, float t) {
float cf0 = (p0 * 2) + (p1 * -2) + (s0 * 1) + (s1 * 1);
float cf1 = (p0 * -3) + (p1 * 3) + (s0 * -2) + (s1 * -1);
float cf2 = (p0 * 0) + (p1 * 0) + (s0 * 1) + (s1 * 0);
float cf3 = (p0 * 1) + (p1 * 0) + (s0 * 0) + (s1 * 0);
return GetPointCubic(cf0, cf1, cf2, cf3, t);
}
private static float GetPointCubic(float cf0, float cf1, float cf2, float cf3, float t) {
return (((cf0 * t + cf1) * t + cf2) * t + cf3);
}
public static float[] CalculateCubicCoef(float frameA, float frameB, float valueA, float valueB, float inSlope, float outSlope) {
return CalculateCubicCoef(frameB - frameA, valueA, valueB, inSlope, outSlope);
}
public static float[] GetCubicSlopes(float time, float delta, float[] coef)
{
float outSlope = coef[1] / time;
float param = coef[3] - (-2 * delta);
float inSlope = param / time - outSlope;
return new float[2] { inSlope, outSlope };
}
public static float[] CalculateCubicCoef(float time, float valueA, float valueB, float inSlope, float outSlope)
{
float[] values = new float[4];
//Cubics have 4 coefficents
return values;
}
}
}

View File

@ -44,9 +44,11 @@ namespace Toolbox.Library.IO
using (var reader = new FileReader(stream, true))
{
reader.Position = 0;
reader.SetByteOrder(true);
uint chunkSize = reader.ReadUInt32();
if (chunkSize == 256)
ushort check = reader.ReadUInt16();
reader.ReadUInt16();
if (check != 0)
reader.SetByteOrder(true);
else
reader.SetByteOrder(false);
uint chunkCount = reader.ReadUInt32();
@ -77,9 +79,11 @@ namespace Toolbox.Library.IO
{
using (var reader = new FileReader(stream, true))
{
reader.SetByteOrder(true);
uint chunkSize = reader.ReadUInt32();
if (chunkSize == 256)
ushort check = reader.ReadUInt16();
reader.ReadUInt16();
if (check != 0)
reader.SetByteOrder(true);
else
reader.SetByteOrder(false);
try
@ -92,6 +96,8 @@ namespace Toolbox.Library.IO
List<byte[]> DecompressedChunks = new List<byte[]>();
Console.WriteLine($"pos {reader.Position}");
//Now search for zlibbed chunks
while (!reader.EndOfStream)
{
@ -101,7 +107,7 @@ namespace Toolbox.Library.IO
ushort magic = reader.ReadUInt16();
///Check zlib magic
if (magic == 0x78da)
if (magic == 0x78da || magic == 0xda78)
{
var data = STLibraryCompression.ZLIB.Decompress(reader.getSection((uint)pos, size));
DecompressedChunks.Add(data);

View File

@ -652,18 +652,6 @@ namespace Toolbox.Library
obj.vertices = GetVertices(msh, transform, obj);
obj.VertexBufferIndex = Index;
//Correct the vertex colors because assimp is broken.
if (Geomerties.Count > Index)
{
Console.WriteLine($"v count {obj.vertices.Count}");
Console.WriteLine($"color count {Geomerties[Index].ColorList.Count}");
for (int v = 0; v < Geomerties[Index].ColorList.Count; v++) {
if (v < obj.vertices.Count)
obj.vertices[v].col = Geomerties[Index].ColorList[v];
}
}
return obj;
}