diff --git a/KKdBaseLib/KKdBaseLib.csproj b/KKdBaseLib/KKdBaseLib.csproj
index b53e575..86d0ed2 100644
--- a/KKdBaseLib/KKdBaseLib.csproj
+++ b/KKdBaseLib/KKdBaseLib.csproj
@@ -6,12 +6,12 @@
korenkonder (C) 2019-2021
A base library
- 0.4.10.2
+ 0.4.10.3
KKdBaseLib
KKdBaseLib
net461
KKdBaseLib
- 0.4.10.2
+ 0.4.10.3
AnyCPU
diff --git a/KKdMainLib/A3DA.cs b/KKdMainLib/A3DA.cs
index 286d13c..7af4ef1 100644
--- a/KKdMainLib/A3DA.cs
+++ b/KKdMainLib/A3DA.cs
@@ -16,6 +16,7 @@ namespace KKdMainLib
private Stream s;
private bool a3dc;
+ private bool a3dcOpt;
private int i, i0, i1;
private int soi;
private int soi0;
@@ -28,10 +29,17 @@ namespace KKdMainLib
private string value;
private string[] dataArray;
private A3DADict dict;
+ private UsedDict usedValues;
private const string BO = ".bin_offset";
private const string MTBO = ".model_transform" + BO;
+ public A3DA(bool a3dcOpt = true)
+ { a3dc = false; i = i0 = i1 = soi = soi0 = soi1 = 0; value = null;
+ name = null; nameView = null; so = null; so0 = null; so1 = null;
+ dataArray = null; s = null; Head = default; Data = default;
+ dict = null; usedValues = null; this.a3dcOpt = a3dcOpt; }
+
public int A3DAReader(string file)
{ using (s = File.OpenReader(file + ".a3da"))
return A3DAReader(ref s); }
@@ -1326,6 +1334,7 @@ namespace KKdMainLib
public byte[] A3DCWriter()
{
+ usedValues = new UsedDict();
Data._.CompressF16 = Head.Format > Format.AFT && Head.Format < Format.FT ?
(Head.Format == Format.MGF ? CompressF16.Type2 : CompressF16.Type1) : 0;
@@ -1360,15 +1369,15 @@ namespace KKdMainLib
if (Data.MObjectHRC != null)
for (i0 = 0; i0 < Data.MObjectHRC.Length; i0++)
{
+ if (Data.MObjectHRC[i0].Instances != null)
+ for (i1 = 0; i1 < Data.MObjectHRC[i0].Instances.Length; i1++)
+ WO(ref Data.MObjectHRC[i0].Instances[i1].MT, ReturnToOffset);
+
WO(ref Data.MObjectHRC[i0].MT, ReturnToOffset);
if (Data.MObjectHRC[i0].Node != null)
for (i1 = 0; i1 < Data.MObjectHRC[i0].Node.Length; i1++)
WO(ref Data.MObjectHRC[i0].Node[i1].MT, ReturnToOffset);
-
- if (Data.MObjectHRC[i0].Instances != null)
- for (i1 = 0; i1 < Data.MObjectHRC[i0].Instances.Length; i1++)
- WO(ref Data.MObjectHRC[i0].Instances[i1].MT, ReturnToOffset);
}
if (Data.Object != null)
@@ -1465,15 +1474,15 @@ namespace KKdMainLib
if (Data.MObjectHRC != null)
for (i0 = 0; i0 < Data.MObjectHRC.Length; i0++)
{
+ if (Data.MObjectHRC[i0].Instances != null)
+ for (i1 = 0; i1 < Data.MObjectHRC[i0].Instances.Length; i1++)
+ W(ref Data.MObjectHRC[i0].Instances[i1].MT);
+
W(ref Data.MObjectHRC[i0].MT);
if (Data.MObjectHRC[i0].Node != null)
for (i1 = 0; i1 < Data.MObjectHRC[i0].Node.Length; i1++)
W(ref Data.MObjectHRC[i0].Node[i1].MT);
-
- if (Data.MObjectHRC[i0].Instances != null)
- for (i1 = 0; i1 < Data.MObjectHRC[i0].Instances.Length; i1++)
- W(ref Data.MObjectHRC[i0].Instances[i1].MT);
}
if (Data.MaterialList != null && (Head.Format == Format.X || Head.Format == Format.XHD))
@@ -1709,9 +1718,24 @@ namespace KKdMainLib
}
else
{
- key.BinOffset = s.P;
- if (key.Type == 0) s.W(0x00L);
- else { s.W((int)key.Type); s.W((float)key.Value); }
+ if (a3dcOpt)
+ {
+ key.BinOffset = s.P;
+ if (key.Type == 0) s.W(0x00L);
+ else { s.W((int)key.Type); s.W((float)key.Value); }
+ }
+ else
+ {
+ KeyValuePair kvp = new KeyValuePair((int)key.Type, key.Value);
+ if (!usedValues.ContainsValue(kvp))
+ {
+ key.BinOffset = s.P;
+ if (key.Type == 0) s.W(0x00L);
+ else { s.W((int)key.Type); s.W((float)key.Value); }
+ usedValues.Add(key.BinOffset.Value, kvp);
+ }
+ else key.BinOffset = usedValues.GK(kvp);
+ }
}
}
diff --git a/KKdMainLib/KKdMainLib.csproj b/KKdMainLib/KKdMainLib.csproj
index dcc523e..98868e9 100644
--- a/KKdMainLib/KKdMainLib.csproj
+++ b/KKdMainLib/KKdMainLib.csproj
@@ -6,12 +6,12 @@
korenkonder (C) 2018-2021
A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
- 0.4.10.2
+ 0.4.10.3
KKdMainLib
KKdMainLib
net461
KKdMainLib
- 0.4.10.2
+ 0.4.10.3
AnyCPU
diff --git a/PD_Tool/Program.cs b/PD_Tool/Program.cs
index 382377c..4091830 100644
--- a/PD_Tool/Program.cs
+++ b/PD_Tool/Program.cs
@@ -350,15 +350,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;
diff --git a/PD_Tool/Properties/AssemblyInfo.cs b/PD_Tool/Properties/AssemblyInfo.cs
index 8130535..a51e903 100644
--- a/PD_Tool/Properties/AssemblyInfo.cs
+++ b/PD_Tool/Properties/AssemblyInfo.cs
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
-[assembly: AssemblyVersion("0.4.10.2")]
-[assembly: AssemblyFileVersion("0.4.10.2")]
+[assembly: AssemblyVersion("0.4.10.3")]
+[assembly: AssemblyFileVersion("0.4.10.3")]
diff --git a/PD_Tool/classes/A3D.cs b/PD_Tool/classes/A3D.cs
index 61991aa..e1c0c7a 100644
--- a/PD_Tool/classes/A3D.cs
+++ b/PD_Tool/classes/A3D.cs
@@ -18,34 +18,50 @@ namespace PD_Tool
foreach (string file in fileNames)
if (file.EndsWith(".mp") || file.EndsWith(".json") || file.EndsWith(".farc")) { mp = true; break; }
+ bool a3dcOpt = false;
Format format = Format.NULL;
string choose = "";
Console.Clear();
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]");
- Program.ConsoleDesign("4. A3DC [AFT/FT/M39]");
- Program.ConsoleDesign("5. A3DC [F2]");
- Program.ConsoleDesign("6. A3DC [MGF]");
- Program.ConsoleDesign("7. A3DC [X]");
- Program.ConsoleDesign("8. A3DC [XHD]");
- if (!mp) Program.ConsoleDesign($"9. {(json ? "JSON" : "MsgPack")}");
+ Program.ConsoleDesign("3. A3DC [DT/AC/F] (A3DC Opt)");
+ Program.ConsoleDesign("4. A3DA [AFT/FT/M39]");
+ Program.ConsoleDesign("5. A3DC [AFT/FT/M39]");
+ Program.ConsoleDesign("6. A3DC [AFT/FT/M39] (A3DC Opt)");
+ Program.ConsoleDesign("7. A3DC [F2]");
+ Program.ConsoleDesign("8. A3DC [F2] (A3DC Opt)");
+ Program.ConsoleDesign("9. A3DC [MGF]");
+ Program.ConsoleDesign("A. A3DC [MGF] (A3DC Opt)");
+ Program.ConsoleDesign("B. A3DC [X]");
+ Program.ConsoleDesign("C. A3DC [X] (A3DC Opt)");
+ Program.ConsoleDesign("D. A3DC [XHD]");
+ Program.ConsoleDesign("E. A3DC [XHD] (A3DC Opt)");
+ if (!mp) Program.ConsoleDesign($"F. {(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.XHD;
- else if (choose == "9") format = Format.NULL;
+ if (choose == "1") format = Format.DT ;
+ else if (choose == "2") format = Format.F ;
+ else if (choose == "3") { format = Format.F ; a3dcOpt = true; }
+ else if (choose == "4") format = Format.AFT;
+ else if (choose == "5") format = Format.AFT;
+ else if (choose == "6") { format = Format.AFT; a3dcOpt = true; }
+ else if (choose == "7") format = Format.F2 ;
+ else if (choose == "8") { format = Format.F2 ; a3dcOpt = true; }
+ else if (choose == "9") format = Format.MGF;
+ else if (choose == "A") { format = Format.MGF; a3dcOpt = true; }
+ else if (choose == "B") format = Format.X ;
+ else if (choose == "C") { format = Format.X ; a3dcOpt = true; }
+ else if (choose == "D") format = Format.XHD;
+ else if (choose == "E") { format = Format.XHD; a3dcOpt = true; }
+ else if (choose == "F") format = Format.NULL;
else return;
int state;
@@ -60,9 +76,9 @@ namespace PD_Tool
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
if (ext == ".farc")
using (farc = new KKdFARC(file))
- FARCProcessor(farc, choose, format);
+ FARCProcessor(farc, choose, format, a3dcOpt);
else if (ext == ".a3da")
- using (a3da = new KKdA3DA())
+ using (a3da = new KKdA3DA(a3dcOpt))
{
state = a3da.A3DAReader(filepath);
if (state == 1)
@@ -71,22 +87,22 @@ namespace PD_Tool
{
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())
+ using (a3da = new KKdA3DA(a3dcOpt))
{
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());
}
}
}
- private static void FARCProcessor(KKdFARC farc, string choose, Format format)
+ private static void FARCProcessor(KKdFARC farc, string choose, Format format, bool a3dcOpt)
{
if (!farc.HeaderReader() || !farc.HasFiles) return;
@@ -107,7 +123,7 @@ namespace PD_Tool
{
KKdA3DA a3da;
for (int i = 0; i < A3DAlist.Count; i++)
- using (a3da = new KKdA3DA())
+ using (a3da = new KKdA3DA(a3dcOpt))
{
data = farc.FileReader(A3DAlist[i]);
int state = a3da.A3DAReader(data);
@@ -115,7 +131,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 +146,7 @@ namespace PD_Tool
for (int i = 0; i < list.Count; i++)
{
KKdA3DA a3da;
- using (a3da = new KKdA3DA())
+ using (a3da = new KKdA3DA(a3dcOpt))
{
data = farc.FileReader(list[i]);
int state = a3da.A3DAReader(data);
@@ -147,7 +164,7 @@ namespace PD_Tool
string ext = Path.GetExtension(list[i]).ToLower();
KKdA3DA a3da;
for (int i1 = 1; i1 < div; i1++)
- using (a3da = new KKdA3DA())
+ using (a3da = new KKdA3DA(a3dcOpt))
{
string file = filename + "_div_" + i1 + ext;
data = farc.FileReader(file);
@@ -164,7 +181,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();