Skip to content

Commit

Permalink
Release v0.4.11.0
Browse files Browse the repository at this point in the history
`A3DA`: Added support for Raw Data Binary
`Aet`: Complete overhaul of AET writer
`FARC`: Fixed compressed files not having correct size and encrypted files not being encrypted
Updated libdeflate to 1.20
  • Loading branch information
korenkonder committed May 11, 2024
1 parent b66b3b0 commit 8b46fbb
Show file tree
Hide file tree
Showing 12 changed files with 1,803 additions and 1,643 deletions.
19 changes: 18 additions & 1 deletion KKdBaseLib/Auth2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,29 @@ public struct Scene
public uint BackColor;
public uint Width;
public uint Height;
public Pointer<Vec2<CountPointer<KFT2>>> Camera;
public Pointer<Camera> Camera;
public CountPointer<Composition> Composition;
public CountPointer<Video > Video;
public CountPointer<Audio > Audio;
}

public struct Camera
{
public CountPointer<KFT2> EyeX;
public CountPointer<KFT2> EyeY;
public CountPointer<KFT2> EyeZ;
public CountPointer<KFT2> PositionX;
public CountPointer<KFT2> PositionY;
public CountPointer<KFT2> PositionZ;
public CountPointer<KFT2> DirectionX;
public CountPointer<KFT2> DirectionY;
public CountPointer<KFT2> DirectionZ;
public CountPointer<KFT2> RotationX;
public CountPointer<KFT2> RotationY;
public CountPointer<KFT2> RotationZ;
public CountPointer<KFT2> Zoom ;
}

