Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35d7712d8f | ||
|
|
df92e13d2c | ||
|
|
803f64e333 | ||
|
|
a7e14e22ad | ||
|
|
d94f45870d | ||
|
|
2b46e0f4bd | ||
|
|
f1547f78b2 | ||
|
|
6c35326dda | ||
|
|
30a51f6bc4 | ||
|
|
54af060c13 | ||
|
|
84fd22b548 | ||
|
|
798b055756 | ||
|
|
30de413922 | ||
|
|
85a22ea0f7 | ||
|
|
99bb4e3571 | ||
|
|
036863a5a6 | ||
|
|
b6017d1d70 | ||
|
|
5de5d23e94 |
+15
-14
@@ -11,13 +11,10 @@ namespace KKdBaseLib
|
||||
public EPType EPTypePost;
|
||||
public float FrameDelta;
|
||||
public float ValueDelta;
|
||||
public int Unk1C;
|
||||
public int Unk20;
|
||||
public int Unk24;
|
||||
public int Unk28;
|
||||
public int Unk2C;
|
||||
public int Unk30;
|
||||
public int Unk34;
|
||||
public int Padding;
|
||||
public long FirstKey;
|
||||
public long SecondKey;
|
||||
public long AfterLastKey;
|
||||
public long Length;
|
||||
public long DataOffset; //Used only in-game and points to KFT3 Array
|
||||
|
||||
@@ -26,24 +23,28 @@ namespace KKdBaseLib
|
||||
public A3DAKey(Key k)
|
||||
{
|
||||
Type = 0; Value = MaxFrames = FrameDelta = ValueDelta = 0; EPTypePre = EPTypePost = 0;
|
||||
Unk1C = Unk20 = Unk24 = Unk28 = Unk2C = Unk30 = Unk34 = 0;
|
||||
FirstKey = SecondKey = AfterLastKey = Padding = 0;
|
||||
Length = DataOffset = 0; Keys = null;
|
||||
|
||||
EPTypePost = k.EPTypePost;
|
||||
EPTypePre = k.EPTypePre;
|
||||
MaxFrames = k.Max ?? 0;
|
||||
if (k.Type > KeyType.Value && k.Length > 1)
|
||||
if (k.Type > KeyType.Static && k.Keys != null && k.Keys.Length > 1)
|
||||
{
|
||||
Type = k.Type;
|
||||
Length = k.Length;
|
||||
Length = k.Keys.Length;
|
||||
Keys = k.Keys;
|
||||
FrameDelta = k.Keys[k.Length - 1].F - k.Keys[0].F;
|
||||
ValueDelta = k.Keys[k.Length - 1].V - k.Keys[0].V;
|
||||
EPTypePost = k.EPTypePost;
|
||||
EPTypePre = k.EPTypePre;
|
||||
FrameDelta = k.Keys[Length - 1].F - k.Keys[0].F;
|
||||
ValueDelta = k.Keys[Length - 1].V - k.Keys[0].V;
|
||||
}
|
||||
else
|
||||
{
|
||||
Type = k.Type;
|
||||
Value = k.Type > 0 ? k.Value : 0.0f;
|
||||
EPTypePost = 0;
|
||||
EPTypePre = 0;
|
||||
FrameDelta = 0;
|
||||
ValueDelta = Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+98
-83
@@ -2,6 +2,7 @@ namespace KKdBaseLib.Auth3D
|
||||
{
|
||||
public struct Data
|
||||
{
|
||||
public string[] Auth2D;
|
||||
public string[] Motion;
|
||||
public string[] ObjectList;
|
||||
public string[] ObjectHRCList;
|
||||
@@ -9,9 +10,11 @@ namespace KKdBaseLib.Auth3D
|
||||
public _ _;
|
||||
public DOF? DOF;
|
||||
public Fog[] Fog;
|
||||
public Chara[] Chara;
|
||||
public Curve[] Curve;
|
||||
public Event[] Event;
|
||||
public Light[] Light;
|
||||
public Point[] Point;
|
||||
public Object[] Object;
|
||||
public Ambient[] Ambient;
|
||||
public ObjectHRC[] ObjectHRC;
|
||||
@@ -20,8 +23,6 @@ namespace KKdBaseLib.Auth3D
|
||||
public PlayControl PlayControl;
|
||||
public PostProcess? PostProcess;
|
||||
public MaterialList[] MaterialList;
|
||||
public ModelTransform[] Chara;
|
||||
public ModelTransform[] Point;
|
||||
public CameraAuxiliary? CameraAuxiliary;
|
||||
}
|
||||
|
||||
@@ -36,8 +37,8 @@ namespace KKdBaseLib.Auth3D
|
||||
public struct Ambient
|
||||
{
|
||||
public string Name;
|
||||
public Vec4<Key>? LightDiffuse;
|
||||
public Vec4<Key>? RimLightDiffuse;
|
||||
public Vec4<Key?>? LightDiffuse;
|
||||
public Vec4<Key?>? RimLightDiffuse;
|
||||
}
|
||||
|
||||
public struct CameraAuxiliary
|
||||
@@ -46,6 +47,7 @@ namespace KKdBaseLib.Auth3D
|
||||
public Key? Exposure;
|
||||
public Key? Saturate;
|
||||
public Key? GammaRate;
|
||||
public Key? ExposureRate;
|
||||
public Key? AutoExposure;
|
||||
}
|
||||
|
||||
@@ -57,17 +59,23 @@ namespace KKdBaseLib.Auth3D
|
||||
|
||||
public struct ViewPoint
|
||||
{
|
||||
public bool FOVHorizontal;
|
||||
public float? Aspect;
|
||||
public float? CameraApertureH;
|
||||
public float? CameraApertureW;
|
||||
public Key FOV;
|
||||
public Key Roll;
|
||||
public Key FocalLength;
|
||||
public bool FOVIsHorizontal;
|
||||
public float Aspect;
|
||||
public float CameraApertureH;
|
||||
public float CameraApertureW;
|
||||
public Key? FocalLength;
|
||||
public Key? FOV;
|
||||
public Key? Roll;
|
||||
public ModelTransform MT;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Chara
|
||||
{
|
||||
public ModelTransform MT;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public struct Curve
|
||||
{
|
||||
public string Name;
|
||||
@@ -76,18 +84,17 @@ namespace KKdBaseLib.Auth3D
|
||||
|
||||
public struct DOF
|
||||
{
|
||||
public string Name;
|
||||
public ModelTransform MT;
|
||||
}
|
||||
|
||||
public struct Event
|
||||
{
|
||||
public int? Type;
|
||||
public float? End;
|
||||
public float? Begin;
|
||||
public float? ClipEnd;
|
||||
public float? ClipBegin;
|
||||
public float? TimeRefScale;
|
||||
public int Type;
|
||||
public float End;
|
||||
public float Begin;
|
||||
public float ClipEnd;
|
||||
public float ClipBegin;
|
||||
public float TimeRefScale;
|
||||
public string Name;
|
||||
public string Param1;
|
||||
public string Ref;
|
||||
@@ -95,32 +102,33 @@ namespace KKdBaseLib.Auth3D
|
||||
|
||||
public struct Fog
|
||||
{
|
||||
public int? Id;
|
||||
public Key End;
|
||||
public Key Start;
|
||||
public Key Density;
|
||||
public Vec4<Key>? Diffuse;
|
||||
public int Id;
|
||||
public Key? End;
|
||||
public Key? Start;
|
||||
public Key? Density;
|
||||
public Vec4<Key?>? Color;
|
||||
}
|
||||
|
||||
public enum CompressF16 : int
|
||||
{
|
||||
F32F32F32F32 = 0,
|
||||
I16F16F32F32 = 1,
|
||||
I16F16F16F16 = 2,
|
||||
Type0 = 0,
|
||||
Type1 = 1,
|
||||
Type2 = 2,
|
||||
}
|
||||
|
||||
public enum EPType : int
|
||||
public enum EPType : int // Pre/Post Infinity
|
||||
{
|
||||
EP_1 = 1,
|
||||
EP_2 = 2,
|
||||
EP_3 = 3,
|
||||
None = 0,
|
||||
Linear = 1,
|
||||
Cycle = 2,
|
||||
CycleOffset = 3,
|
||||
}
|
||||
|
||||
public enum KeyType : int
|
||||
{
|
||||
Null = 0,
|
||||
Value = 1,
|
||||
Lerp = 2,
|
||||
None = 0,
|
||||
Static = 1,
|
||||
Linear = 2,
|
||||
Hermite = 3,
|
||||
Hold = 4,
|
||||
}
|
||||
@@ -128,20 +136,18 @@ namespace KKdBaseLib.Auth3D
|
||||
public struct Key
|
||||
{
|
||||
public KeyType Type;
|
||||
public int Length;
|
||||
public int? BinOffset;
|
||||
public EPType EPTypePre;
|
||||
public EPType EPTypePost;
|
||||
public float? Max;
|
||||
public float Value;
|
||||
public RawD RawData;
|
||||
public bool RawData;
|
||||
public KFT3[] Keys;
|
||||
|
||||
public Key(A3DAKey k)
|
||||
{
|
||||
Type = 0;
|
||||
Value = 0;
|
||||
Length = 0;
|
||||
BinOffset = null;
|
||||
RawData = default;
|
||||
Keys = null;
|
||||
@@ -152,34 +158,31 @@ namespace KKdBaseLib.Auth3D
|
||||
if (k.Length > 1)
|
||||
{
|
||||
Type = k.Type;
|
||||
Length = (int)k.Length;
|
||||
Keys = k.Keys;
|
||||
}
|
||||
else if (k.Length == 1)
|
||||
{
|
||||
Type = KeyType.Value;
|
||||
Type = KeyType.Static;
|
||||
Value = k.Keys[0].V;
|
||||
}
|
||||
}
|
||||
|
||||
public struct RawD
|
||||
{
|
||||
public int KeyType;
|
||||
public int ValueListSize;
|
||||
public string ValueType;
|
||||
public string[] ValueList;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Light
|
||||
{
|
||||
public int? Id;
|
||||
public string Name;
|
||||
public int Id;
|
||||
public string Type;
|
||||
public Vec4<Key>? Ambient;
|
||||
public Vec4<Key>? Diffuse;
|
||||
public Vec4<Key>? Specular;
|
||||
public Vec4<Key>? Incandescence;
|
||||
public Key? ConeAngle;
|
||||
public Key? Constant;
|
||||
public Key? DropOff;
|
||||
public Key? Far;
|
||||
public Key? Intensity;
|
||||
public Key? Linear;
|
||||
public Key? Quadratic;
|
||||
public Vec4<Key?>? Ambient;
|
||||
public Vec4<Key?>? Diffuse;
|
||||
public Vec4<Key?>? Specular;
|
||||
public Vec4<Key?>? ToneCurve;
|
||||
public ModelTransform Position;
|
||||
public ModelTransform SpotDirection;
|
||||
}
|
||||
@@ -187,23 +190,21 @@ namespace KKdBaseLib.Auth3D
|
||||
public struct MaterialList
|
||||
{
|
||||
public string Name;
|
||||
public string HashName;
|
||||
public Key GlowIntensity;
|
||||
public Vec4<Key>? BlendColor;
|
||||
public Vec4<Key>? Incandescence;
|
||||
public Key? GlowIntensity;
|
||||
public Vec4<Key?>? BlendColor;
|
||||
public Vec4<Key?>? Incandescence;
|
||||
}
|
||||
|
||||
public struct MObjectHRC
|
||||
{
|
||||
public string Name;
|
||||
public Node[] Node;
|
||||
public Vec3<float?> JointOrient;
|
||||
public ObjectNode[] Node;
|
||||
public Instance[] Instances;
|
||||
public ModelTransform MT;
|
||||
|
||||
public struct Instance
|
||||
{
|
||||
public int? Shadow;
|
||||
public bool Shadow;
|
||||
public string Name;
|
||||
public string UIDName;
|
||||
public ModelTransform MT;
|
||||
@@ -212,7 +213,6 @@ namespace KKdBaseLib.Auth3D
|
||||
|
||||
public struct ModelTransform
|
||||
{
|
||||
public bool Writed;
|
||||
public int? BinOffset;
|
||||
public Key Visibility;
|
||||
public Vec3<Key> Rot;
|
||||
@@ -220,27 +220,23 @@ namespace KKdBaseLib.Auth3D
|
||||
public Vec3<Key> Trans;
|
||||
}
|
||||
|
||||
public struct Node
|
||||
{
|
||||
public int? Parent;
|
||||
public string Name;
|
||||
public ModelTransform MT;
|
||||
}
|
||||
|
||||
public struct Object
|
||||
{
|
||||
public int? MorphOffset;
|
||||
public float PatOffset;
|
||||
public float MorphOffset;
|
||||
public string Name;
|
||||
public string Pat;
|
||||
public string Morph;
|
||||
public string UIDName;
|
||||
public string ParentName;
|
||||
public string ParentNode;
|
||||
public ModelTransform MT;
|
||||
public TexturePattern[] TexPat;
|
||||
public TextureTransform[] TexTrans;
|
||||
|
||||
public struct TexturePattern
|
||||
{
|
||||
public int? PatOffset;
|
||||
public float PatOffset;
|
||||
public string Pat;
|
||||
public string Name;
|
||||
}
|
||||
@@ -250,29 +246,48 @@ namespace KKdBaseLib.Auth3D
|
||||
public string Name;
|
||||
public Key? Rotate;
|
||||
public Key? RotateFrame;
|
||||
public Vec2<Key?> Offset;
|
||||
public Vec2<Key?> Repeat;
|
||||
public Vec2<Key?> Coverage;
|
||||
public Vec2<Key?> TranslateFrame;
|
||||
public Key? OffsetU;
|
||||
public Key? OffsetV;
|
||||
public Key? RepeatU;
|
||||
public Key? RepeatV;
|
||||
public Key? CoverageU;
|
||||
public Key? CoverageV;
|
||||
public Key? TranslateFrameU;
|
||||
public Key? TranslateFrameV;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ObjectHRC
|
||||
{
|
||||
public int? Shadow;
|
||||
public bool Shadow;
|
||||
public string Name;
|
||||
public string UIDName;
|
||||
public Node[] Node;
|
||||
public Vec3<float?> JointOrient;
|
||||
public string ParentName;
|
||||
public string ParentNode;
|
||||
public ObjectNode[] Node;
|
||||
}
|
||||
|
||||
public struct ObjectNode
|
||||
{
|
||||
public Vec3? JointOrient;
|
||||
public int Parent;
|
||||
public string Name;
|
||||
public ModelTransform MT;
|
||||
}
|
||||
|
||||
public struct PlayControl
|
||||
{
|
||||
public int Begin;
|
||||
public float Begin;
|
||||
public int? Div;
|
||||
public int FPS;
|
||||
public int? Offset;
|
||||
public int Size;
|
||||
public float FPS;
|
||||
public float? Offset;
|
||||
public float Size;
|
||||
}
|
||||
|
||||
public struct Point
|
||||
{
|
||||
public ModelTransform MT;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public struct PostProcess
|
||||
@@ -280,8 +295,8 @@ namespace KKdBaseLib.Auth3D
|
||||
public Key? LensFlare;
|
||||
public Key? LensGhost;
|
||||
public Key? LensShaft;
|
||||
public Vec4<Key>? Ambient;
|
||||
public Vec4<Key>? Diffuse;
|
||||
public Vec4<Key>? Specular;
|
||||
public Vec4<Key?>? Intensity;
|
||||
public Vec4<Key?>? Radius;
|
||||
public Vec4<Key?>? SceneFade;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace KKdBaseLib
|
||||
public static string ToS(this ulong? d) => (d ?? default).ToString();
|
||||
public static string ToS(this ulong d) => d.ToString();
|
||||
public static string ToS(this float? d, int round) => (d ?? default).ToS(round);
|
||||
public static string ToS(this float? d) => (d ?? default).ToS();
|
||||
public static string ToS(this float? d) => (d ?? default).ToS(15);
|
||||
public static string ToS(this float d, int round)
|
||||
{ string s = (d.ToU32() & 0x80000000) != 0 ? "-" : ""; d = (d.ToU32() & 0x7FFFFFFF).ToF32();
|
||||
return s + Math.Round(d, round).ToString().ToLower().Replace(NDS, "."); }
|
||||
|
||||
+95
-81
@@ -24,12 +24,10 @@ namespace KKdBaseLib.F2
|
||||
for (i = 0; i < ENRSCount; i++)
|
||||
{
|
||||
enrsEntry = default;
|
||||
enrsEntry.Offset = ReadENRSValue(ref localPtr);
|
||||
enrsEntry.Count = ReadENRSValue(ref localPtr);
|
||||
enrsEntry.Size = ReadENRSValue(ref localPtr);
|
||||
enrsEntry.Repeat = ReadENRSValue(ref localPtr);
|
||||
|
||||
if (i > 0) enrsEntry.Offset += Array[i - 1].Offset;
|
||||
if (ReadENRSValue(ref localPtr, out enrsEntry.Offset)) return;
|
||||
if (ReadENRSValue(ref localPtr, out enrsEntry.Count )) return;
|
||||
if (ReadENRSValue(ref localPtr, out enrsEntry.Size )) return;
|
||||
if (ReadENRSValue(ref localPtr, out enrsEntry.Repeat)) return;
|
||||
|
||||
if (enrsEntry.Repeat < 1) { enrsEntry.Sub = null; Array[i] = enrsEntry; continue; }
|
||||
|
||||
@@ -37,9 +35,8 @@ namespace KKdBaseLib.F2
|
||||
for (i0 = 0; i0 < enrsEntry.Count; i0++)
|
||||
{
|
||||
sub = default;
|
||||
sub.Skip = ReadENRSValue(ref localPtr, out sub.Type);
|
||||
sub.Reverse = ReadENRSValue(ref localPtr);
|
||||
if (i0 > 0) sub.Skip += enrsEntry.Sub[i0 - 1].SizeSkip;
|
||||
if (ReadENRSValue(ref localPtr, out sub.Skip, out sub.Type)) return;
|
||||
if (ReadENRSValue(ref localPtr, out sub.Reverse )) return;
|
||||
enrsEntry.Sub[i0] = sub;
|
||||
|
||||
if (enrsEntry.Sub[i0].Type == ENRSEntry.Type.Invalid) { Array = null; return; }
|
||||
@@ -65,41 +62,41 @@ namespace KKdBaseLib.F2
|
||||
for (i = 0; i < Array.Length; i++)
|
||||
{
|
||||
ENRSEntry enrsEntry = Array[i];
|
||||
WriteENRSValue(ref localPtr, i > 0 ? enrsEntry.Offset -
|
||||
Array[i - 1].Offset : enrsEntry.Offset);
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Count > enrsEntry.Sub.Length ?
|
||||
enrsEntry.Sub.Length : enrsEntry.Count);
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Size );
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Repeat);
|
||||
if (WriteENRSValue(ref localPtr, enrsEntry.Offset)) goto End;
|
||||
if (WriteENRSValue(ref localPtr, enrsEntry.Count )) goto End;
|
||||
if (WriteENRSValue(ref localPtr, enrsEntry.Size )) goto End;
|
||||
if (WriteENRSValue(ref localPtr, enrsEntry.Repeat)) goto End;
|
||||
|
||||
if (enrsEntry.Repeat < 1) continue;
|
||||
|
||||
for (i0 = 0; i0 < enrsEntry.Count && i0 < enrsEntry.Sub.Length; i0++)
|
||||
{
|
||||
if (enrsEntry.Sub[i0].Type < ENRSEntry.Type. WORD ||
|
||||
enrsEntry.Sub[i0].Type > ENRSEntry.Type.QWORD)
|
||||
if (enrsEntry.Sub[i0].Type > ENRSEntry.Type.QWORD)
|
||||
return data;
|
||||
|
||||
WriteENRSValue(ref localPtr, i0 > 0 ? enrsEntry.Sub[i0].Skip -
|
||||
enrsEntry.Sub[i0 - 1].SizeSkip : enrsEntry.Sub[i0].Skip, enrsEntry.Sub[i0].Type);
|
||||
WriteENRSValue(ref localPtr, enrsEntry.Sub[i0].Reverse);
|
||||
if (WriteENRSValue(ref localPtr, enrsEntry.Sub[i0].Skip, enrsEntry.Sub[i0].Type)) goto End;
|
||||
if (WriteENRSValue(ref localPtr, enrsEntry.Sub[i0].Reverse )) goto End;
|
||||
}
|
||||
}
|
||||
}
|
||||
End:
|
||||
return data;
|
||||
}
|
||||
|
||||
private int length()
|
||||
{
|
||||
if (Array == null)
|
||||
return 0;
|
||||
|
||||
int i, i0;
|
||||
int length = 0x10;
|
||||
for (i = 0; i < Array.Length; i++)
|
||||
{
|
||||
ENRSEntry enrs = Array[i];
|
||||
length += GetSize(i > 0 ? enrs.Offset - Array[i - 1].Offset : enrs.Offset);
|
||||
length += GetSize(enrs.Count );
|
||||
length += GetSize(enrs.Size );
|
||||
length += GetSize(enrs.Repeat);
|
||||
if (GetSize(enrs.Offset, ref length)) goto End;
|
||||
if (GetSize(enrs.Count , ref length)) goto End;
|
||||
if (GetSize(enrs.Size , ref length)) goto End;
|
||||
if (GetSize(enrs.Repeat, ref length)) goto End;
|
||||
|
||||
if (enrs.Repeat < 1) continue;
|
||||
|
||||
@@ -108,15 +105,24 @@ namespace KKdBaseLib.F2
|
||||
if (enrs.Sub[i0].Type < ENRSEntry.Type. WORD ||
|
||||
enrs.Sub[i0].Type > ENRSEntry.Type.QWORD) return length.A(0x10);
|
||||
|
||||
length += GetSizeType(i0 > 0 ? enrs.Sub[i0].Skip -
|
||||
enrs.Sub[i0 - 1].SizeSkip : enrs.Sub[i0].Skip);
|
||||
length += GetSize(enrs.Sub[i0].Reverse);
|
||||
if (GetSizeType(enrs.Sub[i0].Skip , ref length)) goto End;
|
||||
if (GetSize (enrs.Sub[i0].Reverse, ref length)) goto End;
|
||||
}
|
||||
}
|
||||
End:
|
||||
return length.A(0x10);
|
||||
|
||||
static int GetSizeType(int val) => val < 0x00000010 ? 1 : val < 0x00001000 ? 2 : 4;
|
||||
static int GetSize (int val) => val < 0x00000040 ? 1 : val < 0x00004000 ? 2 : 4;
|
||||
static bool GetSizeType(int val, ref int length)
|
||||
{
|
||||
length += val < 0x00000010 ? 1 : val < 0x00001000 ? 2 : val < 0x10000000 ? 4 : 1;
|
||||
return val >= 0x10000000;
|
||||
}
|
||||
|
||||
static bool GetSize (int val, ref int length)
|
||||
{
|
||||
length += val < 0x00000040 ? 1 : val < 0x00004000 ? 2 : val < 0x40000000 ? 4 : 1;
|
||||
return val >= 0x40000000;
|
||||
}
|
||||
}
|
||||
|
||||
/*private static KKdList<ENRS.SubENRS> Optimize(KKdList<ENRS.SubENRS> Sub)
|
||||
@@ -138,73 +144,76 @@ namespace KKdBaseLib.F2
|
||||
|
||||
[System.ThreadStatic] private static ENRSEntry.Value value;
|
||||
|
||||
private unsafe static int ReadENRSValue(ref byte* ptr, out ENRSEntry.Type type)
|
||||
private unsafe static bool ReadENRSValue(ref byte* ptr, out int v, out ENRSEntry.Type type)
|
||||
{
|
||||
int V = *ptr & 0xF;
|
||||
v = *ptr & 0xF;
|
||||
type = (ENRSEntry. Type)((*ptr & 0x30) >> 4);
|
||||
value = (ENRSEntry.Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (value == ENRSEntry.Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (value == ENRSEntry.Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (value == ENRSEntry.Value.Invalid) V = 0;
|
||||
return V;
|
||||
if (value == ENRSEntry.Value.Int32 ) v = (((((v << 8) | *ptr++) << 8) | *ptr++) << 8) | *ptr++;
|
||||
else if (value == ENRSEntry.Value.Int16 ) v = (v << 8) | *ptr++;
|
||||
else if (value == ENRSEntry.Value.Invalid) { v = 0; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe static int ReadENRSValue(ref byte* ptr)
|
||||
private unsafe static bool ReadENRSValue(ref byte* ptr, out int v)
|
||||
{
|
||||
int V = *ptr & 0x3F;
|
||||
v = *ptr & 0x3F;
|
||||
value = (ENRSEntry.Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (value == ENRSEntry.Value.Int32 )
|
||||
{ V = (V << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; ptr += 3; }
|
||||
else if (value == ENRSEntry.Value.Int16 )
|
||||
{ V = (V << 8) | ptr[0]; ptr += 1; }
|
||||
else if (value == ENRSEntry.Value.Invalid) V = 0;
|
||||
return V;
|
||||
if (value == ENRSEntry.Value.Int32 ) v = (((((v << 8) | *ptr++) << 8) | *ptr++) << 8) | *ptr++;
|
||||
else if (value == ENRSEntry.Value.Int16 ) v = (v << 8) | *ptr++;
|
||||
else if (value == ENRSEntry.Value.Invalid) { v = 0; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe static void WriteENRSValue(ref byte* ptr, int val, ENRSEntry.Type type)
|
||||
private unsafe static bool WriteENRSValue(ref byte* ptr, int val, ENRSEntry.Type type)
|
||||
{
|
||||
value = ENRSEntry.Value.Invalid;
|
||||
if (val < 0x00000040) value = ENRSEntry.Value.Int8 ;
|
||||
else if (val < 0x00004000) value = ENRSEntry.Value.Int16;
|
||||
else if (val < 0x40000000) value = ENRSEntry.Value.Int32;
|
||||
*ptr = (byte)((((byte)value << 6) & 0xC0) | (((byte)type << 4) & 0x30));
|
||||
|
||||
if (val < 0x00000010)
|
||||
{ *ptr |= (byte)( val & 0x0F); }
|
||||
byte t = (byte)(((byte)type & 0x3) << 4);
|
||||
if (val < 0x00000010)
|
||||
*ptr++ = (byte)(((byte)ENRSEntry.Value.Int8 << 6) | t | ( val & 0xF));
|
||||
else if (val < 0x00001000)
|
||||
{ *ptr |= (byte)((val >> 8) & 0x0F); ptr++;
|
||||
*ptr = (byte)( val & 0xFF); }
|
||||
{
|
||||
*ptr++ = (byte)(((byte)ENRSEntry.Value.Int16 << 6) | t | ((val >> 8) & 0xF));
|
||||
*ptr++ = (byte)(val & 0xFF);
|
||||
}
|
||||
else if (val < 0x10000000)
|
||||
{ *ptr |= (byte)((val >> 24) & 0x0F); ptr++;
|
||||
*ptr = (byte)((val >> 16) & 0xFF); ptr++;
|
||||
*ptr = (byte)((val >> 8) & 0xFF); ptr++;
|
||||
*ptr = (byte)( val & 0xFF); }
|
||||
ptr++;
|
||||
{
|
||||
*ptr++ = (byte)(((byte)ENRSEntry.Value.Int32 << 6) | t | ((val >> 24) & 0xF));
|
||||
*ptr++ = (byte)((val >> 16) & 0xFF);
|
||||
*ptr++ = (byte)((val >> 8) & 0xFF);
|
||||
*ptr++ = (byte)( val & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr++ = (byte)ENRSEntry.Value.Invalid << 6;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe static void WriteENRSValue(ref byte* ptr, int val)
|
||||
private unsafe static bool WriteENRSValue(ref byte* ptr, int val)
|
||||
{
|
||||
value = ENRSEntry.Value.Invalid;
|
||||
if (val < 0x00000040) value = ENRSEntry.Value.Int8 ;
|
||||
else if (val < 0x00004000) value = ENRSEntry.Value.Int16;
|
||||
else if (val < 0x40000000) value = ENRSEntry.Value.Int32;
|
||||
*ptr = (byte)(((byte)value << 6) & 0xC0);
|
||||
|
||||
if (val < 0x00000040)
|
||||
{ *ptr |= (byte)( val & 0x3F); }
|
||||
if (val < 0x00000040)
|
||||
*ptr++ = (byte)(((byte)ENRSEntry.Value.Int8 << 6) | ( val & 0x3F));
|
||||
else if (val < 0x00004000)
|
||||
{ *ptr |= (byte)((val >> 8) & 0x3F); ptr++;
|
||||
*ptr = (byte)( val & 0xFF); }
|
||||
{
|
||||
*ptr++ = (byte)(((byte)ENRSEntry.Value.Int16 << 6) | ((val >> 8) & 0x3F));
|
||||
*ptr++ = (byte)(val & 0xFF);
|
||||
}
|
||||
else if (val < 0x40000000)
|
||||
{ *ptr |= (byte)((val >> 24) & 0x3F); ptr++;
|
||||
*ptr = (byte)((val >> 16) & 0xFF); ptr++;
|
||||
*ptr = (byte)((val >> 8) & 0xFF); ptr++;
|
||||
*ptr = (byte)( val & 0xFF); }
|
||||
ptr++;
|
||||
{
|
||||
*ptr++ = (byte)(((byte)ENRSEntry.Value.Int32 << 6) | ((val >> 24) & 0x3F));
|
||||
*ptr++ = (byte)((val >> 16) & 0xFF);
|
||||
*ptr++ = (byte)((val >> 8) & 0xFF);
|
||||
*ptr++ = (byte)( val & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr++ = (byte)ENRSEntry.Value.Invalid << 6;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public struct ENRSEntry
|
||||
@@ -215,6 +224,9 @@ namespace KKdBaseLib.F2
|
||||
public int Repeat;
|
||||
public SubENRSEntry[] Sub;
|
||||
|
||||
public ENRSEntry(int offset, int count, int size, int repeat)
|
||||
{ Offset = offset; Count = count; Size = size; Repeat = repeat; Sub = new SubENRSEntry[count]; }
|
||||
|
||||
public enum Type : byte
|
||||
{
|
||||
WORD = 0b00,
|
||||
@@ -237,16 +249,18 @@ namespace KKdBaseLib.F2
|
||||
public int Reverse;
|
||||
public Type Type;
|
||||
|
||||
public SubENRSEntry(int skip, int reverse, Type type)
|
||||
{ Skip = skip; Reverse = reverse; Type = type; }
|
||||
|
||||
public int SizeSkip => Skip + Reverse * (2 << (byte)Type);
|
||||
public int Size => Reverse * (2 << (byte)Type);
|
||||
|
||||
public override string ToString() => "Skip: " + Skip +
|
||||
"; Reverse: " + Reverse + "; Type: " + Type;
|
||||
public override string ToString() =>
|
||||
$"Skip: {Skip}; Reverse: {Reverse}; Type: {Type}";
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
"Offset: " + Offset + "; Count: " + Count + "; " +
|
||||
"Size: " + Size + "; Repeat: " + Repeat;
|
||||
$"Offset: {Offset}; Count: {Count}; Size: {Size}; Repeat: {Repeat}";
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace KKdBaseLib.F2
|
||||
public uint SectionSize; // 0x14
|
||||
public uint Version; // 0x18
|
||||
public uint InnerSignature; // 0x30
|
||||
public uint SectionSignature; // 0x40
|
||||
|
||||
public Format Format;
|
||||
public bool UseBigEndian;
|
||||
|
||||
+69
-35
@@ -12,7 +12,6 @@ namespace KKdBaseLib.F2
|
||||
|
||||
public unsafe void Read(byte[] data, bool shiftX)
|
||||
{
|
||||
Value Val = 0;
|
||||
Offsets = KKdList<long>.New;
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
@@ -25,14 +24,7 @@ namespace KKdBaseLib.F2
|
||||
Offsets.Capacity = length;
|
||||
while (length > i)
|
||||
{
|
||||
v = *l & 0x3F;
|
||||
Val = (Value)(*l & 0xC0);
|
||||
if (Val == Value.Int32)
|
||||
{ v = (v << 24) | (l[1] << 16) | (l[2] << 8) | l[3]; l += 4; i += 4; }
|
||||
else if (Val == Value.Int16)
|
||||
{ v = (v << 8) | l[1]; l += 2; i += 2; }
|
||||
else if (Val == Value.Int8 ) { l ++ ; i ++ ; }
|
||||
else break;
|
||||
if (ReadPOFValue(ref l, out v)) break;
|
||||
j++;
|
||||
offset += v;
|
||||
Offsets.Add(offset << bitShift);
|
||||
@@ -44,44 +36,85 @@ namespace KKdBaseLib.F2
|
||||
public unsafe byte[] Write(bool shiftX)
|
||||
{
|
||||
Offsets.Sort();
|
||||
long offset = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
int max1 = 0x00100 >> bitShift;
|
||||
int max2 = 0x10000 >> bitShift;
|
||||
long j, k, o;
|
||||
byte bitShift, v;
|
||||
bitShift = (byte)(shiftX ? 3 : 2);
|
||||
v = (byte)((1 << bitShift) - 1);
|
||||
|
||||
j = 0;
|
||||
byte[] data = new byte[length(shiftX)];
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
byte Val = 0;
|
||||
*(int*)ptr = length(shiftX);
|
||||
byte* localPtr = ptr + 4;
|
||||
byte* l = ptr + 4;
|
||||
for (int i = 0; i < Offsets.Count; i++)
|
||||
{
|
||||
offset = Offsets[i];
|
||||
if (i > 0) { offset -= Offsets[i - 1]; if (offset == 0) continue; }
|
||||
o = Offsets[i];
|
||||
if ((o & v) != 0)
|
||||
{
|
||||
WritePOFValue(ref l, 0x7FFFFFFF);
|
||||
break;
|
||||
}
|
||||
|
||||
offset >>= bitShift;
|
||||
Val = (byte)(offset > max2 ? Value.Int32 : offset > max1 ? Value.Int16 : Value.Int8);
|
||||
if (offset < max1) *localPtr = (byte)(Val | offset );
|
||||
else if (offset < max2) { *localPtr = (byte)(Val | (offset >> 8)); localPtr++;
|
||||
*localPtr = (byte) offset ; }
|
||||
else { *localPtr = (byte)(Val | (offset >> 24)); localPtr++;
|
||||
*localPtr = (byte) (offset >> 16) ; localPtr++;
|
||||
*localPtr = (byte) (offset >> 8) ; localPtr++;
|
||||
*localPtr = (byte) offset ; }
|
||||
localPtr++;
|
||||
k = o - j;
|
||||
if (i > 0 & k == 0)
|
||||
continue;
|
||||
j = o;
|
||||
o = k;
|
||||
WritePOFValue(ref l, o >> bitShift);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
[System.ThreadStatic] private static Value value;
|
||||
|
||||
private unsafe static bool ReadPOFValue(ref byte* ptr, out int v)
|
||||
{
|
||||
v = *ptr & 0x3F;
|
||||
value = (Value)((*ptr & 0xC0) >> 6);
|
||||
ptr++;
|
||||
if (value == Value.Int32 ) v = (((((v << 8) | *ptr++) << 8) | *ptr++) << 8) | *ptr++;
|
||||
else if (value == Value.Int16 ) v = (v << 8) | *ptr++;
|
||||
else if (value == Value.Invalid) { v = 0; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe static bool WritePOFValue(ref byte* ptr, long val)
|
||||
{
|
||||
if (val < 0x00000040)
|
||||
*ptr++ = (byte)(((byte)Value.Int8 << 6) | ( val & 0x3F));
|
||||
else if (val < 0x00004000)
|
||||
{
|
||||
*ptr++ = (byte)(((byte)Value.Int16 << 6) | ((val >> 8) & 0x3F));
|
||||
*ptr++ = (byte)(val & 0xFF);
|
||||
}
|
||||
else if (val < 0x40000000)
|
||||
{
|
||||
*ptr++ = (byte)(((byte)Value.Int32 << 6) | ((val >> 24) & 0x3F));
|
||||
*ptr++ = (byte)((val >> 16) & 0xFF);
|
||||
*ptr++ = (byte)((val >> 8) & 0xFF);
|
||||
*ptr++ = (byte)( val & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr++ = (byte)Value.Invalid << 6;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int length(bool shiftX = false)
|
||||
{
|
||||
int length = 6;
|
||||
if (Offsets.IsNull)
|
||||
return 0;
|
||||
|
||||
int length = 4;
|
||||
long offset = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
int max1 = 0x00100 >> bitShift;
|
||||
int max2 = 0x10000 >> bitShift;
|
||||
int max1 = 0x00000040;
|
||||
int max2 = 0x00004000;
|
||||
int max3 = 0x40000000;
|
||||
for (int i = 0; i < Offsets.Count; i++)
|
||||
{
|
||||
offset = Offsets[i];
|
||||
@@ -90,17 +123,18 @@ namespace KKdBaseLib.F2
|
||||
offset >>= bitShift;
|
||||
if (offset < max1) length += 1;
|
||||
else if (offset < max2) length += 2;
|
||||
else length += 4;
|
||||
else if (offset < max3) length += 4;
|
||||
else length += 1;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
public enum Value : byte
|
||||
{
|
||||
Invalid = 0b00000000,
|
||||
Int8 = 0b01000000,
|
||||
Int16 = 0b10000000,
|
||||
Int32 = 0b11000000,
|
||||
Invalid = 0b00,
|
||||
Int8 = 0b01,
|
||||
Int16 = 0b10,
|
||||
Int32 = 0b11,
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
|
||||
@@ -12,18 +12,16 @@ namespace KKdBaseLib.F2
|
||||
public uint Length => length(false);
|
||||
public uint LengthX => length( true);
|
||||
|
||||
public uint Depth => Header.Depth;
|
||||
|
||||
public bool HasPOF => POF .NotNull;
|
||||
public bool HasENRS => ENRS.NotNull;
|
||||
public bool HasSubStructs => SubStructs != null;
|
||||
|
||||
public long DataOffset;
|
||||
|
||||
public void Update(bool ShiftX = false)
|
||||
public void Update(bool shiftX = false)
|
||||
{
|
||||
Header.SectionSize = Data != null ? (uint)Data.Length : 0;
|
||||
Header.DataSize = length(ShiftX);
|
||||
Header.DataSize = length(shiftX);
|
||||
}
|
||||
|
||||
private uint length(bool shiftX = false)
|
||||
@@ -31,14 +29,12 @@ namespace KKdBaseLib.F2
|
||||
uint length = Data != null ? (uint)Data.Length : 0;
|
||||
if (HasPOF ) length += 0x20 + (uint)(shiftX ? POF.LengthX : POF.Length);
|
||||
if (HasENRS) length += 0x20 + (uint)ENRS.Length;
|
||||
|
||||
if (HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < SubStructs.Length; i++)
|
||||
length += (uint)(shiftX ? SubStructs[i].LengthX : SubStructs[i].Length)
|
||||
+ SubStructs[i].Header.Length;
|
||||
if (HasPOF || HasENRS || HasSubStructs)
|
||||
length += 0x20;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
+59
-33
@@ -4,67 +4,93 @@ namespace KKdBaseLib
|
||||
{
|
||||
public struct Half : IFormattable
|
||||
{
|
||||
private ushort _value;
|
||||
private ushort value;
|
||||
|
||||
public static Half NaN => new Half { _value = 0x7FFF };
|
||||
public static Half PositiveNaN => new Half { _value = 0x7FFF };
|
||||
public static Half NegativeNaN => new Half { _value = 0xFFFF };
|
||||
public static Half PositiveZero => new Half { _value = 0x0000 };
|
||||
public static Half NegativeZero => new Half { _value = 0x8000 };
|
||||
public static Half PositiveInfinity => new Half { _value = 0x7C00 };
|
||||
public static Half NegativeInfinity => new Half { _value = 0xFC00 };
|
||||
public static Half NaN => new Half { value = 0x7FFF };
|
||||
public static Half PositiveNaN => new Half { value = 0x7FFF };
|
||||
public static Half NegativeNaN => new Half { value = 0xFFFF };
|
||||
public static Half PositiveZero => new Half { value = 0x0000 };
|
||||
public static Half NegativeZero => new Half { value = 0x8000 };
|
||||
public static Half PositiveInfinity => new Half { value = 0x7C00 };
|
||||
public static Half NegativeInfinity => new Half { value = 0xFC00 };
|
||||
|
||||
public static explicit operator Half(ushort bits) => new Half() { _value = bits };
|
||||
public static explicit operator Half(ushort bits) => new Half() { value = bits };
|
||||
|
||||
public static explicit operator ushort(Half bits) => bits._value;
|
||||
public static explicit operator ushort(Half bits) => bits.value;
|
||||
|
||||
public static unsafe implicit operator float(Half h)
|
||||
{
|
||||
int sign = (h._value >> 15) & 0x001;
|
||||
int exponent = ((h._value >> 10) & 0x01F) + 127 - 15;
|
||||
int mantissa = h._value & 0x3FF;
|
||||
int si32;
|
||||
int sign = (h.value >> 15) & 0x001;
|
||||
int exponent = (h.value >> 10) & 0x01F;
|
||||
int mantissa = h.value & 0x3FF;
|
||||
unchecked { si32 = sign != 0 ? (int)0x80000000 : 0x00000000; }
|
||||
|
||||
int si32 = (sign << 31) | (exponent << 23) | (mantissa << 13);
|
||||
if (exponent == 0x1F) si32 |= 0x7F800000;
|
||||
else if (exponent != 0x00) si32 |= (exponent - 15 + 127) << 23;
|
||||
si32 |= mantissa << 13;
|
||||
return *(float*)&si32;
|
||||
}
|
||||
|
||||
public static unsafe explicit operator Half(float val)
|
||||
{
|
||||
int si32 = *(int*)&val;
|
||||
ushort sign = (ushort)( (si32 >> 16) & 0x8000);
|
||||
short exponent = ( short)(((si32 >> 23) & 0x00FF) - 127 + 15);
|
||||
ushort mantissa = (ushort)( (si32 >> 13) & 0x03FF);
|
||||
if ( si32 == 0x00000000) return new Half { value = 0x0000 };
|
||||
else if ((uint)si32 == 0x80000000) return new Half { value = 0x8000 };
|
||||
else
|
||||
{
|
||||
ushort sign = (ushort)((si32 >> 31) & 0x001);
|
||||
ushort exponent = (ushort)((si32 >> 23) & 0x0FF);
|
||||
ushort mantissa = (ushort)((si32 >> 13) & 0x3FF);
|
||||
|
||||
if (exponent < 0) { exponent = 0; mantissa = 0; }
|
||||
else if (exponent > 30) exponent = 31;
|
||||
|
||||
return new Half { _value = (ushort)(sign | (exponent << 10) | mantissa) };
|
||||
if (exponent == 0xFF) exponent = 31;
|
||||
else if (exponent != 0x00)
|
||||
{
|
||||
exponent -= 127 - 15;
|
||||
if (exponent < 0) exponent = mantissa = 0;
|
||||
else if (exponent > 30) exponent = 31;
|
||||
}
|
||||
return new Half { value = (ushort)((sign << 15) | (exponent << 10) | mantissa) };
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe implicit operator double(Half h)
|
||||
{
|
||||
int sign = (h._value >> 15) & 0x001;
|
||||
int exponent = ((h._value >> 10) & 0x01F) + 1023 - 15;
|
||||
int mantissa = h._value & 0x3FF;
|
||||
long si64;
|
||||
long sign = (h.value >> 15) & 0x001;
|
||||
long exponent = (h.value >> 10) & 0x01F;
|
||||
long mantissa = h.value & 0x3FF;
|
||||
unchecked { si64 = sign != 0 ? (long)0x8000000000000000 : 0x0000000000000000; }
|
||||
|
||||
long si64 = ((long)sign << 63) | ((long)exponent << 52) | ((long)mantissa << 42);
|
||||
if (exponent == 0x1F) si64 |= 0x7FF0000000000000;
|
||||
else if (exponent != 0x00) si64 |= (exponent - 15 + 1023) << 52;
|
||||
si64 |= mantissa << 42;
|
||||
return *(double*)&si64;
|
||||
}
|
||||
|
||||
public static unsafe explicit operator Half(double val)
|
||||
{
|
||||
long si64 = *(long*)&val;
|
||||
ushort sign = (ushort) ((si64 >> 48) & 0x8000);
|
||||
short exponent = ( short)(((si64 >> 52) & 0x07FF) - 1023 + 15);
|
||||
ushort mantissa = (ushort) ((si64 >> 42) & 0x03FF);
|
||||
if ( si64 == 0x0000000000000000) return new Half { value = 0x0000 };
|
||||
else if ((ulong)si64 == 0x8000000000000000) return new Half { value = 0x8000 };
|
||||
else
|
||||
{
|
||||
ushort sign = (ushort)((si64 >> 63) & 0x001);
|
||||
ushort exponent = (ushort)((si64 >> 52) & 0x7FF);
|
||||
ushort mantissa = (ushort)((si64 >> 42) & 0x3FF);
|
||||
|
||||
if (exponent < 0) { exponent = 0; mantissa = 0; }
|
||||
else if (exponent > 30) exponent = 31;
|
||||
|
||||
return new Half { _value = (ushort)(sign | (exponent << 10) | mantissa) };
|
||||
if (exponent == 0x7FF) exponent = 31;
|
||||
else if (exponent != 0x00)
|
||||
{
|
||||
exponent -= 1023 - 15;
|
||||
if (exponent < 0) exponent = mantissa = 0;
|
||||
else if (exponent > 30) exponent = 31;
|
||||
}
|
||||
return new Half { value = (ushort)((sign << 15) | (exponent << 10) | mantissa) };
|
||||
}
|
||||
}
|
||||
|
||||
public static Half operator - (Half a ) => new Half() { _value = (ushort)(a._value ^ 0x8000) };
|
||||
public static Half operator - (Half a ) => new Half() { value = (ushort)(a.value ^ 0x8000) };
|
||||
public static Half operator + (Half a, Half b) => (Half)((float)a + (float)b);
|
||||
public static Half operator - (Half a, Half b) => (Half)((float)a - (float)b);
|
||||
public static Half operator * (Half a, Half b) => (Half)((float)a * (float)b);
|
||||
|
||||
@@ -2,7 +2,7 @@ using KKdBaseLib.Auth3D;
|
||||
|
||||
namespace KKdBaseLib.Interpolation
|
||||
{
|
||||
public class A3DAI : IInterpolation<float> //A3DA Interpolation
|
||||
public class A3DAI : IInterpolation<float>, System.IDisposable // A3DA Interpolation
|
||||
{
|
||||
private A3DAKey a3daKey;
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace KKdBaseLib.Interpolation
|
||||
f = -df;
|
||||
ResetFrameCount();
|
||||
|
||||
if (key.Keys != null && key.Length > 0)
|
||||
if (key.Keys != null && key.Keys.Length > 0)
|
||||
{
|
||||
firstKey = key.Keys[0];
|
||||
lastKey = key.Keys[key.Length - 1];
|
||||
lastKey = key.Keys[key.Keys.Length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,56 +111,45 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
private float Interpolate(float frame)
|
||||
{
|
||||
float df = 0;
|
||||
float ep = 0;
|
||||
float f = (int)frame;
|
||||
|
||||
if (f < firstKey.F)
|
||||
if (frame < firstKey.F)
|
||||
{
|
||||
if (a3daKey.EPTypePost < EPType.EP_1 || a3daKey.EPTypePost > EPType.EP_3) return firstKey.V;
|
||||
if (a3daKey.EPTypePost < EPType.Linear || a3daKey.EPTypePost > EPType.CycleOffset)
|
||||
return firstKey.V;
|
||||
|
||||
df = firstKey.F - frame;
|
||||
if (a3daKey.EPTypePre == EPType.EP_1) return firstKey.V - df * firstKey.T1;
|
||||
float df = firstKey.F - frame;
|
||||
if (a3daKey.EPTypePre == EPType.Linear)
|
||||
return firstKey.V - df * firstKey.T1;
|
||||
|
||||
frame = lastKey.F - df % a3daKey.FrameDelta;
|
||||
f = (int)frame;
|
||||
if (a3daKey.EPTypePre == EPType.EP_3)
|
||||
{
|
||||
ep = df / a3daKey.FrameDelta;
|
||||
ep = (ep > 0 && ep != (int)ep) ? (ep - (int)ep > 0 ? 1 : 0) : ep;
|
||||
ep = -(ep + 1) * a3daKey.ValueDelta;
|
||||
}
|
||||
if (a3daKey.EPTypePre == EPType.CycleOffset)
|
||||
ep = -(float)((int)(df / a3daKey.FrameDelta) + 1) * a3daKey.ValueDelta;
|
||||
}
|
||||
else if (f >= lastKey.F)
|
||||
else if (frame >= lastKey.F)
|
||||
{
|
||||
if (a3daKey.EPTypePost < EPType.EP_1 || a3daKey.EPTypePost > EPType.EP_3) return lastKey.V;
|
||||
if (a3daKey.EPTypePost < EPType.Linear || a3daKey.EPTypePost > EPType.CycleOffset)
|
||||
return lastKey.V;
|
||||
|
||||
df = frame - lastKey.F;
|
||||
if (a3daKey.EPTypePost == EPType.EP_1) return lastKey.V + df * lastKey.T2;
|
||||
float df = frame - lastKey.F;
|
||||
if (a3daKey.EPTypePost == EPType.Linear)
|
||||
return lastKey.V + df * lastKey.T2;
|
||||
|
||||
frame = firstKey.F + df % a3daKey.FrameDelta;
|
||||
f = (int)frame;
|
||||
if (a3daKey.EPTypePost == EPType.EP_3)
|
||||
{
|
||||
ep = df / a3daKey.FrameDelta;
|
||||
ep = (ep > 0 && ep != (int)ep) ? (ep - (int)ep > 0 ? 1 : 0) : ep;
|
||||
ep = (ep + 1) * a3daKey.ValueDelta;
|
||||
}
|
||||
if (a3daKey.EPTypePost == EPType.CycleOffset)
|
||||
ep = (float)((int)(df / a3daKey.FrameDelta) + 1) * a3daKey.ValueDelta;
|
||||
}
|
||||
|
||||
if (f <= firstKey.F) return firstKey.V + ep;
|
||||
else if (f >= lastKey.F) return lastKey.V + ep;
|
||||
|
||||
KFT3 c, n;
|
||||
long key = 0;
|
||||
unsafe
|
||||
{
|
||||
fixed (KFT3* ptr = a3daKey.Keys)
|
||||
{
|
||||
long key = 0;
|
||||
long length = a3daKey.Length;
|
||||
long temp;
|
||||
while (length > 0)
|
||||
if (f > a3daKey.Keys[key + (temp = length >> 1)].F)
|
||||
if (frame >= ptr[key + (temp = length >> 1)].F)
|
||||
{
|
||||
key += temp + 1;
|
||||
length -= temp + 1;
|
||||
@@ -172,29 +161,35 @@ namespace KKdBaseLib.Interpolation
|
||||
}
|
||||
}
|
||||
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
float v;
|
||||
if (frame <= c.F || frame >= n.F)
|
||||
v = frame > c.F ? n.V : c.V;
|
||||
else if (a3daKey.Type == KeyType.Linear)
|
||||
{
|
||||
if (a3daKey.Type == KeyType.Lerp)
|
||||
{
|
||||
float t = (frame - c.F) / (n.F - c.F);
|
||||
result = (1 - t) * c.V + t * n.V;
|
||||
}
|
||||
else if (a3daKey.Type == KeyType.Hermite)
|
||||
{
|
||||
float t = (frame - c.F) / (n.F - c.F);
|
||||
float t_2 = (1 - t) * (1 - t);
|
||||
result = t_2 * c.V * (1 + 2 * t) + (t * n.V * (3 - 2 * t) +
|
||||
(t_2 * c.T2 + t * (t - 1) * n.T1) * (n.F - c.F)) * t;
|
||||
}
|
||||
else result = c.V;
|
||||
float t = (frame - c.F) / (n.F - c.F);
|
||||
v = (1.0f - t) * c.V + t * n.V;
|
||||
}
|
||||
else result = frame > c.F ? n.V : c.V;
|
||||
return result + ep;
|
||||
else if (a3daKey.Type == KeyType.Hermite)
|
||||
{
|
||||
float df = f - c.F;
|
||||
float t = df / (n.F - c.F);
|
||||
float t_1 = t - 1.0f;
|
||||
return c.V + t * t * (3.0f - 2.0f * t) * (n.V - c.V) + (t_1 * c.T2 + t * n.T1) * df * t_1;
|
||||
}
|
||||
else v = c.V;
|
||||
return v + ep;
|
||||
}
|
||||
|
||||
public void ResetFrameCount() { f = -df; t = f / rf; }
|
||||
|
||||
public override string ToString() => $"F: {f}; T: {t}; V: {v}";
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
a3daKey.Keys = null;
|
||||
a3daKey = default;
|
||||
f = t = v = df = @if = rf = default;
|
||||
firstKey = lastKey = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace KKdBaseLib.Interpolation
|
||||
{
|
||||
public class PDI : IInterpolation<float> //Project DIVA Interpolation
|
||||
public class MOTI : IInterpolation<float> // MOT Interpolation
|
||||
{
|
||||
private KFT2[] array;
|
||||
private int length;
|
||||
@@ -23,7 +23,7 @@ namespace KKdBaseLib.Interpolation
|
||||
public bool IsNull => array == null || array.Length < 1;
|
||||
public bool NotNull => array != null && array.Length > 0;
|
||||
|
||||
public PDI(KFT2[] array, float interpolationFramerate = 60, float requestedFramerate = 60)
|
||||
public MOTI(KFT2[] array, float interpolationFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
length = 0;
|
||||
this.array = array; f = -1; df = @if = rf = t = v = 0;
|
||||
@@ -87,10 +87,8 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
private float Interpolate(float frame)
|
||||
{
|
||||
float f = (int)frame;
|
||||
|
||||
if (f <= firstKey.F) return firstKey.V;
|
||||
else if (f >= lastKey.F) return lastKey.V;
|
||||
if (frame <= firstKey.F) return firstKey.V;
|
||||
else if (frame >= lastKey.F) return lastKey.V;
|
||||
|
||||
KFT2 c, n;
|
||||
unsafe
|
||||
@@ -101,7 +99,7 @@ namespace KKdBaseLib.Interpolation
|
||||
long length = this.length;
|
||||
long temp;
|
||||
while (length > 0)
|
||||
if (f > array[key + (temp = length >> 1)].F)
|
||||
if (frame >= ptr[key + (temp = length >> 1)].F)
|
||||
{
|
||||
key += temp + 1;
|
||||
length -= temp + 1;
|
||||
@@ -113,16 +111,17 @@ namespace KKdBaseLib.Interpolation
|
||||
}
|
||||
}
|
||||
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
float v;
|
||||
if (frame <= c.F || frame >= n.F)
|
||||
v = frame > c.F ? n.V : c.V;
|
||||
else
|
||||
{
|
||||
float t = (this.f - c.F) / (n.F - c.F);
|
||||
float t_1 = t - 1;
|
||||
result = (t_1 * 2 - 1) * (c.V - n.V) * t * t +
|
||||
(t_1 * c.T + t * n.T) * t_1 * (this.f - c.F) + c.V;
|
||||
float df = f - c.F;
|
||||
float t = df / (n.F - c.F);
|
||||
float t_1 = t - 1.0f;
|
||||
return c.V + t * t * (3.0f - 2.0f * t) * (n.V - c.V) + (t_1 * c.T + t * n.T) * df * t_1;
|
||||
}
|
||||
else result = frame > c.F ? n.V : c.V;
|
||||
return result;
|
||||
return v;
|
||||
}
|
||||
|
||||
public void ResetFrameCount() { f = -df; t = f / rf; }
|
||||
+5
-3
@@ -70,7 +70,7 @@ namespace KKdBaseLib
|
||||
new KFT3(F, V);
|
||||
|
||||
public IKF Check() =>
|
||||
V == 0 ? (KFT0)this : (IKF)this;
|
||||
V.ToU32() == 0x00000000 ? (KFT0)this : (IKF)this;
|
||||
|
||||
public override string ToString() => ToString(true, 7);
|
||||
public string ToString(int round = 7, bool brackets = true) =>
|
||||
@@ -135,7 +135,7 @@ namespace KKdBaseLib
|
||||
new KFT3(F, V, T, T);
|
||||
|
||||
public IKF Check() =>
|
||||
T == 0 ? (V == 0 ? (IKF)ToT0() : ToT1()) : this;
|
||||
T.ToU32() == 0x00000000 ? (V.ToU32() == 0x00000000 ? (IKF)ToT0() : ToT1()) : this;
|
||||
|
||||
public override string ToString() => ToString(true, 7);
|
||||
public string ToString(int round = 7, bool brackets = true) =>
|
||||
@@ -199,7 +199,9 @@ namespace KKdBaseLib
|
||||
public KFT3 ToT3() => this;
|
||||
|
||||
public IKF Check() =>
|
||||
T1 == 0 && T2 == 0 ? (V == 0 ? (IKF)(KFT0)this : (KFT1)this) : T1 == T2 ? (KFT2)this : (IKF)this;
|
||||
T1.ToU32() == 0x00000000 && T2.ToU32() == 0x00000000
|
||||
? (V.ToU32() == 0x00000000 ? (IKF)(KFT0)this : (KFT1)this)
|
||||
: T1.ToU32() == T2.ToU32() ? (KFT2)this : (IKF)this;
|
||||
|
||||
public override string ToString() => ToString(true, 7);
|
||||
public string ToString(int round = 7, bool brackets = true) =>
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder (C) 2019-2020</Copyright>
|
||||
<Copyright>korenkonder (C) 2019-2021</Copyright>
|
||||
<Description>A base library</Description>
|
||||
<FileVersion>0.4.9.6</FileVersion>
|
||||
<FileVersion>0.4.10.8</FileVersion>
|
||||
<PackageId>KKdBaseLib</PackageId>
|
||||
<Product>KKdBaseLib</Product>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<Title>KKdBaseLib</Title>
|
||||
<Version>0.4.9.6</Version>
|
||||
<Version>0.4.10.8</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -24,7 +24,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -37,7 +37,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
|
||||
@@ -27,7 +27,13 @@ namespace KKdBaseLib
|
||||
{
|
||||
this.keyArray = null; this.valArray = null; count = 0; index = 0;
|
||||
if (keyArray == null || valArray == null || keyArray.Length != valArray.Length) return;
|
||||
count = valArray.Length; this.keyArray = keyArray; this.valArray = valArray; }
|
||||
|
||||
count = this.keyArray.Length;
|
||||
this.keyArray = new TKey [count];
|
||||
this.valArray = new TValue[count];
|
||||
System.Array.Copy(keyArray, this.keyArray, count);
|
||||
System.Array.Copy(valArray, this.valArray, count);
|
||||
}
|
||||
|
||||
public KeyValuePair<TKey, TValue> Current => index < count ?
|
||||
new KeyValuePair<TKey, TValue>(keyArray[index], valArray[index]) : default;
|
||||
|
||||
+15
-1
@@ -26,7 +26,21 @@ namespace KKdBaseLib
|
||||
|
||||
|
||||
public KKdList(T[] array)
|
||||
{ index = -1; count = array.Length; this.array = array; enumerator = new Enumerator(this.array); }
|
||||
{
|
||||
index = -1;
|
||||
if (array != null)
|
||||
{
|
||||
count = array.Length;
|
||||
this.array = new T[count];
|
||||
System.Array.Copy(array, this.array, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
this.array = null;
|
||||
}
|
||||
enumerator = new Enumerator(this.array);
|
||||
}
|
||||
|
||||
public T Current => index > -1 && index < Count ? array[index] : default;
|
||||
|
||||
|
||||
+87
-15
@@ -45,7 +45,6 @@ namespace KKdBaseLib
|
||||
{
|
||||
if (dict == null || args.Length < 1) return false;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
string[] newArgs = new string[args.Length - 1];
|
||||
@@ -60,7 +59,16 @@ namespace KKdBaseLib
|
||||
dict.FV(out string val, args.Split(split)) && bool.TryParse(val, out value);
|
||||
|
||||
public static bool FV (this A3DADict dict, ref int value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && int.TryParse(val, out value);
|
||||
dict.FV(out string val, args.Split(split)) && int.TryParse(val, out value);
|
||||
|
||||
public static bool FV (this A3DADict dict, ref uint value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && uint.TryParse(val, out value);
|
||||
|
||||
public static bool FV (this A3DADict dict, ref long value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && long.TryParse(val, out value);
|
||||
|
||||
public static bool FV (this A3DADict dict, ref ulong value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && ulong.TryParse(val, out value);
|
||||
|
||||
public static bool FV (this A3DADict dict, ref float value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && val.ToF32(out value);
|
||||
@@ -74,11 +82,23 @@ namespace KKdBaseLib
|
||||
|
||||
public static bool FV (this A3DADict dict, out bool value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return bool.TryParse(val, out value); value = false; return false; }
|
||||
return bool.TryParse(val, out value); value = false; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out int value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return int.TryParse(val, out value); value = 0; return false; }
|
||||
return int.TryParse(val, out value); value = 0; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out uint value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return uint.TryParse(val, out value); value = 0; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out long value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return long.TryParse(val, out value); value = 0; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out ulong value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return ulong.TryParse(val, out value); value = 0; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out float value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
@@ -88,14 +108,29 @@ namespace KKdBaseLib
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF64(out value); value = 0; return false; }
|
||||
|
||||
public static bool FV<T>(this A3DADict dict, out T value, string args) where T : struct
|
||||
public static bool FV<T>(this A3DADict dict, out T value, string args) where T : struct, Enum
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = Enum.TryParse(val, out T _value); value = _value; return Val; }
|
||||
value = default; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out int? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = int.TryParse(val, out int _value); value = _value; return Val; }
|
||||
{ bool Val = int.TryParse(val, out int _value); value = _value; return Val; }
|
||||
value = null; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out uint? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = uint.TryParse(val, out uint _value); value = _value; return Val; }
|
||||
value = null; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out long? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = long.TryParse(val, out long _value); value = _value; return Val; }
|
||||
value = null; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out ulong? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = ulong.TryParse(val, out ulong _value); value = _value; return Val; }
|
||||
value = null; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out float? value, string args)
|
||||
@@ -119,7 +154,6 @@ namespace KKdBaseLib
|
||||
value = null;
|
||||
if (dict == null || args.Length < 1) return false;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (!dict.ContainsKey(args[0])) return false;
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
@@ -172,7 +206,6 @@ namespace KKdBaseLib
|
||||
if (dict == null) dict = new A3DADict();
|
||||
else if (args.Length < 1) return;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
string[] newArgs = new string[args.Length - 1];
|
||||
@@ -199,13 +232,52 @@ namespace KKdBaseLib
|
||||
|
||||
public static int[] SW(this int length)
|
||||
{
|
||||
int i = 0;
|
||||
List<string> A = new List<string>();
|
||||
for (i = 0; i < length; i++) A.Add(i.ToString());
|
||||
A.Sort();
|
||||
int[] B = new int[length];
|
||||
for (i = 0; i < length; i++) B[i] = int.Parse(A[i]);
|
||||
return B;
|
||||
int i, j, m;
|
||||
|
||||
if (length <= 0) return new int[0];
|
||||
if (length == 1) return new int[1] { 0 };
|
||||
|
||||
int[] sort = new int[length];
|
||||
sort[0] = 0;
|
||||
i = 1;
|
||||
j = 1;
|
||||
|
||||
m = 1;
|
||||
while (m < length)
|
||||
m *= 10;
|
||||
while (i < length)
|
||||
{
|
||||
if (j * 10 < m)
|
||||
{
|
||||
sort[i++] = j;
|
||||
j *= 10;
|
||||
}
|
||||
else if (j >= length)
|
||||
{
|
||||
m /= 10;
|
||||
j /= 10;
|
||||
while (j % 10 == 9) j /= 10;
|
||||
j++;
|
||||
}
|
||||
else if (j % 10 != 9)
|
||||
sort[i++] = j++;
|
||||
|
||||
if (i < length)
|
||||
if (j == length && j % 10 != 9)
|
||||
{
|
||||
m /= 10;
|
||||
j /= 10;
|
||||
while (j % 10 == 9) j /= 10;
|
||||
j++;
|
||||
}
|
||||
else if (j < length && j % 10 == 9)
|
||||
{
|
||||
sort[i++] = j;
|
||||
while (j % 10 == 9) j /= 10;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return sort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ namespace KKdBaseLib
|
||||
|
||||
public Vec2 Column0 { get => new Vec2(Row0.X, Row1.X);
|
||||
set { Row0.X = value.X; Row1.X = value.Y; } }
|
||||
public Vec2 Column1 { get => new Vec2(Row0.Y, Row1.X);
|
||||
public Vec2 Column1 { get => new Vec2(Row0.Y, Row1.Y);
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; } }
|
||||
|
||||
public static Mat2 Identity => new Mat2(new Vec2(1.0f, 0.0f),
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ namespace KKdBaseLib
|
||||
|
||||
public Vec3 Column0 { get => new Vec3(Row0.X, Row1.X, Row2.X);
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; } }
|
||||
public Vec3 Column1 { get => new Vec3(Row0.Y, Row1.X, Row2.Y);
|
||||
public Vec3 Column1 { get => new Vec3(Row0.Y, Row1.Y, Row2.Y);
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; } }
|
||||
public Vec3 Column2 { get => new Vec3(Row0.Z, Row1.Z, Row2.Z);
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; Row2.Z = value.Z;} }
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ namespace KKdBaseLib
|
||||
|
||||
public Vec4 Column0 { get => new Vec4(Row0.X, Row1.X, Row2.X, Row3.X);
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; Row3.X = value.W; } }
|
||||
public Vec4 Column1 { get => new Vec4(Row0.Y, Row1.X, Row2.Y, Row3.Y);
|
||||
public Vec4 Column1 { get => new Vec4(Row0.Y, Row1.Y, Row2.Y, Row3.Y);
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; Row3.Y = value.W; } }
|
||||
public Vec4 Column2 { get => new Vec4(Row0.Z, Row1.Z, Row2.Z, Row3.Z);
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; Row2.Z = value.Z; Row3.Z = value.W; } }
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace KKdBaseLib
|
||||
public MsgPack(string name, object @object)
|
||||
{ Name = name; Object = @object; }
|
||||
|
||||
public static MsgPack Null => new MsgPack();
|
||||
|
||||
public MsgPack this[ int index]
|
||||
{ get => Object is MsgPack[] Array ? Array[index] : default;
|
||||
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
|
||||
|
||||
+45
-54
@@ -12,33 +12,33 @@ namespace KKdBaseLib
|
||||
|
||||
public static Quat Identity => new Quat(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
public Quat(float X, float Y, float Z)
|
||||
public Quat(float x, float y, float z)
|
||||
{
|
||||
X *= 0.5f;
|
||||
Y *= 0.5f;
|
||||
Z *= 0.5f;
|
||||
x *= 0.5f;
|
||||
y *= 0.5f;
|
||||
z *= 0.5f;
|
||||
|
||||
var c1 = (float)System.Math.Cos(X);
|
||||
var c2 = (float)System.Math.Cos(Y);
|
||||
var c3 = (float)System.Math.Cos(Z);
|
||||
var s1 = (float)System.Math.Sin(X);
|
||||
var s2 = (float)System.Math.Sin(Y);
|
||||
var s3 = (float)System.Math.Sin(Z);
|
||||
var c1 = (float)System.Math.Cos(x);
|
||||
var c2 = (float)System.Math.Cos(y);
|
||||
var c3 = (float)System.Math.Cos(z);
|
||||
var s1 = (float)System.Math.Sin(x);
|
||||
var s2 = (float)System.Math.Sin(y);
|
||||
var s3 = (float)System.Math.Sin(z);
|
||||
|
||||
this.X = s1 * c2 * c3 + c1 * s2 * s3;
|
||||
this.Y = c1 * s2 * c3 - s1 * c2 * s3;
|
||||
this.Z = c1 * c2 * s3 + s1 * s2 * c3;
|
||||
W = c1 * c2 * c3 - s1 * s2 * s3;
|
||||
X = s1 * c2 * c3 + c1 * s2 * s3;
|
||||
Y = c1 * s2 * c3 - s1 * c2 * s3;
|
||||
Z = c1 * c2 * s3 + s1 * s2 * c3;
|
||||
W = c1 * c2 * c3 - s1 * s2 * s3;
|
||||
}
|
||||
|
||||
public Quat(Vec3 vec) : this(vec.X, vec.Y, vec.Z)
|
||||
{ }
|
||||
|
||||
public Quat(float X, float Y, float Z, float W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
public Quat(float x, float y, float z, float w)
|
||||
{ X = x; Y = y; Z = z; W = w; }
|
||||
|
||||
public Quat(Vec3 vec, float W)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; this.W = W; }
|
||||
public Quat(Vec3 vec, float w)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; W = w; }
|
||||
|
||||
public Quat(Vec4 vec)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; W = vec.W; }
|
||||
@@ -97,7 +97,7 @@ namespace KKdBaseLib
|
||||
public static Quat operator -(Quat left, Quat right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; left.W -= right.W; return left; }
|
||||
public static Quat operator -(Quat quat) =>
|
||||
new Quat(-quat.X, -quat.Y, -quat.Z, quat.W);
|
||||
new Quat(-quat.X, -quat.Y, -quat.Z, -quat.W);
|
||||
public static Quat operator *( Quat quat, float scale)
|
||||
{ quat.X *= scale ; quat.Y *= scale ; quat.Z *= scale ; quat.W *= scale ; return quat; }
|
||||
public static Quat operator *(float scale, Quat quat)
|
||||
@@ -112,55 +112,46 @@ namespace KKdBaseLib
|
||||
public static bool operator ==(Quat A, Quat B) => A.Equals(B);
|
||||
public static bool operator !=(Quat A, Quat B) => !A.Equals(B);
|
||||
|
||||
public static float Distance (Vec4 left, Vec4 right) =>
|
||||
public static float Distance (Quat left, Quat right) =>
|
||||
((right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W)).Sqrt();
|
||||
public static float DistanceSquared(Vec4 left, Vec4 right) =>
|
||||
public static float DistanceSquared(Quat left, Quat right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W);
|
||||
public static float Dot(Vec4 left, Vec4 right) =>
|
||||
public static float Dot(Quat left, Quat right) =>
|
||||
left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
|
||||
public Vec4 Round( ) =>
|
||||
new Vec4 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ), W = W.Round( ) };
|
||||
public Vec4 Round(int d) =>
|
||||
new Vec4 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
|
||||
public Quat Round( ) =>
|
||||
new Quat { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ), W = W.Round( ) };
|
||||
public Quat Round(int d) =>
|
||||
new Quat { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
|
||||
|
||||
public static Quat Slerp(Quat q1, Quat q2, float blend)
|
||||
{
|
||||
if (q1.LengthSquared == 0.0f)
|
||||
return q2.LengthSquared == 0.0f ? Identity : q2;
|
||||
else if (q2.LengthSquared == 0.0f)
|
||||
return q1;
|
||||
q1 = q1.Normalized;
|
||||
q2 = q2.Normalized;
|
||||
|
||||
float cosHalfAngle = Vec4.Dot((Vec4)q1, (Vec4)q2);
|
||||
|
||||
if (cosHalfAngle >= 1.0f || cosHalfAngle <= -1.0f)
|
||||
return q1;
|
||||
|
||||
if (cosHalfAngle < 0.0f)
|
||||
float dot = Dot(q1, q2);
|
||||
if (dot < 0.0f)
|
||||
{
|
||||
q2.XYZ = -q2.XYZ;
|
||||
q2.W = -q2.W;
|
||||
cosHalfAngle = -cosHalfAngle;
|
||||
q2 = -q2;
|
||||
dot = -dot;
|
||||
}
|
||||
|
||||
float blendA;
|
||||
float blendB;
|
||||
if (cosHalfAngle < 0.99f)
|
||||
Quat result;
|
||||
const float DOT_THRESHOLD = 0.9995f;
|
||||
if (dot <= DOT_THRESHOLD)
|
||||
{
|
||||
float halfAngle = (float)System.Math.Acos(cosHalfAngle);
|
||||
float sinHalfAngle = (float)System.Math.Sin(halfAngle);
|
||||
float oneOverSinHalfAngle = 1.0f / sinHalfAngle;
|
||||
blendA = (float)System.Math.Sin(halfAngle * (1.0f - blend)) * oneOverSinHalfAngle;
|
||||
blendB = (float)System.Math.Sin(halfAngle * blend) * oneOverSinHalfAngle;
|
||||
float theta_0 = (float)System.Math.Acos(dot);
|
||||
float theta = theta_0 * blend;
|
||||
float sin_theta = (float)System.Math.Sin(theta);
|
||||
float sin_theta_0 = (float)System.Math.Sin(theta_0);
|
||||
|
||||
float s0 = (float)System.Math.Cos(theta) - dot * sin_theta / sin_theta_0;
|
||||
float s1 = sin_theta / sin_theta_0;
|
||||
result = s0 * q1 + s1 * q2;
|
||||
}
|
||||
else
|
||||
{
|
||||
blendA = 1.0f - blend;
|
||||
blendB = blend;
|
||||
}
|
||||
|
||||
Quat result = new Quat(blendA * q1.XYZ + blendB * q2.XYZ, blendA * q1.W + blendB * q2.W);
|
||||
result = (1.0f - blend) * q1 + blend * q2;
|
||||
return result.Normalized;
|
||||
}
|
||||
|
||||
@@ -169,7 +160,7 @@ namespace KKdBaseLib
|
||||
public static explicit operator Quat(Vec4 vec) =>
|
||||
new Quat( vec.XYZ, vec.W);
|
||||
|
||||
public bool Equals(Vec4 other) =>
|
||||
public bool Equals(Quat other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z && W == other.W;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
|
||||
+1126
-809
File diff suppressed because it is too large
Load Diff
@@ -1,146 +0,0 @@
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public unsafe struct AddParam : System.IDisposable
|
||||
{
|
||||
private long i;
|
||||
private Stream s;
|
||||
|
||||
public HeaderData Header;
|
||||
|
||||
public void AddParamReader(string file)
|
||||
{
|
||||
Header = new HeaderData();
|
||||
|
||||
s = File.OpenReader(file + ".adp");
|
||||
Header.Count = s.RI64();
|
||||
Header.DataLength = s.RI64();
|
||||
Header.DataOffset = s.RI64();
|
||||
|
||||
if (Header.Count < 1 || Header.DataOffset > s.P || Header.DataLength > s.LI64
|
||||
- Header.DataOffset || Header.Count * 0x20 > s.LI64 - Header.DataOffset) { s.C(); return; }
|
||||
|
||||
Header.Data = new HeaderData.Sub[Header.Count];
|
||||
byte[] data = s.RBy(Header.DataLength, Header.DataOffset);
|
||||
s.C();
|
||||
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
Header.Data[i] = hPtr[i];
|
||||
}
|
||||
|
||||
data = null;
|
||||
}
|
||||
|
||||
public void AddParamWriter(string file)
|
||||
{
|
||||
if (Header.Data == null || Header.Data.LongLength < 1) return;
|
||||
|
||||
Header.Count = Header.Data.LongLength;
|
||||
Header.DataLength = Header.Count * 0x20;
|
||||
Header.DataOffset = 0x18L;
|
||||
|
||||
byte[] data = new byte[Header.DataLength];
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
hPtr[i] = Header.Data[i];
|
||||
}
|
||||
|
||||
s = File.OpenWriter(file + ".adp", true);
|
||||
s.W(Header.Count);
|
||||
s.W(Header.DataLength);
|
||||
s.W(Header.DataOffset);
|
||||
s.W(data);
|
||||
s.C();
|
||||
data = null;
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
Header = new HeaderData();
|
||||
|
||||
MsgPack addParam;
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
if ((addParam = msgPack["AddParam", true]).IsNull) return;
|
||||
|
||||
Header.Count = addParam.Array.LongLength;
|
||||
Header.Data = new HeaderData.Sub[Header.Count];
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
{
|
||||
ref HeaderData.Sub sub = ref Header.Data[i];
|
||||
sub.Time = addParam[i].RF32("Time");
|
||||
sub.Flags = addParam[i].RI32("Flags");
|
||||
sub.Frame = addParam[i].RI32("Frame");
|
||||
sub.ID = addParam[i].RI32("ID");
|
||||
sub.Value = addParam[i].RF32("Value");
|
||||
|
||||
sub.PVBranch = addParam[i].RnI32("PVBranch") ?? 0;
|
||||
float? f = addParam[i].RnF32("Value");
|
||||
if (f.HasValue)
|
||||
{
|
||||
if (sub.ID == 0) { float v = 0; *(uint*)&v = addParam[i].RU32("Value"); sub.Value = v; }
|
||||
else sub.Value = f.Value;
|
||||
}
|
||||
else { float v = 0; *(uint*)&v = 0xFFFFFFFF; sub.Value = v; }
|
||||
|
||||
}
|
||||
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (Header.Data == null || Header.Data.LongLength < 1) return;
|
||||
|
||||
MsgPack addParam = new MsgPack(Header.Data.LongLength, "AddParam");
|
||||
fixed (HeaderData.Sub* ptr = Header.Data)
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
{
|
||||
ref HeaderData.Sub sub = ref Header.Data[i];
|
||||
addParam[i] = MsgPack.New.Add("Time", sub.Time).Add("Flags", sub.Flags).Add("Frame", sub.Frame);
|
||||
|
||||
if (sub.PVBranch > 0)
|
||||
addParam[i] = addParam[i].Add("PVBranch", sub.PVBranch);
|
||||
|
||||
addParam[i] = addParam[i].Add("ID", sub.ID);
|
||||
|
||||
if (sub.ID == 0)
|
||||
addParam[i] = addParam[i].Add("Value", *(uint*)&ptr[i].Value);
|
||||
else if (*(uint*)&ptr[i].Value != 0xFFFFFFFF)
|
||||
addParam[i] = addParam[i].Add("Value", sub.Value);
|
||||
|
||||
}
|
||||
addParam.WriteAfterAll(false, true, file, json);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{ if (s != null) s.D(); s = null; Header = default; }
|
||||
|
||||
public struct HeaderData
|
||||
{
|
||||
public long Count;
|
||||
public long DataLength;
|
||||
public long DataOffset;
|
||||
|
||||
public Sub[] Data;
|
||||
|
||||
public struct Sub
|
||||
{
|
||||
public float Time;
|
||||
public int Flags;
|
||||
public int Frame;
|
||||
public int Pad0C;
|
||||
public int PVBranch;
|
||||
public int ID;
|
||||
public float Value;
|
||||
public int Pad1C;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
-28
@@ -66,9 +66,9 @@ namespace KKdMainLib
|
||||
aet.Width = s.RU32();
|
||||
aet.Height = s.RU32();
|
||||
aet.Camera = s.RP<Vec2<CountPointer<KFT2>>>();
|
||||
aet.Composition = s.ReadCountPointer<Composition>();
|
||||
aet.Video = s.ReadCountPointer<Video >();
|
||||
aet.Audio = s.ReadCountPointer<Audio >();
|
||||
aet.Composition = s.RCP<Composition>();
|
||||
aet.Video = s.RCP<Video >();
|
||||
aet.Audio = s.RCP<Audio >();
|
||||
|
||||
if (aet.Camera.O > 0)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace KKdMainLib
|
||||
s.P = aet.Video.O;
|
||||
for (i = 0; i < aet.Video.C; i++)
|
||||
aet.Video[i] = new Video { O = s.P, Color = s.RU32(), Width = s.RU16(),
|
||||
Height = s.RU16(), Frames = s.RF32(), Identifiers = s.ReadCountPointer<Video.Identifier>() };
|
||||
Height = s.RU16(), Frames = s.RF32(), Identifiers = s.RCP<Video.Identifier>() };
|
||||
|
||||
for (i = 0; i < aet.Video.C; i++)
|
||||
{
|
||||
@@ -511,7 +511,7 @@ namespace KKdMainLib
|
||||
obj.Type = (Layer.AetLayerType )s.RU8 ();
|
||||
obj.VidItmOff = s.RI32();
|
||||
obj.ParentLayer = s.RI32();
|
||||
obj.Marker = s.ReadCountPointer<Marker>();
|
||||
obj.Marker = s.RCP<Marker>();
|
||||
obj.Video = s.RP<VideoData>();
|
||||
obj.Audio = s.RP<AudioData>();
|
||||
|
||||
@@ -523,14 +523,14 @@ namespace KKdMainLib
|
||||
video.TransferMode.Flags = (VideoData.VideoTransferMode.TransferFlags )s.RU8();
|
||||
video.TransferMode.TrackMatte = (VideoData.VideoTransferMode.TransferTrackMatte)s.RU8();
|
||||
video.Padding = s.RU8();
|
||||
video. AnchorX = s.ReadCountPointer<KFT2>();
|
||||
video. AnchorY = s.ReadCountPointer<KFT2>();
|
||||
video.PositionX = s.ReadCountPointer<KFT2>();
|
||||
video.PositionY = s.ReadCountPointer<KFT2>();
|
||||
video.Rotation = s.ReadCountPointer<KFT2>();
|
||||
video. ScaleX = s.ReadCountPointer<KFT2>();
|
||||
video. ScaleY = s.ReadCountPointer<KFT2>();
|
||||
video.Opacity = s.ReadCountPointer<KFT2>();
|
||||
video. AnchorX = s.RCP<KFT2>();
|
||||
video. AnchorY = s.RCP<KFT2>();
|
||||
video.PositionX = s.RCP<KFT2>();
|
||||
video.PositionY = s.RCP<KFT2>();
|
||||
video.Rotation = s.RCP<KFT2>();
|
||||
video. ScaleX = s.RCP<KFT2>();
|
||||
video. ScaleY = s.RCP<KFT2>();
|
||||
video.Opacity = s.RCP<KFT2>();
|
||||
video.Video3D = s.RP<VideoData.Video3DData>();
|
||||
|
||||
RKF(ref video. AnchorX);
|
||||
@@ -546,14 +546,14 @@ namespace KKdMainLib
|
||||
{
|
||||
ref VideoData.Video3DData video3DData = ref video.Video3D.V;
|
||||
s.P = video.Video3D.O;
|
||||
video3DData. AnchorZ = s.ReadCountPointer<KFT2>();
|
||||
video3DData. PositionZ = s.ReadCountPointer<KFT2>();
|
||||
video3DData.DirectionX = s.ReadCountPointer<KFT2>();
|
||||
video3DData.DirectionY = s.ReadCountPointer<KFT2>();
|
||||
video3DData.DirectionZ = s.ReadCountPointer<KFT2>();
|
||||
video3DData. RotationX = s.ReadCountPointer<KFT2>();
|
||||
video3DData. RotationY = s.ReadCountPointer<KFT2>();
|
||||
video3DData. ScaleZ = s.ReadCountPointer<KFT2>();
|
||||
video3DData. AnchorZ = s.RCP<KFT2>();
|
||||
video3DData. PositionZ = s.RCP<KFT2>();
|
||||
video3DData.DirectionX = s.RCP<KFT2>();
|
||||
video3DData.DirectionY = s.RCP<KFT2>();
|
||||
video3DData.DirectionZ = s.RCP<KFT2>();
|
||||
video3DData. RotationX = s.RCP<KFT2>();
|
||||
video3DData. RotationY = s.RCP<KFT2>();
|
||||
video3DData. ScaleZ = s.RCP<KFT2>();
|
||||
|
||||
RKF(ref video3DData. AnchorZ);
|
||||
RKF(ref video3DData. PositionZ);
|
||||
@@ -570,10 +570,10 @@ namespace KKdMainLib
|
||||
{
|
||||
ref AudioData audio = ref obj.Audio.V;
|
||||
s.P = obj.Audio.O;
|
||||
audio.VolumeL = s.ReadCountPointer<KFT2>();
|
||||
audio.VolumeR = s.ReadCountPointer<KFT2>();
|
||||
audio. PanL = s.ReadCountPointer<KFT2>();
|
||||
audio. PanR = s.ReadCountPointer<KFT2>();
|
||||
audio.VolumeL = s.RCP<KFT2>();
|
||||
audio.VolumeR = s.RCP<KFT2>();
|
||||
audio. PanL = s.RCP<KFT2>();
|
||||
audio. PanR = s.RCP<KFT2>();
|
||||
|
||||
RKF(ref audio.VolumeL);
|
||||
RKF(ref audio.VolumeR);
|
||||
@@ -732,8 +732,9 @@ namespace KKdMainLib
|
||||
|
||||
public MsgPack MsgPackWriter(ref Pointer<Scene> aetData)
|
||||
{
|
||||
if (aetData.O <= 0) return default;
|
||||
|
||||
int i, i0;
|
||||
if (aetData.O <= 0) return MsgPack.Null;
|
||||
ref Scene aet = ref aetData.V;
|
||||
|
||||
MsgPack msgPack = MsgPack.New.Add("Name", aet.Name.V).Add("StartFrame", aet.StartFrame)
|
||||
@@ -752,7 +753,7 @@ namespace KKdMainLib
|
||||
rootLayer[i0] = WL(ref aet.Composition[i].E[i0]);
|
||||
msgPack.Add(rootLayer);
|
||||
|
||||
if (aet.Composition[i].C > 1)
|
||||
if (aet.Composition.C > 1)
|
||||
{
|
||||
MsgPack compositions = new MsgPack(aet.Composition.C - 1, "Composition");
|
||||
for (i = 0; i < aet.Composition.C - 1; i++)
|
||||
@@ -966,7 +967,8 @@ namespace KKdMainLib
|
||||
|
||||
private MsgPack WMP(ref CountPointer<KFT2> kfe, string name)
|
||||
{
|
||||
if (kfe.C < 1) return MsgPack.Null;
|
||||
if (kfe.C < 1) return default;
|
||||
|
||||
if (kfe.C == 1) return new MsgPack(name, kfe.E[0].V);
|
||||
MsgPack msg = new MsgPack(kfe.C, name);
|
||||
for (int i = 0; i < kfe.E.Length; i++)
|
||||
|
||||
+77
-77
@@ -1,6 +1,5 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -9,39 +8,39 @@ namespace KKdMainLib.DB
|
||||
public class Aet : System.IDisposable
|
||||
{
|
||||
private int i, i0, i1, i2;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public AetSet[] AetSets;
|
||||
|
||||
public void BINReader(string file)
|
||||
{
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
s = File.OpenReader(file + ".bin");
|
||||
|
||||
int aetSetsLength = _IO.RI32();
|
||||
int aetSetsOffset = _IO.RI32();
|
||||
int aetsLength = _IO.RI32();
|
||||
int aetsOffset = _IO.RI32();
|
||||
int aetSetsLength = s.RI32();
|
||||
int aetSetsOffset = s.RI32();
|
||||
int aetsLength = s.RI32();
|
||||
int aetsOffset = s.RI32();
|
||||
|
||||
_IO.P = aetSetsOffset;
|
||||
s.P = aetSetsOffset;
|
||||
AetSets = new AetSet[aetSetsLength];
|
||||
for (i = 0; i < aetSetsLength; i++)
|
||||
{
|
||||
AetSets[i].Id = _IO.RI32();
|
||||
AetSets[i].Name = _IO.RSaO();
|
||||
AetSets[i].FileName = _IO.RSaO();
|
||||
_IO.RI32();
|
||||
AetSets[i].SpriteSetId = _IO.RI32();
|
||||
AetSets[i].Id = s.RI32();
|
||||
AetSets[i].Name = s.RSaO();
|
||||
AetSets[i].FileName = s.RSaO();
|
||||
s.RI32();
|
||||
AetSets[i].SpriteSetId = s.RI32();
|
||||
}
|
||||
|
||||
int setIndex;
|
||||
AET aet = new AET();
|
||||
int[] AetCount = new int[aetSetsLength];
|
||||
|
||||
_IO.P = aetsOffset;
|
||||
s.P = aetsOffset;
|
||||
for (i = 0; i < aetsLength; i++)
|
||||
{
|
||||
_IO.PI64 += 10;
|
||||
setIndex = _IO.RI16();
|
||||
s.PI64 += 10;
|
||||
setIndex = s.RI16();
|
||||
AetCount[setIndex]++;
|
||||
}
|
||||
|
||||
@@ -51,18 +50,18 @@ namespace KKdMainLib.DB
|
||||
AetCount[i] = 0;
|
||||
}
|
||||
|
||||
_IO.P = aetsOffset;
|
||||
s.P = aetsOffset;
|
||||
for (i = 0; i < aetsLength; i++)
|
||||
{
|
||||
aet.Id = _IO.RI32();
|
||||
aet.Name = _IO.RSaO();
|
||||
_IO.RI16();
|
||||
setIndex = _IO.RI16();
|
||||
aet.Id = s.RI32();
|
||||
aet.Name = s.RSaO();
|
||||
s.RI16();
|
||||
setIndex = s.RI16();
|
||||
|
||||
AetSets[setIndex].Aets[AetCount[setIndex]] = aet; AetCount[setIndex]++;
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +70,13 @@ namespace KKdMainLib.DB
|
||||
if (AetSets == null) return;
|
||||
if (AetSets.Length == 0) return;
|
||||
|
||||
List<string> SetName = new List<string>();
|
||||
List<string> SetFileName = new List<string>();
|
||||
KKdList<string> setName = KKdList<string>.New;
|
||||
KKdList<string> setFileName = KKdList<string>.New;
|
||||
|
||||
List<int> Ids = new List<int>();
|
||||
List<int> SetIds = new List<int>();
|
||||
KKdList<int> ids = KKdList<int>.New;
|
||||
KKdList<int> setIds = KKdList<int>.New;
|
||||
|
||||
List<int> NotAdd = new List<int>();
|
||||
KKdList<int> notAdd = KKdList<int>.New;
|
||||
AET temp;
|
||||
AetSet set;
|
||||
|
||||
@@ -85,11 +84,11 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
set = AetSets[i];
|
||||
if (set. Name != null)
|
||||
if (SetName .Contains(set. Name)) { NotAdd.Add(i); continue; }
|
||||
else SetName .Add (set. Name);
|
||||
if (setName .Contains(set. Name)) { notAdd.Add(i); continue; }
|
||||
else setName .Add (set. Name);
|
||||
if (set.FileName != null)
|
||||
if (SetFileName.Contains(set.FileName)) { NotAdd.Add(i); continue; }
|
||||
else SetFileName.Add (set.FileName);
|
||||
if (setFileName.Contains(set.FileName)) { notAdd.Add(i); continue; }
|
||||
else setFileName.Add (set.FileName);
|
||||
|
||||
if (set.NewId)
|
||||
{
|
||||
@@ -99,93 +98,94 @@ namespace KKdMainLib.DB
|
||||
}
|
||||
|
||||
if (set.Id != null)
|
||||
if (SetIds.Contains((int)set.Id)) { NotAdd.Add(i); continue; }
|
||||
else SetIds.Add ((int)set.Id);
|
||||
if (setIds.Contains((int)set.Id)) { notAdd.Add(i); continue; }
|
||||
else setIds.Add ((int)set.Id);
|
||||
|
||||
for (i0 = 0; i0 < set.Aets.Length; i0++)
|
||||
{
|
||||
temp = set.Aets[i0];
|
||||
if (temp.Id != null)
|
||||
if ( Ids.Contains((int)temp.Id)) { NotAdd.Add(i); break; }
|
||||
else Ids.Add ((int)temp.Id);
|
||||
if ( ids.Contains((int)temp.Id)) { notAdd.Add(i); break; }
|
||||
else ids.Add ((int)temp.Id);
|
||||
}
|
||||
}
|
||||
SetName = null;
|
||||
SetFileName = null;
|
||||
setName .Dispose();
|
||||
setFileName.Dispose();
|
||||
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
set = AetSets[i];
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
if (notAdd.Contains(i)) continue;
|
||||
if (!set.NewId) continue;
|
||||
|
||||
i1 = 0;
|
||||
if (set.Id == null) while (true)
|
||||
{ if (!SetIds.Contains(i1)) { AetSets[i].Id = i1; SetIds.Add(i1); break; } i1++; }
|
||||
{ if (!setIds.Contains(i1)) { AetSets[i].Id = i1; setIds.Add(i1); break; } i1++; }
|
||||
|
||||
for (i0 = 0, i1 = 0; i0 < set.Aets.Length; i0++)
|
||||
if (set.Aets[i0].Id == null) while (true) { if (!Ids.Contains(i1))
|
||||
{ AetSets[i].Aets[i0].Id = i1; Ids.Add(i1); break; } i1++; }
|
||||
if (set.Aets[i0].Id == null) while (true) { if (!ids.Contains(i1))
|
||||
{ AetSets[i].Aets[i0].Id = i1; ids.Add(i1); break; } i1++; }
|
||||
}
|
||||
|
||||
Ids = null;
|
||||
SetIds = null;
|
||||
ids.Dispose();
|
||||
setIds.Dispose();
|
||||
|
||||
for (i = 0, i0 = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
if (!NotAdd.Contains(i)) { i0 += AetSets[i].Aets.Length; i2++; }
|
||||
if (!notAdd.Contains(i)) { i0 += AetSets[i].Aets.Length; i2++; }
|
||||
|
||||
i1 = i0 * 12;
|
||||
i1 = i1.A(0x20) + 0x20;
|
||||
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
_IO.W(i2);
|
||||
_IO.W(i1);
|
||||
_IO.W(i0);
|
||||
_IO.W(0x20);
|
||||
_IO.W(0x9066906690669066);
|
||||
_IO.W(0x9066906690669066);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
s.W(i2);
|
||||
s.W(i1);
|
||||
s.W(i0);
|
||||
s.W(0x20);
|
||||
s.W(0x9066906690669066);
|
||||
s.W(0x9066906690669066);
|
||||
|
||||
_IO.P = (i1 + i2 * 0x14).A(0x20);
|
||||
s.P = (i1 + i2 * 0x14).A(0x20);
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
AetSets[i]. NameOffset = _IO.P; _IO.W(AetSets[i]. Name + "\0");
|
||||
AetSets[i].FileNameOffset = _IO.P; _IO.W(AetSets[i].FileName + "\0");
|
||||
if (notAdd.Contains(i)) continue;
|
||||
AetSets[i]. NameOffset = s.P; s.W(AetSets[i]. Name + "\0");
|
||||
AetSets[i].FileNameOffset = s.P; s.W(AetSets[i].FileName + "\0");
|
||||
}
|
||||
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) continue;
|
||||
if (notAdd.Contains(i)) continue;
|
||||
for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++)
|
||||
{ AetSets[i].Aets[i0].NameOffset = _IO.P; _IO.W(AetSets[i].Aets[i0].Name + "\0"); }
|
||||
{ AetSets[i].Aets[i0].NameOffset = s.P; s.W(AetSets[i].Aets[i0].Name + "\0"); }
|
||||
}
|
||||
_IO.A(0x08, true);
|
||||
s.A(0x08, true);
|
||||
|
||||
_IO.P = 0x20;
|
||||
s.P = 0x20;
|
||||
for (i = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
if (notAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++)
|
||||
{
|
||||
_IO.W(AetSets[i].Aets[i0].Id );
|
||||
_IO.W(AetSets[i].Aets[i0].NameOffset);
|
||||
_IO.W((ushort) i0 );
|
||||
_IO.W((ushort)(i - i2));
|
||||
s.W(AetSets[i].Aets[i0].Id );
|
||||
s.W(AetSets[i].Aets[i0].NameOffset);
|
||||
s.W((ushort) i0 );
|
||||
s.W((ushort)(i - i2));
|
||||
}
|
||||
}
|
||||
_IO.A(0x20);
|
||||
s.A(0x20);
|
||||
|
||||
for (i = 0, i2 = 0; i < AetSets.Length; i++)
|
||||
{
|
||||
if (NotAdd.Contains(i)) { i2++; continue; }
|
||||
if (notAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
_IO.W(AetSets[i].Id );
|
||||
_IO.W(AetSets[i]. NameOffset);
|
||||
_IO.W(AetSets[i].FileNameOffset);
|
||||
_IO.W(i - i2);
|
||||
_IO.W(AetSets[i].SpriteSetId );
|
||||
s.W(AetSets[i].Id );
|
||||
s.W(AetSets[i]. NameOffset);
|
||||
s.W(AetSets[i].FileNameOffset);
|
||||
s.W(i - i2);
|
||||
s.W(AetSets[i].SpriteSetId );
|
||||
}
|
||||
_IO.C();
|
||||
notAdd.Dispose();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
@@ -218,7 +218,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; AetSets = null; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; AetSets = null; disposed = true; } }
|
||||
|
||||
public struct AET
|
||||
{
|
||||
@@ -246,10 +246,10 @@ namespace KKdMainLib.DB
|
||||
|
||||
public void ReadMsgPack(MsgPack msg)
|
||||
{
|
||||
FileName = msg.RS ("FileName" );
|
||||
FileName = msg.RS ("FileName" );
|
||||
Id = msg.RnU16( "Id");
|
||||
Name = msg.RS ( "Name" );
|
||||
NewId = msg.RB("NewId" );
|
||||
Name = msg.RS ( "Name" );
|
||||
NewId = msg.RB ("NewId" );
|
||||
SpriteSetId = msg.RnU16("SpriteSetId");
|
||||
|
||||
MsgPack Temp;
|
||||
|
||||
+28
-21
@@ -8,7 +8,7 @@ namespace KKdMainLib.DB
|
||||
public class Auth : IDisposable
|
||||
{
|
||||
private int i;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public string[] Category;
|
||||
public UID[] UIDs;
|
||||
@@ -17,16 +17,16 @@ namespace KKdMainLib.DB
|
||||
{
|
||||
A3DADict dict = new A3DADict();
|
||||
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
s = File.OpenReader(file + ".bin");
|
||||
|
||||
_IO.Format = Format.F;
|
||||
int signature = _IO.RI32();
|
||||
s.Format = Format.F;
|
||||
int signature = s.RI32();
|
||||
if (signature != 0x44334123) return;
|
||||
signature = _IO.RI32();
|
||||
signature = s.RI32();
|
||||
if (signature != 0x5F5F5F41) return;
|
||||
_IO.RI64();
|
||||
s.RI64();
|
||||
|
||||
string[] strData = _IO.RS(_IO.L - _IO.P).Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
string[] strData = s.RS(s.L - s.P).Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
for (i = 0; i < strData.Length; i++)
|
||||
dict.GD(strData[i]);
|
||||
strData = null;
|
||||
@@ -51,45 +51,52 @@ namespace KKdMainLib.DB
|
||||
}
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
dict.Clear();
|
||||
dict = null;
|
||||
}
|
||||
|
||||
public void BINWriter(string file)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
|
||||
_IO.W("#A3DA__________\n");
|
||||
_IO.W("#" + DateTime.UtcNow.ToString("ddd MMM dd HH:mm:ss yyyy",
|
||||
System.Globalization.CultureInfo.InvariantCulture) + "\n");
|
||||
s.W("#A3DA__________\n");
|
||||
s.W("# date time was eliminated.\n");
|
||||
|
||||
if (Category != null)
|
||||
{
|
||||
int[] so = Category.Length.SW();
|
||||
for (i = 0; i < Category.Length; i++)
|
||||
_IO.W($"category.{so[i]}.value={ Category[so[i]]}\n");
|
||||
_IO.W($"category.length={Category.Length}\n");
|
||||
s.W($"category.{so[i]}.value={ Category[so[i]]}\n");
|
||||
s.W($"category.length={Category.Length}\n");
|
||||
}
|
||||
|
||||
if (UIDs != null)
|
||||
{
|
||||
int[] so = UIDs.Length.SW();
|
||||
int max = -1;
|
||||
for (i = 0; i < UIDs.Length; i++)
|
||||
{
|
||||
if (UIDs[so[i]].Category != null && UIDs[so[i]].Category != "")
|
||||
_IO.W($"uid.{so[i]}.category=" + UIDs[so[i]].Category + "\n");
|
||||
s.W($"uid.{so[i]}.category=" + UIDs[so[i]].Category + "\n");
|
||||
if (UIDs[so[i]].OrgUid != null)
|
||||
_IO.W($"uid.{so[i]}.org_uid=" + UIDs[so[i]].OrgUid + "\n");
|
||||
{
|
||||
int orgUid = UIDs[so[i]].OrgUid.Value;
|
||||
s.W($"uid.{so[i]}.org_uid=" + orgUid + "\n");
|
||||
if (max < orgUid)
|
||||
max = orgUid;
|
||||
}
|
||||
if (UIDs[so[i]].Size != null)
|
||||
_IO.W($"uid.{so[i]}.size=" + UIDs[so[i]].Size + "\n");
|
||||
s.W($"uid.{so[i]}.size=" + UIDs[so[i]].Size + "\n");
|
||||
if (UIDs[so[i]].Value != null && UIDs[so[i]].Value != "")
|
||||
_IO.W($"uid.{so[i]}.value=" + UIDs[so[i]].Value + "\n");
|
||||
s.W($"uid.{so[i]}.value=" + UIDs[so[i]].Value + "\n");
|
||||
}
|
||||
_IO.W($"uid.length={UIDs.Length}\n");
|
||||
s.W($"uid.length={UIDs.Length}\n");
|
||||
if (max != -1)
|
||||
s.W($"uid.max={max}\n");
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
@@ -151,7 +158,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; Category = null; UIDs = null; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; Category = null; UIDs = null; disposed = true; } }
|
||||
|
||||
public struct UID
|
||||
{
|
||||
|
||||
+62
-65
@@ -1,6 +1,5 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -9,27 +8,27 @@ namespace KKdMainLib.DB
|
||||
public class Spr : System.IDisposable
|
||||
{
|
||||
private int i, i0, i1, i2;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public SpriteSet[] SpriteSets;
|
||||
|
||||
public void BINReader(string file)
|
||||
{
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
s = File.OpenReader(file + ".bin");
|
||||
|
||||
int spriteSetsLength = _IO.RI32();
|
||||
int spriteSetsOffset = _IO.RI32();
|
||||
int spritesLength = _IO.RI32();
|
||||
int spritesOffset = _IO.RI32();
|
||||
int spriteSetsLength = s.RI32();
|
||||
int spriteSetsOffset = s.RI32();
|
||||
int spritesLength = s.RI32();
|
||||
int spritesOffset = s.RI32();
|
||||
|
||||
_IO.P = spriteSetsOffset;
|
||||
s.P = spriteSetsOffset;
|
||||
SpriteSets = new SpriteSet[spriteSetsLength];
|
||||
for (i = 0; i < spriteSetsLength; i++)
|
||||
{
|
||||
SpriteSets[i].Id = _IO.RI32();
|
||||
SpriteSets[i].Name = _IO.RSaO();
|
||||
SpriteSets[i].FileName = _IO.RSaO();
|
||||
_IO.RI32();
|
||||
SpriteSets[i].Id = s.RI32();
|
||||
SpriteSets[i].Name = s.RSaO();
|
||||
SpriteSets[i].FileName = s.RSaO();
|
||||
s.RI32();
|
||||
}
|
||||
|
||||
int setIndex;
|
||||
@@ -38,11 +37,11 @@ namespace KKdMainLib.DB
|
||||
int[] sprCount = new int[spriteSetsLength];
|
||||
int[] texCount = new int[spriteSetsLength];
|
||||
|
||||
_IO.P = spritesOffset;
|
||||
s.P = spritesOffset;
|
||||
for (i = 0; i < spritesLength; i++)
|
||||
{
|
||||
_IO.PI64 += 10;
|
||||
setIndex = _IO.RI16();
|
||||
s.PI64 += 10;
|
||||
setIndex = s.RI16();
|
||||
isTexture = (setIndex & 0x1000) == 0x1000;
|
||||
setIndex &= 0xFFF;
|
||||
|
||||
@@ -59,13 +58,13 @@ namespace KKdMainLib.DB
|
||||
texCount[i] = 0;
|
||||
}
|
||||
|
||||
_IO.P = spritesOffset;
|
||||
s.P = spritesOffset;
|
||||
for (i = 0; i < spritesLength; i++)
|
||||
{
|
||||
st.Id = _IO.RI32();
|
||||
st.Name = _IO.RSaO();
|
||||
_IO.RI16();
|
||||
setIndex = _IO.RI16();
|
||||
st.Id = s.RI32();
|
||||
st.Name = s.RSaO();
|
||||
s.RI16();
|
||||
setIndex = s.RI16();
|
||||
isTexture = (setIndex & 0x1000) == 0x1000;
|
||||
setIndex &= 0xFFF;
|
||||
|
||||
@@ -73,7 +72,7 @@ namespace KKdMainLib.DB
|
||||
else { SpriteSets[setIndex]. Sprites[sprCount[setIndex]] = st; sprCount[setIndex]++; }
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void BINWriter(string file)
|
||||
@@ -81,13 +80,13 @@ namespace KKdMainLib.DB
|
||||
if (SpriteSets == null) return;
|
||||
if (SpriteSets.Length == 0) return;
|
||||
|
||||
List<string> setName = new List<string>();
|
||||
List<string> setFileName = new List<string>();
|
||||
KKdList<string> setName = KKdList<string>.New;
|
||||
KKdList<string> setFileName = KKdList<string>.New;
|
||||
|
||||
List<int> ids = new List<int>();
|
||||
List<int> setIds = new List<int>();
|
||||
KKdList<int> ids = KKdList<int>.New;
|
||||
KKdList<int> setIds = KKdList<int>.New;
|
||||
|
||||
List<int> notAdd = new List<int>();
|
||||
KKdList<int> notAdd = KKdList<int>.New;
|
||||
SpriteTexture temp;
|
||||
SpriteSet set;
|
||||
|
||||
@@ -130,8 +129,8 @@ namespace KKdMainLib.DB
|
||||
else ids.Add ((int)temp.Id);
|
||||
}
|
||||
}
|
||||
setName = null;
|
||||
setFileName = null;
|
||||
setName .Dispose();
|
||||
setFileName.Dispose();
|
||||
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
@@ -151,11 +150,8 @@ namespace KKdMainLib.DB
|
||||
while (set. Sprites[i0].Id == null)
|
||||
if (!ids.Contains(i1)) ids.Add((int)(SpriteSets[i]. Sprites[i0].Id = i1)); else i1++;
|
||||
}
|
||||
|
||||
ids = null;
|
||||
setIds = null;
|
||||
|
||||
|
||||
ids.Dispose();
|
||||
setIds.Dispose();
|
||||
|
||||
for (i = 0, i0 = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
if (!notAdd.Contains(i)) { i0 += SpriteSets[i].Sprites.Length + SpriteSets[i].Textures.Length; i2++; }
|
||||
@@ -163,68 +159,69 @@ namespace KKdMainLib.DB
|
||||
i1 = i0 * 12;
|
||||
i1 = i1.A(0x20) + 0x20;
|
||||
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
_IO.W(i2);
|
||||
_IO.W(i1);
|
||||
_IO.W(i0);
|
||||
_IO.W(0x20);
|
||||
_IO.W(0x9066906690669066);
|
||||
_IO.W(0x9066906690669066);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
s.W(i2);
|
||||
s.W(i1);
|
||||
s.W(i0);
|
||||
s.W(0x20);
|
||||
s.W(0x9066906690669066);
|
||||
s.W(0x9066906690669066);
|
||||
|
||||
_IO.P = (i1 + i2 * 0x10).A(0x20);
|
||||
s.P = (i1 + i2 * 0x10).A(0x20);
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (notAdd.Contains(i)) continue;
|
||||
for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++)
|
||||
{ SpriteSets[i].Textures[i0].NameOffset = _IO.P;
|
||||
_IO.W(SpriteSets[i].Textures[i0].Name + "\0"); }
|
||||
{ SpriteSets[i].Textures[i0].NameOffset = s.P;
|
||||
s.W(SpriteSets[i].Textures[i0].Name + "\0"); }
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++)
|
||||
{ SpriteSets[i]. Sprites[i0].NameOffset = _IO.P;
|
||||
_IO.W(SpriteSets[i]. Sprites[i0].Name + "\0"); }
|
||||
{ SpriteSets[i]. Sprites[i0].NameOffset = s.P;
|
||||
s.W(SpriteSets[i]. Sprites[i0].Name + "\0"); }
|
||||
}
|
||||
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (notAdd.Contains(i)) continue;
|
||||
SpriteSets[i]. NameOffset = _IO.P; _IO.W(SpriteSets[i]. Name + "\0");
|
||||
SpriteSets[i].FileNameOffset = _IO.P; _IO.W(SpriteSets[i].FileName + "\0");
|
||||
SpriteSets[i]. NameOffset = s.P; s.W(SpriteSets[i]. Name + "\0");
|
||||
SpriteSets[i].FileNameOffset = s.P; s.W(SpriteSets[i].FileName + "\0");
|
||||
}
|
||||
s.A(0x08, true);
|
||||
|
||||
_IO.A(0x08, true);
|
||||
_IO.P = 0x20;
|
||||
s.P = 0x20;
|
||||
for (i = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (notAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++)
|
||||
{
|
||||
_IO.W(SpriteSets[i].Textures[i0].Id );
|
||||
_IO.W(SpriteSets[i].Textures[i0].NameOffset);
|
||||
_IO.W((ushort) i0 );
|
||||
_IO.W((ushort)(0x1000 | (i - i2)));
|
||||
s.W(SpriteSets[i].Textures[i0].Id );
|
||||
s.W(SpriteSets[i].Textures[i0].NameOffset);
|
||||
s.W((ushort) i0 );
|
||||
s.W((ushort)(0x1000 | (i - i2)));
|
||||
}
|
||||
|
||||
for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++)
|
||||
{
|
||||
_IO.W(SpriteSets[i]. Sprites[i0].Id );
|
||||
_IO.W(SpriteSets[i]. Sprites[i0].NameOffset);
|
||||
_IO.W((ushort) i0 );
|
||||
_IO.W((ushort)(i - i2));
|
||||
s.W(SpriteSets[i]. Sprites[i0].Id );
|
||||
s.W(SpriteSets[i]. Sprites[i0].NameOffset);
|
||||
s.W((ushort) i0 );
|
||||
s.W((ushort)(i - i2));
|
||||
}
|
||||
}
|
||||
_IO.A(0x20);
|
||||
s.A(0x20);
|
||||
|
||||
for (i = 0, i2 = 0; i < SpriteSets.Length; i++)
|
||||
{
|
||||
if (notAdd.Contains(i)) { i2++; continue; }
|
||||
|
||||
_IO.W(SpriteSets[i].Id );
|
||||
_IO.W(SpriteSets[i]. NameOffset);
|
||||
_IO.W(SpriteSets[i].FileNameOffset);
|
||||
_IO.W(i - i2);
|
||||
s.W(SpriteSets[i].Id );
|
||||
s.W(SpriteSets[i]. NameOffset);
|
||||
s.W(SpriteSets[i].FileNameOffset);
|
||||
s.W(i - i2);
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
notAdd.Dispose();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json = false)
|
||||
@@ -256,7 +253,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; SpriteSets = null; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; SpriteSets = null; disposed = true; } }
|
||||
|
||||
public struct SpriteTexture
|
||||
{
|
||||
|
||||
+3
-4
@@ -19,10 +19,9 @@ namespace KKdMainLib
|
||||
s = File.OpenReader(filepath + ext);
|
||||
|
||||
header.Format = Format.F;
|
||||
header.SectionSignature = s.RU32();
|
||||
if (header.SectionSignature == 0x43505845)
|
||||
header = s.ReadHeader(true, true);
|
||||
if (header.SectionSignature != 0x64) return;
|
||||
uint signature = s.RU32();
|
||||
if (signature == 0x43505845) { header = s.ReadHeader(true); signature = s.RU32(); }
|
||||
if (signature != 0x64) return;
|
||||
|
||||
s.O = s.P - 0x4;
|
||||
Dex = new EXP[s.RI32()];
|
||||
|
||||
+53
-21
@@ -10,6 +10,7 @@ namespace KKdMainLib
|
||||
private int i;
|
||||
private Stream s;
|
||||
|
||||
public bool pvListPDA;
|
||||
public PvList[] pvList;
|
||||
public PsrData[] psrData;
|
||||
|
||||
@@ -20,6 +21,7 @@ namespace KKdMainLib
|
||||
|
||||
public void DBReader(string file)
|
||||
{
|
||||
pvListPDA = false;
|
||||
Success = false;
|
||||
if (!File.Exists(file)) return;
|
||||
string text = File.ReadAllText(file);
|
||||
@@ -28,17 +30,26 @@ namespace KKdMainLib
|
||||
|
||||
pvList = null;
|
||||
psrData = null;
|
||||
if (file.Contains("psrData") && array.Length % 13 < 2)
|
||||
if (file.Contains("psrData") && array.Length % 13 == 0)
|
||||
{
|
||||
psrData = new PsrData[array.Length / 13];
|
||||
for (i = 0; i < psrData.Length; i++) psrData[i].SetValue(array, i);
|
||||
Success = true;
|
||||
}
|
||||
else if (file.Contains("psrData")) Success = true;
|
||||
else if (file.Contains("PvList") && array.Length % 7 < 2)
|
||||
else if (file.Contains("PvList") && (array.Length % 7 == 0 || array.Length % 6 == 0))
|
||||
{
|
||||
pvList = new PvList[array.Length / 7];
|
||||
for (i = 0; i < pvList.Length; i++) pvList[i].SetValue(array, i);
|
||||
if (array[2] != "0" && array[2] != "1")
|
||||
{
|
||||
pvListPDA = true;
|
||||
pvList = new PvList[array.Length / 6];
|
||||
for (i = 0; i < pvList.Length; i++) pvList[i].SetValue(array, i, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvList = new PvList[array.Length / 7];
|
||||
for (i = 0; i < pvList.Length; i++) pvList[i].SetValue(array, i, false);
|
||||
}
|
||||
Success = true;
|
||||
}
|
||||
else if (file.Contains("PvList")) Success = true;
|
||||
@@ -63,12 +74,12 @@ namespace KKdMainLib
|
||||
if (pvList != null && pvList.Length > 0)
|
||||
{
|
||||
for (i = 0; i < pvList.Length - 1; i++)
|
||||
s.W(UrlEncode(pvList[i].ToString() + c));
|
||||
s.W(UrlEncode(pvList[i].ToString()));
|
||||
s.W(UrlEncode(pvList[i].ToString(pvListPDA) + c));
|
||||
s.W(UrlEncode(pvList[i].ToString(pvListPDA)));
|
||||
}
|
||||
else s.W("%2A%2A%2A");
|
||||
}
|
||||
|
||||
|
||||
return s.ToArray(true);
|
||||
}
|
||||
|
||||
@@ -85,6 +96,7 @@ namespace KKdMainLib
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
pvListPDA = false;
|
||||
Success = false;
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
bool compact = msgPack.RB("Compact");
|
||||
@@ -112,6 +124,13 @@ namespace KKdMainLib
|
||||
for (i = 0; i < this.pvList.Length; i++)
|
||||
this.pvList[i].SetValue(pvList[i], compact);
|
||||
}
|
||||
else if ((pvList = msgPack["PvListPDA", true]).NotNull)
|
||||
{
|
||||
pvListPDA = true;
|
||||
this.pvList = new PvList[pvList.Array.Length];
|
||||
for (i = 0; i < this.pvList.Length; i++)
|
||||
this.pvList[i].SetValue(pvList[i], compact);
|
||||
}
|
||||
Success = true;
|
||||
pvList.Dispose();
|
||||
}
|
||||
@@ -139,11 +158,11 @@ namespace KKdMainLib
|
||||
if (pvList != null)
|
||||
{msgPack.Add("Compact", true);
|
||||
|
||||
MsgPack PvList = new MsgPack(pvList.Length, "PvList");
|
||||
MsgPack PvList = new MsgPack(pvList.Length, pvListPDA ? "PvListPDA" : "PvList");
|
||||
for (i = 0; i < pvList.Length; i++) PvList[i] = pvList[i].WriteMP();
|
||||
msgPack.Add(PvList);
|
||||
}
|
||||
else msgPack.Add(new MsgPack("PvList", null));
|
||||
else msgPack.Add(new MsgPack(pvListPDA ? "PvListPDA" : "PvList", null));
|
||||
}
|
||||
msgPack.Write(file, false, json).Dispose();
|
||||
}
|
||||
@@ -154,7 +173,7 @@ namespace KKdMainLib
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; psrData = null;
|
||||
pvList = null; Success = false; disposed = true; } }
|
||||
pvList = null; pvListPDA = false; Success = false; disposed = true; } }
|
||||
|
||||
public struct PsrData
|
||||
{
|
||||
@@ -231,7 +250,7 @@ namespace KKdMainLib
|
||||
NameExtra = msg.RS ( "NameExtra");
|
||||
Score = msg.RI32("Score");
|
||||
ScoreExtra = msg.RI32("ScoreExtra");
|
||||
|
||||
|
||||
if (Name == null)
|
||||
{
|
||||
Name = msg.RS ( "Name0");
|
||||
@@ -262,15 +281,27 @@ namespace KKdMainLib
|
||||
public Date StartShow;
|
||||
public Date EndShow;
|
||||
|
||||
public void SetValue(string[] data, int i = 0)
|
||||
public void SetValue(string[] data, int i = 0, bool pda = false)
|
||||
{
|
||||
PV_ID = int.Parse(data[i * 7]);
|
||||
Version = int.Parse(data[i * 7 + 1]);
|
||||
Edition = int.Parse(data[i * 7 + 2]);
|
||||
AdvDemoStart.SV(data[i * 7 + 3]);
|
||||
AdvDemoEnd .SV(data[i * 7 + 4]);
|
||||
StartShow .SV(data[i * 7 + 5]);
|
||||
EndShow .SV(data[i * 7 + 6]);
|
||||
if (pda)
|
||||
{
|
||||
PV_ID = int.Parse(data[i * 6]);
|
||||
Version = int.Parse(data[i * 6 + 1]);
|
||||
AdvDemoStart.SV(data[i * 6 + 2]);
|
||||
AdvDemoEnd.SV(data[i * 6 + 3]);
|
||||
StartShow.SV(data[i * 6 + 4]);
|
||||
EndShow.SV(data[i * 6 + 5]);
|
||||
}
|
||||
else
|
||||
{
|
||||
PV_ID = int.Parse(data[i * 7]);
|
||||
Version = int.Parse(data[i * 7 + 1]);
|
||||
Edition = int.Parse(data[i * 7 + 2]);
|
||||
AdvDemoStart.SV(data[i * 7 + 3]);
|
||||
AdvDemoEnd .SV(data[i * 7 + 4]);
|
||||
StartShow .SV(data[i * 7 + 5]);
|
||||
EndShow .SV(data[i * 7 + 6]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetValue(MsgPack msg, bool Compact)
|
||||
@@ -313,8 +344,9 @@ namespace KKdMainLib
|
||||
return msgPack;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
UrlEncode($"{PV_ID},{Version},{Edition},{AdvDemoStart},{AdvDemoEnd},{StartShow},{EndShow}");
|
||||
public string ToString(bool pda) => !pda
|
||||
? UrlEncode($"{PV_ID},{Version},{Edition},{AdvDemoStart},{AdvDemoEnd},{StartShow},{EndShow}")
|
||||
: UrlEncode($"{PV_ID},{Version},{AdvDemoStart},{AdvDemoEnd},{StartShow},{EndShow}");
|
||||
}
|
||||
|
||||
public struct Date
|
||||
|
||||
+141
-18
@@ -6,15 +6,15 @@ namespace KKdMainLib
|
||||
{
|
||||
public static class HeaderExtensions
|
||||
{
|
||||
public static Header ReadHeader(this Stream stream, bool seek, bool readSectionSignature = true)
|
||||
public static Header ReadHeader(this Stream stream, bool seek)
|
||||
{
|
||||
if (seek)
|
||||
if (stream.PI64 > 4) stream.PI64 -= 4;
|
||||
else stream.PI64 = 0;
|
||||
return stream.ReadHeader(readSectionSignature);
|
||||
return stream.ReadHeader();
|
||||
}
|
||||
|
||||
public static Header ReadHeader(this Stream stream, bool readSectionSignature = true)
|
||||
public static Header ReadHeader(this Stream stream)
|
||||
{
|
||||
Header header = new Header { Format = Format.F2 };
|
||||
header.Signature = stream.RU32();
|
||||
@@ -36,7 +36,6 @@ namespace KKdMainLib
|
||||
stream.RI64();
|
||||
}
|
||||
stream.Format = header.Format;
|
||||
if (readSectionSignature) header.SectionSignature = stream.RU32E();
|
||||
return header;
|
||||
}
|
||||
|
||||
@@ -132,7 +131,7 @@ namespace KKdMainLib
|
||||
else @struct.POF .Read(Data, sig == 0x31464F50);
|
||||
}
|
||||
else if (header.Depth == 0 && sig == 0x43505854)
|
||||
subStructs.Add(new Struct { Header = header, DataOffset = stream.P, Data = stream.RBy(l) });
|
||||
subStructs.Add(stream.RSt(header));
|
||||
else if (header.Depth > depth) subStructs.Add(stream.RSt(header));
|
||||
else { stream.PI64 -= header.Length; break; }
|
||||
lastSig = sig;
|
||||
@@ -147,24 +146,25 @@ namespace KKdMainLib
|
||||
{
|
||||
byte[] Data;
|
||||
using (Stream stream = File.OpenWriter())
|
||||
{ stream.W(@struct, shiftX, useDepth); stream.WEOFC(); Data = stream.ToArray(); }
|
||||
{ stream.W(@struct, 0, shiftX, useDepth); stream.WEOFC(); Data = stream.ToArray(); }
|
||||
return Data;
|
||||
}
|
||||
|
||||
public static void W(this Stream stream, Struct @struct, bool shiftX = false, bool useDepth = true)
|
||||
public static void W(this Stream stream, Struct @struct, uint depth = 0,
|
||||
bool shiftX = false, bool useDepth = true)
|
||||
{
|
||||
@struct.Update(shiftX);
|
||||
|
||||
stream.W(@struct.Header);
|
||||
@struct.Header.Depth = depth;
|
||||
stream.W(@struct.Header, @struct.Header.Length == 0x40);
|
||||
if (@struct.Data != null) stream.W(@struct.Data);
|
||||
if (@struct.HasPOF ) stream.W(@struct.POF , shiftX, useDepth ? @struct.Depth + 1 : 0u);
|
||||
if (@struct.HasENRS) stream.W(@struct.ENRS, useDepth ? @struct.Depth + 1 : 0u);
|
||||
if (@struct.HasPOF ) stream.W(@struct.POF , shiftX, useDepth ? depth + 1 : 0u);
|
||||
if (@struct.HasENRS) stream.W(@struct.ENRS, useDepth ? depth + 1 : 0u);
|
||||
if (@struct.HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < @struct.SubStructs.Length; i++)
|
||||
stream.W(@struct.SubStructs[i], shiftX);
|
||||
stream.WEOFC(@struct.Depth + 1);
|
||||
}
|
||||
stream.W(@struct.SubStructs[i], depth + 1, shiftX, useDepth);
|
||||
if (@struct.HasPOF || @struct.HasENRS || @struct.HasSubStructs)
|
||||
stream.WEOFC(depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,8 +200,12 @@ namespace KKdMainLib
|
||||
|
||||
public static MsgPack Write(this MsgPack mp, string file, bool ignoreNull, bool json = false)
|
||||
{
|
||||
if (json) using (JSON _IO = new JSON(File.OpenWriter(file + ".json", true))) _IO.W(mp, ignoreNull, "\n", " ");
|
||||
else using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true))) _IO.W(mp, ignoreNull);
|
||||
if (json)
|
||||
using (JSON _IO = new JSON(File.OpenWriter(file + ".json", true)))
|
||||
_IO.W(mp, ignoreNull, "\n", " ");
|
||||
else
|
||||
using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true)))
|
||||
_IO.W(mp, ignoreNull);
|
||||
return mp;
|
||||
}
|
||||
|
||||
@@ -212,8 +216,12 @@ namespace KKdMainLib
|
||||
public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool ignoreNull, bool json = false)
|
||||
{
|
||||
byte[] data = null;
|
||||
if (json) using (JSON _IO = new JSON(File.OpenWriter())) { _IO.W(mp, ignoreNull, true); data = _IO.ToArray(); }
|
||||
else using ( MP _IO = new MP(File.OpenWriter())) { _IO.W(mp, ignoreNull ); data = _IO.ToArray(); }
|
||||
if (json)
|
||||
using (JSON _IO = new JSON(File.OpenWriter()))
|
||||
{ _IO.W(mp, ignoreNull, true); data = _IO.ToArray(); }
|
||||
else
|
||||
using ( MP _IO = new MP(File.OpenWriter()))
|
||||
{ _IO.W(mp, ignoreNull ); data = _IO.ToArray(); }
|
||||
File.WriteAllBytes(file + (json ? ".json" : ".mp"), data);
|
||||
return mp;
|
||||
}
|
||||
@@ -238,4 +246,119 @@ namespace KKdMainLib
|
||||
return kf;
|
||||
}
|
||||
}
|
||||
|
||||
public static class HashExt
|
||||
{
|
||||
public static uint HashFNV1a64(this byte[] array) =>
|
||||
array.HashMurmurHash(array.Length);
|
||||
|
||||
public static ulong HashFNV1a64(this byte[] array, int length) // 0x1403B04D0 in SBZV_7.10; FNV 1a 64-bit
|
||||
{
|
||||
int i = 0;
|
||||
ulong hash = 0xCBF29CE484222325;
|
||||
while (i < length)
|
||||
{ hash = 0x100000001B3 * (hash ^ (ulong)array[i]); i++; }
|
||||
return (hash >> 32) ^ hash;
|
||||
}
|
||||
|
||||
public static uint HashMurmurHash(this byte[] array, uint salt = 0,
|
||||
bool alreadyUpper = false, bool bigEndian = false) =>
|
||||
array.HashMurmurHash(array.Length, salt, alreadyUpper, bigEndian);
|
||||
|
||||
public static uint HashMurmurHash(this byte[] array, int length, uint salt = 0,
|
||||
bool alreadyUpper = false, bool bigEndian = false) // 0x814D7A9C in PCSB00554; MurmurHash
|
||||
{
|
||||
uint a, b, hash;
|
||||
int i;
|
||||
|
||||
const uint m = 0x7FD652AD;
|
||||
const int r = 16;
|
||||
|
||||
hash = salt + 0xDEADBEEF;
|
||||
if (alreadyUpper)
|
||||
{
|
||||
if (bigEndian)
|
||||
for (i = 0; length > 3; length -= 4, i += 4)
|
||||
{
|
||||
b = (uint)array[i + 3] | ((uint)array[i + 2] << 8)
|
||||
| ((uint)array[i + 1] << 16) | ((uint)array[i + 0] << 24);
|
||||
hash += b;
|
||||
hash *= m;
|
||||
hash ^= hash >> r;
|
||||
}
|
||||
else
|
||||
for (i = 0; length > 3; length -= 4, i += 4)
|
||||
{
|
||||
b = (uint)array[i + 0] | ((uint)array[i + 1] << 8)
|
||||
| ((uint)array[i + 2] << 16) | ((uint)array[i + 3] << 24);
|
||||
hash += b;
|
||||
hash *= m;
|
||||
hash ^= hash >> r;
|
||||
}
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
if (length > 1)
|
||||
{
|
||||
if (length > 2)
|
||||
hash += (uint)array[i + 2] << 16;
|
||||
hash += (uint)array[i + 1] << 8;
|
||||
}
|
||||
hash += array[i];
|
||||
hash *= m;
|
||||
hash ^= hash >> r;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bigEndian)
|
||||
for (i = 0; length > 3; length -= 4, i += 4)
|
||||
{
|
||||
b = (uint)array[i + 3] | ((uint)array[i + 2] << 8)
|
||||
| ((uint)array[i + 1] << 16) | ((uint)array[i + 0] << 24);
|
||||
a = b & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0xFFFFFF00) | a ;
|
||||
a = (b >> 8) & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0xFFFF00FF) | (a << 8);
|
||||
a = (b >> 16) & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0xFF00FFFF) | (a << 16);
|
||||
a = (b >> 24) & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0x00FFFFFF) | (a << 24);
|
||||
hash += b;
|
||||
hash *= m;
|
||||
hash ^= hash >> r;
|
||||
}
|
||||
else
|
||||
for (i = 0; length > 3; length -= 4, i += 4)
|
||||
{
|
||||
b = (uint)array[i + 0] | ((uint)array[i + 1] << 8)
|
||||
| ((uint)array[i + 2] << 16) | ((uint)array[i + 3] << 24);
|
||||
a = b & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0xFFFFFF00) | a ;
|
||||
a = (b >> 8) & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0xFFFF00FF) | (a << 8);
|
||||
a = (b >> 16) & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0xFF00FFFF) | (a << 16);
|
||||
a = (b >> 24) & 0xFF; if (a > 0x60 && a < 0x7B) a -= 0x20; b = (b & 0x00FFFFFF) | (a << 24);
|
||||
hash += b;
|
||||
hash *= m;
|
||||
hash ^= hash >> r;
|
||||
}
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
if (length > 1)
|
||||
{
|
||||
if (length > 2)
|
||||
{
|
||||
b = array[i + 2]; if (b > 0x60 && b < 0x7B) b -= 0x20; hash += b << 16;
|
||||
}
|
||||
b = array[i + 1]; if (b > 0x60 && b < 0x7B) b -= 0x20; hash += b << 8;
|
||||
}
|
||||
b = array[i]; if (b > 0x60 && b < 0x7B) b -= 0x20; hash += b;
|
||||
hash *= m;
|
||||
hash ^= hash >> r;
|
||||
}
|
||||
}
|
||||
|
||||
hash *= m;
|
||||
hash ^= hash >> 10;
|
||||
hash *= m;
|
||||
hash ^= hash >> 17;
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+317
-32
@@ -8,45 +8,312 @@ namespace KKdMainLib.F2
|
||||
{
|
||||
private int i;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public bool IsX;
|
||||
public CountPointer<BLT> BLTs;
|
||||
|
||||
public void BLTReader(string file)
|
||||
{
|
||||
IsX = false;
|
||||
BLTs = default;
|
||||
s = File.OpenReader(file + ".blt", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x544D4C42 || header.InnerSignature != 0x3) return;
|
||||
s.P -= 0x4;
|
||||
byte[] bltData = File.ReadAllBytes(file + ".blt");
|
||||
Struct _BLMT = bltData.RSt(); bltData = null;
|
||||
if (_BLMT.Header.Signature != 0x544D4C42) return;
|
||||
|
||||
s = File.OpenReader(_BLMT.Data);
|
||||
s.IsBE = _BLMT.Header.UseBigEndian;
|
||||
|
||||
BLTs = s.RCPE<BLT>();
|
||||
if (BLTs.C < 1) { s.C(); BLTs.C = -1; return; }
|
||||
|
||||
if (BLTs.C > 0 && BLTs.O == 0) { s.C(); BLTs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
_IO.Position = BLTs.Offset;
|
||||
BLTs = _IO.ReadCountPointerX<BLT>();
|
||||
}*/
|
||||
|
||||
s.P = BLTs.O;
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
if (!(BLTs.C > 0 && BLTs.O == 0))
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
s.RI32E();
|
||||
blt.Color .X = s.RF32E();
|
||||
blt.Color .Y = s.RF32E();
|
||||
blt.Color .Z = s.RF32E();
|
||||
blt.Brightpass.X = s.RF32E();
|
||||
blt.Brightpass.Y = s.RF32E();
|
||||
blt.Brightpass.Z = s.RF32E();
|
||||
blt.Range = s.RF32E();
|
||||
s.PI64 = BLTs.O - _BLMT.Header.Length;
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
blt.Flags = (Flags)s.RI32E();
|
||||
blt.Color .X = s.RF32E();
|
||||
blt.Color .Y = s.RF32E();
|
||||
blt.Color .Z = s.RF32E();
|
||||
blt.Brightpass.X = s.RF32E();
|
||||
blt.Brightpass.Y = s.RF32E();
|
||||
blt.Brightpass.Z = s.RF32E();
|
||||
blt.Range = s.RF32E();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsX = true;
|
||||
BLTs.O = (int)s.RI64E();
|
||||
s.PI64 = BLTs.O;
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
blt.Flags = (Flags)s.RI32E();
|
||||
blt.Color .X = s.RF32E();
|
||||
blt.Color .Y = s.RF32E();
|
||||
blt.Color .Z = s.RF32E();
|
||||
blt.Brightpass.X = s.RF32E();
|
||||
blt.Brightpass.Y = s.RF32E();
|
||||
blt.Brightpass.Z = s.RF32E();
|
||||
blt.Range = s.RF32E();
|
||||
blt.Unk1 = s.RF32 ();
|
||||
blt.Unk2 = s.RI32 ();
|
||||
blt.Unk3 = s.RF32 ();
|
||||
}
|
||||
}
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void BLTWriter(string file)
|
||||
{
|
||||
if (BLTs.E == null || BLTs.C < 1) return;
|
||||
|
||||
if (file.EndsWith("_bloom"))
|
||||
file = file.Substring(0, file.Length - 6);
|
||||
|
||||
s = File.OpenWriter();
|
||||
s.IsBE = false;
|
||||
s.Format = Format.F2;
|
||||
|
||||
ENRS e = default;
|
||||
POF p = default;
|
||||
p.Offsets = KKdList<long>.New;
|
||||
if (!IsX)
|
||||
{
|
||||
s.W(BLTs.C);
|
||||
s.W(0x50);
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
s.W((int)blt.Flags);
|
||||
s.W(blt.Color .X);
|
||||
s.W(blt.Color .Y);
|
||||
s.W(blt.Color .Z);
|
||||
s.W(blt.Brightpass.X);
|
||||
s.W(blt.Brightpass.Y);
|
||||
s.W(blt.Brightpass.Z);
|
||||
s.W(blt.Range );
|
||||
}
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[2];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x20, BLTs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x08, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x44);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.W(BLTs.C);
|
||||
s.A(0x08);
|
||||
s.W(0x10L);
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
s.W((int)blt.Flags);
|
||||
s.W(blt.Color .X);
|
||||
s.W(blt.Color .Y);
|
||||
s.W(blt.Color .Z);
|
||||
s.W(blt.Brightpass.X);
|
||||
s.W(blt.Brightpass.Y);
|
||||
s.W(blt.Brightpass.Z);
|
||||
s.W(blt.Range );
|
||||
s.W(blt.Unk1 );
|
||||
s.W(blt.Unk2 );
|
||||
s.W(blt.Unk3 );
|
||||
}
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[2];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x02, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x01, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[0].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x04, 0x01, ENRS.ENRSEntry.Type.QWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x2C, BLTs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x08, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x08);
|
||||
}
|
||||
|
||||
s.A(0x10, true);
|
||||
byte[] data = s.ToArray(true);
|
||||
|
||||
Struct _BLMT = default;
|
||||
_BLMT.Header.Signature = 0x544D4C42;
|
||||
_BLMT.Header.DataSize = (uint)data.Length;
|
||||
_BLMT.Header.Length = 0x40;
|
||||
_BLMT.Header.Depth = 0;
|
||||
_BLMT.Header.SectionSize = (uint)data.Length;
|
||||
_BLMT.Header.Version = 0;
|
||||
_BLMT.Header.InnerSignature = 0x03;
|
||||
|
||||
_BLMT.Header.UseBigEndian = false;
|
||||
_BLMT.Header.UseSectionSize = true;
|
||||
_BLMT.Header.Format = Format.F2;
|
||||
_BLMT.Data = data;
|
||||
_BLMT.ENRS = e;
|
||||
_BLMT.POF = p;
|
||||
File.WriteAllBytes(file + ".blt", _BLMT.W(IsX, true));
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
IsX = false;
|
||||
BLTs = default;
|
||||
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
MsgPack bloom;
|
||||
if ((bloom = msgPack["Bloom", true]).NotNull)
|
||||
{
|
||||
BLTs.E = new BLT[bloom.Array.Length];
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
blt = default;
|
||||
MsgPack b = bloom[i];
|
||||
MsgPack temp;
|
||||
if ((temp = b["Color"]).NotNull)
|
||||
{
|
||||
blt.Flags |= Flags.Color;
|
||||
blt.Color.X = temp.RF32("X");
|
||||
blt.Color.Y = temp.RF32("Y");
|
||||
blt.Color.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = b["Brightpass"]).NotNull)
|
||||
{
|
||||
blt.Flags |= Flags.Brightpass;
|
||||
blt.Brightpass.X = temp.RF32("X");
|
||||
blt.Brightpass.Y = temp.RF32("Y");
|
||||
blt.Brightpass.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = b["Range"]).Object != null)
|
||||
{
|
||||
blt.Flags |= Flags.Range;
|
||||
blt.Range = temp.RF32();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((bloom = msgPack["BloomX", true]).NotNull)
|
||||
{
|
||||
IsX = true;
|
||||
s.IsX = true;
|
||||
BLTs.E = new BLT[bloom.Array.Length];
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
blt = default;
|
||||
MsgPack b = bloom[i];
|
||||
MsgPack temp;
|
||||
if ((temp = b["Color"]).NotNull)
|
||||
{
|
||||
blt.Flags |= Flags.Color;
|
||||
blt.Color.X = temp.RF32("X");
|
||||
blt.Color.Y = temp.RF32("Y");
|
||||
blt.Color.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = b["Brightpass"]).NotNull)
|
||||
{
|
||||
blt.Flags |= Flags.Brightpass;
|
||||
blt.Brightpass.X = temp.RF32("X");
|
||||
blt.Brightpass.Y = temp.RF32("Y");
|
||||
blt.Brightpass.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = b["Range"]).Object != null)
|
||||
{
|
||||
blt.Flags |= Flags.Range;
|
||||
blt.Range = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = b["Unk1"]).Object != null)
|
||||
{
|
||||
blt.Flags |= Flags.Unk1;
|
||||
blt.Unk1 = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = b["Unk2"]).Object != null)
|
||||
{
|
||||
blt.Flags |= Flags.Unk2;
|
||||
blt.Unk2 = temp.RI32();
|
||||
}
|
||||
|
||||
if ((temp = b["Unk3"]).Object != null)
|
||||
{
|
||||
blt.Flags |= Flags.Unk3;
|
||||
blt.Unk3 = temp.RF32();
|
||||
}
|
||||
}
|
||||
}
|
||||
bloom.Dispose();
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (BLTs.E == null || BLTs.C < 1) return;
|
||||
|
||||
MsgPack bloom;
|
||||
if (!IsX)
|
||||
{
|
||||
bloom = new MsgPack(BLTs.C, "Bloom");
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
MsgPack b = MsgPack.New;
|
||||
if ((blt.Flags & Flags.Color) != 0)
|
||||
b.Add(new MsgPack("Color")
|
||||
.Add("X", blt.Color.X)
|
||||
.Add("Y", blt.Color.Y)
|
||||
.Add("Z", blt.Color.Z));
|
||||
if ((blt.Flags & Flags.Brightpass) != 0)
|
||||
b.Add(new MsgPack("Brightpass")
|
||||
.Add("X", blt.Brightpass.X)
|
||||
.Add("Y", blt.Brightpass.Y)
|
||||
.Add("Z", blt.Brightpass.Z));
|
||||
if ((blt.Flags & Flags.Range) != 0)
|
||||
b.Add("Range", blt.Range);
|
||||
bloom[i] = b;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bloom = new MsgPack(BLTs.C, "BloomX");
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
MsgPack b = MsgPack.New;
|
||||
if ((blt.Flags & Flags.Color) != 0)
|
||||
b.Add(new MsgPack("Color")
|
||||
.Add("X", blt.Color.X)
|
||||
.Add("Y", blt.Color.Y)
|
||||
.Add("Z", blt.Color.Z));
|
||||
if ((blt.Flags & Flags.Brightpass) != 0)
|
||||
b.Add(new MsgPack("Brightpass")
|
||||
.Add("X", blt.Brightpass.X)
|
||||
.Add("Y", blt.Brightpass.Y)
|
||||
.Add("Z", blt.Brightpass.Z));
|
||||
if ((blt.Flags & Flags.Range) != 0)
|
||||
b.Add("Range", blt.Range);
|
||||
if ((blt.Flags & Flags.Unk1) != 0)
|
||||
b.Add("Unk1", blt.Unk1);
|
||||
if ((blt.Flags & Flags.Unk2) != 0)
|
||||
b.Add("Unk2", blt.Unk2);
|
||||
if ((blt.Flags & Flags.Unk3) != 0)
|
||||
b.Add("Unk3", blt.Unk3);
|
||||
bloom[i] = b;
|
||||
}
|
||||
}
|
||||
bloom.Write(false, true, file + "_bloom", json);
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (BLTs.C < 1) return;
|
||||
@@ -54,23 +321,41 @@ namespace KKdMainLib.F2
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("ID,ColorR,ColorG,ColorB,BrightpassR,BrightpassG,BrightpassB,Range\n");
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
s.W(i + "," + BLTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_bloom.txt", s.ToArray(true));
|
||||
s.W($"{i},{ BLTs[i]}\n");
|
||||
File.WriteAllBytes($"{file}_bloom.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; BLTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; BLTs = default; IsX = false; disposed = true; } }
|
||||
|
||||
public struct BLT
|
||||
{
|
||||
public Vec3 Color;
|
||||
public Vec3 Brightpass;
|
||||
public Flags Flags;
|
||||
public Vec3 Color;
|
||||
public Vec3 Brightpass;
|
||||
public float Range;
|
||||
public float Unk1;
|
||||
public int Unk2;
|
||||
public float Unk3;
|
||||
|
||||
public override string ToString() => Color .ToString(6) + "," +
|
||||
Brightpass.ToString(6) + "," +
|
||||
Range .ToS(6);
|
||||
public override string ToString() =>
|
||||
((Flags & Flags.Color) != 0
|
||||
? $"{Color.X.ToS(6)},{Color.Y.ToS(6)},{Color.Z.ToS(6)}," : ",,,") +
|
||||
((Flags & Flags.Brightpass) != 0
|
||||
? $"{Brightpass.X.ToS(6)},{Brightpass.Y.ToS(6)},{Brightpass.Z.ToS(6)}," : ",,,") +
|
||||
((Flags & Flags.Range) != 0
|
||||
? $"{Range.ToS(6)}" : "");
|
||||
}
|
||||
|
||||
public enum Flags : int
|
||||
{
|
||||
Color = 0b000001,
|
||||
Brightpass = 0b000010,
|
||||
Range = 0b000100,
|
||||
Unk1 = 0b001000,
|
||||
Unk2 = 0b010000,
|
||||
Unk3 = 0b100000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,45 +8,322 @@ namespace KKdMainLib.F2
|
||||
{
|
||||
private int i;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public bool IsX;
|
||||
public CountPointer<CCT> CCTs;
|
||||
|
||||
public void CCTReader(string file)
|
||||
{
|
||||
IsX = false;
|
||||
CCTs = default;
|
||||
s = File.OpenReader(file + ".cct", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x54524343 || header.InnerSignature != 0x3) return;
|
||||
s.P -= 0x4;
|
||||
byte[] ccData = File.ReadAllBytes(file + ".cct");
|
||||
Struct _CCRT = ccData.RSt(); ccData = null;
|
||||
if (_CCRT.Header.Signature != 0x54524343) return;
|
||||
|
||||
s = File.OpenReader(_CCRT.Data);
|
||||
s.IsBE = _CCRT.Header.UseBigEndian;
|
||||
|
||||
CCTs = s.RCPE<CCT>();
|
||||
if (CCTs.C < 1) { s.C(); CCTs.C = -1; return; }
|
||||
|
||||
if (CCTs.C > 0 && CCTs.O == 0) { s.C(); CCTs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
_IO.Position = CCTs.Offset;
|
||||
CCTs = _IO.ReadCountPointerX<CCT>();
|
||||
}*/
|
||||
|
||||
s.P = CCTs.O;
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
if (!(CCTs.C > 0 && CCTs.O == 0))
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
s.RI32E();
|
||||
cct.Hue = s.RF32E();
|
||||
cct.Saturation = s.RF32E();
|
||||
cct.Lightness = s.RF32E();
|
||||
cct.Exposure = s.RF32E();
|
||||
cct.Gamma.X = s.RF32E();
|
||||
cct.Gamma.Y = s.RF32E();
|
||||
cct.Gamma.Z = s.RF32E();
|
||||
cct.Contrast = s.RF32E();
|
||||
s.PI64 = CCTs.O - _CCRT.Header.Length;
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
cct.Flags = (Flags)s.RI32E();
|
||||
cct.Hue = s.RF32E();
|
||||
cct.Saturation = s.RF32E();
|
||||
cct.Lightness = s.RF32E();
|
||||
cct.Exposure = s.RF32E();
|
||||
cct.Gamma.X = s.RF32E();
|
||||
cct.Gamma.Y = s.RF32E();
|
||||
cct.Gamma.Z = s.RF32E();
|
||||
cct.Contrast = s.RF32E();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsX = true;
|
||||
s.IsX = true;
|
||||
CCTs.O = (int)s.RI64E();
|
||||
s.PI64 = CCTs.O;
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
cct.Flags = (Flags)s.RI32E();
|
||||
cct.Hue = s.RF32E();
|
||||
cct.Saturation = s.RF32E();
|
||||
cct.Lightness = s.RF32E();
|
||||
cct.Exposure = s.RF32E();
|
||||
cct.Gamma.X = s.RF32E();
|
||||
cct.Gamma.Y = s.RF32E();
|
||||
cct.Gamma.Z = s.RF32E();
|
||||
cct.Contrast = s.RF32E();
|
||||
}
|
||||
}
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void CCTWriter(string file)
|
||||
{
|
||||
if (CCTs.E == null || CCTs.C < 1) return;
|
||||
|
||||
if (file.EndsWith("_cc"))
|
||||
file = file.Substring(0, file.Length - 3);
|
||||
|
||||
s = File.OpenWriter();
|
||||
s.IsBE = false;
|
||||
s.Format = Format.F2;
|
||||
|
||||
ENRS e = default;
|
||||
POF p = default;
|
||||
p.Offsets = KKdList<long>.New;
|
||||
if (!IsX)
|
||||
{
|
||||
s.W(CCTs.C);
|
||||
s.W(0x50);
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
s.W((int)cct.Flags);
|
||||
s.W(cct.Hue );
|
||||
s.W(cct.Saturation);
|
||||
s.W(cct.Lightness );
|
||||
s.W(cct.Exposure );
|
||||
s.W(cct.Gamma.X );
|
||||
s.W(cct.Gamma.Y );
|
||||
s.W(cct.Gamma.Z );
|
||||
s.W(cct.Contrast );
|
||||
}
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[2];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x24, CCTs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x08, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x44);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.W(CCTs.C);
|
||||
s.A(0x08);
|
||||
s.W(0x10L);
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
s.W((int)cct.Flags);
|
||||
s.W(cct.Hue );
|
||||
s.W(cct.Saturation);
|
||||
s.W(cct.Lightness );
|
||||
s.W(cct.Exposure );
|
||||
s.W(cct.Gamma.X );
|
||||
s.W(cct.Gamma.Y );
|
||||
s.W(cct.Gamma.Z );
|
||||
s.W(cct.Contrast );
|
||||
}
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[2];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x02, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x01, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[0].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x04, 0x01, ENRS.ENRSEntry.Type.QWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x24, CCTs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x08, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x08);
|
||||
}
|
||||
|
||||
s.C();
|
||||
s.A(0x10, true);
|
||||
byte[] data = s.ToArray(true);
|
||||
|
||||
Struct _CCRT = default;
|
||||
_CCRT.Header.Signature = 0x54524343;
|
||||
_CCRT.Header.DataSize = (uint)data.Length;
|
||||
_CCRT.Header.Length = 0x40;
|
||||
_CCRT.Header.Depth = 0;
|
||||
_CCRT.Header.SectionSize = (uint)data.Length;
|
||||
_CCRT.Header.Version = 0;
|
||||
_CCRT.Header.InnerSignature = 0x03;
|
||||
|
||||
_CCRT.Header.UseBigEndian = false;
|
||||
_CCRT.Header.UseSectionSize = true;
|
||||
_CCRT.Header.Format = Format.F2;
|
||||
_CCRT.Data = data;
|
||||
_CCRT.ENRS = e;
|
||||
_CCRT.POF = p;
|
||||
File.WriteAllBytes(file + ".cct", _CCRT.W(IsX, true));
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
IsX = false;
|
||||
CCTs = default;
|
||||
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
MsgPack cc;
|
||||
if ((cc = msgPack["ColorCorrection", true]).NotNull)
|
||||
{
|
||||
CCTs.E = new CCT[cc.Array.Length];
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
cct = default;
|
||||
MsgPack c = cc[i];
|
||||
MsgPack temp;
|
||||
if ((temp = c["Hue"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Hue;
|
||||
cct.Hue = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Saturation"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Saturation;
|
||||
cct.Saturation = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Lightness"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Lightness;
|
||||
cct.Lightness = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Exposure"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Exposure;
|
||||
cct.Exposure = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Gamma"]).NotNull)
|
||||
{
|
||||
cct.Flags |= Flags.Gamma;
|
||||
cct.Gamma.X = temp.RF32("X");
|
||||
cct.Gamma.Y = temp.RF32("Y");
|
||||
cct.Gamma.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = c["Contrast"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Contrast;
|
||||
cct.Contrast = temp.RF32();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((cc = msgPack["ColorCorrectionX", true]).NotNull)
|
||||
{
|
||||
IsX = true;
|
||||
CCTs.E = new CCT[cc.Array.Length];
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
cct = default;
|
||||
MsgPack c = cc[i];
|
||||
MsgPack temp;
|
||||
if ((temp = c["Hue"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Hue;
|
||||
cct.Hue = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Saturation"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Saturation;
|
||||
cct.Saturation = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Lightness"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Lightness;
|
||||
cct.Lightness = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Exposure"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Exposure;
|
||||
cct.Exposure = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = c["Gamma"]).NotNull)
|
||||
{
|
||||
cct.Flags |= Flags.Gamma;
|
||||
cct.Gamma.X = temp.RF32("X");
|
||||
cct.Gamma.Y = temp.RF32("Y");
|
||||
cct.Gamma.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = c["Contrast"]).Object != null)
|
||||
{
|
||||
cct.Flags |= Flags.Contrast;
|
||||
cct.Contrast = temp.RF32();
|
||||
}
|
||||
}
|
||||
}
|
||||
cc.Dispose();
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (CCTs.E == null || CCTs.C < 1) return;
|
||||
|
||||
MsgPack cc;
|
||||
if (!IsX)
|
||||
{
|
||||
cc = new MsgPack(CCTs.C, "ColorCorrection");
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
MsgPack c = MsgPack.New;
|
||||
if ((cct.Flags & Flags.Hue) != 0)
|
||||
c.Add("Hue", cct.Hue);
|
||||
if ((cct.Flags & Flags.Saturation) != 0)
|
||||
c.Add("Saturation", cct.Saturation);
|
||||
if ((cct.Flags & Flags.Lightness) != 0)
|
||||
c.Add("Lightness", cct.Lightness);
|
||||
if ((cct.Flags & Flags.Exposure) != 0)
|
||||
c.Add("Exposure", cct.Exposure);
|
||||
if ((cct.Flags & Flags.Gamma) != 0)
|
||||
c.Add(new MsgPack("Gamma")
|
||||
.Add("X", cct.Gamma.X)
|
||||
.Add("Y", cct.Gamma.Y)
|
||||
.Add("Z", cct.Gamma.Z));
|
||||
if ((cct.Flags & Flags.Contrast) != 0)
|
||||
c.Add("Contrast", cct.Contrast);
|
||||
cc[i] = c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cc = new MsgPack(CCTs.C, "ColorCorrectionX");
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
MsgPack c = MsgPack.New;
|
||||
if ((cct.Flags & Flags.Hue) != 0)
|
||||
c.Add("Hue", cct.Hue);
|
||||
if ((cct.Flags & Flags.Saturation) != 0)
|
||||
c.Add("Saturation", cct.Saturation);
|
||||
if ((cct.Flags & Flags.Lightness) != 0)
|
||||
c.Add("Lightness", cct.Lightness);
|
||||
if ((cct.Flags & Flags.Exposure) != 0)
|
||||
c.Add("Exposure", cct.Exposure);
|
||||
if ((cct.Flags & Flags.Gamma) != 0)
|
||||
c.Add(new MsgPack("Gamma")
|
||||
.Add("X", cct.Gamma.X)
|
||||
.Add("Y", cct.Gamma.Y)
|
||||
.Add("Z", cct.Gamma.Z));
|
||||
if ((cct.Flags & Flags.Contrast) != 0)
|
||||
c.Add("Contrast", cct.Contrast);
|
||||
cc[i] = c;
|
||||
}
|
||||
}
|
||||
cc.Write(false, true, file + "_cc", json);
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
@@ -56,29 +333,47 @@ namespace KKdMainLib.F2
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("ID,Hue,Saturation,Lightness,Exposure,GammaR,GammaG,GammaB,Contrast\n");
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
s.W(i + "," + CCTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_cc.txt", s.ToArray(true));
|
||||
s.W($"{i},{CCTs[i]}\n");
|
||||
File.WriteAllBytes($"{file}_cc.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; CCTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; CCTs = default; IsX = false; disposed = true; } }
|
||||
|
||||
public struct CCT
|
||||
{
|
||||
public Flags Flags;
|
||||
public float Hue;
|
||||
public float Saturation;
|
||||
public float Lightness;
|
||||
public float Exposure;
|
||||
public Vec3 Gamma;
|
||||
public Vec3 Gamma;
|
||||
public float Contrast;
|
||||
|
||||
public override string ToString() => Hue .ToS(6) + "," +
|
||||
Saturation.ToS(6) + "," +
|
||||
Lightness .ToS(6) + "," +
|
||||
Exposure .ToS(6) + "," +
|
||||
Gamma .ToString(6) + "," +
|
||||
Contrast .ToS(6);
|
||||
public override string ToString() =>
|
||||
((Flags & Flags.Hue) != 0
|
||||
? $"{Hue.ToS(6)}," : ",") +
|
||||
((Flags & Flags.Saturation) != 0
|
||||
? $"{Saturation.ToS(6)}," : ",") +
|
||||
((Flags & Flags.Lightness) != 0
|
||||
? $"{Lightness.ToS(6)}," : ",") +
|
||||
((Flags & Flags.Exposure) != 0
|
||||
? $"{Exposure.ToS(6)}," : ",") +
|
||||
((Flags & Flags.Gamma) != 0
|
||||
? $"{Gamma.X.ToS(6)},{Gamma.Y.ToS(6)},{Gamma.Z.ToS(6)}," : ",,,") +
|
||||
((Flags & Flags.Contrast) != 0
|
||||
? $"{Contrast.ToS(6)}" : "");
|
||||
}
|
||||
|
||||
public enum Flags : int
|
||||
{
|
||||
Hue = 0b000001,
|
||||
Saturation = 0b000010,
|
||||
Lightness = 0b000100,
|
||||
Exposure = 0b001000,
|
||||
Gamma = 0b010000,
|
||||
Contrast = 0b100000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+302
-32
@@ -8,45 +8,297 @@ namespace KKdMainLib.F2
|
||||
{
|
||||
private int i;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public bool IsX;
|
||||
public CountPointer<DFT> DFTs;
|
||||
|
||||
public void DFTReader(string file)
|
||||
{
|
||||
IsX = false;
|
||||
DFTs = default;
|
||||
s = File.OpenReader(file + ".dft", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x54464F44 || header.InnerSignature != 0x3) return;
|
||||
s.P -= 0x4;
|
||||
byte[] dftData = File.ReadAllBytes(file + ".dft");
|
||||
Struct _DOFT = dftData.RSt(); dftData = null;
|
||||
if (_DOFT.Header.Signature != 0x54464F44) return;
|
||||
|
||||
s = File.OpenReader(_DOFT.Data);
|
||||
s.IsBE = _DOFT.Header.UseBigEndian;
|
||||
|
||||
DFTs = s.RCPE<DFT>();
|
||||
if (DFTs.C < 1) { s.C(); DFTs.C = -1; return; }
|
||||
|
||||
if (DFTs.C > 0 && DFTs.O == 0) { s.C(); DFTs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
_IO.Position = DFTs.Offset;
|
||||
DFTs = _IO.ReadCountPointerX<DFT>();
|
||||
}*/
|
||||
|
||||
s.P = DFTs.O;
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
if (!(DFTs.C > 0 && DFTs.O == 0))
|
||||
{
|
||||
ref DFT DFT = ref DFTs.E[i];
|
||||
s.RI32E();
|
||||
DFT. Focus = s.RF32E();
|
||||
DFT. FocusRange = s.RF32E();
|
||||
DFT.FuzzingRange = s.RF32E();
|
||||
DFT.Ratio = s.RF32E();
|
||||
DFT.Quality = s.RF32E();
|
||||
if (s.IsX) s.RI32();
|
||||
s.PI64 = DFTs.O - _DOFT.Header.Length;
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
dft.Flags = (Flags)s.RI32E();
|
||||
dft.Focus = s.RF32E();
|
||||
dft.FocusRange = s.RF32E();
|
||||
dft.FuzzingRange = s.RF32E();
|
||||
dft.Ratio = s.RF32E();
|
||||
dft.Quality = s.RF32E();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsX = true;
|
||||
s.IsX = true;
|
||||
DFTs.O = (int)s.RI64E();
|
||||
s.PI64 = DFTs.O;
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
dft.Flags = (Flags)s.RI32E();
|
||||
dft.Focus = s.RF32E();
|
||||
dft.FocusRange = s.RF32E();
|
||||
dft.FuzzingRange = s.RF32E();
|
||||
dft.Ratio = s.RF32E();
|
||||
dft.Quality = s.RF32E();
|
||||
dft.Unk = s.RI32 ();
|
||||
}
|
||||
}
|
||||
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void DFTWriter(string file)
|
||||
{
|
||||
if (DFTs.E == null || DFTs.C < 1) return;
|
||||
|
||||
if (file.EndsWith("_dof"))
|
||||
file = file.Substring(0, file.Length - 4);
|
||||
|
||||
s = File.OpenWriter();
|
||||
s.IsBE = false;
|
||||
s.Format = Format.F2;
|
||||
|
||||
ENRS e = default;
|
||||
POF p = default;
|
||||
p.Offsets = KKdList<long>.New;
|
||||
if (!IsX)
|
||||
{
|
||||
s.W(DFTs.C);
|
||||
s.W(0x50);
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
s.W((int)dft.Flags);
|
||||
s.W(dft.Focus );
|
||||
s.W(dft.FocusRange );
|
||||
s.W(dft.FuzzingRange);
|
||||
s.W(dft.Ratio );
|
||||
s.W(dft.Quality );
|
||||
}
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[2];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x18, DFTs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x06, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x44);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.W(DFTs.C);
|
||||
s.A(0x08);
|
||||
s.W(0x10L);
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
s.W((int)dft.Flags);
|
||||
s.W(dft.Focus );
|
||||
s.W(dft.FocusRange );
|
||||
s.W(dft.FuzzingRange);
|
||||
s.W(dft.Ratio );
|
||||
s.W(dft.Quality );
|
||||
s.W(dft.Unk );
|
||||
}
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[2];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x02, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x01, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[0].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x04, 0x01, ENRS.ENRSEntry.Type.QWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x1C, DFTs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x06, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x08);
|
||||
}
|
||||
|
||||
s.A(0x10, true);
|
||||
byte[] data = s.ToArray(true);
|
||||
|
||||
Struct _DOFT = default;
|
||||
_DOFT.Header.Signature = 0x54464F44;
|
||||
_DOFT.Header.DataSize = (uint)data.Length;
|
||||
_DOFT.Header.Length = 0x40;
|
||||
_DOFT.Header.Depth = 0;
|
||||
_DOFT.Header.SectionSize = (uint)data.Length;
|
||||
_DOFT.Header.Version = 0;
|
||||
_DOFT.Header.InnerSignature = 0x03;
|
||||
|
||||
_DOFT.Header.UseBigEndian = false;
|
||||
_DOFT.Header.UseSectionSize = true;
|
||||
_DOFT.Header.Format = Format.F2;
|
||||
_DOFT.Data = data;
|
||||
_DOFT.ENRS = e;
|
||||
_DOFT.POF = p;
|
||||
File.WriteAllBytes(file + ".dft", _DOFT.W(IsX, true));
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
IsX = false;
|
||||
DFTs = default;
|
||||
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
MsgPack dof;
|
||||
if ((dof = msgPack["DOF", true]).NotNull)
|
||||
{
|
||||
DFTs.E = new DFT[dof.Array.Length];
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
dft = default;
|
||||
MsgPack d = dof[i];
|
||||
MsgPack temp;
|
||||
if ((temp = d["Focus"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Focus;
|
||||
dft.Focus = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["FocusRange"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.FocusRange;
|
||||
dft.FocusRange = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["FuzzingRange"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.FuzzingRange;
|
||||
dft.FuzzingRange = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["Ratio"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Ratio;
|
||||
dft.Ratio = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["Quality"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Quality;
|
||||
dft.Quality = temp.RF32();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((dof = msgPack["DOFX", true]).NotNull)
|
||||
{
|
||||
IsX = true;
|
||||
DFTs.E = new DFT[dof.Array.Length];
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
dft = default;
|
||||
MsgPack d = dof[i];
|
||||
MsgPack temp;
|
||||
if ((temp = d["Focus"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Focus;
|
||||
dft.Focus = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["FocusRange"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.FocusRange;
|
||||
dft.FocusRange = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["FuzzingRange"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.FuzzingRange;
|
||||
dft.FuzzingRange = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["Ratio"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Ratio;
|
||||
dft.Ratio = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["Quality"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Quality;
|
||||
dft.Quality = temp.RF32();
|
||||
}
|
||||
|
||||
if ((temp = d["Unk"]).Object != null)
|
||||
{
|
||||
dft.Flags |= Flags.Unk;
|
||||
dft.Unk = temp.RI32();
|
||||
}
|
||||
}
|
||||
}
|
||||
dof.Dispose();
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (DFTs.E == null || DFTs.C < 1) return;
|
||||
|
||||
MsgPack dof;
|
||||
if (!IsX)
|
||||
{
|
||||
dof = new MsgPack(DFTs.C, "DOF");
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
MsgPack d = MsgPack.New;
|
||||
if ((dft.Flags & Flags.Focus) != 0)
|
||||
d.Add("Focus", dft.Focus);
|
||||
if ((dft.Flags & Flags.FocusRange) != 0)
|
||||
d.Add("FocusRange", dft.FocusRange);
|
||||
if ((dft.Flags & Flags.FuzzingRange) != 0)
|
||||
d.Add("FuzzingRange", dft.FuzzingRange);
|
||||
if ((dft.Flags & Flags.Ratio) != 0)
|
||||
d.Add("Ratio", dft.Ratio);
|
||||
if ((dft.Flags & Flags.Quality) != 0)
|
||||
d.Add("Quality", dft.Quality);
|
||||
dof[i] = d;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dof = new MsgPack(DFTs.C, "DOFX");
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT dft = ref DFTs.E[i];
|
||||
MsgPack d = MsgPack.New;
|
||||
if ((dft.Flags & Flags.Focus) != 0)
|
||||
d.Add("Focus", dft.Focus);
|
||||
if ((dft.Flags & Flags.FocusRange) != 0)
|
||||
d.Add("FocusRange", dft.FocusRange);
|
||||
if ((dft.Flags & Flags.FuzzingRange) != 0)
|
||||
d.Add("FuzzingRange", dft.FuzzingRange);
|
||||
if ((dft.Flags & Flags.Ratio) != 0)
|
||||
d.Add("Ratio", dft.Ratio);
|
||||
if ((dft.Flags & Flags.Quality) != 0)
|
||||
d.Add("Quality", dft.Quality);
|
||||
if ((dft.Flags & Flags.Unk) != 0)
|
||||
d.Add("Unk", dft.Unk);
|
||||
dof[i] = d;
|
||||
}
|
||||
}
|
||||
dof.Write(false, true, file + "_dof", json);
|
||||
}
|
||||
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (DFTs.C < 1) return;
|
||||
@@ -54,27 +306,45 @@ namespace KKdMainLib.F2
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("ID,Focus,FocusRange,FuzzingRange,Ratio,Quality\n");
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
s.W(i + "," + DFTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_dof.txt", s.ToArray(true));
|
||||
s.W($"{i},{DFTs[i]}\n");
|
||||
File.WriteAllBytes($"{file}_dof.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; DFTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; DFTs = default; IsX = false; disposed = true; } }
|
||||
|
||||
public struct DFT
|
||||
{
|
||||
public Flags Flags;
|
||||
public float Focus;
|
||||
public float FocusRange;
|
||||
public float FuzzingRange;
|
||||
public float Ratio;
|
||||
public float Quality;
|
||||
public int Unk;
|
||||
|
||||
public override string ToString() => Focus .ToS(6) + "," +
|
||||
FocusRange.ToS(6) + "," +
|
||||
FuzzingRange.ToS(6) + "," +
|
||||
Ratio .ToS(6) + "," +
|
||||
Quality .ToS(6);
|
||||
public override string ToString() =>
|
||||
((Flags & Flags.Focus) != 0
|
||||
? $"{Focus.ToS(6)}," : ",") +
|
||||
((Flags & Flags.FocusRange) != 0
|
||||
? $"{FocusRange.ToS(6)}," : ",") +
|
||||
((Flags & Flags.FuzzingRange) != 0
|
||||
? $"{FuzzingRange.ToS(6)}," : ",") +
|
||||
((Flags & Flags.Ratio) != 0
|
||||
? $"{Ratio.ToS(6)}," : ",") +
|
||||
((Flags & Flags.Quality) != 0
|
||||
? $"{Quality.ToS(6)}" : "");
|
||||
}
|
||||
|
||||
public enum Flags : int
|
||||
{
|
||||
Focus = 0b000001,
|
||||
FocusRange = 0b000010,
|
||||
FuzzingRange = 0b000100,
|
||||
Ratio = 0b001000,
|
||||
Quality = 0b010000,
|
||||
Unk = 0b100000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+848
-85
@@ -8,70 +8,785 @@ namespace KKdMainLib.F2
|
||||
{
|
||||
private int i, i0;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public CountPointer<CountPointer<LIT>> LITs;
|
||||
public bool IsX;
|
||||
public CountPointer<LightStruct> LITs;
|
||||
|
||||
public void LITReader(string file)
|
||||
{
|
||||
IsX = false;
|
||||
LITs = default;
|
||||
s = File.OpenReader(file + ".lit", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x4354494C || header.InnerSignature != 0x2 ||
|
||||
header.SectionSignature != 0x2) return;
|
||||
byte[] litData = File.ReadAllBytes(file + ".lit");
|
||||
Struct _LITC = litData.RSt(); litData = null;
|
||||
if (_LITC.Header.Signature != 0x4354494C) return;
|
||||
|
||||
LITs = s.RCPE<CountPointer<LIT>>();
|
||||
s = File.OpenReader(_LITC.Data);
|
||||
s.IsBE = _LITC.Header.UseBigEndian;
|
||||
|
||||
s.RI32();
|
||||
LITs = s.RCPE<LightStruct>();
|
||||
if (LITs.C < 1) { s.C(); LITs.C = -1; return; }
|
||||
|
||||
s.P = LITs.O;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
s.PI64 = LITs.O - _LITC.Header.Length;
|
||||
if (s.RI32() != 0)
|
||||
{
|
||||
LITs[i] = s.RCPX<LIT>();
|
||||
if ((LITs[i].C > 0 || LITs[i].O == 0) && !s.IsX) { s.C(); LITs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
_IO.Position = LITs.Offset;
|
||||
LITs[i] = _IO.ReadCountPointerX<LIT>();
|
||||
}
|
||||
if (_IO.IsX) IO.ReadInt64();*/
|
||||
}
|
||||
s.PI64 = LITs.O - _LITC.Header.Length;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
LITs.E[i] = new LightStruct
|
||||
{ C0 = s.RI32E(), O0 = s.RI32E() };
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
s.P = LITs[i].O;
|
||||
for (i0 = 0; i0 < LITs[i].C; i0++)
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E[i0];
|
||||
lit.Id = (Id )s.RI32E();
|
||||
lit.Flags = (Flags)s.RI32E();
|
||||
lit.Type = (Type )s.RI32E();
|
||||
if (s.IsX) { s.RI64(); s.RI64(); s.RI64(); }
|
||||
lit.Ambient .X = s.RF32E();
|
||||
lit.Ambient .Y = s.RF32E();
|
||||
lit.Ambient .Z = s.RF32E();
|
||||
lit.Ambient .W = s.RF32E();
|
||||
lit.Diffuse .X = s.RF32E();
|
||||
lit.Diffuse .Y = s.RF32E();
|
||||
lit.Diffuse .Z = s.RF32E();
|
||||
lit.Diffuse .W = s.RF32E();
|
||||
lit.Specular .X = s.RF32E();
|
||||
lit.Specular .Y = s.RF32E();
|
||||
lit.Specular .Z = s.RF32E();
|
||||
lit.Specular .W = s.RF32E();
|
||||
lit.Position .X = s.RF32E();
|
||||
lit.Position .Y = s.RF32E();
|
||||
lit.Position .Z = s.RF32E();
|
||||
lit.ToneCurve.X = s.RF32E();
|
||||
lit.ToneCurve.Y = s.RF32E();
|
||||
lit.ToneCurve.Z = s.RF32E();
|
||||
if (s.IsX) { s.RI64(); s.RI64(); s.RI64();
|
||||
s.RI64(); s.RI64(); s.RI32(); }
|
||||
s.PI64 = LITs.E[i].O0 - _LITC.Header.Length;
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
lit.Id = s.RI32E();
|
||||
lit.Flags = (Flags)s.RI32E();
|
||||
lit.Type = (Type )s.RI32E();
|
||||
lit.Ambient .X = s.RF32E();
|
||||
lit.Ambient .Y = s.RF32E();
|
||||
lit.Ambient .Z = s.RF32E();
|
||||
lit.Ambient .W = s.RF32E();
|
||||
lit.Diffuse .X = s.RF32E();
|
||||
lit.Diffuse .Y = s.RF32E();
|
||||
lit.Diffuse .Z = s.RF32E();
|
||||
lit.Diffuse .W = s.RF32E();
|
||||
lit.Specular .X = s.RF32E();
|
||||
lit.Specular .Y = s.RF32E();
|
||||
lit.Specular .Z = s.RF32E();
|
||||
lit.Specular .W = s.RF32E();
|
||||
lit.Position .X = s.RF32E();
|
||||
lit.Position .Y = s.RF32E();
|
||||
lit.Position .Z = s.RF32E();
|
||||
lit.ToneCurve.X = s.RF32E();
|
||||
lit.ToneCurve.Y = s.RF32E();
|
||||
lit.ToneCurve.Z = s.RF32E();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsX = true;
|
||||
s.PI64 = LITs.O;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
LITs.E[i] = new LightStruct
|
||||
{ C0 = s.RI32E(), C1 = s.RI32E(), O0 = (int)s.RI64E(), O1 = (int)s.RI64E() };
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
s.P = LITs.E[i].O0;
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
lit.Id = s.RI32E();
|
||||
lit.Flags = (Flags)s.RI32E();
|
||||
lit.Type = (Type )s.RI32E();
|
||||
s.RI32();
|
||||
long off = s.RI64();
|
||||
lit.HasStr = s.RI64() != 0;
|
||||
lit.Unk10 = s.RI32();
|
||||
lit.Ambient .X = s.RF32E();
|
||||
lit.Ambient .Y = s.RF32E();
|
||||
lit.Ambient .Z = s.RF32E();
|
||||
lit.Ambient .W = s.RF32E();
|
||||
lit.Diffuse .X = s.RF32E();
|
||||
lit.Diffuse .Y = s.RF32E();
|
||||
lit.Diffuse .Z = s.RF32E();
|
||||
lit.Diffuse .W = s.RF32E();
|
||||
lit.Specular .X = s.RF32E();
|
||||
lit.Specular .Y = s.RF32E();
|
||||
lit.Specular .Z = s.RF32E();
|
||||
lit.Specular .W = s.RF32E();
|
||||
lit.Position .X = s.RF32E();
|
||||
lit.Position .Y = s.RF32E();
|
||||
lit.Position .Z = s.RF32E();
|
||||
lit.Unk01 = s.RF32();
|
||||
lit.Unk02 = s.RF32();
|
||||
lit.Unk03 = s.RF32();
|
||||
lit.Unk04 = s.RF32();
|
||||
lit.Unk05.X = s.RF32();
|
||||
lit.Unk05.Y = s.RF32();
|
||||
lit.Unk05.Z = s.RF32();
|
||||
lit.ToneCurve.X = s.RF32E();
|
||||
lit.ToneCurve.Y = s.RF32E();
|
||||
lit.ToneCurve.Z = s.RF32E();
|
||||
lit.Unk = s.RF32();
|
||||
lit.Unk06 = s.RF32();
|
||||
lit.Unk07 = s.RF32();
|
||||
lit.Unk08 = s.RF32();
|
||||
|
||||
lit.Str = off > 0 ? s.RaO(off).ToSJIS() : "";
|
||||
}
|
||||
|
||||
s.P = LITs.E[i].O1;
|
||||
for (i0 = 0; i0 < LITs.E[i].C1; i0++)
|
||||
{
|
||||
ref LITX lit = ref LITs.E[i].E1[i0];
|
||||
lit.C = s.RI32E();
|
||||
s.RI32E();
|
||||
lit.O = (int)s.RI64E();
|
||||
}
|
||||
|
||||
for (i0 = 0; i0 < LITs.E[i].C1; i0++)
|
||||
{
|
||||
ref LITX lit = ref LITs.E[i].E1[i0];
|
||||
ref KeyValuePair<int, int>[] data = ref lit.E;
|
||||
data = new KeyValuePair<int, int>[lit.C];
|
||||
|
||||
s.P = lit.O;
|
||||
for (int i1 = 0; i1 < lit.C; i1++)
|
||||
data[i1] = new KeyValuePair<int, int>(s.RI32E(), s.RI32E());
|
||||
}
|
||||
}
|
||||
}
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void LITWriter(string file)
|
||||
{
|
||||
if (LITs.E == null || LITs.C < 1) return;
|
||||
|
||||
if (file.EndsWith("_light"))
|
||||
file = file.Substring(0, file.Length - 6);
|
||||
|
||||
s = File.OpenWriter();
|
||||
s.IsBE = false;
|
||||
s.Format = Format.F2;
|
||||
|
||||
ENRS e = default;
|
||||
POF p = default;
|
||||
p.Offsets = KKdList<long>.New;
|
||||
if (!IsX)
|
||||
{
|
||||
s.W(0x02);
|
||||
s.W(LITs.C);
|
||||
s.W(0x50);
|
||||
s.A(0x10);
|
||||
|
||||
int offset0 = 0x50 + (LITs.C * 0x08).A(0x10);
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
s.W(LITs.E[i].C0 > 0 ? LITs.E[i].C0 : 0);
|
||||
s.W(LITs.E[i].C0 > 0 ? offset0 : 0);
|
||||
offset0 += (0x54 * (LITs.E[i].C0 > 0 ? LITs.E[i].C0 : 0)).A(0x10);
|
||||
}
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
s.W( lit.Id );
|
||||
s.W((int)lit.Flags);
|
||||
s.W((int)lit.Type );
|
||||
s.W(lit.Ambient .X);
|
||||
s.W(lit.Ambient .Y);
|
||||
s.W(lit.Ambient .Z);
|
||||
s.W(lit.Ambient .W);
|
||||
s.W(lit.Diffuse .X);
|
||||
s.W(lit.Diffuse .Y);
|
||||
s.W(lit.Diffuse .Z);
|
||||
s.W(lit.Diffuse .W);
|
||||
s.W(lit.Specular .X);
|
||||
s.W(lit.Specular .Y);
|
||||
s.W(lit.Specular .Z);
|
||||
s.W(lit.Specular .W);
|
||||
s.W(lit.Position .X);
|
||||
s.W(lit.Position .Y);
|
||||
s.W(lit.Position .Z);
|
||||
s.W(lit.ToneCurve.X);
|
||||
s.W(lit.ToneCurve.Y);
|
||||
s.W(lit.ToneCurve.Z);
|
||||
}
|
||||
s.A(0x10);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
if (LITs.E[i].C0 > 0)
|
||||
count += LITs.E[i].C0;
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[3];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x01, 0x10, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x03, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x10, 0x01, 0x08, LITs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[2] = new ENRS.ENRSEntry((LITs.C * 0x08).A(0x10), 0x01, 0x54, count);
|
||||
e.Array[2].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x15, ENRS.ENRSEntry.Type.DWORD);
|
||||
|
||||
p.Offsets.Add(0x48);
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
p.Offsets.Add(0x54 + 0x08 * i);
|
||||
}
|
||||
else
|
||||
{
|
||||
long offset0 = 0x50 + (LITs.C * 0x18).A(0x10);
|
||||
long offset1 = offset0;
|
||||
long offset2 = offset0 + 0x10;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
offset1 += LITs.E[i].C0 * 0x98;
|
||||
offset1 = offset1.A(0x10);
|
||||
|
||||
long offset3 = offset1;
|
||||
long offset4 = offset1 + 0x08;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
offset3 += LITs.E[i].C1 * 0x10;
|
||||
offset3 = offset3.A(0x10);
|
||||
long offset5 = offset3;
|
||||
long offset6 = offset3;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C1; i0++)
|
||||
offset6 += LITs.E[i].E1[i0].C * 0x08;
|
||||
|
||||
byte[][][] strdata = new byte[LITs.C][][];
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
strdata[i] = new byte[LITs.E[i].C0][];
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
strdata[i][i0] = lit.HasStr && lit.Str != null && lit.Str != "" ? lit.Str.ToSJIS() : null;
|
||||
}
|
||||
}
|
||||
|
||||
s.W(0x02);
|
||||
s.W(LITs.C);
|
||||
s.W(0x50L);
|
||||
s.A(0x10);
|
||||
s.P = 0x50;
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
s.W(LITs.E[i].C0 > 0 ? LITs.E[i].C0 : 0);
|
||||
s.W(LITs.E[i].C1 > 0 ? LITs.E[i].C1 : 0);
|
||||
s.W(LITs.E[i].C0 > 0 ? offset0 : 0);
|
||||
s.W(LITs.E[i].C1 > 0 ? offset1 : 0);
|
||||
offset0 += 0x98 * (LITs.E[i].C0 > 0 ? LITs.E[i].C0 : 0);
|
||||
offset1 += 0x10 * (LITs.E[i].C1 > 0 ? LITs.E[i].C1 : 0);
|
||||
}
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
s.W( lit.Id );
|
||||
s.W((int)lit.Flags);
|
||||
s.W((int)lit.Type );
|
||||
s.W((int)0);
|
||||
if (lit.HasStr && strdata[i][i0] != null && strdata[i][i0].Length > 0)
|
||||
{ s.W(offset6); s.W((long)strdata[i][i0].HashMurmurHash(strdata[i][i0].Length));
|
||||
offset6 += strdata[i][i0].Length + 1; }
|
||||
else
|
||||
{ s.W(0x00L); s.W((long)(lit.HasStr ? 0x0CAD3078 : 0)); }
|
||||
s.W(lit.Unk10 );
|
||||
s.W(lit.Ambient .X);
|
||||
s.W(lit.Ambient .Y);
|
||||
s.W(lit.Ambient .Z);
|
||||
s.W(lit.Ambient .W);
|
||||
s.W(lit.Diffuse .X);
|
||||
s.W(lit.Diffuse .Y);
|
||||
s.W(lit.Diffuse .Z);
|
||||
s.W(lit.Diffuse .W);
|
||||
s.W(lit.Specular .X);
|
||||
s.W(lit.Specular .Y);
|
||||
s.W(lit.Specular .Z);
|
||||
s.W(lit.Specular .W);
|
||||
s.W(lit.Position .X);
|
||||
s.W(lit.Position .Y);
|
||||
s.W(lit.Position .Z);
|
||||
s.W(lit.Unk01 );
|
||||
s.W(lit.Unk02 );
|
||||
s.W(lit.Unk03 );
|
||||
s.W(lit.Unk04 );
|
||||
s.W(lit.Unk05.X );
|
||||
s.W(lit.Unk05.Y );
|
||||
s.W(lit.Unk05.Z );
|
||||
s.W(lit.ToneCurve.X);
|
||||
s.W(lit.ToneCurve.Y);
|
||||
s.W(lit.ToneCurve.Z);
|
||||
s.W(lit.Unk );
|
||||
s.W(lit.Unk06 );
|
||||
s.W(lit.Unk07 );
|
||||
s.W(lit.Unk08 );
|
||||
}
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C1; i0++)
|
||||
{
|
||||
ref LITX lit = ref LITs.E[i].E1[i0];
|
||||
s.W(lit.C);
|
||||
s.W((int)0);
|
||||
s.W(offset5);
|
||||
offset5 += lit.C * 0x08;
|
||||
}
|
||||
s.A(0x10);
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C1; i0++)
|
||||
{
|
||||
ref LITX lit = ref LITs.E[i].E1[i0];
|
||||
for (int i1 = 0; i1 < lit.C; i1++)
|
||||
{
|
||||
s.W(lit.E[i1].Key);
|
||||
s.W(lit.E[i1].Value);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
if (lit.HasStr && strdata[i][i0] != null && strdata[i][i0].Length > 0)
|
||||
{
|
||||
s.W(strdata[i][i0]);
|
||||
s.W((byte)0);
|
||||
}
|
||||
}
|
||||
s.A(0x10);
|
||||
|
||||
bool sub = false;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
if (LITs.E[i].C1 > 0) { sub = true; break; }
|
||||
|
||||
int count = 0;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
if (LITs.E[i].C0 > 0)
|
||||
count += LITs.E[i].C0;
|
||||
|
||||
e.Array = new ENRS.ENRSEntry[sub ? 5 : 3];
|
||||
e.Array[0] = new ENRS.ENRSEntry(0x00, 0x02, 0x50, 0x01);
|
||||
e.Array[0].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[0].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x01, ENRS.ENRSEntry.Type.QWORD);
|
||||
e.Array[1] = new ENRS.ENRSEntry(0x50, 0x02, 0x18, LITs.C);
|
||||
e.Array[1].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[1].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.QWORD);
|
||||
e.Array[2] = new ENRS.ENRSEntry((LITs.C * 0x18).A(0x10), 0x03, 0x98, count);
|
||||
e.Array[2].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x03, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[2].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x18, 0x0F, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[2].Sub[2] = new ENRS.ENRSEntry.SubENRSEntry(0x20, 0x03, ENRS.ENRSEntry.Type.DWORD);
|
||||
if (sub)
|
||||
{
|
||||
int sub_count = 0;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
if (LITs.E[i].C1 > 0)
|
||||
sub_count += LITs.E[i].C1;
|
||||
|
||||
e.Array[3] = new ENRS.ENRSEntry((count * 0x98).A(0x10), 0x02, 0x10, sub_count);
|
||||
e.Array[3].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x01, ENRS.ENRSEntry.Type.DWORD);
|
||||
e.Array[3].Sub[1] = new ENRS.ENRSEntry.SubENRSEntry(0x04, 0x01, ENRS.ENRSEntry.Type.QWORD);
|
||||
e.Array[4] = new ENRS.ENRSEntry(sub_count * 0x10, 0x01, 0x08, LITs.E[0].E1[0].C);
|
||||
e.Array[4].Sub[0] = new ENRS.ENRSEntry.SubENRSEntry(0x00, 0x02, ENRS.ENRSEntry.Type.DWORD);
|
||||
}
|
||||
|
||||
p.Offsets.Add(0x08);
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
if (LITs.E[i].C0 > 0)
|
||||
p.Offsets.Add(0x58 + 0x18 * i);
|
||||
if (LITs.E[i].C1 > 0)
|
||||
p.Offsets.Add(0x60 + 0x18 * i);
|
||||
}
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E0[i0];
|
||||
if (lit.HasStr && strdata[i][i0] != null && strdata[i][i0].Length > 0)
|
||||
p.Offsets.Add(offset2);
|
||||
offset2 += 0x98;
|
||||
}
|
||||
|
||||
if (sub)
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
for (i0 = 0; i0 < LITs.E[i].C1; i0++)
|
||||
{
|
||||
p.Offsets.Add(offset4);
|
||||
offset4 += 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
s.A(0x10, true);
|
||||
byte[] data = s.ToArray(true);
|
||||
|
||||
Struct _LITC = default;
|
||||
_LITC.Header.Signature = 0x4354494C;
|
||||
_LITC.Header.DataSize = (uint)data.Length;
|
||||
_LITC.Header.Length = 0x40;
|
||||
_LITC.Header.Depth = 0;
|
||||
_LITC.Header.SectionSize = (uint)data.Length;
|
||||
_LITC.Header.Version = 0;
|
||||
_LITC.Header.InnerSignature = 0x02;
|
||||
|
||||
_LITC.Header.UseBigEndian = false;
|
||||
_LITC.Header.UseSectionSize = true;
|
||||
_LITC.Header.Format = Format.F2;
|
||||
_LITC.Data = data;
|
||||
_LITC.ENRS = e;
|
||||
_LITC.POF = p;
|
||||
File.WriteAllBytes(file + ".lit", _LITC.W(IsX, true));
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
IsX = false;
|
||||
LITs = default;
|
||||
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
MsgPack light;
|
||||
if ((light = msgPack["Light", true]).NotNull)
|
||||
{
|
||||
LITs.E = new LightStruct[light.Array.Length];
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
ref LightStruct lit = ref LITs.E[i];
|
||||
lit = default;
|
||||
MsgPack l = light[i];
|
||||
MsgPack l0;
|
||||
if ((l0 = l["MainData", true]).IsNull)
|
||||
continue;
|
||||
|
||||
lit.C0 = l0.Array.Length;
|
||||
for (i0 = 0; i0 < lit.C0; i0++)
|
||||
{
|
||||
ref LIT lit0 = ref lit.E0[i0];
|
||||
MsgPack l1 = l0[i0];
|
||||
MsgPack temp;
|
||||
if ((temp = l1["Id"]).Object != null)
|
||||
lit0.Id = temp.RI32();
|
||||
|
||||
if ((temp = l1["Type"]).Object != null)
|
||||
{
|
||||
lit0.Flags |= Flags.Type;
|
||||
lit0.Type = (Type)temp.RI32();
|
||||
}
|
||||
|
||||
if ((temp = l1["Str"]).Object != null)
|
||||
{
|
||||
lit0.HasStr = true;
|
||||
lit0.Str = temp.RS();
|
||||
}
|
||||
|
||||
if ((temp = l1["Ambient"]).Object != null)
|
||||
{
|
||||
lit0.Flags |= Flags.Ambient;
|
||||
lit0.Ambient.X = temp.RF32("R");
|
||||
lit0.Ambient.Y = temp.RF32("G");
|
||||
lit0.Ambient.Z = temp.RF32("B");
|
||||
lit0.Ambient.W = temp.RF32("A");
|
||||
}
|
||||
|
||||
if ((temp = l1["Diffuse"]).Object != null)
|
||||
{
|
||||
lit0.Flags |= Flags.Diffuse;
|
||||
lit0.Diffuse.X = temp.RF32("R");
|
||||
lit0.Diffuse.Y = temp.RF32("G");
|
||||
lit0.Diffuse.Z = temp.RF32("B");
|
||||
lit0.Diffuse.W = temp.RF32("A");
|
||||
}
|
||||
|
||||
if ((temp = l1["Specular"]).Object != null)
|
||||
{
|
||||
lit0.Flags |= Flags.Specular;
|
||||
lit0.Specular.X = temp.RF32("R");
|
||||
lit0.Specular.Y = temp.RF32("G");
|
||||
lit0.Specular.Z = temp.RF32("B");
|
||||
lit0.Specular.W = temp.RF32("A");
|
||||
}
|
||||
|
||||
if ((temp = l1["Position"]).Object != null)
|
||||
{
|
||||
lit0.Flags |= Flags.Position;
|
||||
lit0.Position.X = temp.RF32("X");
|
||||
lit0.Position.Y = temp.RF32("Y");
|
||||
lit0.Position.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = l1["ToneCurve"]).Object != null)
|
||||
{
|
||||
lit0.Flags |= Flags.ToneCurve;
|
||||
lit0.ToneCurve.X = temp.RF32("Begin" );
|
||||
lit0.ToneCurve.Y = temp.RF32("End" );
|
||||
lit0.ToneCurve.Z = temp.RF32("BlendRate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((light = msgPack["LightX", true]).NotNull)
|
||||
{
|
||||
IsX = true;
|
||||
LITs.E = new LightStruct[light.Array.Length];
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
ref LightStruct lit = ref LITs.E[i];
|
||||
lit = default;
|
||||
MsgPack l = light[i];
|
||||
MsgPack l0;
|
||||
if ((l0 = l["MainData", true]).IsNull)
|
||||
continue;
|
||||
|
||||
lit.C0 = l0.Array.Length;
|
||||
for (i0 = 0; i0 < lit.C0; i0++)
|
||||
{
|
||||
ref LIT lit0 = ref lit.E0[i0];
|
||||
lit0 = default;
|
||||
MsgPack l1;
|
||||
if ((l1 = l0[i0]).IsNull)
|
||||
continue;
|
||||
|
||||
MsgPack temp;
|
||||
if ((temp = l1["Id"]).Object != null)
|
||||
lit0.Id = temp.RI32();
|
||||
|
||||
if ((temp = l1["Flags"]).Object != null)
|
||||
lit0.Flags = (Flags)temp.RI32();
|
||||
|
||||
if ((temp = l1["Type"]).Object != null)
|
||||
lit0.Type = (Type)temp.RI32();
|
||||
|
||||
if ((temp = l1["Ambient"]).Object != null)
|
||||
{
|
||||
lit0.Ambient.X = temp.RF32("R");
|
||||
lit0.Ambient.Y = temp.RF32("G");
|
||||
lit0.Ambient.Z = temp.RF32("B");
|
||||
lit0.Ambient.W = temp.RF32("A");
|
||||
}
|
||||
|
||||
if ((temp = l1["Diffuse"]).Object != null)
|
||||
{
|
||||
lit0.Diffuse.X = temp.RF32("R");
|
||||
lit0.Diffuse.Y = temp.RF32("G");
|
||||
lit0.Diffuse.Z = temp.RF32("B");
|
||||
lit0.Diffuse.W = temp.RF32("A");
|
||||
}
|
||||
|
||||
if ((temp = l1["Specular"]).Object != null)
|
||||
{
|
||||
lit0.Specular.X = temp.RF32("R");
|
||||
lit0.Specular.Y = temp.RF32("G");
|
||||
lit0.Specular.Z = temp.RF32("B");
|
||||
lit0.Specular.W = temp.RF32("A");
|
||||
}
|
||||
|
||||
if ((temp = l1["Position"]).Object != null)
|
||||
{
|
||||
lit0.Position.X = temp.RF32("X");
|
||||
lit0.Position.Y = temp.RF32("Y");
|
||||
lit0.Position.Z = temp.RF32("Z");
|
||||
}
|
||||
|
||||
if ((temp = l1["ToneCurve"]).Object != null)
|
||||
lit0.ToneCurve.X = temp.RF32("Begin" );
|
||||
lit0.ToneCurve.Y = temp.RF32("End" );
|
||||
lit0.ToneCurve.Z = temp.RF32("BlendRate");
|
||||
|
||||
if ((temp = l1["Str"]).Object != null)
|
||||
{
|
||||
lit0.HasStr = true;
|
||||
lit0.Str = temp.RS();
|
||||
}
|
||||
|
||||
if ((temp = l1["Unk01"]).Object != null)
|
||||
lit0.Unk01 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk02"]).Object != null)
|
||||
lit0.Unk02 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk03"]).Object != null)
|
||||
lit0.Unk03 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk04"]).Object != null)
|
||||
lit0.Unk04 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk05"]).Object != null)
|
||||
lit0.Unk05.X = temp.RF32("X");
|
||||
lit0.Unk05.Y = temp.RF32("Y");
|
||||
lit0.Unk05.Z = temp.RF32("Z");
|
||||
|
||||
if ((temp = l1["Unk06"]).Object != null)
|
||||
lit0.Unk06 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk07"]).Object != null)
|
||||
lit0.Unk07 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk08"]).Object != null)
|
||||
lit0.Unk08 = temp.RF32();
|
||||
|
||||
if ((temp = l1["Unk10"]).Object != null)
|
||||
lit0.Unk10 = temp.RI32();
|
||||
|
||||
if ((temp = l1["Unk"]).Object != null)
|
||||
lit0.Unk = temp.RF32();
|
||||
}
|
||||
|
||||
if ((l0 = l["SubData", true]).IsNull)
|
||||
continue;
|
||||
|
||||
lit.C1 = l0.Array.Length;
|
||||
for (i0 = 0; i0 < lit.C1; i0++)
|
||||
{
|
||||
ref LITX lit1 = ref lit.E1[i0];
|
||||
lit1 = default;
|
||||
MsgPack l1;
|
||||
if ((l1 = l0[i0]).IsNull && l1.Array != null)
|
||||
continue;
|
||||
|
||||
lit1.C = l1.Array.Length;
|
||||
lit1.E = new KeyValuePair<int, int>[lit1.C];
|
||||
for (int i1 = 0; i1 < lit1.C; i1++)
|
||||
{
|
||||
lit1.E[i1] = default;
|
||||
MsgPack l2 = l1[i1];
|
||||
MsgPack temp;
|
||||
if ((temp = l2["Key"]).Object != null)
|
||||
lit1.E[i1].Key = temp.RI32();
|
||||
|
||||
if ((temp = l2["Value"]).Object != null)
|
||||
lit1.E[i1].Value = temp.RI32();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
light.Dispose();
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (LITs.E == null || LITs.C < 1) return;
|
||||
|
||||
MsgPack light;
|
||||
if (!IsX)
|
||||
{
|
||||
light = new MsgPack(LITs.C, "Light");
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
ref LightStruct lit = ref LITs.E[i];
|
||||
MsgPack l = MsgPack.New;
|
||||
MsgPack l0 = new MsgPack(lit.C0, "MainData");
|
||||
for (i0 = 0; i0 < lit.C0; i0++)
|
||||
{
|
||||
ref LIT lit0 = ref lit.E0[i0];
|
||||
MsgPack l1 = MsgPack.New;
|
||||
l1.Add("Id", lit0.Id);
|
||||
if ((lit0.Flags & Flags.Type) != 0)
|
||||
l1.Add("Type", (int)lit0.Type);
|
||||
if ((lit0.Flags & Flags.Ambient) != 0)
|
||||
l1.Add(new MsgPack("Ambient")
|
||||
.Add("R", lit0.Ambient.X)
|
||||
.Add("G", lit0.Ambient.Y)
|
||||
.Add("B", lit0.Ambient.Z)
|
||||
.Add("A", lit0.Ambient.W));
|
||||
if ((lit0.Flags & Flags.Diffuse) != 0)
|
||||
l1.Add(new MsgPack("Diffuse")
|
||||
.Add("R", lit0.Diffuse.X)
|
||||
.Add("G", lit0.Diffuse.Y)
|
||||
.Add("B", lit0.Diffuse.Z)
|
||||
.Add("A", lit0.Diffuse.W));
|
||||
if ((lit0.Flags & Flags.Specular) != 0)
|
||||
l1.Add(new MsgPack("Specular")
|
||||
.Add("R", lit0.Specular.X)
|
||||
.Add("G", lit0.Specular.Y)
|
||||
.Add("B", lit0.Specular.Z)
|
||||
.Add("A", lit0.Specular.W));
|
||||
if ((lit0.Flags & Flags.Position) != 0)
|
||||
l1.Add(new MsgPack("Position")
|
||||
.Add("X", lit0.Position.X)
|
||||
.Add("Y", lit0.Position.Y)
|
||||
.Add("Z", lit0.Position.Z));
|
||||
if ((lit0.Flags & Flags.ToneCurve) != 0)
|
||||
l1.Add(new MsgPack("ToneCurve")
|
||||
.Add("Begin" , lit0.ToneCurve.X)
|
||||
.Add("End" , lit0.ToneCurve.Y)
|
||||
.Add("BlendRate", lit0.ToneCurve.Z));
|
||||
l0[i0] = l1;
|
||||
}
|
||||
l.Add(l0);
|
||||
light[i] = l;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
light = new MsgPack(LITs.C, "LightX");
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
ref LightStruct lit = ref LITs.E[i];
|
||||
MsgPack l = MsgPack.New;
|
||||
MsgPack l0 = new MsgPack(lit.C0, "MainData");
|
||||
for (i0 = 0; i0 < lit.C0; i0++)
|
||||
{
|
||||
ref LIT lit0 = ref lit.E0[i0];
|
||||
MsgPack l1 = MsgPack.New;
|
||||
l1.Add("Id", lit0.Id);
|
||||
l1.Add("Flags", (int)lit0.Flags);
|
||||
l1.Add("Type", (int)lit0.Type);
|
||||
l1.Add(new MsgPack("Ambient")
|
||||
.Add("R", lit0.Ambient.X)
|
||||
.Add("G", lit0.Ambient.Y)
|
||||
.Add("B", lit0.Ambient.Z)
|
||||
.Add("A", lit0.Ambient.W));
|
||||
l1.Add(new MsgPack("Diffuse")
|
||||
.Add("R", lit0.Diffuse.X)
|
||||
.Add("G", lit0.Diffuse.Y)
|
||||
.Add("B", lit0.Diffuse.Z)
|
||||
.Add("A", lit0.Diffuse.W));
|
||||
l1.Add(new MsgPack("Specular")
|
||||
.Add("R", lit0.Specular.X)
|
||||
.Add("G", lit0.Specular.Y)
|
||||
.Add("B", lit0.Specular.Z)
|
||||
.Add("A", lit0.Specular.W));
|
||||
l1.Add(new MsgPack("Position")
|
||||
.Add("X", lit0.Position.X)
|
||||
.Add("Y", lit0.Position.Y)
|
||||
.Add("Z", lit0.Position.Z));
|
||||
l1.Add(new MsgPack("ToneCurve")
|
||||
.Add("Begin" , lit0.ToneCurve.X)
|
||||
.Add("End" , lit0.ToneCurve.Y)
|
||||
.Add("BlendRate", lit0.ToneCurve.Z));
|
||||
|
||||
if (lit0.HasStr)
|
||||
l1.Add("Str", lit0.Str ?? "");
|
||||
l1.Add("Unk01", lit0.Unk01);
|
||||
l1.Add("Unk02", lit0.Unk02);
|
||||
l1.Add("Unk03", lit0.Unk03);
|
||||
l1.Add("Unk04", lit0.Unk04);
|
||||
l1.Add(new MsgPack("Unk05")
|
||||
.Add("X", lit0.Unk05.X)
|
||||
.Add("Y", lit0.Unk05.Y)
|
||||
.Add("Z", lit0.Unk05.Z));
|
||||
l1.Add("Unk06", lit0.Unk06);
|
||||
l1.Add("Unk07", lit0.Unk07);
|
||||
l1.Add("Unk08", lit0.Unk08);
|
||||
l1.Add("Unk10", lit0.Unk10);
|
||||
l1.Add("Unk", lit0.Unk);
|
||||
l0[i0] = l1;
|
||||
}
|
||||
l.Add(l0);
|
||||
|
||||
if (lit.C1 > 0)
|
||||
{
|
||||
l0 = new MsgPack(lit.C1, "SubData");
|
||||
for (i0 = 0; i0 < lit.C1; i0++)
|
||||
{
|
||||
ref LITX lit1 = ref lit.E1[i0];
|
||||
MsgPack l1 = new MsgPack(lit1.C);
|
||||
for (int i1 = 0; i1 < lit1.C; i1++)
|
||||
l1[i1] = MsgPack.New
|
||||
.Add("Key" , lit1.E[i1].Key )
|
||||
.Add("Value", lit1.E[i1].Value);
|
||||
l0[i0] = l1;
|
||||
}
|
||||
l.Add(l0);
|
||||
}
|
||||
light[i] = l;
|
||||
}
|
||||
}
|
||||
light.Write(false, true, file + "_light", json);
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
i = 0;
|
||||
@@ -81,44 +796,85 @@ namespace KKdMainLib.F2
|
||||
s.WPSSJIS("Type,AmbientR,AmbientG,AmbientB,DiffuseR,DiffuseG,DiffuseB,SpecularR,SpecularG," +
|
||||
"SpecularB,SpecularA,PosX,PosY,PosZ,ToneCurveBegin,ToneCurveEnd,ToneCurveBlendRate," +
|
||||
(file.EndsWith("_chara") ? "コメント" : "ID") + "\n");
|
||||
for (i0 = 0; i0 < LITs[i].C; i0++)
|
||||
s.W(LITs[i][i0] + "," + i + "\n");
|
||||
File.WriteAllBytes(file + "_light.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
public struct LIT
|
||||
{
|
||||
public Id Id;
|
||||
public Flags Flags;
|
||||
public Type Type;
|
||||
public Vec4 Ambient;
|
||||
public Vec4 Diffuse;
|
||||
public Vec4 Specular;
|
||||
public Vec3 Position;
|
||||
public Vec3 ToneCurve;
|
||||
|
||||
public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : Type + "," +
|
||||
((Flags & Flags.Ambient ) == 0 ? ",,," : Ambient .ToString(6) + ",") +
|
||||
((Flags & Flags.Diffuse ) == 0 ? ",,," : Diffuse .ToString(6) + ",") +
|
||||
((Flags & Flags.Specular ) == 0 ? ",,,," : Specular .ToString(6) + ",") +
|
||||
((Flags & Flags.Position ) == 0 ? ",,," : Position .ToString(6) + ",") +
|
||||
((Flags & Flags.ToneCurve) == 0 ? ",,," : ToneCurve.ToString(6));
|
||||
for (i0 = 0; i0 < LITs.E[i].C0; i0++)
|
||||
s.W($"{LITs.E[i].E0[i0]},{i}\n");
|
||||
File.WriteAllBytes($"{file}_light.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; LITs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; LITs = default; IsX = false; disposed = true; } }
|
||||
|
||||
public struct LightStruct
|
||||
{
|
||||
public int C0 { get => E0 != null ? E0.Length : 0;
|
||||
set => E0 = value > -1 ? new LIT[value] : null; }
|
||||
public int O0;
|
||||
public LIT[] E0;
|
||||
|
||||
public int C1 { get => E1 != null ? E1.Length : 0;
|
||||
set => E1 = value > -1 ? new LITX[value] : default; }
|
||||
public int O1;
|
||||
public LITX[] E1;
|
||||
|
||||
public LIT this[int index]
|
||||
{ get => E0 != null && index > -1 && index < E0.LongLength ? E0[index] : default;
|
||||
set { if (E0 != null && index > -1 && index < E0.LongLength) E0[index] = value; } }
|
||||
|
||||
public LITX this[int index, bool x]
|
||||
{ get => E1 != null && index > -1 && index < E1.LongLength ? E1[index] : default;
|
||||
set { if (E1 != null && index > -1 && index < E1.LongLength) E1[index] = value; } }
|
||||
|
||||
public override string ToString() => C0 < 1 ? "No Entries" :
|
||||
C0 == 1 ? E0[0].ToString() : "Count: " + C0;
|
||||
}
|
||||
|
||||
public struct LIT
|
||||
{
|
||||
public int Id;
|
||||
public Flags Flags;
|
||||
public Type Type;
|
||||
public string Str;
|
||||
public bool HasStr;
|
||||
public Vec4 Ambient;
|
||||
public Vec4 Diffuse;
|
||||
public Vec4 Specular;
|
||||
public Vec3 Position;
|
||||
public float Unk01;
|
||||
public float Unk02;
|
||||
public float Unk03;
|
||||
public float Unk04;
|
||||
public Vec3 Unk05;
|
||||
public Vec3 ToneCurve;
|
||||
public float Unk;
|
||||
public float Unk06;
|
||||
public float Unk07;
|
||||
public float Unk08;
|
||||
public int Unk10;
|
||||
|
||||
public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : $"{(Type)Type}," +
|
||||
((Flags & Flags.Ambient ) != 0
|
||||
? $"{Ambient .X.ToS(6)},{Ambient .Y.ToS(6)},{Ambient .Z.ToS(6)}," : ",,,") +
|
||||
((Flags & Flags.Diffuse ) != 0
|
||||
? $"{Diffuse .X.ToS(6)},{Diffuse .Y.ToS(6)},{Diffuse .Z.ToS(6)}," : ",,,") +
|
||||
((Flags & Flags.Specular ) != 0
|
||||
? $"{Specular .X.ToS(6)},{Specular .Y.ToS(6)},{Specular .Z.ToS(6)},{Specular .W.ToS(6)}," : ",,,,") +
|
||||
((Flags & Flags.Position ) != 0
|
||||
? $"{Position .X.ToS(6)},{Position .Y.ToS(6)},{Position .Z.ToS(6)}," : ",,,") +
|
||||
((Flags & Flags.ToneCurve) != 0
|
||||
? $"{ToneCurve.X.ToS(6)},{ToneCurve.Y.ToS(6)},{ToneCurve.Z.ToS(6)}" : ",,");
|
||||
}
|
||||
|
||||
public enum Id : int
|
||||
{
|
||||
CHARA = 0,
|
||||
STAGE = 1,
|
||||
SUN = 2,
|
||||
REFLECT = 3,
|
||||
SHADOW = 4,
|
||||
CHARA_COLOR = 5,
|
||||
CHARA_F = 6,
|
||||
PROJECTION = 7,
|
||||
CHARA = 0x00,
|
||||
STAGE = 0x01,
|
||||
SUN = 0x02,
|
||||
REFLECT = 0x03,
|
||||
SHADOW = 0x04,
|
||||
CHARA_COLOR = 0x05,
|
||||
CHARA_F = 0x06,
|
||||
PROJECTION = 0x07,
|
||||
}
|
||||
|
||||
public enum Type : int
|
||||
@@ -131,12 +887,19 @@ namespace KKdMainLib.F2
|
||||
|
||||
public enum Flags : int
|
||||
{
|
||||
Type = 0b0000000001,
|
||||
Ambient = 0b0000000010,
|
||||
Diffuse = 0b0000000100,
|
||||
Specular = 0b0000001000,
|
||||
Position = 0b0000010000,
|
||||
ToneCurve = 0b1000000000,
|
||||
Type = 0b00000000000000001,
|
||||
Ambient = 0b00000000000000010,
|
||||
Diffuse = 0b00000000000000100,
|
||||
Specular = 0b00000000000001000,
|
||||
Position = 0b00000000000010000,
|
||||
ToneCurve = 0b00000001000000000,
|
||||
}
|
||||
}
|
||||
|
||||
public struct LITX
|
||||
{
|
||||
public int C;
|
||||
public int O;
|
||||
public KeyValuePair<int, int>[] E;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-16
@@ -21,7 +21,7 @@ namespace KKdMainLib
|
||||
public Farc Signature = Farc.FArC;
|
||||
public Format Format = Format.DT;
|
||||
public string FilePath, DirectoryPath;
|
||||
public bool HasFiles => Files.IsNull ? false : Files.Count > 0;
|
||||
public bool HasFiles => !Files.IsNull || Files.Count > 0;
|
||||
public int CompressionLevel = 12;
|
||||
|
||||
private readonly byte[] key = "project_diva.bin".ToASCII();
|
||||
@@ -43,7 +43,7 @@ namespace KKdMainLib
|
||||
if (!File.Exists(FilePath)) return false;
|
||||
|
||||
Stream reader = File.OpenReader(FilePath);
|
||||
DirectoryPath = Path.GetFullPath(FilePath).Replace(Path.GetExtension(FilePath), "");
|
||||
DirectoryPath = Path.RemoveExtension(Path.GetFullPath(FilePath));
|
||||
Signature = (Farc)reader.RI32E(true);
|
||||
if (Signature != Farc.FArc && Signature != Farc.FArC && Signature != Farc.FARC)
|
||||
{ reader.Dispose(); return false; }
|
||||
@@ -140,15 +140,9 @@ namespace KKdMainLib
|
||||
FARCFile file = Files[i];
|
||||
if (Signature != Farc.FARC)
|
||||
{
|
||||
if (Signature == Farc.FArC)
|
||||
using (MSIO.MemoryStream memorystream = new MSIO.MemoryStream(
|
||||
File.ReadAllBytes(FilePath, file.SizeComp, file.Offset)))
|
||||
using (GZipStream gZipStream = new GZipStream(memorystream, CompressionMode.Decompress))
|
||||
{
|
||||
file.Data = new byte[file.SizeUnc];
|
||||
gZipStream.Read(file.Data, 0, file.SizeUnc);
|
||||
}
|
||||
else file.Data = File.ReadAllBytes(FilePath, file.SizeUnc, file.Offset);
|
||||
file.Data = Signature == Farc.FArC && file.SizeUnc > 0
|
||||
? File.ReadAllBytes(FilePath, file.SizeComp, file.Offset).InflateGZip(file.SizeUnc)
|
||||
: File.ReadAllBytes(FilePath, file.SizeUnc, file.Offset);
|
||||
Files[i] = file;
|
||||
return file.Data;
|
||||
}
|
||||
@@ -224,7 +218,7 @@ namespace KKdMainLib
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{
|
||||
string ext = Path.GetExtension(Files[i].Name).ToLower();
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".vag")
|
||||
if (ext == ".a3da" || ext == ".diva" || ext == ".farc" || ext == ".vag")
|
||||
{ Signature = Farc.FArc; break; }
|
||||
}
|
||||
|
||||
@@ -233,8 +227,8 @@ namespace KKdMainLib
|
||||
|
||||
using (Stream headerWriter = File.OpenWriter())
|
||||
{
|
||||
if (Signature == Farc.FArc) headerWriter.WE(0x20, true);
|
||||
else if (Signature == Farc.FArC) headerWriter.WE(0x10, true);
|
||||
if (Signature == Farc.FArc) headerWriter.WE(0x01, true);
|
||||
else if (Signature == Farc.FArC) headerWriter.WE(0x01, true);
|
||||
else if (Signature == Farc.FARC)
|
||||
{
|
||||
headerWriter.WE((int)FARCType, true);
|
||||
@@ -285,8 +279,8 @@ namespace KKdMainLib
|
||||
{
|
||||
file.Type |= Type.GZip;
|
||||
data = file.Data.DeflateGZip(CompressionLevel);
|
||||
file.SizeComp = data.Length;
|
||||
}
|
||||
file.SizeComp = data.Length;
|
||||
|
||||
if (Signature == Farc.FARC && (FARCType & Type.Enc) != 0)
|
||||
{
|
||||
@@ -295,7 +289,6 @@ namespace KKdMainLib
|
||||
System.Array.Copy(data, tempData, data.Length);
|
||||
for (int i1 = file.Data.Length; i1 < alignLength; i1++) tempData[i1] = 0x78;
|
||||
data = Encrypt(tempData, false);
|
||||
file.SizeComp = data.Length;
|
||||
}
|
||||
writer.W(data);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
private const string libDeflateString = "libdeflate.dll";
|
||||
|
||||
public static void CheckLib()
|
||||
public static void CheckLib()
|
||||
{
|
||||
if (!File.Exists(libDeflateString))
|
||||
File.WriteAllBytes(libDeflateString, Properties.Resources.libdeflate);
|
||||
@@ -73,15 +73,16 @@ namespace KKdMainLib.IO
|
||||
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int result;
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_gzip_decompress(d, inPtr, data.Length, outPtr, (int)length, &actualOut);
|
||||
result = libdeflate_gzip_decompress(d, inPtr, data.Length, outPtr, (int)length, &actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
return data.InflateGZip(length * 2);
|
||||
return data.InflateGZip(length * 2 + 1);
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
@@ -137,11 +138,11 @@ namespace KKdMainLib.IO
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_deflate_decompress(void* d, byte* inData, int inBytes,
|
||||
private static extern int libdeflate_deflate_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_deflate_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
private static extern int libdeflate_deflate_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualInBytes, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
@@ -152,11 +153,11 @@ namespace KKdMainLib.IO
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_gzip_decompress(void* d, byte* inData, int inBytes,
|
||||
private static extern int libdeflate_gzip_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_gzip_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
private static extern int libdeflate_gzip_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualInBytes, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
@@ -167,7 +168,7 @@ namespace KKdMainLib.IO
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_zlib_decompress(void* d, byte* inData, int inBytes,
|
||||
private static extern int libdeflate_zlib_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
|
||||
+21
-14
@@ -66,22 +66,22 @@ namespace KKdMainLib.IO
|
||||
}
|
||||
|
||||
public static long RIX(this Stream stream ) =>
|
||||
stream.IsX ? stream.RI64() : stream.RI32E( );
|
||||
stream.IsX ? stream.RI64E( ) : stream.RI32E( );
|
||||
public static long RIX(this Stream stream, bool isBE) =>
|
||||
stream.IsX ? stream.RI64() : stream.RI32E(isBE);
|
||||
stream.IsX ? stream.RI64E(isBE) : stream.RI32E(isBE);
|
||||
|
||||
public static void WX(this Stream stream, long val, ref POF pof)
|
||||
{ if (stream.IsX) stream.W ( val);
|
||||
{ if (stream.IsX) stream.WE( val);
|
||||
else stream.WE((int)val); pof.Offsets.Add(stream.P); }
|
||||
public static void WX(this Stream stream, long val, ref POF pof, bool isBE)
|
||||
{ if (stream.IsX) stream.W ( val );
|
||||
{ if (stream.IsX) stream.WE( val, isBE);
|
||||
else stream.WE((int)val, isBE); pof.Offsets.Add(stream.P); }
|
||||
|
||||
public static void WX(this Stream stream, long val)
|
||||
{ if (stream.IsX) stream.W ( val);
|
||||
{ if (stream.IsX) stream.WE( val);
|
||||
else stream.WE((int)val); }
|
||||
public static void WX(this Stream stream, long val, bool isBE)
|
||||
{ if (stream.IsX) stream.W ( val );
|
||||
{ if (stream.IsX) stream.WE( val, isBE);
|
||||
else stream.WE((int)val, isBE); }
|
||||
|
||||
public static byte[] RaO(this Stream stream, long offset = -1, long length = -1)
|
||||
@@ -98,28 +98,35 @@ namespace KKdMainLib.IO
|
||||
|
||||
public static string RSaO(this Stream stream)
|
||||
{
|
||||
long Position = stream.PI64 + (stream.IsX ? 8 : 4);
|
||||
stream.PI64 = stream.RIX();
|
||||
long offset = stream.RIX();
|
||||
if (offset < 1)
|
||||
return "";
|
||||
|
||||
long position = stream.PI64;
|
||||
stream.PI64 = offset;
|
||||
string s = stream.NTUTF8();
|
||||
stream.PI64 = Position;
|
||||
stream.PI64 = position;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string RSaO(this Stream stream, long offset)
|
||||
{
|
||||
long Position = stream.PI64;
|
||||
long position = stream.PI64;
|
||||
stream.PI64 = offset;
|
||||
string s = stream.NTUTF8();
|
||||
stream.PI64 = Position;
|
||||
stream.PI64 = position;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string RSaO(this Stream stream, long offset, long length)
|
||||
{
|
||||
long Position = stream.PI64;
|
||||
if (length < 1)
|
||||
return "";
|
||||
|
||||
long position = stream.PI64;
|
||||
stream.PI64 = offset;
|
||||
string s = stream.RSUTF8(length);
|
||||
stream.PI64 = Position;
|
||||
stream.PI64 = position;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -149,7 +156,7 @@ namespace KKdMainLib.IO
|
||||
public static void W<T>(this Stream stream, Pointer<T> val) =>
|
||||
stream.W(val.O);
|
||||
|
||||
public static CountPointer<T> ReadCountPointer<T>(this Stream stream) =>
|
||||
public static CountPointer<T> RCP<T>(this Stream stream) =>
|
||||
new CountPointer<T> { C = stream.RI32(), O = stream.RI32() };
|
||||
|
||||
public static void W<T>(this Stream stream, CountPointer<T> val)
|
||||
|
||||
+13
-4
@@ -131,16 +131,22 @@ namespace KKdMainLib.IO
|
||||
|
||||
private object RF()
|
||||
{
|
||||
string s = " ";
|
||||
string s = "";
|
||||
_IO.SW();
|
||||
if (_IO.PCUTF8() == '-') s += _IO.RCUTF8();
|
||||
bool negative = false;
|
||||
if (_IO.PCUTF8() == '-') { _IO.RCUTF8(); negative = true; }
|
||||
if (_IO.PCUTF8() == '0') s += _IO.RCUTF8();
|
||||
else s += RD ();
|
||||
char c = _IO.PCUTF8();
|
||||
if (c == '.') s += _IO.RCUTF8() + RD();
|
||||
else if (negative && s == "0")
|
||||
return (float)-0.0f;
|
||||
else if (c != 'e' && c != 'E')
|
||||
{
|
||||
long val = long.Parse(s);
|
||||
if (negative) s = "-" + s;
|
||||
long val;
|
||||
try { val = long.Parse(s); }
|
||||
catch { return ulong.Parse(s); }
|
||||
if (val >= 0x00000000 && val < 0x000000100) return ( byte)val;
|
||||
else if (val >= -0x00000080 && val < 0x000000080) return ( sbyte)val;
|
||||
else if (val >= -0x00008000 && val < 0x000008000) return ( short)val;
|
||||
@@ -159,7 +165,10 @@ namespace KKdMainLib.IO
|
||||
s += RD();
|
||||
}
|
||||
double d = s.ToF64();
|
||||
return (float)d == d ? (float)d : d;
|
||||
if ((float)d == d)
|
||||
return negative ? (((float)d).ToU32() | 0x80000000).ToF32() : (float)d;
|
||||
else
|
||||
return negative ? (d.ToU64() | 0x8000000000000000).ToF64() : d;
|
||||
}
|
||||
|
||||
private bool RBo()
|
||||
|
||||
@@ -62,5 +62,11 @@ namespace KKdMainLib.IO
|
||||
|
||||
public static bool IsPathRooted(string path) =>
|
||||
MSIOP.IsPathRooted(path);
|
||||
|
||||
public static string RemoveExtension(string path) =>
|
||||
path.Substring(0, path.Length - GetExtension(path).Length);
|
||||
|
||||
public static string ReplaceExtension(string path, string ext) =>
|
||||
path.Substring(0, path.Length - GetExtension(path).Length) + ext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder (C) 2018-2020</Copyright>
|
||||
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files</Description>
|
||||
<FileVersion>0.4.9.6</FileVersion>
|
||||
<Copyright>korenkonder (C) 2018-2021</Copyright>
|
||||
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/XHD/FT/VRFL/M39 files</Description>
|
||||
<FileVersion>0.4.10.8</FileVersion>
|
||||
<PackageId>KKdMainLib</PackageId>
|
||||
<Product>KKdMainLib</Product>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<Title>KKdMainLib</Title>
|
||||
<Version>0.4.9.6</Version>
|
||||
<Version>0.4.10.8</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -24,7 +24,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -37,7 +37,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj" />
|
||||
|
||||
+78
-54
@@ -11,6 +11,8 @@ namespace KKdMainLib
|
||||
public MotHeader[] MOT;
|
||||
private Stream s;
|
||||
|
||||
[System.ThreadStatic] public bool Modern;
|
||||
|
||||
public void MOTReader(string file)
|
||||
{
|
||||
s = File.OpenReader(file + ".bin");
|
||||
@@ -40,12 +42,12 @@ namespace KKdMainLib
|
||||
i0 = 1;
|
||||
s.P = mot.BoneInfo.O;
|
||||
s.RU16();
|
||||
while (s.RU16() != 0) i0++;
|
||||
while (s.P < s.L && s.RU16() != 0) i0++;
|
||||
|
||||
mot.BoneInfo.V = new BoneInfo[i0];
|
||||
mot.BoneInfo.V = new int[i0];
|
||||
s.P = mot.BoneInfo.O;
|
||||
for (i0 = 0; i0 < mot.BoneInfo.V.Length; i0++)
|
||||
mot.BoneInfo.V[i0].Id = s.RU16();
|
||||
mot.BoneInfo.V[i0] = s.RU16();
|
||||
|
||||
s.P = mot.KeySet.O;
|
||||
int info = s.RU16();
|
||||
@@ -67,7 +69,7 @@ namespace KKdMainLib
|
||||
if (key.Type == KeySetType.Static)
|
||||
{ key.Keys = new KFT2[1];
|
||||
key.Keys[0].V = s.RF32(); }
|
||||
else if (key.Type == KeySetType.Linear)
|
||||
else if (key.Type == KeySetType.Linear && !Modern)
|
||||
{
|
||||
key.Keys = new KFT2[s.RU16()];
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
@@ -76,7 +78,7 @@ namespace KKdMainLib
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].V = s.RF32();
|
||||
}
|
||||
else if (key.Type == KeySetType.Interpolated)
|
||||
else if (key.Type == KeySetType.Tangent && !Modern)
|
||||
{
|
||||
key.Keys = new KFT2[s.RU16()];
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
@@ -85,6 +87,27 @@ namespace KKdMainLib
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
{ key.Keys[i1].V = s.RF32(); key.Keys[i1].T = s.RF32(); }
|
||||
}
|
||||
else if (key.Type != KeySetType.None)
|
||||
{
|
||||
key.Keys = new KFT2[s.RU16()];
|
||||
ushort type = s.RU16();
|
||||
if (key.Type == KeySetType.Tangent)
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].T = s.RF32();
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].V = s.RF16();
|
||||
s.A(0x4);
|
||||
}
|
||||
else
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].V = s.RF32();
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].F = s.RU16();
|
||||
s.A(0x4);
|
||||
}
|
||||
}
|
||||
}
|
||||
s.C();
|
||||
@@ -120,30 +143,39 @@ namespace KKdMainLib
|
||||
ref KeySet key = ref mot.KeySet.V[i0];
|
||||
if (key.Type == KeySetType.Static)
|
||||
s.W(key.Keys[0].V);
|
||||
else if (key.Type == KeySetType.Linear)
|
||||
else if ((key.Type == KeySetType.Linear
|
||||
|| key.Type == KeySetType.Tangent) && !Modern)
|
||||
{
|
||||
s.W((ushort)key.Keys.Length);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
s.W((ushort)key.Keys[i1].F);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
s.W(key.Keys[i1].V);
|
||||
if (key.Type == KeySetType.Tangent)
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
{ s.W(key.Keys[i1].V); s.W(key.Keys[i1].T); }
|
||||
else
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
s.W(key.Keys[i1].V);
|
||||
}
|
||||
else if (key.Type == KeySetType.Interpolated)
|
||||
else if (key.Type != KeySetType.None)
|
||||
{
|
||||
s.W((ushort)key.Keys.Length);
|
||||
s.W((ushort)0);
|
||||
if (key.Type == KeySetType.Tangent)
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
s.W(key.Keys[i1].T);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
s.W((ushort)key.Keys[i1].F);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
s.W(key.Keys[i1].V);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
{ s.W(key.Keys[i1].V); s.W(key.Keys[i1].T); }
|
||||
s.W((ushort)key.Keys[i1].F);
|
||||
s.A(0x4);
|
||||
}
|
||||
}
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
|
||||
mot.BoneInfo.O = s.P;
|
||||
for (i0 = 0; i0 < mot.BoneInfo.V.Length; i0++)
|
||||
s.W((ushort)mot.BoneInfo.V[i0].Id);
|
||||
s.W((ushort)mot.BoneInfo.V[i0]);
|
||||
s.W((ushort)0);
|
||||
}
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
@@ -210,14 +242,9 @@ namespace KKdMainLib
|
||||
else if (keySet.Type == KeySetType.Static)
|
||||
{
|
||||
keySet.Keys = new KFT2[1];
|
||||
if (temp1.Array == null) continue;
|
||||
else if (temp1.Array.Length == 0) continue;
|
||||
else if (temp1.Array[0].Array == null) continue;
|
||||
else if (temp1.Array[0].Array.Length == 0) continue;
|
||||
else if (temp1.Array[0].Array.Length == 1)
|
||||
keySet.Keys[0] = new KFT2(temp1.Array[0][0].RF32());
|
||||
else if (temp1.Array[0].Array.Length > 1)
|
||||
keySet.Keys[0] = new KFT2(temp1.Array[0][0].RF32(), temp1.Array[0][1].RF32());
|
||||
if (temp1.Array == null) continue;
|
||||
else if (temp1.Array.Length == 0) continue;
|
||||
else keySet.Keys[0] = new KFT2(0.0f, temp1.Array[0].RF32());
|
||||
}
|
||||
else if (keySet.Type == KeySetType.Linear)
|
||||
{
|
||||
@@ -233,7 +260,7 @@ namespace KKdMainLib
|
||||
keySet.Keys[i1] = new KFT2(array[0].RF32(), array[1].RF32());
|
||||
}
|
||||
}
|
||||
else if (keySet.Type == KeySetType.Interpolated)
|
||||
else if (keySet.Type == KeySetType.Tangent)
|
||||
{
|
||||
keySet.Keys = new KFT2[temp1.Array.Length];
|
||||
for (i1 = 0; i1 < temp1.Array.Length; i1++)
|
||||
@@ -254,9 +281,9 @@ namespace KKdMainLib
|
||||
|
||||
if ((temp = msgPack["BoneInfo", true]).NotNull)
|
||||
{
|
||||
mot.BoneInfo.V = new BoneInfo[temp.Array.Length];
|
||||
mot.BoneInfo.V = new int[temp.Array.Length];
|
||||
for (i = 0; i < mot.BoneInfo.V.Length; i++)
|
||||
mot.BoneInfo.V[i].Id = temp[i].RI32();
|
||||
mot.BoneInfo.V[i] = temp[i].RI32();
|
||||
}
|
||||
temp.Dispose();
|
||||
}
|
||||
@@ -273,41 +300,43 @@ namespace KKdMainLib
|
||||
|
||||
keySets[i0] = new MsgPack(2);
|
||||
keySets[i0].Array[0] = (byte)keySet.Type;
|
||||
keySets[i0].Array[1] = new MsgPack(keySet.Keys.Length);
|
||||
if (keySet.Type == KeySetType.Static)
|
||||
{
|
||||
IKF kf = keySet.Keys[0].Check();
|
||||
if (kf is KFT0 KFT0) keySets[i0].Array[1][0] =
|
||||
new MsgPack(null, new MsgPack[] { KFT0.F });
|
||||
else if (kf is KFT1 KFT1) keySets[i0].Array[1][0] =
|
||||
new MsgPack(null, new MsgPack[] { KFT1.F, KFT1.V });
|
||||
MsgPack k = default;
|
||||
if (kf is KFT0 KFT0) k = new MsgPack(null, new MsgPack[] { 0.0f });
|
||||
else if (kf is KFT1 KFT1) k = new MsgPack(null, new MsgPack[] { KFT1.V });
|
||||
keySets[i0].Array[1] = k;
|
||||
}
|
||||
else if (keySet.Type == KeySetType.Linear)
|
||||
{
|
||||
MsgPack k = new MsgPack(keySet.Keys.Length);
|
||||
for (i1 = 0; i1 < keySet.Keys.Length; i1++)
|
||||
{
|
||||
IKF kf = keySet.Keys[i1].Check();
|
||||
if (kf is KFT0 KFT0) keySets[i0].Array[1][i1] =
|
||||
new MsgPack(null, new MsgPack[] { KFT0.F });
|
||||
else if (kf is KFT1 KFT1) keySets[i0].Array[1][i1] =
|
||||
new MsgPack(null, new MsgPack[] { KFT1.F, KFT1.V });
|
||||
if (kf is KFT0 KFT0) k[i1] = new MsgPack(null, new MsgPack[] { KFT0.F });
|
||||
else if (kf is KFT1 KFT1) k[i1] = new MsgPack(null, new MsgPack[] { KFT1.F, KFT1.V });
|
||||
}
|
||||
keySets[i0].Array[1] = k;
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgPack k = new MsgPack(keySet.Keys.Length);
|
||||
for (i1 = 0; i1 < keySet.Keys.Length; i1++)
|
||||
{
|
||||
IKF kf = keySet.Keys[i1].Check();
|
||||
if (kf is KFT0 KFT0) keySets[i0].Array[1][i1] =
|
||||
new MsgPack(null, new MsgPack[] { KFT0.F });
|
||||
else if (kf is KFT1 KFT1) keySets[i0].Array[1][i1] =
|
||||
new MsgPack(null, new MsgPack[] { KFT1.F, KFT1.V });
|
||||
else if (kf is KFT2 KFT2) keySets[i0].Array[1][i1] =
|
||||
new MsgPack(null, new MsgPack[] { KFT2.F, KFT2.V, KFT2.T });
|
||||
if (kf is KFT0 KFT0) k[i1] = new MsgPack(null, new MsgPack[] { KFT0.F });
|
||||
else if (kf is KFT1 KFT1) k[i1] = new MsgPack(null, new MsgPack[] { KFT1.F, KFT1.V });
|
||||
else if (kf is KFT2 KFT2) k[i1] = new MsgPack(null, new MsgPack[] { KFT2.F, KFT2.V, KFT2.T });
|
||||
}
|
||||
keySets[i0].Array[1] = k;
|
||||
}
|
||||
}
|
||||
mot.Add(keySets);
|
||||
|
||||
MsgPack boneInfo = new MsgPack(Mot.BoneInfo.V.Length, "BoneInfo");
|
||||
for (i0 = 0; i0 < Mot.BoneInfo.V.Length; i0++)
|
||||
boneInfo[i0] = Mot.BoneInfo.V[i0].Id;
|
||||
boneInfo[i0] = Mot.BoneInfo.V[i0];
|
||||
mot.Add(boneInfo);
|
||||
|
||||
return mot;
|
||||
@@ -323,8 +352,8 @@ namespace KKdMainLib
|
||||
{
|
||||
public int KeySetOffset;
|
||||
public int KeySetTypesOffset;
|
||||
public Pointer< KeySet []> KeySet ;
|
||||
public Pointer<BoneInfo[]> BoneInfo;
|
||||
public Pointer<KeySet[]> KeySet ;
|
||||
public Pointer< int[]> BoneInfo;
|
||||
|
||||
public int HighBits;
|
||||
public int FrameCount;
|
||||
@@ -335,22 +364,17 @@ namespace KKdMainLib
|
||||
public KFT2[] Keys;
|
||||
public KeySetType Type;
|
||||
|
||||
public override string ToString() => $"Type: {Type}" + (Type == KeySetType.Static ?
|
||||
$"; Value: {Keys[0].V}" : Type > KeySetType.Static ? $"; Keys: {Keys.Length}" : "");
|
||||
public override string ToString() =>
|
||||
$"Type: {Type}" + (Type == KeySetType.Static ? $"; Value: {Keys[0].V}"
|
||||
: Type > KeySetType.Static ? $"; Keys: {Keys.Length}; First Key: {Keys[0]}" : "");
|
||||
}
|
||||
|
||||
public enum KeySetType : byte
|
||||
{
|
||||
None = 0b00,
|
||||
Static = 0b01,
|
||||
Linear = 0b10,
|
||||
Interpolated = 0b11,
|
||||
}
|
||||
|
||||
public struct BoneInfo
|
||||
{
|
||||
public string Name;
|
||||
public int Id;
|
||||
None = 0b00,
|
||||
Static = 0b01,
|
||||
Linear = 0b10,
|
||||
Tangent = 0b11,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+676
-423
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -18,10 +18,10 @@ namespace KKdMainLib
|
||||
|
||||
header = new Header();
|
||||
s.Format = Format.F;
|
||||
header.Signature = s.RU32();
|
||||
if (header.Signature == 0x41525453)
|
||||
uint signature = s.RU32();
|
||||
if (signature == 0x41525453)
|
||||
{
|
||||
header = s.ReadHeader(true, false);
|
||||
header = s.ReadHeader(true);
|
||||
s.IsBE = header.UseBigEndian;
|
||||
s.Format = header.Format;
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace KKdMainLib
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((header.Signature >> 24) > 0) { header.Format = Format.DT; s.IsBE = true; }
|
||||
if ((signature >> 24) > 0) { header.Format = Format.DT; s.IsBE = true; }
|
||||
else header.Format = Format.F;
|
||||
int count = 0;
|
||||
for (uint i = header.Signature; i != 0 && s.P >= 0 && s.P < s.L; count++)
|
||||
for (uint i = signature; i != 0 && s.P >= 0 && s.P < s.L; count++)
|
||||
i = s.RU32();
|
||||
Strings = new String[count];
|
||||
|
||||
|
||||
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder (C) 2019-2020</Copyright>
|
||||
<Copyright>korenkonder (C) 2019-2021</Copyright>
|
||||
<Description>A simple library for working with Project Diva F/AFT/F2/X/FT audio files</Description>
|
||||
<FileVersion>0.1.2.0</FileVersion>
|
||||
<PackageId>KKdSoundLib</PackageId>
|
||||
@@ -24,7 +24,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -37,7 +37,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj" />
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -36,11 +36,10 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0018, IDE0032, IDE0044, IDE0045, IDE0046, IDE0051, IDE0055, IDE0059, IDE0063, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="classes\A3D.cs" />
|
||||
<Compile Include="classes\ADP.cs" />
|
||||
<Compile Include="classes\AET.cs" />
|
||||
<Compile Include="classes\BLT.cs" />
|
||||
<Compile Include="classes\CCT.cs" />
|
||||
|
||||
+69
-50
@@ -47,7 +47,8 @@ namespace PD_Tool
|
||||
|
||||
private static void MainMenu()
|
||||
{
|
||||
Console.Title = "PD_Tool v0.4.9.6";
|
||||
Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
Console.Title = $"PD_Tool v{ver}";
|
||||
Console.Clear();
|
||||
|
||||
ConsoleDesign(true);
|
||||
@@ -60,7 +61,7 @@ namespace PD_Tool
|
||||
ConsoleDesign("5. DB_Tools");
|
||||
ConsoleDesign("6. AC/DT/F/AFT Converting Tools");
|
||||
ConsoleDesign("7. F/F2/FT Converting Tools");
|
||||
ConsoleDesign("8. X/XHD Converting Tools");
|
||||
ConsoleDesign("8. X/XHD/VRFL Converting Tools");
|
||||
ConsoleDesign("9. FT/M39 Converting Tools");
|
||||
ConsoleDesign(json ? "A. MsgPack to JSON" : "A. JSON to MsgPack");
|
||||
ConsoleDesign(false);
|
||||
@@ -77,6 +78,7 @@ namespace PD_Tool
|
||||
if (choose == null || choose == "") return;
|
||||
if (choose[0] == 'M') json = false;
|
||||
else if (choose[0] == 'J') json = true ;
|
||||
else if (choose[0] >= 'A' && choose[0] <= 'A') Functions();
|
||||
}
|
||||
|
||||
private static void Functions()
|
||||
@@ -95,7 +97,8 @@ namespace PD_Tool
|
||||
Choose(1, "", out string[] FileNames);
|
||||
foreach (string FileName in FileNames) DIVAFILE.Encrypt(FileName);
|
||||
}
|
||||
else if (choose[0] == '5') DataBase.Processor(json);
|
||||
else if (choose[0] == '5')
|
||||
DataBase.Processor(json, choose.Length > 1 ? choose[1] : '\0');
|
||||
else if (choose[0] == '6')
|
||||
{
|
||||
string localChoose = "";
|
||||
@@ -161,11 +164,11 @@ namespace PD_Tool
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") BLT.Processor();
|
||||
else if (localChoose == "3") CCT.Processor();
|
||||
else if (localChoose == "2") BLT.Processor(json);
|
||||
else if (localChoose == "3") CCT.Processor(json);
|
||||
else if (localChoose == "4") DEX.Processor(json);
|
||||
else if (localChoose == "5") DFT.Processor();
|
||||
else if (localChoose == "6") LIT.Processor();
|
||||
else if (localChoose == "5") DFT.Processor(json);
|
||||
else if (localChoose == "6") LIT.Processor(json);
|
||||
else if (localChoose == "7") STR.Processor(json);
|
||||
else if (localChoose == "8") VAG.Processor();
|
||||
else choose = localChoose;
|
||||
@@ -176,13 +179,17 @@ namespace PD_Tool
|
||||
if (choose.Length == 1)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "X/XHD Converting Tools";
|
||||
Console.Title = "X/XHD/VRFL Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. DEX" );
|
||||
ConsoleDesign("3. VAG" );
|
||||
ConsoleDesign("1. A3DA");
|
||||
ConsoleDesign("2. Bloom" );
|
||||
ConsoleDesign("3. Color Correction");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DOF" );
|
||||
ConsoleDesign("6. Light" );
|
||||
ConsoleDesign("7. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
@@ -192,8 +199,12 @@ namespace PD_Tool
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") DEX.Processor(json);
|
||||
else if (localChoose == "3") VAG.Processor();
|
||||
else if (localChoose == "2") BLT.Processor(json);
|
||||
else if (localChoose == "3") CCT.Processor(json);
|
||||
else if (localChoose == "4") DEX.Processor(json);
|
||||
else if (localChoose == "5") DFT.Processor(json);
|
||||
else if (localChoose == "6") LIT.Processor(json);
|
||||
else if (localChoose == "7") VAG.Processor();
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose[0] == '9')
|
||||
@@ -207,14 +218,13 @@ namespace PD_Tool
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. AddParam");
|
||||
ConsoleDesign("3. AET" );
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DIVA" );
|
||||
ConsoleDesign("6. MotHead" );
|
||||
ConsoleDesign("7. MOT" );
|
||||
ConsoleDesign("8. STR" );
|
||||
ConsoleDesign("9. Table" );
|
||||
ConsoleDesign("2. AET" );
|
||||
ConsoleDesign("3. DEX" );
|
||||
ConsoleDesign("4. DIVA" );
|
||||
ConsoleDesign("5. MotHead" );
|
||||
ConsoleDesign("6. MOT" );
|
||||
ConsoleDesign("7. STR" );
|
||||
ConsoleDesign("8. Table" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
@@ -224,14 +234,13 @@ namespace PD_Tool
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") ADP.Processor(json);
|
||||
else if (localChoose == "3") AET.Processor(json);
|
||||
else if (localChoose == "4") DEX.Processor(json);
|
||||
else if (localChoose == "5") DIV.Processor();
|
||||
else if (localChoose == "6") MHD.Processor(json);
|
||||
else if (localChoose == "7") MOT.Processor(json);
|
||||
else if (localChoose == "8") STR.Processor(json);
|
||||
else if (localChoose == "9") TBL.Processor(json);
|
||||
else if (localChoose == "2") AET.Processor(json);
|
||||
else if (localChoose == "3") DEX.Processor(json);
|
||||
else if (localChoose == "4") DIV.Processor();
|
||||
else if (localChoose == "5") MHD.Processor(json);
|
||||
else if (localChoose == "6") MOT.Processor(json);
|
||||
else if (localChoose == "7") STR.Processor(json);
|
||||
else if (localChoose == "8") TBL.Processor(json);
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose[0] == 'A')
|
||||
@@ -242,12 +251,12 @@ namespace PD_Tool
|
||||
if (json)
|
||||
{
|
||||
Console.Title = "MsgPack to JSON: " + Path.GetFileNameWithoutExtension(file);
|
||||
file.Replace(Path.GetExtension(file), "").ToJSON ();
|
||||
Path.RemoveExtension(file).ToJSON ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Title = "JSON to MsgPack: " + Path.GetFileNameWithoutExtension(file);
|
||||
file.Replace(Path.GetExtension(file), "").ToMsgPack();
|
||||
Path.RemoveExtension(file).ToMsgPack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,15 +266,15 @@ namespace PD_Tool
|
||||
public static void ConsoleDesign(string text, params string[] args)
|
||||
{
|
||||
text = string.Format(text, args);
|
||||
string Text = "█ █";
|
||||
string Text = "X X";
|
||||
Text = Text.Remove(3) + text + Text.Remove(0, text.Length + 3);
|
||||
Console.WriteLine(Text);
|
||||
}
|
||||
|
||||
public static void ConsoleDesign(bool Fill)
|
||||
{
|
||||
if (Fill) Console.WriteLine("████████████████████████████████████████████████████");
|
||||
else Console.WriteLine("█ █");
|
||||
if (Fill) Console.WriteLine("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
|
||||
else Console.WriteLine("X X");
|
||||
}
|
||||
|
||||
private static string GetArgs(string name, bool And, params string[] ext)
|
||||
@@ -290,36 +299,46 @@ namespace PD_Tool
|
||||
|
||||
public static string Choose(int code, string filetype, out string[] FileNames)
|
||||
{
|
||||
string mp = GetArgs("MessagePack", true, "mp" );
|
||||
string json = GetArgs("JSON" , true, "json");
|
||||
string bin = GetArgs("BIN" , true, "bin" );
|
||||
string wav = GetArgs("WAV" , true, "wav" );
|
||||
|
||||
FileNames = new string[0];
|
||||
if (code == 1)
|
||||
{
|
||||
string Filter = GetArgs("All;", false, "*");
|
||||
string mp = GetArgs("MessagePack", true, "mp" );
|
||||
string json = GetArgs("JSON" , true, "json");
|
||||
string bin = GetArgs("BIN" , true, "bin" );
|
||||
string wav = GetArgs("WAV" , true, "wav" );
|
||||
|
||||
string Filter = GetArgs("All", false, "*");
|
||||
if (filetype == "a3da") Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + json + mp;
|
||||
else if (filetype == "adp" ) Filter = GetArgs("ADP" , "adp", "json", "mp") +
|
||||
GetArgs("ADP", true, "adp" ) + json + mp;
|
||||
else if (filetype == "bin" ) Filter = GetArgs("BIN" , "bin", "json", "mp") +
|
||||
bin + json + mp;
|
||||
else if (filetype == "blt" ) Filter = GetArgs("BLT" , "blt");
|
||||
else if (filetype == "blt" ) Filter = GetArgs("BLT" , "blt", "json", "mp") +
|
||||
GetArgs("BLT", true, "blt") + json + mp;
|
||||
else if (filetype == "bon" ) Filter = GetArgs("BON" , "bon", "bin", "json", "mp") +
|
||||
GetArgs("BON", true, "bon") + bin + json + mp;
|
||||
else if (filetype == "cct" ) Filter = GetArgs("CCT" , "cct");
|
||||
else if (filetype == "cct" ) Filter = GetArgs("CCT" , "cct", "json", "mp") +
|
||||
GetArgs("CCT", true, "cct") + json + mp;
|
||||
else if (filetype == "databank") Filter = GetArgs("DAT", "dat", "json", "mp") +
|
||||
GetArgs("DAT", true, "dat") + json + mp;
|
||||
else if (filetype == "dex" ) Filter = GetArgs("DEX" , "dex", "bin", "json", "mp") +
|
||||
GetArgs("DEX", true, "dex") + bin + json + mp;
|
||||
else if (filetype == "dft" ) Filter = GetArgs("DFT" , "dft");
|
||||
else if (filetype == "dft" ) Filter = GetArgs("DFT" , "dft", "json", "mp") +
|
||||
GetArgs("DFT", true, "dft") + json + mp;
|
||||
else if (filetype == "diva") Filter = GetArgs("DIVA", "diva", "wav") +
|
||||
GetArgs("DIVA", true, "diva") + wav;
|
||||
else if (filetype == "dsc" ) Filter = GetArgs("DSC" , "dsc", "json", "mp") +
|
||||
GetArgs("DSC", true, "dsc") + json + mp;
|
||||
else if (filetype == "dve" ) Filter = GetArgs("Particle", "dve", "farc", "json", "mp") +
|
||||
GetArgs("Particle", true, "dve") + GetArgs("Particle", true, "farc") + json + mp;
|
||||
else if (filetype == "farc") Filter = GetArgs("FARC", "farc");
|
||||
else if (filetype == "json") Filter = GetArgs("JSON", "json");
|
||||
else if (filetype == "igb" ) Filter = GetArgs("IGB", "igb");
|
||||
else if (filetype == "mgftxt") Filter = GetArgs("MGF2AFT txt", "txt");
|
||||
else if (filetype == "mp" ) Filter = GetArgs("MessagePack", "mp");
|
||||
else if (filetype == "lit") Filter = GetArgs("LIT" , "lit");
|
||||
else if (filetype == "lit") Filter = GetArgs("LIT" , "lit", "json", "mp") +
|
||||
GetArgs("LIT", true, "lit") + json + mp;
|
||||
else if (filetype == "pvdb") Filter = GetArgs("PV DB / PV Field", "txt", "json", "mp") +
|
||||
GetArgs("PV DB / PV Field", true, "txt") + json + mp;
|
||||
else if (filetype == "str" ) Filter = GetArgs("STR" , "str", "bin", "json", "mp") +
|
||||
GetArgs("STR", true, "str") + bin + json + mp;
|
||||
else if (filetype == "tbl" ) Filter = GetArgs("Table" , "bin", "farc", "json", "mp") +
|
||||
@@ -327,15 +346,15 @@ namespace PD_Tool
|
||||
else if (filetype == "vag" ) Filter = GetArgs("VAG" , "vag", "wav") +
|
||||
GetArgs("VAG", true, "vag") + wav;
|
||||
|
||||
using OpenFileDialog ofd = new OpenFileDialog { //InitialDirectory = Application.StartupPath,
|
||||
Filter = Filter, Multiselect = true, Title = "Choose file(s) to open:" };
|
||||
using OpenFileDialog ofd = new OpenFileDialog { Filter = Filter,
|
||||
Multiselect = true, Title = "Choose file(s) to open:" };
|
||||
if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames;
|
||||
}
|
||||
else if (code == 2)
|
||||
{
|
||||
string Return = "";
|
||||
using (OpenFileDialog ofd = new OpenFileDialog { //InitialDirectory = Application.StartupPath,
|
||||
ValidateNames = false, CheckFileExists = false, Filter = " | ", CheckPathExists = true,
|
||||
using (OpenFileDialog ofd = new OpenFileDialog { ValidateNames = false,
|
||||
CheckFileExists = false, Filter = " | ", CheckPathExists = true,
|
||||
Title = "Choose any file in folder:", FileName = "Folder Selection." })
|
||||
if (ofd.ShowDialog() == DialogResult.OK) Return = Path.GetDirectoryName(ofd.FileName);
|
||||
return Return;
|
||||
|
||||
@@ -2,14 +2,14 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("PD_Tool")]
|
||||
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files")]
|
||||
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/XHD/FT/VRFL/M39 files")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PD_Tool")]
|
||||
[assembly: AssemblyCopyright("korenkonder (C) 2017-2020")]
|
||||
[assembly: AssemblyCopyright("korenkonder (C) 2017-2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.9.6")]
|
||||
[assembly: AssemblyFileVersion("0.4.9.6")]
|
||||
[assembly: AssemblyVersion("0.4.10.8")]
|
||||
[assembly: AssemblyFileVersion("0.4.10.8")]
|
||||
|
||||
+31
-26
@@ -24,6 +24,9 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(" Tip: A3DC Opt - A3DC Optimization");
|
||||
Program.ConsoleDesign(" WARNING! CHECK RESULTS AFTER CONVERTING ");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. A3DA [DT/AC/F]");
|
||||
Program.ConsoleDesign("2. A3DC [DT/AC/F]");
|
||||
Program.ConsoleDesign("3. A3DA [AFT/FT/M39]");
|
||||
@@ -31,19 +34,21 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign("5. A3DC [F2]");
|
||||
Program.ConsoleDesign("6. A3DC [MGF]");
|
||||
Program.ConsoleDesign("7. A3DC [X]");
|
||||
if (!mp) Program.ConsoleDesign($"8. {(json ? "JSON" : "MsgPack")}");
|
||||
Program.ConsoleDesign("8. A3DC [XHD/VRFL]");
|
||||
if (!mp) Program.ConsoleDesign($"9. {(json ? "JSON" : "MsgPack")}");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
if (choose == "1") format = Format.DT ;
|
||||
else if (choose == "2") format = Format.F ;
|
||||
else if (choose == "3") format = Format.AFT;
|
||||
else if (choose == "4") format = Format.AFT;
|
||||
else if (choose == "5") format = Format.F2;
|
||||
else if (choose == "6") format = Format.MGF;
|
||||
else if (choose == "7") format = Format.X ;
|
||||
else if (choose == "8") format = Format.NULL;
|
||||
if (choose == "1") format = Format.DT ;
|
||||
else if (choose == "2") format = Format.F ;
|
||||
else if (choose == "3") format = Format.AFT;
|
||||
else if (choose == "4") format = Format.AFT;
|
||||
else if (choose == "5") format = Format.F2 ;
|
||||
else if (choose == "6") format = Format.MGF;
|
||||
else if (choose == "7") format = Format.X ;
|
||||
else if (choose == "8") format = Format.XHD;
|
||||
else if (choose == "9") format = Format.NULL;
|
||||
else return;
|
||||
|
||||
int state;
|
||||
@@ -52,36 +57,34 @@ namespace PD_Tool
|
||||
KKdFARC farc;
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".farc")
|
||||
using (farc = new KKdFARC(file))
|
||||
FARCProcessor(farc, choose, format);
|
||||
else if (ext == ".a3da")
|
||||
using (a3da = new KKdA3DA(true))
|
||||
using (a3da = new KKdA3DA())
|
||||
{
|
||||
state = a3da.A3DAReader(filepath);
|
||||
if (state == 1)
|
||||
if (choose == "8") a3da.MsgPackWriter(filepath, json);
|
||||
if (choose == "9") a3da.MsgPackWriter(filepath, json);
|
||||
else
|
||||
{
|
||||
a3da.Head.Format = format;
|
||||
|
||||
File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
|
||||
choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter());
|
||||
choose == "4") ? a3da.A3DAWriter() : a3da.A3DCWriter());
|
||||
}
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
using (a3da = new KKdA3DA(true))
|
||||
using (a3da = new KKdA3DA())
|
||||
{
|
||||
a3da.MsgPackReader(filepath, ext == ".json");
|
||||
a3da.Head.Format = format;
|
||||
|
||||
File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
|
||||
choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter());
|
||||
choose == "4") ? a3da.A3DAWriter() : a3da.A3DCWriter());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +110,7 @@ namespace PD_Tool
|
||||
{
|
||||
KKdA3DA a3da;
|
||||
for (int i = 0; i < A3DAlist.Count; i++)
|
||||
using (a3da = new KKdA3DA(true))
|
||||
using (a3da = new KKdA3DA())
|
||||
{
|
||||
data = farc.FileReader(A3DAlist[i]);
|
||||
int state = a3da.A3DAReader(data);
|
||||
@@ -115,7 +118,8 @@ namespace PD_Tool
|
||||
{
|
||||
KKdFARC.FARCFile file = farc.Files[i];
|
||||
a3da.Head.Format = format;
|
||||
file.Data = (choose == "1"|| choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter();
|
||||
file.Data = (choose == "1"|| choose == "4")
|
||||
? a3da.A3DAWriter() : a3da.A3DCWriter();
|
||||
farc.Files[i] = file;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +133,7 @@ namespace PD_Tool
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
KKdA3DA a3da;
|
||||
using (a3da = new KKdA3DA(true))
|
||||
using (a3da = new KKdA3DA())
|
||||
{
|
||||
data = farc.FileReader(list[i]);
|
||||
int state = a3da.A3DAReader(data);
|
||||
@@ -143,11 +147,11 @@ namespace PD_Tool
|
||||
{
|
||||
if (a3daArray[i].Data.PlayControl.Div == null) continue;
|
||||
int div = a3daArray[i].Data.PlayControl.Div.Value;
|
||||
string filename = Path.GetFileNameWithoutExtension(list[i]);
|
||||
string ext = Path.GetExtension(list[i]);
|
||||
string filename = Path.RemoveExtension(list[i]);
|
||||
string ext = Path.GetExtension(list[i]).ToLower();
|
||||
KKdA3DA a3da;
|
||||
for (int i1 = 1; i1 < div; i1++)
|
||||
using (a3da = new KKdA3DA(true))
|
||||
using (a3da = new KKdA3DA())
|
||||
{
|
||||
string file = filename + "_div_" + i1 + ext;
|
||||
data = farc.FileReader(file);
|
||||
@@ -156,7 +160,7 @@ namespace PD_Tool
|
||||
}
|
||||
a3daArray[i].Data.PlayControl.Div = null;
|
||||
}
|
||||
|
||||
|
||||
farc.Files.Capacity = 0;
|
||||
farc.Files.Capacity = list.Count;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
@@ -164,7 +168,8 @@ namespace PD_Tool
|
||||
KKdFARC.FARCFile file = default;
|
||||
file.Name = list[i];
|
||||
a3daArray[i].Head.Format = format;
|
||||
file.Data = (choose == "1" || choose == "3") ? a3daArray[i].A3DAWriter() : a3daArray[i].A3DCWriter();
|
||||
file.Data = (choose == "1" || choose == "4")
|
||||
? a3daArray[i].A3DAWriter() : a3daArray[i].A3DCWriter();
|
||||
farc.Files.Add(file);
|
||||
}
|
||||
farc.Save();
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class ADP
|
||||
{
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "Add Param Converter";
|
||||
Program.Choose(1, "adp", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
string filepath, ext;
|
||||
AddParam adp;
|
||||
foreach (string file in fileNames)
|
||||
using (adp = new AddParam())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Add Param Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".adp")
|
||||
{
|
||||
adp.AddParamReader(filepath);
|
||||
adp. MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
adp. MsgPackReader(filepath, ext == ".json");
|
||||
adp.AddParamWriter(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
using (aet = new Aet())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "AET Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
|
||||
+30
-9
@@ -1,37 +1,58 @@
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class BLT
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "Bloom Converter";
|
||||
Program.Choose(1, "blt", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
bool bloom = false;
|
||||
foreach (string file in fileNames)
|
||||
if (file.EndsWith(".blt")) { bloom = true; break; }
|
||||
|
||||
string choose = "";
|
||||
if (bloom)
|
||||
{
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. JSON");
|
||||
Program.ConsoleDesign("2. TXT");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
|
||||
string filepath, ext;
|
||||
Bloom blt;
|
||||
foreach (string file in fileNames)
|
||||
using (blt = new Bloom())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "Bloom Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".blt")
|
||||
{
|
||||
blt.BLTReader(filepath);
|
||||
blt.TXTWriter(filepath);
|
||||
if (choose == "2" && !blt.IsX)
|
||||
blt.TXTWriter(filepath);
|
||||
else
|
||||
blt.MsgPackWriter(filepath, json);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
else if (ext == ".json" || ext == ".mp")
|
||||
{
|
||||
blt.TXTReader(filepath);
|
||||
blt.MsgPackReader(filepath, json);
|
||||
blt.BLTWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
-10
@@ -1,37 +1,58 @@
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class CCT
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "Color Correction Converter";
|
||||
Program.Choose(1, "cct", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
bool cc = false;
|
||||
foreach (string file in fileNames)
|
||||
if (file.EndsWith(".cct")) { cc = true; break; }
|
||||
|
||||
string choose = "";
|
||||
if (cc)
|
||||
{
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. JSON");
|
||||
Program.ConsoleDesign("2. TXT");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
|
||||
string filepath, ext;
|
||||
ColorCorrection cct;
|
||||
foreach (string file in fileNames)
|
||||
using (cct = new ColorCorrection())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "Color Correction Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".cct")
|
||||
{
|
||||
cct.CCTReader(filepath);
|
||||
cct.TXTWriter(filepath);
|
||||
if (choose == "2" && !cct.IsX)
|
||||
cct.TXTWriter(filepath);
|
||||
else
|
||||
cct.MsgPackWriter(filepath, json);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
else if (ext == ".json" || ext == ".mp")
|
||||
{
|
||||
blt.TXTReader(filepath);
|
||||
blt.CCTWriter(filepath);
|
||||
}*/
|
||||
cct.MsgPackReader(filepath, json);
|
||||
cct.CCTWriter(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,8 @@ namespace PD_Tool
|
||||
KKdMainLib.DataBank db;
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
string filename = Path.GetFileNameWithoutExtension(file);
|
||||
file_split = filename.Split('_');
|
||||
|
||||
@@ -46,9 +46,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
using (dex = new KKdDEX())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "DEX Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin" || ext == ".dex") dex. DEXReader(filepath, ext );
|
||||
|
||||
+30
-9
@@ -1,37 +1,58 @@
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class DFT
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "DOF Converter";
|
||||
Program.Choose(1, "dft", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
bool cc = false;
|
||||
foreach (string file in fileNames)
|
||||
if (file.EndsWith(".dft")) { cc = true; break; }
|
||||
|
||||
string choose = "";
|
||||
if (cc)
|
||||
{
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. JSON");
|
||||
Program.ConsoleDesign("2. TXT");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
|
||||
string filepath, ext;
|
||||
DOF dft;
|
||||
foreach (string file in fileNames)
|
||||
using (dft = new DOF())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".dft")
|
||||
{
|
||||
dft.DFTReader(filepath);
|
||||
dft.TXTWriter(filepath);
|
||||
if (choose == "2" && !dft.IsX)
|
||||
dft.TXTWriter(filepath);
|
||||
else
|
||||
dft.MsgPackWriter(filepath, json);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
else if (ext == ".json" || ext == ".mp")
|
||||
{
|
||||
dft.TXTReader(filepath);
|
||||
dft.MsgPackReader(filepath, json);
|
||||
dft.DFTWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib.IO;
|
||||
using KKdSoundLib;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -17,9 +17,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
diva = new DIVA();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "DIVA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".diva") diva.DIVAReader(filepath);
|
||||
|
||||
+28
-26
@@ -1,32 +1,34 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aet = KKdMainLib.DB.Aet;
|
||||
using Auth = KKdMainLib.DB.Auth;
|
||||
using Spr = KKdMainLib.DB.Spr;
|
||||
using KKdMainLib.DB;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class DataBase
|
||||
{
|
||||
public static void Processor(bool json)
|
||||
public static void Processor(bool json, char choose)
|
||||
{
|
||||
Console.Title = "DB Converter";
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of DataBase file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. Auth DB Converter");
|
||||
Program.ConsoleDesign("2. AET DB Converter");
|
||||
Program.ConsoleDesign("3. SPR DB Converter");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("R. Return to Main Menu");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine().ToUpper();
|
||||
if (format == "1") AuthDBProcessor(json);
|
||||
if (format == "2") AETDBProcessor(json);
|
||||
if (format == "3") SPRDBProcessor(json);
|
||||
if (choose == '\0')
|
||||
{
|
||||
Console.Title = "DB Converter";
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of DataBase file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. Auth DB Converter");
|
||||
Program.ConsoleDesign("2. AET DB Converter");
|
||||
Program.ConsoleDesign("3. SPR DB Converter");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("R. Return to Main Menu");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine().ToUpper();
|
||||
if (format.Length > 0) choose = format[0];
|
||||
}
|
||||
if (choose == '1') AuthDBProcessor(json);
|
||||
if (choose == '2') AETDBProcessor(json);
|
||||
if (choose == '3') SPRDBProcessor(json);
|
||||
}
|
||||
|
||||
public static void AuthDBProcessor(bool JSON)
|
||||
@@ -41,8 +43,8 @@ namespace PD_Tool
|
||||
using (auth = new Auth())
|
||||
{
|
||||
Console.Title = "Auth DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
if (ext == ".bin")
|
||||
{
|
||||
@@ -69,8 +71,8 @@ namespace PD_Tool
|
||||
using (aet = new Aet())
|
||||
{
|
||||
Console.Title = "AET DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
if (ext == ".bin")
|
||||
{
|
||||
@@ -97,8 +99,8 @@ namespace PD_Tool
|
||||
using (spr = new Spr())
|
||||
{
|
||||
Console.Title = "SPR DB Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
filepath = file.Replace(Path.GetExtension(file), "");
|
||||
|
||||
if (ext == ".bin")
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib.IO;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
namespace PD_Tool
|
||||
|
||||
+29
-8
@@ -6,32 +6,53 @@ namespace PD_Tool
|
||||
{
|
||||
public class LIT
|
||||
{
|
||||
public static void Processor()
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "Light Converter";
|
||||
Program.Choose(1, "lit", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
bool bloom = false;
|
||||
foreach (string file in fileNames)
|
||||
if (file.EndsWith(".lit")) { bloom = true; break; }
|
||||
|
||||
string choose = "";
|
||||
if (bloom)
|
||||
{
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. JSON");
|
||||
Program.ConsoleDesign("2. TXT");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
|
||||
string filepath, ext;
|
||||
Light lit;
|
||||
foreach (string file in fileNames)
|
||||
using (lit = new Light())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "Light Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".lit")
|
||||
{
|
||||
lit.LITReader(filepath);
|
||||
lit.TXTWriter(filepath);
|
||||
if (choose == "2" && !lit.IsX)
|
||||
lit.TXTWriter(filepath);
|
||||
else
|
||||
lit.MsgPackWriter(filepath, json);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
else if (ext == ".json" || ext == ".mp")
|
||||
{
|
||||
lit.TXTReader(filepath);
|
||||
lit.MsgPackReader(filepath, json);
|
||||
lit.LITWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
using (mhd = new MotHead())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "MotHead Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
|
||||
@@ -16,9 +16,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
using (str = new KKdSTR())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "STR Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".str" || ext == ".bin")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -19,9 +19,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
using (tbl = new Tables())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "Table Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdMainLib.IO;
|
||||
using KKdVAG = KKdSoundLib.VAG;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -42,9 +42,8 @@ namespace PD_Tool
|
||||
foreach (string file in fileNames)
|
||||
using (VAG = new KKdVAG())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
filepath = Path.RemoveExtension(file);
|
||||
ext = Path.GetExtension(file).ToLower();
|
||||
|
||||
Console.Title = "VAG Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".vag") { VAG.VAGReader(filepath); VAG.WAVWriter(filepath ); }
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
|
||||
|
||||
# Dependencies:
|
||||
+ `.NET Standard 2.0`: Required to build KKdBaseLib, KKdMainLib and KKdSoundLib C# projects.
|
||||
+ `.NET Framework 4.6.1`: Required to run/build PD_Tool C# project.
|
||||
+ `.NET Framework 4.6.1`: Required to build KKdBaseLib, KKdMainLib and KKdSoundLib C# projects and to run/build PD_Tool C# project.
|
||||
|
||||
# Tools:
|
||||
- `FARC Extract/Create`
|
||||
@@ -20,8 +19,8 @@ A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
|
||||
- `DIVA Converter`
|
||||
- `MotHead Converter`
|
||||
- `MOT Converter`
|
||||
- `Table Converter`
|
||||
- `STR Converter`
|
||||
- `Table Converter`
|
||||
- `F/F2/FT Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `Bloom Converter`
|
||||
@@ -43,5 +42,5 @@ A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
|
||||
- `DIVA Converter`
|
||||
- `MotHead Converter`
|
||||
- `MOT Converter`
|
||||
- `Table Converter`
|
||||
- `STR Converter`
|
||||
- `Table Converter`
|
||||
|
||||
Reference in New Issue
Block a user