Compare commits

..
2 Commits
Author SHA1 Message Date
KujiKita e0d651bd55 Release v0.4.6.2p1
A3DA Key fix
2019-07-03 14:52:16 +03:00
KujiKita 3bbbea9536 Release v0.4.6.2
Some fixes and changes
2019-07-03 01:08:18 +03:00
37 changed files with 436 additions and 632 deletions
+148 -137
View File
@@ -11,8 +11,6 @@ namespace KKdMainLib.A3DA
{
private const bool A3DCOpt = true;
private const string d = ".";
private const string BO = "bin_offset";
private const string MTBO = "model_transform.bin_offset";
private int SOi0;
private int SOi1;
@@ -77,7 +75,7 @@ namespace KKdMainLib.A3DA
}
else { IO.Close(); return 0; }
if (Data.Header.Format < Main.Format.F || Data.Header.Format == Main.Format.FT)
if (Data.Header.Format == Main.Format.DT)
Data.Head.StringLength = IO.Length - 0x10;
string[] STRData = IO.ReadString(Data.Head.StringLength).Replace("\r", "").Split('\n');
@@ -91,7 +89,7 @@ namespace KKdMainLib.A3DA
A3DAReader();
if (Data.Header.Format == Main.Format.F || Data.Header.Format > Main.Format.FT)
if (Data.Header.Format >= Main.Format.F && Data.Header.Format != Main.Format.FT)
{
IO.Position = IO.Offset + Data.Head.BinaryOffset;
IO.Offset = IO.Position;
@@ -376,30 +374,36 @@ namespace KKdMainLib.A3DA
if (Dict.FindValue(out value, name + "tex_pat.length"))
{
Data.Object[i0].TP = new Object.TexturePattern[int.Parse(value)];
for (i1 = 0; i1 < Data.Object[i0].TP.Length; i1++)
Data.Object[i0].TexPat = new Object.TexturePattern[int.Parse(value)];
for (i1 = 0; i1 < Data.Object[i0].TexPat.Length; i1++)
{
nameView = name + "tex_pat" + d + i1 + d;
Dict.FindValue(out Data.Object[i0].TP[i1].Name , nameView + "name" );
Dict.FindValue(out Data.Object[i0].TP[i1].Pat , nameView + "pat" );
Dict.FindValue(out Data.Object[i0].TP[i1].PatOffset, nameView + "pat_offset");
Dict.FindValue(out Data.Object[i0].TexPat[i1].Name , nameView + "name" );
Dict.FindValue(out Data.Object[i0].TexPat[i1].Pat , nameView + "pat" );
Dict.FindValue(out Data.Object[i0].TexPat[i1].PatOffset, nameView + "pat_offset");
}
}
if (Dict.FindValue(out value, name + "tex_transform.length"))
{
Data.Object[i0].TT = new Object.TextureTransform[int.Parse(value)];
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
Data.Object[i0].TexTrans = new Object.TextureTransform[int.Parse(value)];
for (i1 = 0; i1 < Data.Object[i0].TexTrans.Length; i1++)
{
nameView = name + "tex_transform" + d + i1 + d;
Dict.FindValue(out Data.Object[i0].TT[i1].Name, nameView + "name");
Data.Object[i0].TT[i1].C = Dict.ReadKeyUV(nameView + "coverage" );
Data.Object[i0].TT[i1].O = Dict.ReadKeyUV(nameView + "offset" );
Data.Object[i0].TT[i1].R = Dict.ReadKeyUV(nameView + "repeat" );
Data.Object[i0].TT[i1].Ro = Dict.ReadKey (nameView + "rotate" + d);
Data.Object[i0].TT[i1].RF = Dict.ReadKey (nameView + "rotateFrame"+ d);
Data.Object[i0].TT[i1].TF = Dict.ReadKeyUV(nameView + "translateFrame");
Dict.FindValue(out Data.Object[i0].TexTrans[i1].Name, nameView + "name");
Data.Object[i0].TexTrans[i1].Coverage =
Dict.ReadKeyUV(nameView + "coverage" );
Data.Object[i0].TexTrans[i1].Offset =
Dict.ReadKeyUV(nameView + "offset" );
Data.Object[i0].TexTrans[i1].Repeat =
Dict.ReadKeyUV(nameView + "repeat" );
Data.Object[i0].TexTrans[i1]. Rotate =
Dict.ReadKey (nameView + "rotate" + d);
Data.Object[i0].TexTrans[i1]. RotateFrame =
Dict.ReadKey (nameView + "rotateFrame"+ d);
Data.Object[i0].TexTrans[i1].TranslateFrame =
Dict.ReadKeyUV(nameView + "translateFrame");
}
}
@@ -748,36 +752,42 @@ namespace KKdMainLib.A3DA
IO.Write(name + "parent_name=", Data.Object[SOi0].ParentName);
IO.Write(Data.Object[SOi0].MT, name, A3DC, IsX, 0b01100);
if (Data.Object[SOi0].TP != null)
if (Data.Object[SOi0].TexPat != null)
{
nameView = name + "tex_pat" + d;
SO1 = Data.Object[SOi0].TP.Length.SortWriter();
for (i1 = 0; i1 < Data.Object[SOi0].TP.Length; i1++)
SO1 = Data.Object[SOi0].TexPat.Length.SortWriter();
for (i1 = 0; i1 < Data.Object[SOi0].TexPat.Length; i1++)
{
SOi1 = SO1[i1];
IO.Write(nameView + SOi1 + d + "name=" , Data.Object[SOi0].TP[SOi1].Name );
IO.Write(nameView + SOi1 + d + "pat=" , Data.Object[SOi0].TP[SOi1].Pat );
IO.Write(nameView + SOi1 + d + "pat_offset=", Data.Object[SOi0].TP[SOi1].PatOffset);
IO.Write(nameView + SOi1 + d + "name=" , Data.Object[SOi0].TexPat[SOi1].Name );
IO.Write(nameView + SOi1 + d + "pat=" , Data.Object[SOi0].TexPat[SOi1].Pat );
IO.Write(nameView + SOi1 + d + "pat_offset=", Data.Object[SOi0].TexPat[SOi1].PatOffset);
}
IO.Write(nameView + "length=", Data.Object[SOi0].TP.Length);
IO.Write(nameView + "length=", Data.Object[SOi0].TexPat.Length);
}
if (Data.Object[SOi0].TT != null)
if (Data.Object[SOi0].TexTrans != null)
{
SO1 = Data.Object[SOi0].TT.Length.SortWriter();
SO1 = Data.Object[SOi0].TexTrans.Length.SortWriter();
nameView = name + "tex_transform" + d;
for (i1 = 0; i1 < Data.Object[SOi0].TT.Length; i1++)
for (i1 = 0; i1 < Data.Object[SOi0].TexTrans.Length; i1++)
{
SOi1 = SO1[i1];
IO.Write(nameView + SOi1 + d + "name=", Data.Object[SOi0].TT[SOi1].Name);
IO.Write(Data.Object[SOi0].TT[SOi1].C , nameView + SOi1 + d, "coverage" , A3DC);
IO.Write(Data.Object[SOi0].TT[SOi1].O , nameView + SOi1 + d, "offset" , A3DC);
IO.Write(Data.Object[SOi0].TT[SOi1].R , nameView + SOi1 + d, "repeat" , A3DC);
IO.Write(Data.Object[SOi0].TT[SOi1].Ro, nameView + SOi1 + d, "rotate" , A3DC);
IO.Write(Data.Object[SOi0].TT[SOi1].RF, nameView + SOi1 + d, "rotateFrame" , A3DC);
IO.Write(Data.Object[SOi0].TT[SOi1].TF, nameView + SOi1 + d, "translateFrame", A3DC);
IO.Write(nameView + SOi1 + d + "name=", Data.Object[SOi0].TexTrans[SOi1].Name);
IO.Write(Data.Object[SOi0].TexTrans[SOi1].Coverage ,
nameView + SOi1 + d, "coverage" , A3DC);
IO.Write(Data.Object[SOi0].TexTrans[SOi1].Offset ,
nameView + SOi1 + d, "offset" , A3DC);
IO.Write(Data.Object[SOi0].TexTrans[SOi1].Repeat ,
nameView + SOi1 + d, "repeat" , A3DC);
IO.Write(Data.Object[SOi0].TexTrans[SOi1]. Rotate ,
nameView + SOi1 + d, "rotate" , A3DC);
IO.Write(Data.Object[SOi0].TexTrans[SOi1]. RotateFrame,
nameView + SOi1 + d, "rotateFrame" , A3DC);
IO.Write(Data.Object[SOi0].TexTrans[SOi1].TranslateFrame,
nameView + SOi1 + d, "translateFrame", A3DC);
}
IO.Write(nameView + "length=", + Data.Object[SOi0].TT.Length);
IO.Write(nameView + "length=", + Data.Object[SOi0].TexTrans.Length);
}
IO.Write(Data.Object[SOi0].MT, name, A3DC, IsX, 0b00010);
@@ -970,15 +980,15 @@ namespace KKdMainLib.A3DA
for (i0 = 0; i0 < Data.Object.Length; i0++)
{
IO.ReadMT(ref Data.Object[i0].MT, CompressF16);
if (Data.Object[i0].TT != null)
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
if (Data.Object[i0].TexTrans != null)
for (i1 = 0; i1 < Data.Object[i0].TexTrans.Length; i1++)
{
IO.ReadKeyUV(ref Data.Object[i0].TT[i1].C , CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TT[i1].O , CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TT[i1].R , CompressF16);
IO.ReadKey (ref Data.Object[i0].TT[i1].Ro, CompressF16);
IO.ReadKey (ref Data.Object[i0].TT[i1].RF, CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TT[i1].TF, CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TexTrans[i1].Coverage , CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TexTrans[i1].Offset , CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TexTrans[i1].Repeat , CompressF16);
IO.ReadKey (ref Data.Object[i0].TexTrans[i1]. Rotate , CompressF16);
IO.ReadKey (ref Data.Object[i0].TexTrans[i1]. RotateFrame, CompressF16);
IO.ReadKeyUV(ref Data.Object[i0].TexTrans[i1].TranslateFrame, CompressF16);
}
}
@@ -1169,15 +1179,15 @@ namespace KKdMainLib.A3DA
for (i0 = 0; i0 < Data.Object.Length; i0++)
{
Write(ref Data.Object[i0].MT);
if (Data.Object[i0].TT != null)
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
if (Data.Object[i0].TexTrans != null)
for (i1 = 0; i1 < Data.Object[i0].TexTrans.Length; i1++)
{
Write(ref Data.Object[i0].TT[i1].C );
Write(ref Data.Object[i0].TT[i1].O );
Write(ref Data.Object[i0].TT[i1].R );
Write(ref Data.Object[i0].TT[i1].Ro);
Write(ref Data.Object[i0].TT[i1].RF);
Write(ref Data.Object[i0].TT[i1].TF);
Write(ref Data.Object[i0].TexTrans[i1].Coverage );
Write(ref Data.Object[i0].TexTrans[i1].Offset );
Write(ref Data.Object[i0].TexTrans[i1].Repeat );
Write(ref Data.Object[i0].TexTrans[i1]. Rotate );
Write(ref Data.Object[i0].TexTrans[i1]. RotateFrame);
Write(ref Data.Object[i0].TexTrans[i1].TranslateFrame);
}
}
@@ -1251,10 +1261,10 @@ namespace KKdMainLib.A3DA
IO.WriteEndian(Data.Head.BinaryOffset, true);
IO.WriteEndian(Data.Head.BinaryLength, true);
IO.WriteEndian(0x20, true);
if (Data.Header.Format != Main.Format.F)
if (Data.Header.Format > Main.Format.FT)
{
IO.Position = A3DCEnd;
IO.WriteEOFC(0);
IO.WriteEOFC();
}
IO.Close();
@@ -1280,7 +1290,10 @@ namespace KKdMainLib.A3DA
if (Key.Trans != null)
{
Key.BinOffset = IO.Position;
IO.Write(Key.Type);
int Type = Key.Type.Value;
if (Key.EPTypePost.HasValue) Type |= (Key.EPTypePost.Value & 0xF) << 12;
if (Key.EPTypePre .HasValue) Type |= (Key.EPTypePre .Value & 0xF) << 12;
IO.Write(Type);
IO.Write(0x00);
IO.Write((float)Key.Max);
IO.Write(Key.Trans.Length);
@@ -1513,11 +1526,11 @@ namespace KKdMainLib.A3DA
{
Data.MObjectHRC[i0] = new MObjectHRC
{
MT = Temp[i].ReadMT(),
Name = Temp[i].ReadString("Name"),
MT = Temp[i0].ReadMT(),
Name = Temp[i0].ReadString("Name"),
};
if (Temp[i].Element("JointOrient", out MsgPack JointOrient))
if (Temp[i0].Element("JointOrient", out MsgPack JointOrient))
Data.MObjectHRC[i0].JointOrient = new Vector3<double?>
{
X = JointOrient.ReadDouble("X"),
@@ -1525,7 +1538,7 @@ namespace KKdMainLib.A3DA
Z = JointOrient.ReadDouble("Z"),
};
if (Temp[i].ElementArray("Instance", out MsgPack Instance))
if (Temp[i0].ElementArray("Instance", out MsgPack Instance))
{
Data.MObjectHRC[i0].Instance = new Instance[Instance.Array.Length];
for (i1 = 0; i1 < Data.MObjectHRC[i0].Instance.Length; i1++)
@@ -1538,7 +1551,7 @@ namespace KKdMainLib.A3DA
};
}
if (Temp[i].ElementArray("Node", out MsgPack Node))
if (Temp[i0].ElementArray("Node", out MsgPack Node))
{
Data.MObjectHRC[i0].Node = new Node[Temp.Array.Length];
for (i1 = 0; i1 < Data.MObjectHRC[i0].Node.Length; i1++)
@@ -1573,39 +1586,39 @@ namespace KKdMainLib.A3DA
{
Data.Object[i0] = new Object
{
MT = Temp[i].ReadMT(),
Morph = Temp[i].ReadString("Morph" ),
MorphOffset = Temp[i].ReadNInt32("MorphOffset"),
Name = Temp[i].ReadString( "Name"),
ParentName = Temp[i].ReadString( "ParentName"),
UIDName = Temp[i].ReadString( "UIDName"),
MT = Temp[i0].ReadMT(),
Morph = Temp[i0].ReadString("Morph" ),
MorphOffset = Temp[i0].ReadNInt32("MorphOffset"),
Name = Temp[i0].ReadString( "Name"),
ParentName = Temp[i0].ReadString( "ParentName"),
UIDName = Temp[i0].ReadString( "UIDName"),
};
if (Temp[i].ElementArray("TP", out MsgPack TP))
if (Temp[i0].ElementArray("TexturePattern", out MsgPack TexPat))
{
Data.Object[i0].TP = new Object.TexturePattern[TP.Array.Length];
for (i1 = 0; i1 < Data.Object[i0].TP.Length; i1++)
Data.Object[i0].TP[i1] = new Object.TexturePattern
Data.Object[i0].TexPat = new Object.TexturePattern[TexPat.Array.Length];
for (i1 = 0; i1 < Data.Object[i0].TexPat.Length; i1++)
Data.Object[i0].TexPat[i1] = new Object.TexturePattern
{
Name = TP[i1].ReadString("Name" ),
Pat = TP[i1].ReadString("Pat" ),
PatOffset = TP[i1].ReadNInt32("PatOffset"),
Name = TexPat[i1].ReadString("Name" ),
Pat = TexPat[i1].ReadString("Pat" ),
PatOffset = TexPat[i1].ReadNInt32("PatOffset"),
};
}
if (Temp[i].ElementArray("TT", out MsgPack TT))
if (Temp[i0].ElementArray("TextureTransform", out MsgPack TexTrans))
{
Data.Object[i0].TT = new Object.TextureTransform[TT.Array.Length];
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
Data.Object[i0].TT[i1] = new Object.TextureTransform
Data.Object[i0].TexTrans = new Object.TextureTransform[TexTrans.Array.Length];
for (i1 = 0; i1 < Data.Object[i0].TexTrans.Length; i1++)
Data.Object[i0].TexTrans[i1] = new Object.TextureTransform
{
Name = TT[i1].ReadString("Name"),
C = TT[i1].ReadKeyUV ("C" ),
O = TT[i1].ReadKeyUV ("O" ),
R = TT[i1].ReadKeyUV ("R" ),
Ro = TT[i1].ReadKey ("Ro" ),
RF = TT[i1].ReadKey ("RF" ),
TF = TT[i1].ReadKeyUV ("TF" ),
Name = TexTrans[i1].ReadString("Name"),
Coverage = TexTrans[i1].ReadKeyUV("Coverage" ),
Offset = TexTrans[i1].ReadKeyUV("Offset" ),
Repeat = TexTrans[i1].ReadKeyUV("Repeat" ),
Rotate = TexTrans[i1].ReadKey ( "Rotate" ),
RotateFrame = TexTrans[i1].ReadKey ( "RotateFrame"),
TranslateFrame = TexTrans[i1].ReadKeyUV("TranslateFrame"),
};
}
}
@@ -1618,12 +1631,12 @@ namespace KKdMainLib.A3DA
{
Data.ObjectHRC[i0] = new ObjectHRC
{
Name = Temp[i].ReadString ( "Name"),
Shadow = Temp[i].ReadNDouble( "Shadow"),
UIDName = Temp[i].ReadString ("UIDName"),
Name = Temp[i0].ReadString ( "Name"),
Shadow = Temp[i0].ReadNDouble( "Shadow"),
UIDName = Temp[i0].ReadString ("UIDName"),
};
if (Temp[i].Element("JointOrient", out MsgPack JointOrient))
if (Temp[i0].Element("JointOrient", out MsgPack JointOrient))
Data.ObjectHRC[i0].JointOrient = new Vector3<double?>
{
X = JointOrient.ReadDouble("X"),
@@ -1631,7 +1644,7 @@ namespace KKdMainLib.A3DA
Z = JointOrient.ReadDouble("Z"),
};
if (Temp[i].ElementArray("Node", out MsgPack Node))
if (Temp[i0].ElementArray("Node", out MsgPack Node))
{
Data.ObjectHRC[i0].Node = new Node[Node.Array.Length];
for (i1 = 0; i1 < Data.ObjectHRC[i0].Node.Length; i1++)
@@ -1722,27 +1735,24 @@ namespace KKdMainLib.A3DA
{
MsgPack CameraRoot = new MsgPack(Data.CameraRoot.Length, "CameraRoot");
for (i = 0; i < Data.CameraRoot.Length; i++)
{
CameraRoot[i] = MsgPack.New
.Add(null, Data.CameraRoot[i].MT)
.Add("Interest" , Data.CameraRoot[i].Interest )
.Add(new MsgPack("ViewPoint")
.Add(null, Data.CameraRoot[i].ViewPoint.MT)
.Add("Aspect" , Data.CameraRoot[i].ViewPoint.Aspect )
.Add("CameraApertureH", Data.CameraRoot[i].ViewPoint.CameraApertureH)
.Add("CameraApertureW", Data.CameraRoot[i].ViewPoint.CameraApertureW)
.Add("FOVHorizontal" , Data.CameraRoot[i].ViewPoint.FOVHorizontal )
.Add("FocalLength" , Data.CameraRoot[i].ViewPoint.FocalLength )
.Add("FOV" , Data.CameraRoot[i].ViewPoint.FOV )
.Add("Roll" , Data.CameraRoot[i].ViewPoint.Roll ));
}
.Add(Data.CameraRoot[i].MT)
.Add("Interest", Data.CameraRoot[i].Interest)
.Add(new MsgPack("ViewPoint").Add(Data.CameraRoot[i].ViewPoint.MT)
.Add("Aspect" , Data.CameraRoot[i].ViewPoint.Aspect )
.Add("CameraApertureH", Data.CameraRoot[i].ViewPoint.CameraApertureH)
.Add("CameraApertureW", Data.CameraRoot[i].ViewPoint.CameraApertureW)
.Add("FOVHorizontal" , Data.CameraRoot[i].ViewPoint.FOVHorizontal )
.Add("FocalLength" , Data.CameraRoot[i].ViewPoint.FocalLength )
.Add("FOV" , Data.CameraRoot[i].ViewPoint.FOV )
.Add("Roll" , Data.CameraRoot[i].ViewPoint.Roll ));
A3D.Add(CameraRoot);
}
if (Data.Chara != null)
{
MsgPack Chara = new MsgPack(Data.Chara.Length, "Chara");
for (i = 0; i < Data.Curve.Length; i++) Chara[i] = MsgPack.New.Add(null, Data.Chara[i]);
for (i = 0; i < Data.Chara.Length; i++) Chara[i] = MsgPack.New.Add(Data.Chara[i]);
A3D.Add(Chara);
}
@@ -1818,7 +1828,7 @@ namespace KKdMainLib.A3DA
{
MsgPack Instance = new MsgPack(Data.MObjectHRC[i0].Instance.Length, "Instance");
for (i1 = 0; i1 < Data.MObjectHRC[i0].Instance.Length; i1++)
Instance[i1] = MsgPack.New.Add(null, Data.MObjectHRC[i0].Instance[i1].MT)
Instance[i1] = MsgPack.New.Add(Data.MObjectHRC[i0].Instance[i1].MT)
.Add( "Name", Data.MObjectHRC[i0].Instance[i1]. Name)
.Add("Shadow" , Data.MObjectHRC[i0].Instance[i1].Shadow )
.Add("UIDName", Data.MObjectHRC[i0].Instance[i1].UIDName);
@@ -1829,13 +1839,13 @@ namespace KKdMainLib.A3DA
{
MsgPack Node = new MsgPack(Data.MObjectHRC[i0].Node.Length, "Node");
for (i1 = 0; i1 < Data.MObjectHRC[i0].Node.Length; i1++)
Node[i1] = MsgPack.New.Add(null, Data.MObjectHRC[i0].Node[i1].MT)
Node[i1] = MsgPack.New.Add(Data.MObjectHRC[i0].Node[i1].MT)
.Add("Name" , Data.MObjectHRC[i0].Node[i1].Name )
.Add("Parent", Data.MObjectHRC[i0].Node[i1].Parent);
_MObjectHRC.Add(Node);
}
MObjectHRC[i0] = _MObjectHRC.Add(null, Data.MObjectHRC[i0].MT);
MObjectHRC[i0] = _MObjectHRC.Add(Data.MObjectHRC[i0].MT);
}
A3D.Add(MObjectHRC);
}
@@ -1873,33 +1883,34 @@ namespace KKdMainLib.A3DA
MsgPack Object = new MsgPack(Data.Object.Length, "Object");
for (i0 = 0; i0 < Data.Object.Length; i0++)
{
MsgPack _Object = MsgPack.New.Add(null, Data.Object[i0].MT)
MsgPack _Object = MsgPack.New.Add(Data.Object[i0].MT)
.Add("Morph" , Data.Object[i0].Morph )
.Add("MorphOffset", Data.Object[i0].MorphOffset)
.Add( "Name" , Data.Object[i0]. Name )
.Add("ParentName" , Data.Object[i0].ParentName )
.Add( "UIDName" , Data.Object[i0]. UIDName );
if (Data.Object[i0].TP != null)
if (Data.Object[i0].TexPat != null)
{
MsgPack TP = new MsgPack(Data.Object[i0].TP.Length, "TP");
for (i1 = 0; i1 < Data.Object[i0].TP.Length; i1++)
TP[i1] = MsgPack.New.Add("Name" , Data.Object[i0].TP[i1].Name )
.Add("Pat" , Data.Object[i0].TP[i1].Pat )
.Add("PatOffset", Data.Object[i0].TP[i1].PatOffset);
_Object.Add(TP);
MsgPack TexPat = new MsgPack(Data.Object[i0].TexPat.Length, "TexturePattern");
for (i1 = 0; i1 < Data.Object[i0].TexPat.Length; i1++)
TexPat[i1] = MsgPack.New.Add("Name" , Data.Object[i0].TexPat[i1].Name )
.Add("Pat" , Data.Object[i0].TexPat[i1].Pat )
.Add("PatOffset", Data.Object[i0].TexPat[i1].PatOffset);
_Object.Add(TexPat);
}
if (Data.Object[i0].TT != null)
if (Data.Object[i0].TexTrans != null)
{
MsgPack TT = new MsgPack(Data.Object[i0].TT.Length, "TT");
for (i1 = 0; i1 < Data.Object[i0].TT.Length; i1++)
TT[i1] = MsgPack.New.Add("Name", Data.Object[i0].TT[i1].Name)
.Add("C" , Data.Object[i0].TT[i1].C )
.Add("O" , Data.Object[i0].TT[i1].O )
.Add("R" , Data.Object[i0].TT[i1].R )
.Add("Ro" , Data.Object[i0].TT[i1].Ro )
.Add("RF" , Data.Object[i0].TT[i1].RF )
.Add("TF" , Data.Object[i0].TT[i1].TF );
_Object.Add(TT);
MsgPack TexTrans = new MsgPack(Data.Object[i0].TexTrans.Length, "TextureTransform");
for (i1 = 0; i1 < Data.Object[i0].TexTrans.Length; i1++)
TexTrans[i1] = MsgPack.New
.Add("Name" , Data.Object[i0].TexTrans[i1].Name )
.Add("Coverage" , Data.Object[i0].TexTrans[i1].Coverage )
.Add("Offset" , Data.Object[i0].TexTrans[i1].Offset )
.Add("Repeat" , Data.Object[i0].TexTrans[i1].Repeat )
.Add( "Rotate" , Data.Object[i0].TexTrans[i1].Rotate )
.Add( "RotateFrame", Data.Object[i0].TexTrans[i1]. RotateFrame)
.Add("TranslateFrame", Data.Object[i0].TexTrans[i1].TranslateFrame);
_Object.Add(TexTrans);
}
Object[i0] = _Object;
}
@@ -1925,7 +1936,7 @@ namespace KKdMainLib.A3DA
{
MsgPack Node = new MsgPack(Data.ObjectHRC[i0].Node.Length, "Node");
for (i1 = 0; i1 < Data.ObjectHRC[i0].Node.Length; i1++)
Node[i1] = MsgPack.New.Add(null, Data.ObjectHRC[i0].Node[i1].MT)
Node[i1] = MsgPack.New.Add(Data.ObjectHRC[i0].Node[i1].MT)
.Add("Name" , Data.ObjectHRC[i0].Node[i1].Name )
.Add("Parent", Data.ObjectHRC[i0].Node[i1].Parent);
_ObjectHRC.Add(Node);
@@ -1961,7 +1972,7 @@ namespace KKdMainLib.A3DA
{
MsgPack Point = new MsgPack(Data.Point.Length, "Point");
for (i = 0; i < Data.Point.Length; i++)
Point[i] = MsgPack.New.Add(null, Data.Point[i]);
Point[i] = MsgPack.New.Add(Data.Point[i]);
A3D.Add(Point);
}
@@ -2084,10 +2095,10 @@ namespace KKdMainLib.A3DA
public int? Type;
public int? Length;
public int? BinOffset;
public int? EPTypePre;
public int? EPTypePost;
public double? Max;
public double? Value;
public double? EPTypePost;
public double? EPTypePre;
public RawD RawData;
public IKeyFrame<double, double>[] Trans;
@@ -2170,8 +2181,8 @@ namespace KKdMainLib.A3DA
public string UIDName;
public string ParentName;
public ModelTransform MT;
public TexturePattern[] TP; //TexPat
public TextureTransform[] TT; //TexTrans
public TexturePattern[] TexPat;
public TextureTransform[] TexTrans;
public struct TexturePattern
{
@@ -2183,12 +2194,12 @@ namespace KKdMainLib.A3DA
public struct TextureTransform
{
public string Name;
public KeyUV C; //Coverage
public KeyUV O; //Offset
public KeyUV R; //Repeat
public Key Ro; //Rotate
public Key RF; //RotateFrame
public KeyUV TF; //TranslateFrameU
public KeyUV Coverage;
public KeyUV Offset;
public KeyUV Repeat;
public Key Rotate;
public Key RotateFrame;
public KeyUV TranslateFrame;
}
}
+19 -13
View File
@@ -128,7 +128,7 @@ namespace KKdMainLib.A3DA
if (A3DC && !MT.Writed && (Flags & 0b10000) == 0b10000)
{ IO.Write(Temp + MTBO + "=", MT.BinOffset); MT.Writed = true; }
if (A3DC) return;
if (A3DC && !IsX) return;
if ((Flags & 0b01000) == 0b01000) IO.Write(MT.Rot , Temp + "rot" + d, A3DC);
if ((Flags & 0b00100) == 0b00100) IO.Write(MT.Scale , Temp + "scale" + d, A3DC);
@@ -270,9 +270,14 @@ namespace KKdMainLib.A3DA
Key.Value = IO.ReadSingle();
if (Key.Type == 0x0000 || Key.Type == 0x0001) return;
Key.Max = IO.ReadSingle();
Key.Length = IO.ReadInt32 ();
if (Key.Type >> 8 != 0)
{
Key.EPTypePost = (Key.Type >> 12) & 0xF;
Key.EPTypePre = (Key.Type >> 8) & 0xF;
}
Key.Type = Key.Type & 0xFF;
Key.Trans = new IKeyFrame<double, double>[(int)Key.Length];
KeyFrameT3<double, double> Temp;
for (int i = 0; i < Key.Length; i++)
@@ -356,10 +361,10 @@ namespace KKdMainLib.A3DA
{
if (k.Object == null) return null;
Key Key = new Key { EPTypePost = k.ReadNDouble("Post"),
EPTypePre = k.ReadNDouble("Pre"), Max = k.ReadNDouble("M"),
Type = k.ReadNInt32("T"), Value = k.ReadNDouble("V") };
if (k.ReadBoolean("RD")) Key.RawData = new Key.RawD() { KeyType = -1, ValueType = "float" };
Key Key = new Key { EPTypePost = k.ReadNInt32("EPTypePost"),
EPTypePre = k.ReadNInt32("EPTypePre"), Max = k.ReadNDouble("Max"),
Type = k.ReadNInt32("Type"), Value = k.ReadNDouble("Value") };
if (k.ReadBoolean("RawData")) Key.RawData = new Key.RawD() { KeyType = -1, ValueType = "float" };
if (Key.Type == 0) Key.Value = 0.0;
if (Key.Type < 2) return Key;
@@ -401,12 +406,13 @@ namespace KKdMainLib.A3DA
return Key;
}
public static MsgPack Add(this MsgPack MsgPack, string name, ModelTransform MT) =>
name == null ?
public static MsgPack Add(this MsgPack MsgPack, ModelTransform MT) =>
MsgPack.Add("Rot" , MT.Rot )
.Add("Scale" , MT.Scale )
.Add("Trans" , MT.Trans )
.Add("Visibility", MT.Visibility):
.Add("Visibility", MT.Visibility);
public static MsgPack Add(this MsgPack MsgPack, string name, ModelTransform MT) =>
MsgPack.Add(new MsgPack(name).Add("Rot" , MT.Rot )
.Add("Scale" , MT.Scale )
.Add("Trans" , MT.Trans )
@@ -429,12 +435,12 @@ namespace KKdMainLib.A3DA
if (Key == null) return MsgPack;
if (Key.Type == null) return MsgPack;
MsgPack Keys = new MsgPack(name).Add("T", Key.Type);
MsgPack Keys = new MsgPack(name).Add("Type", Key.Type);
if (Key.Trans != null)
{
Keys.Add("M", Key.Max).Add("Post", Key.EPTypePost).Add("Pre", Key.EPTypePre);
Keys = Keys.Add("Max", Key.Max).Add("EPTypePost", Key.EPTypePost).Add("EPTypePre", Key.EPTypePre);
if (Key.RawData.KeyType != null) Keys.Add("RD", true);
if (Key.RawData.KeyType != null) Keys.Add("RawData", true);
MsgPack Trans = new MsgPack(Key.Trans.Length, "Trans");
MsgPack K;
@@ -471,7 +477,7 @@ namespace KKdMainLib.A3DA
}
Keys.Add(Trans);
}
else if (Key.Value != 0) Keys.Add("V", Key.Value);
else if (Key.Value != 0) Keys.Add("Value", Key.Value);
return MsgPack.Add(Keys);
}
+22 -20
View File
@@ -1,6 +1,5 @@
//Original: AetSet.bt Version: 2.0 by samyuu
//using System.Collections.Generic;
using KKdMainLib.IO;
using KKdMainLib.Types;
using KKdMainLib.MessagePack;
@@ -82,7 +81,7 @@ namespace KKdMainLib.Aet
for (i0 = 0; i0 < Aet.Layers[i].Count; i0++, i1++)
{
Aet.Layers[i].Objects[i0] = IO.ReadAetObject();
Aet.Layers[i].ObjectIDs[i0] = i1;
Aet.Layers[i].Objects[i0].ID = i1;
}
}
@@ -230,7 +229,7 @@ namespace KKdMainLib.Aet
bool Found = false;
for (int I = 0; I < Aet.Layers.Count; I++)
for (int I0 = 0; I0 < Aet.Layers.Entries[I].Count; I0++)
if (Aet.Layers.Entries[I].ObjectIDs[I0] == Obj.Pic.Value.ParentObjectID)
if (Aet.Layers[I][I0].ID == Obj.Pic.Value.ParentObjectID)
{
Found = true;
IO.Write(Aet.Layers.Entries[I].Objects[I0].Offset);
@@ -258,7 +257,7 @@ namespace KKdMainLib.Aet
bool Found = false;
for (int I = 0; I < Aet.Layers.Count; I++)
for (int I0 = 0; I0 < Aet.Layers.Entries[I].Count; I0++)
if (Aet.Layers.Entries[I].ObjectIDs[I0] == Obj.Eff.Value.ParentObjectID)
if (Aet.Layers[I][I0].ID == Obj.Eff.Value.ParentObjectID)
{
Found = true;
IO.Write(Aet.Layers.Entries[I].Objects[I0].Offset);
@@ -323,7 +322,7 @@ namespace KKdMainLib.Aet
AET = new AetHeader();
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
if (!MsgPack.ElementArray("Aet", out MsgPack Aet)) { MsgPack = MsgPack.New; return; }
if (!MsgPack.ElementArray("Aet", out MsgPack Aet)) { MsgPack.Dispose(); return; }
if (Aet.Array != null)
if (Aet.Array.Length > 0)
@@ -333,7 +332,7 @@ namespace KKdMainLib.Aet
MsgPackReader(Aet.Array[i], ref AET.Data[i] );
}
MsgPack = MsgPack.New;
MsgPack.Dispose();
}
public void MsgPackWriter(string file, bool JSON)
@@ -385,12 +384,15 @@ namespace KKdMainLib.Aet
i = Aet.Layers.Count - 1;
if (AET.ElementArray("RootLayer", out Temp))
{
Aet.Layers.Entries[i].Objects = new AetObject[Temp.Array.Length];
Aet.Layers.Entries[i].Count = Temp.Array.Length;
for (i0 = 0; i0 < Aet.Layers[i].Count; i0++)
Aet.Layers.Entries[i].Objects[i0].ReadMP(Temp[i0]);
}
else if (AET.Element("RootLayer", out Temp))
{
Aet.Layers.Entries[i].Count = 1;
Aet.Layers.Entries[i].Objects[0].ReadMP(Temp);
}
else return;
AetData.Offset = 0;
@@ -409,12 +411,12 @@ namespace KKdMainLib.Aet
i = Aet.Layers.Count - 1;
if (Aet.Layers[i].Count == 1)
AET.Add(Aet.Layers[i][0].WriteMP(ref Aet, Aet.Layers[i].ObjectIDs[0], "RootLayer"));
AET.Add(Aet.Layers[i][0].WriteMP(ref Aet, "RootLayer"));
if (Aet.Layers[i].Count > 1)
{
MsgPack RootLayer = new MsgPack(Aet.Layers[i].Count, "RootLayer");
for (i0 = 0; i0 < Aet.Layers[i].Count; i0++)
RootLayer[i0] = Aet.Layers[i][i0].WriteMP(ref Aet, Aet.Layers[i].ObjectIDs[i0]);
RootLayer[i0] = Aet.Layers[i][i0].WriteMP(ref Aet);
AET.Add(RootLayer);
}
@@ -458,10 +460,9 @@ namespace KKdMainLib.Aet
public int Count
{
get => Objects != null ? Objects.Length : 0;
set { ObjectIDs = new int[value]; Objects = new AetObject[value]; }
set => Objects = new AetObject[value];
}
public int Offset;
public int[] ObjectIDs;
public AetObject[] Objects;
public void ReadMP(MsgPack msg)
@@ -484,17 +485,17 @@ namespace KKdMainLib.Aet
if (Count < 1)
return MsgPack.New.Add("ID", Id);
else if (Count == 1)
return MsgPack.New.Add("ID", Id).Add(this.Objects[0].WriteMP(ref Aet, ObjectIDs[0], "Object"));
return MsgPack.New.Add("ID", Id).Add(this.Objects[0].WriteMP(ref Aet, "Object"));
MsgPack Objects = new MsgPack(Count, "Objects");
for (int i = 0; i < Count; i++)
Objects[i] = this.Objects[i].WriteMP(ref Aet, ObjectIDs[i]);
Objects[i] = this.Objects[i].WriteMP(ref Aet);
return MsgPack.New.Add("ID", Id).Add(Objects);
}
public AetObject this[int index]
{
get { if (Count > 0) return Objects[index]; return default(AetObject); }
set { if (Count > 0) { Objects[index] = value; } }
get => Count > 0 ? Objects[index] : default;
set { if (Count > 0) { Objects[index] = value; } }
}
public override string ToString() => "Count: " + Count;
@@ -502,6 +503,7 @@ namespace KKdMainLib.Aet
public struct AetObject
{
public int ID;
public int Offset;
public Pointer<string> Name;
public float StartTime0;
@@ -516,8 +518,9 @@ namespace KKdMainLib.Aet
public Pointer<Audio > Aif;
public Pointer<Effect > Eff;
public int ReadMP(MsgPack msg)
public void ReadMP(MsgPack msg)
{
ID = msg.ReadInt32 ("ID" );
Name.Value = msg.ReadString("Name" );
StartTime0 = msg.ReadSingle("StartTime0" );
LoopDuration = msg.ReadSingle("LoopDuration" );
@@ -533,10 +536,9 @@ namespace KKdMainLib.Aet
else if (msg.Element("Eff", out MsgPack Eff))
{ Type = ObjType.Eff; this.Eff.Value.ReadMP(Eff); }
else Type = ObjType.Nop;
return msg.ReadInt32("ID");
}
public MsgPack WriteMP(ref AetData Aet, int ID, string name = null)
public MsgPack WriteMP(ref AetData Aet, string name = null)
{
MsgPack AetObject = new MsgPack(name).Add("ID", ID).Add("Name", Name.Value)
.Add("StartTime0", StartTime0).Add("LoopDuration", LoopDuration)
@@ -602,7 +604,7 @@ namespace KKdMainLib.Aet
for (int i = 0; i < Aet.Layers.Count; i++)
for (int i1 = 0; i1 < Aet.Layers[i].Count; i1++)
if (Aet.Layers[i][i1].Offset == ParentObjectID)
{ Pic.Add("ParentObjectID", Aet.Layers[i].ObjectIDs[i1]); break; }
{ Pic.Add("ParentObjectID", Aet.Layers[i][i1].ID); break; }
if (Marker.Count == 1)
Pic.Add(Marker.Entries[0].WriteMP("Marker"));
@@ -683,7 +685,7 @@ namespace KKdMainLib.Aet
for (int i = 0; i < Aet.Layers.Count; i++)
for (int i1 = 0; i1 < Aet.Layers[i].Count; i1++)
if (Aet.Layers[i][i1].Offset == ParentObjectID)
{ Eff.Add("ParentObjectID", Aet.Layers[i].ObjectIDs[i1]); break; }
{ Eff.Add("ParentObjectID", Aet.Layers[i][i1].ID); break; }
if (Marker.Count == 1)
Eff.Add(Marker[0].WriteMP("Marker"));
+1 -1
View File
@@ -190,7 +190,7 @@ namespace KKdMainLib.DB
public void MsgPackReader(string file, bool JSON)
{
MsgPack MsgPack = file.ReadMP(JSON);
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
if (MsgPack.ElementArray("AetDB", out MsgPack AetDB))
{
+16 -22
View File
@@ -70,8 +70,7 @@ namespace KKdMainLib.DB
{
int[] SO = Category.Length.SortWriter();
for (int i = 0; i < Category.Length; i++)
if (Category[SO[i]] != null)
IO.Write("category." + SO[i] + ".value=", Category[SO[i]]);
IO.Write("category." + SO[i] + ".value=", Category[SO[i]]);
IO.Write("category.length=", Category.Length);
}
@@ -80,16 +79,12 @@ namespace KKdMainLib.DB
int[] SO = _UID.Length.SortWriter();
for (int i = 0; i < _UID.Length; i++)
{
if (_UID[SO[i]].Category != null)
if (_UID[SO[i]].Category != "")
IO.Write("uid." + SO[i] + ".category=", _UID[SO[i]].Category);
if (_UID[SO[i]].OrgUid != null)
IO.Write("uid." + SO[i] + ".org_uid=" , _UID[SO[i]].OrgUid );
if (_UID[SO[i]].Size != null)
IO.Write("uid." + SO[i] + ".size=" , _UID[SO[i]].Size );
if (_UID[SO[i]].Value != null)
if (_UID[SO[i]].Value != "")
IO.Write("uid." + SO[i] + ".value=" , _UID[SO[i]].Value );
if (_UID[SO[i]].Category != "")
IO.Write("uid." + SO[i] + ".category=", _UID[SO[i]].Category);
IO.Write("uid." + SO[i] + ".org_uid=" , _UID[SO[i]].OrgUid );
IO.Write("uid." + SO[i] + ".size=" , _UID[SO[i]].Size );
if (_UID[SO[i]].Value != "")
IO.Write("uid." + SO[i] + ".value=" , _UID[SO[i]].Value );
}
IO.Write("uid.length=", _UID.Length);
}
@@ -99,7 +94,7 @@ namespace KKdMainLib.DB
public void MsgPackReader(string file, bool JSON)
{
MsgPack MsgPack = file.ReadMP(JSON);
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
if (MsgPack.Element("AuthDB", out MsgPack AuthDB))
{
@@ -115,10 +110,10 @@ namespace KKdMainLib.DB
_UID = new UID[Temp.Array.Length];
for (int i = 0; i < _UID.Length; i++)
{
_UID[i].Category = Temp[i].ReadString("C");
_UID[i].OrgUid = Temp[i].ReadNInt32("O");
_UID[i].Size = Temp[i].ReadNInt32("S");
_UID[i].Value = Temp[i].ReadString("V");
_UID[i].Category = Temp[i].ReadString("Category");
_UID[i].OrgUid = Temp[i].ReadNInt32("OrgUid" );
_UID[i].Size = Temp[i].ReadNInt32("Size" );
_UID[i].Value = Temp[i].ReadString("Value" );
}
}
}
@@ -140,11 +135,10 @@ namespace KKdMainLib.DB
{
MsgPack UID = new MsgPack(_UID.Length, "UID");
for (int i = 0; i < _UID.Length; i++)
UID[i] = MsgPack.New
.Add("C", _UID[i].Category)
.Add("O", _UID[i].OrgUid )
.Add("S", _UID[i].Size )
.Add("V", _UID[i].Value );
UID[i] = MsgPack.New.Add("Category", _UID[i].Category)
.Add("OrgUid" , _UID[i].OrgUid )
.Add("Size" , _UID[i].Size )
.Add("Value" , _UID[i].Value );
AuthDB.Add(UID);
}
+1 -21
View File
@@ -15,26 +15,6 @@ namespace KKdMainLib.DB
public void BINReader(string file)
{
/*Stream IO0 = File.OpenReader(file + "0.bin");
Stream IO1 = File.OpenReader(file + "1.bin");
List<int> _0 = new List<int>();
List<int> _1 = new List<int>();
IO0.Position = 0x20;
for (i = 0; i < 124; i++)
{ _0.Add(IO0.ReadInt32()); IO0.LongPosition += 8; }
IO1.Position = 0x20;
for (i = 0; i < 124; i++)
{ _1.Add(IO1.ReadInt32()); IO1.LongPosition += 8; }
IO0.Close();
IO1.Close();
IO = File.OpenWriter(@"F:\Source\MikuMikuModel\DatabaseConverter\msgpack-json-tools\aet_gam_pv643.bin");
IO.Position = 0x10;
for (i = 0; i < 108; i++)
{ IO.ReadInt32(); i1 = _1[_0.IndexOf(IO.ReadInt32())]; IO.Position -= 4; IO.Write(i1); }
IO.Close();*/
IO = File.OpenReader(file + ".bin");
int spriteSetsLength = IO.ReadInt32();
@@ -247,7 +227,7 @@ namespace KKdMainLib.DB
public void MsgPackReader(string file, bool JSON = false)
{
MsgPack MsgPack = file.ReadMP(JSON);
MsgPack MsgPack = file.ReadMPAllAtOnce(JSON);
if (MsgPack.ElementArray("SprDB", out MsgPack SprDB))
{
+6 -12
View File
@@ -109,19 +109,15 @@ namespace KKdMainLib
IO.Write(0x64);
IO.Write(Dex.Length);
if (Header.IsX) IO.Write((long)0x28);
else IO.Write( 0x20);
if (Header.IsX) IO.Write((long)0x00);
else IO.Write( 0x00);
IO.WriteX(Header.IsX ? 0x28 : 0x20);
IO.WriteX(0x00);
int Position0 = IO.Position;
IO.Write((long)0x00);
IO.Write((long)0x00);
for (int i = 0; i < Dex.Length * 3; i++)
if (Header.IsX) IO.Write((long)0x00);
else IO.Write( 0x00);
for (int i = 0; i < Dex.Length * 3; i++) IO.WriteX(0x00);
IO.Align(0x20, true);
@@ -156,8 +152,7 @@ namespace KKdMainLib
}
IO.Align(0x10, true);
if (Header.IsX) IO.Seek(Header.Lenght + 0x28, 0);
else IO.Seek(Header.Lenght + 0x20, 0);
IO.Position = Header.Lenght + (Header.IsX ? 0x28 : 0x20);
for (int i0 = 0; i0 < Dex.Length; i0++)
{
IO.Write(Dex[i0].MainOffset);
@@ -172,8 +167,7 @@ namespace KKdMainLib
if (Header.IsX) IO.Write(0x00);
}
if (Header.IsX) IO.Seek(Position0 - 8, 0);
else IO.Seek(Position0 - 4, 0);
IO.Position = Position0 - (Header.IsX ? 8 : 4);
IO.Write(Position1);
if (IO.Format > Main.Format.F)
+3 -1
View File
@@ -7,7 +7,9 @@ namespace KKdMainLib
{
public static class DIVAFILE
{
private static readonly byte[] Key = "file access deny".ToASCII();
private static readonly byte[] Key = new byte[]
{ 0x66, 0x69, 0x6C, 0x65, 0x20, 0x61, 0x63, 0x63,
0x65, 0x73, 0x73, 0x20, 0x64, 0x65, 0x6E, 0x79 };
public static void Decrypt(this string file)
{
+9 -9
View File
@@ -49,12 +49,12 @@ namespace KKdMainLib
IO = File.OpenWriter();
if (file.Contains("psrData"))
for (i = 0; i < psrDat.Length; i++)
IO.Write(psrDat[i].ToString() + ",");
IO.Write(psrDat[i].ToString() + c);
else if (file.Contains("PvList"))
if (pvList.Length != 0)
for (i = 0; i < pvList.Length; i++)
IO.Write(UrlEncode(pvList[i].ToString() +
((i + 1 != pvList.Length) ? "," : "")));
((i + 1 != pvList.Length) ? c : "")));
else IO.Write("%2A%2A%2A");
@@ -143,7 +143,7 @@ namespace KKdMainLib
.Add(p2.WriteMP("P2")).Add(p3.WriteMP("P3"));
public override string ToString() =>
UrlEncode(p1.ToString() + "," + p2.ToString() + "," + p3.ToString() + "," + PV_ID);
UrlEncode(p1.ToString() + c + p2.ToString() + c + p3.ToString() + c + PV_ID);
}
public struct Player
@@ -200,9 +200,9 @@ namespace KKdMainLib
.Add("Score" , Score0).Add("Name" , Name0);
public override string ToString() =>
(Score0 + (Has2P ? ("." + Score1) : "") + "," + UrlEncode(Name0) +
(Has2P ? ("xxx" + UrlEncode(Name1)) : "") + "," +
Diff + "," + (Has2P ? "0.1" : "0")).Replace("*", "%2A");
(Score0 + (Has2P ? (d + Score1) : "") + c + UrlEncode(Name0) +
(Has2P ? ("xxx" + UrlEncode(Name1)) : "") + c +
Diff + c + (Has2P ? "0.1" : "0")).Replace("*", "%2A");
}
public struct PvList
@@ -277,9 +277,9 @@ namespace KKdMainLib
}
public override string ToString() =>
UrlEncode(PV_ID + "," + (Enable ? 1 : 0) + "," + (Extra ? 1 : 0) + "," +
AdvDemoStart.ToString() + "," + AdvDemoEnd.ToString() + "," +
StartShow.ToString() + "," + EndShow.ToString());
UrlEncode(PV_ID + c + (Enable ? 1 : 0) + c + (Extra ? 1 : 0) + c +
AdvDemoStart.ToString() + c + AdvDemoEnd.ToString() + c +
StartShow.ToString() + c + EndShow.ToString());
}
public struct Date
+17 -20
View File
@@ -1,6 +1,5 @@
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
using System;
using System.IO.Compression;
using System.Security.Cryptography;
using KKdMainLib.IO;
@@ -45,15 +44,13 @@ namespace KKdMainLib
private FARC HeaderReader()
{
NewFARC();
Console.Title = "FARC Extractor - Archive: " + Path.GetFileName(FilePath);
if (!File.Exists(FilePath))
{ Console.WriteLine("File {0} doesn't exist.", Path.GetFileName(FilePath)); return this; }
if (!File.Exists(FilePath)) return this;
Stream reader = File.OpenReader(FilePath);
DirectoryPath = Path.GetFullPath(FilePath).Replace(Path.GetExtension(FilePath), "");
Signature = (Farc)reader.ReadInt32Endian(true);
if (Signature != Farc.FArc && Signature != Farc.FArC && Signature != Farc.FARC)
{ Console.WriteLine("Unknown signature"); reader.Close(); return this; }
{ reader.Close(); return this; }
int HeaderLength = reader.ReadInt32Endian(true);
if (Signature == Farc.FARC)
@@ -157,11 +154,10 @@ namespace KKdMainLib
cryptoStream.Read(Files[i].Data, 0, FileSize);
Files[i].Data = SkipData(Files[i].Data, 0x10);
}
else if (Files[i].Type.HasFlag(Type.ECB))
else
using (CryptoStream cryptoStream = new CryptoStream(stream,
GetAes(false, null).CreateDecryptor(), CryptoStreamMode.Read))
cryptoStream.Read(Files[i].Data, 0, FileSize);
else stream.Read(Files[i].Data, 0, FileSize);
Encrypted = true;
}
@@ -209,19 +205,24 @@ namespace KKdMainLib
return SkipData;
}
public void Pack()
public FARC Pack()
{
NewFARC();
string[] files = Directory.GetFiles(DirectoryPath);
Files = new FARCFile[files.Length];
for (int i = 0; i < files.Length; i++)
Files[i] = new FARCFile { Name = Path.GetFileName(files[i]), Data = File.ReadAllBytes(files[i]) };
files = null;
return this;
}
public void CompressStuff()
{
for (int i = 0; i < Files.Length; i++)
{
Files[i] = new FARCFile { Name = files[i] };
string ext = Path.GetExtension(files[i]).ToLower();
string ext = Path.GetExtension(Files[i].Name).ToLower();
if (ext == ".a3da" || ext == ".diva" || ext == ".vag") Signature = Farc.FArc;
}
files = null;
Stream writer = File.OpenWriter(DirectoryPath + ".farc", true);
writer.WriteEndian((int)Signature, true);
@@ -233,7 +234,7 @@ namespace KKdMainLib
{
HeaderWriter.WriteEndian((int)FARCType, true);
HeaderWriter.Write (0x00);
HeaderWriter.WriteEndian(0x40 , true);
HeaderWriter.WriteEndian(0x40, true);
HeaderWriter.Write (0x00);
}
int HeaderPartLength = Signature == Farc.FArc ? 0x09 : 0x0D;
@@ -245,14 +246,12 @@ namespace KKdMainLib
int Align = writer.Position.Align(0x10) - writer.Position;
for (int i1 = 0; i1 < Align; i1++)
if (Signature == Farc.FArc) writer.WriteByte(0x00);
else writer.WriteByte(0x78);
writer.WriteByte((byte)(Signature == Farc.FArc ? 0x00 : 0x78));
for (int i = 0; i < Files.Length; i++)
CompressStuff(i, ref Files, ref writer);
if (Signature == Farc.FARC) writer.Position = 0x1C;
else writer.Position = 0x0C;
writer.Position = Signature == Farc.FARC ? 0x1C : 0x0C;
for (int i = 0; i < Files.Length; i++)
{
writer.Write(Path.GetFileName(Files[i].Name) + "\0");
@@ -267,7 +266,6 @@ namespace KKdMainLib
private void CompressStuff(int i, ref FARCFile[] Files, ref Stream writer)
{
Files[i].Offset = writer.Position;
Files[i].Data = File.ReadAllBytes(Files[i].Name);
Files[i].SizeUnc = Files[i].Data.Length;
Files[i].Type = Type.None;
@@ -299,8 +297,7 @@ namespace KKdMainLib
{
int Align = writer.Position.Align(0x20) - writer.Position;
for (int i1 = 0; i1 < Align; i1++)
if (Signature == Farc.FArc) writer.WriteByte(0x00);
else writer.WriteByte(0x78);
writer.WriteByte((byte)(Signature == Farc.FArc ? 0x00 : 0x78));
}
}
+7
View File
@@ -43,6 +43,13 @@ namespace KKdMainLib.IO
public static long ReadIntX(this Stream stream, bool IsBE) => stream.IsX ?
stream.ReadInt64() : stream.ReadUInt32Endian(IsBE);
public static void WriteX(this Stream stream, long val)
{ if (stream.IsX) stream.Write ( val);
else stream.WriteEndian((int)val); }
public static void WriteX(this Stream stream, long val, bool IsBE)
{ if (stream.IsX) stream.Write ( val );
else stream.WriteEndian((int)val, IsBE); }
public static byte[] ReadAtOffset(this Stream stream, long Offset = 0, long Length = 0)
{
byte[] arr = null;
+3 -3
View File
@@ -28,9 +28,9 @@ namespace KKdMainLib.IO
public uint UIntOffset { get => (uint)LongOffset; set => LongOffset = value; }
public long LongOffset;
public int Length { get => ( int)stream.Length; set => stream.SetLength(value); }
public uint UIntLength { get => (uint)stream.Length; set => stream.SetLength(value); }
public long LongLength { get => stream.Length; set => stream.SetLength(value); }
public int Length { get => ( int)stream.Length - Offset; set => stream.SetLength(value + Offset); }
public uint UIntLength { get => (uint)stream.Length - UIntOffset; set => stream.SetLength(value + UIntOffset); }
public long LongLength { get => stream.Length - LongOffset; set => stream.SetLength(value + LongOffset); }
public int Position
{ get => ( int)stream.Position - Offset; set => stream.Position = value + Offset; }
+4
View File
@@ -22,6 +22,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +35,8 @@
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="A3DA\A3DAExt.cs" />
+10 -13
View File
@@ -80,6 +80,7 @@ namespace KKdMainLib
OpenFileDialog ofd = new OpenFileDialog { InitialDirectory = Application.StartupPath,
Multiselect = true, Title = "Choose file(s) to open:" };
ofd.Filter = GetArgs("All;", false, "*");
if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "json", "mp") +
GetArgs("A3DA", true, "a3da") + JSON + MsgPack;
else if (filetype == "bin" ) ofd.Filter = GetArgs("BIN" , "bin", "json", "mp") +
@@ -106,7 +107,6 @@ namespace KKdMainLib
GetArgs("STR", true, "str") + BIN + JSON + MsgPack;
else if (filetype == "vag" ) ofd.Filter = GetArgs("VAG", "vag", "wav") +
GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav");
else ofd.Filter = GetArgs("All;", false, "*");
if (ofd.ShowDialog() == DialogResult.OK)
FileNames = ofd.FileNames;
@@ -122,7 +122,7 @@ namespace KKdMainLib
return "";
}
public static void ChooseSave(int code, string filetype,
public static void ChooseSave(string filetype,
out string InitialDirectory, out string[] FileNames)
{
InitialDirectory = "";
@@ -179,24 +179,21 @@ namespace KKdMainLib
}
public static bool FindValue(this Dictionary<string, object> Dict,
ref bool value, char Split, string args)
{ if (Dict.FindValue(out string val, args.Split(Split)))
return bool.TryParse(val, out value); return false; }
ref bool value, char Split, string args) =>
Dict.FindValue(out string val, args.Split(Split)) ? bool.TryParse(val, out value) : false;
public static bool FindValue(this Dictionary<string, object> Dict,
ref int value, char Split, string args)
{ if (Dict.FindValue(out string val, args.Split(Split)))
return int.TryParse(val, out value); return false; }
ref int value, char Split, string args) =>
Dict.FindValue(out string val, args.Split(Split)) ? int.TryParse(val, out value) : false;
public static bool FindValue(this Dictionary<string, object> Dict,
ref double value, char Split, string args)
{ if (Dict.FindValue(out string val, args.Split(Split)))
return val.ToDouble(out value); return false; }
ref double value, char Split, string args) =>
Dict.FindValue(out string val, args.Split(Split)) ? val.ToDouble( out value) : false;
public static bool FindValue(this Dictionary<string, object> Dict,
ref string value, char Split, string args)
{ if (Dict.FindValue(out string val, args.Split(Split)))
{ value = val; return true; } return false; }
{ value = val; return true; } return false; }
public static bool FindValue(this Dictionary<string, object> Dict,
out bool value, string args)
@@ -217,7 +214,7 @@ namespace KKdMainLib
out int? value, string args)
{ if (Dict.FindValue(out string val, args.Split('.' )))
{ bool Val = int.TryParse(val, out int _value);
value = _value; return Val; } value = null; return false; }
value = _value; return Val; } value = null; return false; }
public static bool FindValue(this Dictionary<string, object> Dict,
out double? value, string args)
+38 -8
View File
@@ -4,13 +4,45 @@ namespace KKdMainLib
{
public static class MathExtensions
{
public static void FloorCeiling(ref double Value)
{ if (Value % 1 >= 0.5) Value = (long)(Value + 0.5);
else Value = (long) Value; }
private const double RadPi = 180 / Math.PI;
public static double ToDegrees(this double val) => val * RadPi;
public static double ToRadians(this double val) => val / RadPi;
public static long FloorCeiling(this double Value)
{ if (Value % 1 >= 0.5) return (long)(Value + 0.5);
else return (long) Value; }
public static double Acos (this double d ) => Math.Acos (d );
public static double Asin (this double d ) => Math.Asin (d );
public static double Atan (this double d ) => Math.Atan (d );
public static double Aсtg (this double d ) => 1 / Math.Atan (d );
public static double Cos (this double d ) => Math.Cos (d );
public static double Cosh (this double val) => Math.Cosh (val);
public static double Sin (this double a ) => Math.Sin (a );
public static double Sinh (this double val) => Math.Sinh (val);
public static double Tan (this double a ) => Math.Tan (a );
public static double Tanh (this double val) => Math.Tanh (val);
public static double Ctg (this double a ) => 1 / Math.Tan (a );
public static double Ctgh (this double val) => 1 / Math.Tanh (val);
public static double Abs (this double val) => Math.Abs (val);
public static double Ceiling(this double a ) => Math.Ceiling(a );
public static double Exp (this double d ) => Math.Exp (d );
public static double Log (this double d ) => Math.Log (d );
public static double Log10 (this double d ) => Math.Log10 (d );
public static double Round (this double d ) => Math.Round (d );
public static int Sign (this double val) => Math.Sign (val);
public static double Sqrt (this double d ) => Math.Sqrt (d );
public static double Atan2(this double y , double x ) => Math.Atan2(y , x );
public static double Log (this double val , double newBase) => Math.Log (val , newBase);
public static double Max (this double val1, double val2 ) => Math.Max (val1, val2 );
public static double Min (this double val1, double val2 ) => Math.Min (val1, val2 );
public static double Pow (this double x , double y ) => Math.Pow (x , y );
public static double Round(this double val , int d ) => Math.Round(val , d );
public static void FloorCeiling( ref double Value) =>
Value = Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long) Value;
public static long FloorCeiling(this double Value) =>
Value % 1 >= 0.5 ? (long)(Value + 0.5) : (long) Value;
public static int Align(this int value, int alignement, int divide = 1) =>
((value % alignement == 0) ? value : (value + alignement - value % alignement)) / divide;
@@ -160,8 +192,6 @@ namespace KKdMainLib
else if (c < 0x00000000) c = 0x00000000;
return (uint)c;
}
public static double Round(this double c, int d = 0) => Math.Round(c, d);
public static unsafe sbyte* GetPtr(this sbyte[] array)
{ sbyte* Ptr; fixed ( sbyte* tempPtr = array) Ptr = tempPtr; return Ptr; }
+1 -1
View File
@@ -131,7 +131,7 @@ namespace KKdMainLib.MessagePack
int Length = 0;
if (Type == Types.Str8 ) Length = _IO.ReadByte();
else if (Type == Types.Str16) Length = _IO.ReadInt16Endian(true);
else Length = _IO.ReadInt32Endian(true);
else Length = _IO.ReadInt32Endian(true);
return _IO.ReadString(Length);
}
return null;
-2
View File
@@ -18,8 +18,6 @@ namespace KKdMainLib.MessagePack
public MsgPack Read() => ReadValue();
private string ReadKey() => ReadString();
private MsgPack ReadValue(string Key = null)
{
char c = _IO.SkipWhitespace().PeekCharUTF8();
+9 -18
View File
@@ -8,10 +8,8 @@ namespace KKdMainLib.MessagePack
public string Name;
public object Object;
public MsgPack[] Array => Object is MsgPack[] List ?
List : null;
public KKdList<MsgPack> List => Object is KKdList<MsgPack> List ?
List : default(KKdList<MsgPack>);
public MsgPack[] Array => Object is MsgPack[] List ? List : null;
public KKdList<MsgPack> List => Object is KKdList<MsgPack> List ? List : default;
public static MsgPack New => new MsgPack { Object = KKdList<MsgPack>.New };
public static MsgPack NewReserve(int Capacity) =>
@@ -21,8 +19,7 @@ namespace KKdMainLib.MessagePack
{ Object = KKdList<MsgPack>.New; this.Name = Name; }
public MsgPack(long Count, string Name = null)
{ if (Count > 0) { Object = new MsgPack[Count]; }
else Object = null; this.Name = Name; }
{ Object = Count > 0 ? new MsgPack[Count] : null; this.Name = Name; }
public MsgPack(string Name, object Object)
{ this.Name = Name; this.Object = Object; }
@@ -30,8 +27,8 @@ namespace KKdMainLib.MessagePack
public static MsgPack Null => new MsgPack();
public MsgPack this[int index]
{ get { if (Object is MsgPack[] Array) return Array[index]; return default(MsgPack); }
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
{ get => Object is MsgPack[] Array ? Array[index] : default;
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
public MsgPack Add(MsgPack obj)
{ if (Object is KKdList<MsgPack> List) { List.Add(obj); Object = List; } return this; }
@@ -44,7 +41,8 @@ namespace KKdMainLib.MessagePack
public override string ToString() => Name ?? "" +
(List. NotNull ? ((Name != null ? " " : "") + "Elements Count: " + List .Count ) :
(Array != null ? ((Name != null ? " " : "") + "Elements Count: " + Array.Length) : Object.ToString()));
(Array != null ? ((Name != null ? " " : "") + "Elements Count: " + Array.Length) :
Object.ToString()));
public static explicit operator MsgPack(byte[] val) => new MsgPack(null, val);
public static explicit operator MsgPack(string val) => new MsgPack(null, val);
@@ -232,15 +230,8 @@ namespace KKdMainLib.MessagePack
public string ReadString()
{ if (Object is string String) return String; return null; }
public bool ElementArray(string Name, out MsgPack MsgPack)
{
if (Element(Name, out MsgPack))
{
if (MsgPack.Array == null) return false;
return true;
}
return false;
}
public bool ElementArray(string Name, out MsgPack MsgPack) =>
Element(Name, out MsgPack) ? MsgPack.Array != null : false;
public bool Element(string Name, out MsgPack MsgPack)
{
-200
View File
@@ -1,200 +0,0 @@
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
using KKdMainLib.IO;
using KKdMainLib.Types;
using KKdMainLib.MessagePack;
namespace KKdMainLib
{
public class Mot
{
private int i, i0, i1;
private Stream IO;
public Mot()
{ i = i0 = i1 = 0; IO = null; }
public unsafe void MOTReader(string file, bool JSON)
{
IO = File.OpenReader(file + ".bin");
i = 0;
while (true)
{
if (IO.ReadInt32() == 0) break;
IO.ReadInt32();
IO.ReadInt32();
IO.ReadInt32();
i++;
}
if (i == 0) return;
int MOTCount = i;
MsgPack m = new MsgPack(MOTCount, "Mot");
MotHeader[] MMOT = new MotHeader[MOTCount];
for (i = 0; i < MOTCount; i++)
{
ref MotHeader Mot = ref MMOT[i];
IO.Position = 0x10 * i;
Mot. KeySet.Offset = IO.ReadInt32();
Mot.KeySetTypesOffset = IO.ReadInt32();
Mot. KeySetOffset = IO.ReadInt32();
Mot. BoneInfo.Offset = IO.ReadInt32();
i0 = 1;
IO.Position = Mot.BoneInfo.Offset;
IO.ReadUInt16();
while (true) { if (IO.ReadUInt16() == 0) break; i0++; }
Mot.BoneInfo.Value = new BoneInfo[i0];
IO.Position = Mot.BoneInfo.Offset;
for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++)
Mot.BoneInfo.Value[i0].Id = IO.ReadUInt16();
IO.Position = Mot.KeySet.Offset;
int info = IO.ReadUInt16();
Mot.HighBits = info >> 14;
Mot.FrameCount = IO.ReadUInt16();
Mot.KeySet.Value = new KeySet[info & 0x3FFF];
IO.Position = Mot.KeySetTypesOffset;
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
{
if (i0 % 8 == 0) i1 = IO.ReadUInt16();
Mot.KeySet.Value[i0] = new KeySet
{ Type = (KeySetType)((i1 >> (i0 % 8 * 2)) & 3) };
}
IO.Position = Mot.KeySetOffset;
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
Mot.KeySet.Value[i0].Read(IO);
m[i] = MsgPackWriter(ref MMOT[i]);
m[i].Write(true, file + "." + i.ToString("d2"), JSON);
}
IO.Close();
//for (i = 0; i < MOTCount; i++)
// m[i] = MsgPackWriter(ref MMOT[i]);
m.Write(true, file, JSON);
MMOT = null;
m = new MsgPack();
System.GC.Collect();
}
public MsgPack MsgPackWriter(ref MotHeader Mot)
{
MsgPack MOT = MsgPack.NewReserve(3).Add("FrameCount", Mot.FrameCount).Add("HighBits", Mot.HighBits);
MsgPack KeySets = new MsgPack(Mot.KeySet.Value.Length, "KeySets");
for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++)
{
ref KeySet KeySet = ref Mot.KeySet.Value[i0];
if (KeySet.Type != KeySetType.None)
{
MsgPack keySet = MsgPack.NewReserve(2).Add("T", KeySet.Type.ToString());
if (KeySet.Type == KeySetType.Interpolated)
{
MsgPack Keys = new MsgPack(KeySet.Keys.Length, "K");
for (i1 = 0; i1 < KeySet.Keys.Length; i1++)
if (KeySet.Keys[i1] is KeyFrameT0<ushort, float> KeyT0)
Keys[i1] = MsgPack.NewReserve(1).Add("F", KeyT0.Frame);
else if (KeySet.Keys[i1] is KeyFrameT1<ushort, float> KeyT1)
Keys[i1] = MsgPack.NewReserve(2).Add("F", KeyT1.Frame).Add("V", KeyT1.Value);
else if (KeySet.Keys[i1] is KeyFrameT2<ushort, float> KeyT2)
Keys[i1] = MsgPack.NewReserve(3).Add("F", KeyT2.Frame).Add("V",
KeyT2.Value).Add("I", KeyT2.Interpolation);
keySet.Add(Keys);
}
else if(KeySet.Type == KeySetType.Linear)
{
MsgPack Keys = new MsgPack(KeySet.Keys.Length, "K");
for (i1 = 0; i1 < KeySet.Keys.Length; i1++)
if (KeySet.Keys[i1] is KeyFrameT0<ushort, float> KeyT0)
Keys[i1] = MsgPack.NewReserve(1).Add("F", KeyT0.Frame);
else if (KeySet.Keys[i1] is KeyFrameT1<ushort, float> KeyT1)
Keys[i1] = MsgPack.NewReserve(2).Add("F", KeyT1.Frame).Add("V", KeyT1.Value);
keySet.Add(Keys);
}
else if (KeySet.Type == KeySetType.Static)
if (KeySet.Keys[0] is KeyFrameT1<ushort, float> Key) keySet.Add("K", Key.Value);
KeySets[i0] = keySet;
}
}
MOT.Add(KeySets);
MsgPack BoneInfo = new MsgPack(Mot.BoneInfo.Value.Length, "BoneInfo");
for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++)
BoneInfo[i0] = (MsgPack)Mot.BoneInfo.Value[i0].Id;
MOT.Add(BoneInfo);
return MOT;
}
public struct MotHeader
{
public int KeySetOffset;
public int KeySetTypesOffset;
public Pointer< KeySet []> KeySet ;
public Pointer<BoneInfo[]> BoneInfo;
public int HighBits;
public int FrameCount;
}
public struct KeySet
{
public IKeyFrame<ushort, float>[] Keys;
public KeySetType Type;
public void Read(Stream IO)
{
if (Type == KeySetType.None ) return;
else if (Type == KeySetType.Static) { Keys = new IKeyFrame<ushort, float>[]
{ new KeyFrameT1<ushort, float> { Value = IO.ReadSingle() } }; return; }
Keys = new IKeyFrame<ushort, float>[IO.ReadUInt16()];
if (Type == KeySetType.Interpolated)
{
for (int i = 0; i < Keys.Length; i++)
Keys[i] = new KeyFrameT2<ushort, float>{ Frame = IO.ReadUInt16() };
IO.Align(0x4);
for (int i = 0; i < Keys.Length; i++)
if (Keys[i] is KeyFrameT2<ushort, float> Key)
{
Key.Value = IO.ReadSingle();
Key.Interpolation = IO.ReadSingle();
Keys[i] = Key.Check();
}
}
else
{
for (int i = 0; i < Keys.Length; i++)
Keys[i] = new KeyFrameT1<ushort, float> { Frame = IO.ReadUInt16() };
IO.Align(0x4);
for (int i = 0; i < Keys.Length; i++)
if (Keys[i] is KeyFrameT1<ushort, float> Key)
{ Key.Value = IO.ReadSingle(); Keys[i] = Key; }
}
}
}
public enum KeySetType : byte
{
None = 0b00,
Static = 0b01,
Linear = 0b10,
Interpolated = 0b11,
}
public struct BoneInfo
{
public string Name;
public int Id;
}
}
}
+5 -5
View File
@@ -20,8 +20,8 @@ namespace KKdMainLib
public static PDHead ReadHeader(this Stream stream, bool Seek)
{
if (Seek)
if (stream.Position >= 4) stream.Seek(-4, SeekOrigin.Current);
else stream.Seek( 0, 0);
if (stream.Position >= 4) stream.LongPosition -= 4;
else stream.LongPosition = 0;
return stream.ReadHeader();
}
@@ -55,9 +55,9 @@ namespace KKdMainLib
stream.Write(0x00);
}
public static void WriteEOFC(this Stream stream, int ID)
{ PDHead Header = new PDHead { Format = Main.Format.F2LE, ID = ID,
Lenght = 0x20, Signature = 0x43464F45, }; stream.Write(Header); }
public static void WriteEOFC(this Stream stream, int ID = 0) =>
stream.Write(new PDHead { Format = Main.Format.F2LE, ID = ID,
Lenght = 0x20, Signature = 0x43464F45, });
}
}
+5 -11
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using KKdMainLib.IO;
namespace KKdMainLib
@@ -69,7 +68,7 @@ namespace KKdMainLib
for (int i = 0; i < POF.Offsets.Count && i < POF.POFOffsets.Count; i++)
if (POF.Offsets[i] != POF.POFOffsets[i])
Console.WriteLine("Not right POF{0} offset table.\n" +
System.Console.WriteLine("Not right POF{0} offset table.\n" +
" Expected: {1}\n Got: {2}", POF.Type,
POF.Offsets[i].ToString("X8"), POF.POFOffsets[i].ToString("X8"));
}
@@ -113,18 +112,13 @@ namespace KKdMainLib
stream.WriteEOFC(ID);
}
public static long ReadUInt32Endian(this Stream IO, ref POF POF) =>
IO.GetOffset(ref POF).ReadUInt32Endian();
public static long ReadUInt32Endian(this Stream IO, ref POF POF ) =>
IO.GetOffset(ref POF).ReadUInt32Endian( );
public static long ReadUInt32Endian(this Stream IO, ref POF POF, bool IsBE) =>
IO.GetOffset(ref POF).ReadUInt32Endian(IsBE);
public static long ReadInt64(this Stream IO, ref POF POF) =>
public static long ReadInt64 (this Stream IO, ref POF POF) =>
IO.GetOffset(ref POF).ReadInt64();
public static long ReadIntX(this Stream IO, ref POF POF ) =>
IO.IsX ? IO.ReadInt64() : IO.ReadUInt32Endian( );
public static long ReadIntX(this Stream IO, ref POF POF, bool IsBE) =>
IO.IsX ? IO.ReadInt64() : IO.ReadUInt32Endian(IsBE);
public static string ReadStringAtOffset(this Stream IO, ref POF POF, long Offset = 0, long Length = 0) =>
IO.GetOffset(ref POF).ReadStringAtOffset(Offset, Length);
}
+3 -3
View File
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("KKdMainLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT files")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KKdMainLib")]
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("2BA7EFC6-91D1-8BBC-C487-06C7F36CC789")]
[assembly: AssemblyVersion("0.4.6.1")]
[assembly: AssemblyFileVersion("0.4.6.1")]
[assembly: AssemblyVersion("0.4.6.2")]
[assembly: AssemblyFileVersion("0.4.6.2")]
+8 -11
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using KKdMainLib.IO;
using KKdMainLib.IO;
using KKdMainLib.Types;
using KKdMainLib.MessagePack;
using MPIO = KKdMainLib.MessagePack.IO;
namespace KKdMainLib
{
@@ -112,17 +110,16 @@ namespace KKdMainLib
writer.GetOffset(ref POF).Write(0x00);
writer.WriteEndian(STRs[i].ID);
}
writer.Align(16);
writer.Align(0x10);
}
else
{
for (int i = 0; i < Count; i++)
writer.Write(0x00);
writer.Align(32);
for (int i = 0; i < Count; i++) writer.Write(0x00);
writer.Align(0x20);
}
List<string> UsedSTR = new List<string>();
List<int> UsedSTRPos = new List<int>();
KKdList<string> UsedSTR = KKdList<string>.New;
KKdList<int> UsedSTRPos = KKdList<int>.New;
int[] STRPos = new int[Count];
for (int i1 = 0; i1 < Count; i1++)
{
@@ -143,7 +140,7 @@ namespace KKdMainLib
}
if (writer.Format > Main.Format.FT)
{
writer.Align(16);
writer.Align(0x10);
Offset = writer.UIntPosition;
writer.Position = 0x80;
}
-2
View File
@@ -11,7 +11,5 @@ namespace KKdMainLib
public static byte[] ToUTF8 (this string Data ) => Encoding.UTF8 .GetBytes (Data );
public static byte[] ToASCII(this char[] Data ) => Encoding.ASCII.GetBytes (Data );
public static byte[] ToUTF8 (this char[] Data ) => Encoding.UTF8 .GetBytes (Data );
public static string ToBase64(this byte[] Array) => Convert. ToBase64String(Array);
public static byte[] FromBase64(this string Data ) => Convert.FromBase64String(Data );
}
}
+16 -34
View File
@@ -12,18 +12,12 @@ namespace KKdMainLib.Types
public static explicit operator double(Half h)
{
if (h._value == 0x0000)
return +0;
else if (h._value == 0x8000)
return (-0);
else if (h._value == 0x7C00)
return double.PositiveInfinity;
else if (h._value == 0xFC00)
return double.NegativeInfinity;
else if (h._value >> 10 == 0x1F)
return double.NaN;
else if (h._value >> 10 == 0x3F)
return -double.NaN;
if (h._value == 0x0000) return +0;
else if (h._value == 0x8000) return -0;
else if (h._value == 0x7C00) return double.PositiveInfinity;
else if (h._value == 0xFC00) return double.NegativeInfinity;
else if (h._value >> 10 == 0x001F) return double.NaN;
else if (h._value >> 10 == 0x003F) return -double.NaN;
long exponent = ((h._value >> 10) & 0x1F);
long mantissa = (h._value & 0x3FF);
@@ -38,20 +32,13 @@ namespace KKdMainLib.Types
public static explicit operator Half(double val)
{
Half h = new Half();
if (val == +0)
h._value = 0x0000;
else if (val == -0)
h._value = 0x8000;
else if (val == double.NaN)
h._value = 0x7FFF;
else if (val == -double.NaN)
h._value = 0xFFFF;
else if (val == double.PositiveInfinity)
h._value = 0x7C00;
else if (val == double.NegativeInfinity)
h._value = 0xFC00;
else
h._value = ToDouble(val);
if (val == +0 ) h._value = 0x0000;
else if (val == -0 ) h._value = 0x8000;
else if (val == double.NaN ) h._value = 0x7FFF;
else if (val == -double.NaN ) h._value = 0xFFFF;
else if (val == double.PositiveInfinity) h._value = 0x7C00;
else if (val == double.NegativeInfinity) h._value = 0xFC00;
else h._value = ToDouble(val);
return h;
}
@@ -76,10 +63,8 @@ namespace KKdMainLib.Types
{
ushort exponent_max = (ushort)Math.Ceiling(x * Pow2);
ushort exponent_min = (ushort)Math.Floor (x * Pow2);
ushort exponent = 0;
if (Math.Abs(x - exponent_max / Pow2) > Math.Abs(x - exponent_min / Pow2))
exponent = exponent_max;
else exponent = exponent_min;
ushort exponent = Math.Abs(x - exponent_max / Pow2) >
Math.Abs(x - exponent_min / Pow2) ? exponent_max : exponent_min;
ushort mantissa = (ushort)(i + MaxPow - 1);
ushort d = (ushort)(Sign | ((mantissa & 0x001F) << 10) | (exponent & 0x03FF));
return d;
@@ -88,10 +73,7 @@ namespace KKdMainLib.Types
else i++;
}
if (i >= +0)
return 0x7C00;
else
return 0xFC00;
return i >= +0 ? (ushort)0x7C00 : (ushort)0xFC00;
}
public override string ToString() => ((double)this).ToString();
+6 -22
View File
@@ -46,11 +46,8 @@
public IKeyFrame<TKey, TVal> ToKeyFrameT3() =>
new KeyFrameT3<TKey, TVal> { Frame = Frame, Value = Value };
public IKeyFrame<TKey, TVal> Check()
{
if (Value.Equals(default(TVal))) return ToKeyFrameT0();
return this;
}
public IKeyFrame<TKey, TVal> Check() =>
Value.Equals(default(TVal)) ? ToKeyFrameT0() : (this);
public override string ToString() => ToString(true);
public string ToString(bool Brackets) =>
@@ -129,26 +126,13 @@
(Brackets ? "(" : "") + Main.ToString(Frame) + "," + Main.ToString(Value) + "," +
Main.ToString(Interpolation1) + "," + Main.ToString(Interpolation2) + (Brackets ? ")" : "");
public IKeyFrame<TKey, TVal> ToKeyFrameT2(IKeyFrame<TKey, TVal>
Previous, out KeyFrameT2<TKey, TVal> Current)
{
if (Previous is KeyFrameT2<TKey, TVal> PreviousT2)
Current = new KeyFrameT2<TKey, TVal> { Frame = PreviousT2.Frame,
Value = PreviousT2.Value, Interpolation = Interpolation1 };
else
Current = new KeyFrameT2<TKey, TVal> { Frame = Frame,
Value = Value, Interpolation = Interpolation1 };
return new KeyFrameT2<TKey, TVal> { Frame = Frame,
Value = Value, Interpolation = Interpolation2 };
}
public IKeyFrame<TKey, TVal> ToKeyFrameT2(IKeyFrame<TKey, TVal>
Previous, out IKeyFrame<TKey, TVal> Current)
{
if (Previous is KeyFrameT2<TKey, TVal> PreviousT2)
Current = new KeyFrameT2<TKey, TVal> { Frame = PreviousT2.Frame,
Value = PreviousT2.Value, Interpolation = Interpolation1 };
else
Current = new KeyFrameT2<TKey, TVal> { Frame = Frame,
Current = Previous is KeyFrameT2<TKey, TVal> PreviousT2
? new KeyFrameT2<TKey, TVal> { Frame = PreviousT2.Frame,
Value = PreviousT2.Value, Interpolation = Interpolation1 }
: new KeyFrameT2<TKey, TVal> { Frame = Frame,
Value = Value, Interpolation = Interpolation1 };
return new KeyFrameT2<TKey, TVal> { Frame = Frame,
Value = Value, Interpolation = Interpolation2 };
+4 -4
View File
@@ -29,16 +29,16 @@ namespace KKdMainLib.Types
{
index = 0;
Count = Array.Length;
this.array = Array;
array = Array;
}
public T Current => index < Count ? array[index] : default(T);
public T Current => index < Count ? array[index] : default;
object IEnumerator.Current => Current;
public T this[int index]
{ get { if (array != null) return array[index]; return default(T); }
set { if (array != null) array[index] = value; } }
{ get => array != null ? array[index] : default;
set { if (array != null) array[index] = value; } }
public bool MoveNext()
{ if (index == (Count - 1)) { index = 0; return false; }
+3 -4
View File
@@ -15,11 +15,10 @@
public int Offset;
public T[] Entries;
public T this[int index]
{
get { if (Count > 0) return Entries[index]; return default(T); }
set { if (Count > 0) { Entries[index] = value; } }
}
{ get => Count > 0 ? Entries[index] : default;
set { if (Count > 0) Entries[index] = value; } }
public override string ToString() => Count < 1 ? "No Entries" :
Count == 1 ? Entries[0].ToString() : "Count: " + Count;
+1 -2
View File
@@ -1,5 +1,4 @@
using System;
using KKdMainLib;
using KKdMainLib;
using KKdMainLib.IO;
namespace KKdSoundLib
+4
View File
@@ -22,6 +22,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +35,8 @@
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="Extensions.cs" />
+1 -1
View File
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("KKdSoundLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("A simple library for working with Project Diva F/AFT/F2/X/FT audio files")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KKdSoundLib")]
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KKdSoundLib
namespace KKdSoundLib
{
public static class WAV
{
+4
View File
@@ -22,6 +22,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +35,8 @@
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>7.3</LangVersion>
<NoWarn>IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="classes\DataBase.cs" />
+3 -3
View File
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("PD_Tool")]
[assembly: AssemblyDescription("A simple tool for working with Project Diva A/DT/F/AFT/F2/X/FT files")]
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT files")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PD_Tool")]
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
[assembly: AssemblyVersion("0.4.6.1")]
[assembly: AssemblyFileVersion("0.4.6.1")]
[assembly: AssemblyVersion("0.4.6.2")]
[assembly: AssemblyFileVersion("0.4.6.2")]
+1 -2
View File
@@ -64,8 +64,7 @@ namespace PD_Tool
else if (type == "R") return;
else FARC.Signature = KKdFARC.Farc.FArC;
Console.Title = "FARC Creator - Directory: " + Path.GetDirectoryName(file);
FARC.DirectoryPath = file;
FARC.Pack();
new KKdFARC(file, true).Pack();
}
}
}
+20 -20
View File
@@ -15,34 +15,37 @@ namespace PD_Tool.Tools
string filepath = "";
string ext = "";
bool MP = true;
bool MP = false;
foreach (string file in FileNames)
if (file.EndsWith(".mp" )) { MP = false; break; }
else if (file.EndsWith(".json")) { MP = false; break; }
if (file.EndsWith(".mp" )) { MP = true; break; }
else if (file.EndsWith(".json")) { MP = true; break; }
Main.Format Format = Main.Format.NULL;
if (!MP)
string format = "";
if (MP)
{
Console.Clear();
Main.ConsoleDesign(true);
Main.ConsoleDesign(" Choose type of format to export:");
Main.ConsoleDesign(false);
Main.ConsoleDesign("1. DT PS3");
Main.ConsoleDesign("2. F PS3/PSV");
Main.ConsoleDesign("3. FT PS4");
Main.ConsoleDesign("4. F2nd PS3/PSV");
Main.ConsoleDesign("5. MGF PSV");
Main.ConsoleDesign("6. X PS4/PSV");
Main.ConsoleDesign("1. A3DA [DT/AC/F]");
Main.ConsoleDesign("2. A3DC [DT/AC/F]");
Main.ConsoleDesign("3. A3DA [AFT/FT] ");
Main.ConsoleDesign("4. A3DC [AFT/FT] ");
Main.ConsoleDesign("5. A3DC [F2] ");
Main.ConsoleDesign("6. A3DC [MGF] ");
Main.ConsoleDesign("7. A3DC [X] ");
Main.ConsoleDesign(false);
Main.ConsoleDesign(true);
Console.WriteLine();
string format = Console.ReadLine();
format = Console.ReadLine();
if (format == "1") Format = Main.Format.DT ;
else if (format == "2") Format = Main.Format.F ;
else if (format == "3") Format = Main.Format.FT ;
else if (format == "4") Format = Main.Format.F2LE;
else if (format == "5") Format = Main.Format.MGF ;
else if (format == "6") Format = Main.Format.X ;
else if (format == "4") Format = Main.Format.FT ;
else if (format == "5") Format = Main.Format.F2LE;
else if (format == "6") Format = Main.Format.MGF ;
else if (format == "7") Format = Main.Format.X ;
else return;
}
@@ -64,14 +67,11 @@ namespace PD_Tool.Tools
{
A.MsgPackReader(filepath, ext == ".json");
A.IO = File.OpenWriter(filepath + ".a3da", true);
if (A.Data.Header.Format >= Main.Format.F2LE)
A.Data._.CompressF16 = Format == Main.Format.MGF ? 2 : 1;
A.Data._.CompressF16 = A.Data.Header.Format > Main.Format.FT ? Format == Main.Format.MGF ? 2 : 1 : 0;
A.Data.Header.Format = Format;
if (A.Data.Header.Format > Main.Format.DT && A.Data.Header.Format != Main.Format.FT)
A.A3DCWriter(filepath);
else
A.A3DAWriter();
if (format != "1" && format != "3") A.A3DCWriter(filepath);
else A.A3DAWriter();
}
A = null;
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using KKdMainLib;
using KKdMainLib.IO;
using KKdMot = KKdMainLib.Mot;
namespace PD_Tool.Tools
{
public class MOT
{
public static void Processor(bool JSON)
{
Console.Title = "MOT Converter";
KKdMot Mot;
Main.Choose(1, "bin", out string[] FileNames);
if (FileNames.Length < 1) return;
string filepath = "";
string ext = "";
foreach (string file in FileNames)
{
Mot = new KKdMot();
ext = Path.GetExtension(file);
filepath = file.Replace(ext, "");
ext = ext.ToLower();
Console.Title = "MOT Converter: " + Path.GetFileNameWithoutExtension(file);
if (ext == ".bin") Mot.MOTReader(filepath, JSON);
else if (ext == ".mp" || ext == ".json")
{
//Mot.MsgPackReader(filepath, ext == ".json");
//Mot. AETWriter(filepath);
}
Mot = new KKdMot();
}
}
}
}