public struct Composition
{
public int P;
Expand Down
6 changes: 6 additions & 0 deletions KKdBaseLib/Auth3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public struct Key
public float? Max;
public float Value;
public bool RawData;
public bool RawDataBinary;
public int? RawDataValueListSize;
public int? RawDataValueListOffset;
public KFT3[] Keys;

public Key(A3DAKey k)
Expand All @@ -150,6 +153,9 @@ public Key(A3DAKey k)
Value = 0;
BinOffset = null;
RawData = default;
RawDataBinary = default;
RawDataValueListSize = null;
RawDataValueListOffset = null;
Keys = null;

EPTypePost = k.EPTypePost;
Expand Down
6 changes: 3 additions & 3 deletions KKdBaseLib/KKdBaseLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder (C) 2019-2022</Copyright>
<Copyright>korenkonder (C) 2019-2024</Copyright>
<Description>A base library</Description>
<FileVersion>0.4.10.12</FileVersion>
<FileVersion>0.4.11.0</FileVersion>
<PackageId>KKdBaseLib</PackageId>
<Product>KKdBaseLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdBaseLib</Title>
<Version>0.4.10.12</Version>
<Version>0.4.11.0</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
126 changes: 88 additions & 38 deletions KKdMainLib/A3DA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using KKdMainLib.IO;
using Object = KKdBaseLib.Auth3D.Object;
using A3DADict = System.Collections.Generic.Dictionary<string, object>;
using UsedDict = System.Collections.Generic.Dictionary< int, KKdBaseLib.KeyValuePair<int, float>>;

namespace KKdMainLib
{
Expand Down Expand Up @@ -1075,7 +1074,7 @@ private Vec3<Key> RV3(string str) =>
private Key RK(string str)
{
Key key = new Key();
if ( dict.FV(out key.BinOffset, str + BO )) return key;
if ( dict.FV(out key.BinOffset, str + BO )) return key;
if (!dict.FV(out int type , str + ".type")) return default;

key.Type = (KeyType)type;
Expand All @@ -1095,11 +1094,24 @@ private Key RK(string str)

if (keyType != 0)
{
dict.FV(out string valueType, str + ".raw_data.value_type");
dict.FV(out int valueListSize, str + ".raw_data.value_list_size");

if (dict.FV(out int valueListOffset, str + ".raw_data.value_list_offset"))
{
if (keyType != 3)
return default;

key.RawData = true;
key.RawDataBinary = true;
key.RawDataValueListSize = valueListSize;
key.RawDataValueListOffset = valueListOffset;
return key;
}

string[] VL = null;
dict.FV(out string value_type, str + ".raw_data.value_type");
if (dict.FV(out value, str + ".raw_data.value_list"))
VL = value.Split(',');
dict.FV(out int valueListSize, str + ".raw_data.value_list_size");
value = "";

int ds = keyType + 1;
Expand Down Expand Up @@ -1180,7 +1192,7 @@ private void W(ref Key key, string str) =>

private void W(ref Key key, string str, bool a3dc)
{
if (a3dc) { W(str + BO, key.BinOffset); return; }
if (a3dc && !(key.RawData && key.RawDataBinary)) { W(str + BO, key.BinOffset); return; }

int i = 0;
if (key.Type < KeyType.Linear || key.Keys == null || (key.Keys != null && key.Keys.Length == 0))
Expand Down Expand Up @@ -1216,30 +1228,37 @@ private void W(ref Key key, string str, bool a3dc)
else if (key.Keys != null)
{
int length = key.Keys.Length;
int keyType = 0;
IKF kf;
W(str + ".max", (float)(key.Max ?? Data.PlayControl.Size));
for (i = 0; i < length && keyType < 3; i++)
int keyType = 0;
if (key.RawDataBinary)
{
kf = key.Keys[i].Check();
if (kf is KFT0 && keyType < 0) keyType = 0;
else if (kf is KFT1 && keyType < 1) keyType = 1;
else if (kf is KFT2 && keyType < 2) keyType = 2;
else if (kf is KFT3 && keyType < 3) keyType = 3;
W(str + ".raw_data.value_list_offset", key.RawDataValueListOffset);
keyType = 3;
}
int valueListSize = length * keyType + length;
s.W(str + ".raw_data.value_list=");
if (keyType == 0) for (i = 0; i < length; i++)
s.W(key.Keys[i].ToT0().ToString(false) + (i + 1 < length ? "," : ""));
else if (keyType == 1) for (i = 0; i < length; i++)
s.W(key.Keys[i].ToT1().ToString(false) + (i + 1 < length ? "," : ""));
else if (keyType == 2) for (i = 0; i < length; i++)
s.W(key.Keys[i].ToT2().ToString(false) + (i + 1 < length ? "," : ""));
else if (keyType == 3) for (i = 0; i < length; i++)
s.W(key.Keys[i] .ToString(false) + (i + 1 < length ? "," : ""));
s.P--;
s.W('\n');
W(str + ".raw_data.value_list_size", valueListSize);
else
{
for (i = 0; i < length && keyType < 3; i++)
{
IKF kf = key.Keys[i].Check();
if (kf is KFT0 && keyType < 0) keyType = 0;
else if (kf is KFT1 && keyType < 1) keyType = 1;
else if (kf is KFT2 && keyType < 2) keyType = 2;
else if (kf is KFT3 && keyType < 3) keyType = 3;
}

s.W(str + ".raw_data.value_list=");
if (keyType == 0) for (i = 0; i < length; i++)
s.W(key.Keys[i].ToT0().ToString(false) + (i + 1 < length ? "," : ""));
else if (keyType == 1) for (i = 0; i < length; i++)
s.W(key.Keys[i].ToT1().ToString(false) + (i + 1 < length ? "," : ""));
else if (keyType == 2) for (i = 0; i < length; i++)
s.W(key.Keys[i].ToT2().ToString(false) + (i + 1 < length ? "," : ""));
else if (keyType == 3) for (i = 0; i < length; i++)
s.W(key.Keys[i] .ToString(false) + (i + 1 < length ? "," : ""));
s.P--;
s.W('\n');
}
W(str + ".raw_data.value_list_size", length * keyType + length);
W(str + ".raw_data.value_type" , "float" );
W(str + ".raw_data_key_type" , keyType );
W(str + ".type", (int)key.Type);
Expand Down Expand Up @@ -1673,14 +1692,15 @@ public byte[] A3DCWriter()

private void RMT(ref ModelTransform mt)
{
if (mt.BinOffset == null) return;

s.P = (int)mt.BinOffset;
if (mt.BinOffset.HasValue)
{
s.P = (int)mt.BinOffset;

ReadOffset(out mt.Scale);
ReadOffset(out mt.Rot );
ReadOffset(out mt.Trans);
mt.Visibility = new Key { BinOffset = s.RI32() };
ReadOffset(out mt.Scale);
ReadOffset(out mt.Rot);
ReadOffset(out mt.Trans);
mt.Visibility = new Key { BinOffset = s.RI32() };
}

RV3(ref mt.Scale );
RV3(ref mt.Rot , true);
Expand All @@ -1705,15 +1725,32 @@ private void RKN(ref Key? key)

private void RK(ref Key key, bool f16 = false)
{
int length;
if (key.RawData)
{
if (!key.RawDataBinary)
return;

s.P = (int)key.RawDataValueListOffset;
key.RawDataValueListOffset = 0;

length = (int)key.RawDataValueListSize / 4;
key.Keys = new KFT3[length];
for (int i = 0; i < key.Keys.Length; i++)
{ ref KFT3 kf = ref key.Keys[i]; Vec4 v = s.RV4(); kf.F = v.X; kf.V = v.Y;
kf.T1 = v.Z; kf.T2 = v.W; }
return;
}

if (key.BinOffset == null || key.BinOffset < 0) return;

s.P = (int)key.BinOffset;
int Type = s.RI32();
int Type = s.RI32();
key.Value = s.RF32();
key.Type = (KeyType)(Type & 0xFF);
if (key.Type < KeyType.Linear) return;
key.Max = s.RF32();
int length = s.RI32();
key.Max = s.RF32();
length = s.RI32();
key.EPTypePost = (EPType)((Type >> 12) & 0xF);
key.EPTypePre = (EPType)((Type >> 8) & 0xF);
key.Keys = new KFT3[length];
Expand Down Expand Up @@ -1774,6 +1811,17 @@ private void W(ref Key? key)

private void W(ref Key key, bool f16 = false)
{
if (key.RawData) {
if (!key.RawDataBinary)
return;

key.RawDataValueListOffset = s.P;
key.RawDataValueListSize = key.Keys.Length * 4;
for (i = 0; i < key.Keys.Length; i++)
{ ref KFT3 kf = ref key.Keys[i]; s.W(new Vec4(kf.F, kf.V, kf.T1, kf.T2)); }
return;
}

key.BinOffset = s.P;
if (key.Type > KeyType.Static && key.Keys != null)
{
Expand Down Expand Up @@ -2906,7 +2954,8 @@ public static Key RK(this MsgPack msgPack)
if (key.Type == 0) { key.Value = 0; return key; }
else if (key.Type < KeyType.Linear) return key;

key.RawData = msgPack.RB("RawData");
key.RawData = msgPack.RB("RawData");
key.RawDataBinary = msgPack.RB("RawDataBinary");
MsgPack trans;
if ((trans = msgPack["Keys", true]).IsNull && (trans = msgPack["Trans", true]).IsNull) return key;

Expand Down Expand Up @@ -2982,7 +3031,8 @@ public static MsgPack Add(this MsgPack msgPack, string name, ref Key key)
if (key.EPTypePre != EPType.None)
keys.Add("EPTypePre", key.EPTypePre.ToString());

if (key.RawData) keys.Add("RawData", true);
if (key.RawData ) keys.Add("RawData" , true);
if (key.RawDataBinary) keys.Add("RawDataBinary", true);

int length = key.Keys.Length;
MsgPack Keys = new MsgPack(length, "Keys");
Expand Down
Loading

0 comments on commit 8b46fbb

Please sign in to comment.