Compare commits

...
3 Commits
Author SHA1 Message Date
korenkonder a7e14e22ad Release v0.4.10.5
A3DA
2021-09-17 21:00:31 +03:00
korenkonder d94f45870d Release v0.4.10.4
A3DA
2021-05-26 22:43:16 +03:00
korenkonder 2b46e0f4bd Release v0.4.10.3
A3DA
2021-05-24 04:02:18 +03:00
11 changed files with 334 additions and 421 deletions
+4 -5
View File
@@ -192,18 +192,17 @@ namespace KKdBaseLib.Auth3D
public struct MaterialList
{
public ulong HashName;
public string Name;
public Key GlowIntensity;
public Vec4<Key?>? BlendColor;
public Vec4<Key?>? Incandescence;
public Vec4<Key?> BlendColor;
public Vec4<Key?> Incandescence;
}
public struct MObjectHRC
{
public string Name;
public Node[] Node;
public Vec3<float?> JointOrient;
public Vec3? JointOrient;
public Instance[] Instances;
public ModelTransform MT;
@@ -275,7 +274,7 @@ namespace KKdBaseLib.Auth3D
public string Name;
public string UIDName;
public Node[] Node;
public Vec3<float?> JointOrient;
public Vec3? JointOrient;
}
public struct PlayControl
+2 -2
View File
@@ -6,12 +6,12 @@
<Configuration></Configuration>
<Copyright>korenkonder (C) 2019-2021</Copyright>
<Description>A base library</Description>
<FileVersion>0.4.10.2</FileVersion>
<FileVersion>0.4.10.5</FileVersion>
<PackageId>KKdBaseLib</PackageId>
<Product>KKdBaseLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdBaseLib</Title>
<Version>0.4.10.2</Version>
<Version>0.4.10.5</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+249 -172
View File
@@ -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); }
@@ -141,12 +149,10 @@ namespace KKdMainLib
Saturate = RKN(name + ".saturate" ),
};
if (Data.CameraAuxiliary.Value.GammaRate.HasValue)
if (Data.CameraAuxiliary.Value.ExposureRate.HasValue
|| Data.CameraAuxiliary.Value.GammaRate.HasValue)
if (Head.Format < Format.F || Head.Format == Format.AFT || Head.Format >= Format.FT)
Head.Format = Format.F;
if (Data.CameraAuxiliary.Value.ExposureRate.HasValue)
Head.Format = Format.X;
}
if (dict.SW("play_control"))
@@ -167,12 +173,12 @@ namespace KKdMainLib
Data.PostProcess = new PostProcess()
{
Ambient = RRGBAK(name + ".Ambient" ),
Diffuse = RRGBAK(name + ".Diffuse" ),
Specular = RRGBAK(name + ".Specular" ),
LensFlare = RKN (name + ".lens_flare"),
LensGhost = RKN (name + ".lens_ghost"),
LensShaft = RKN (name + ".lens_shaft"),
Ambient = RRGBAKN(name + ".Ambient" ),
Diffuse = RRGBAKN(name + ".Diffuse" ),
Specular = RRGBAKN(name + ".Specular" ),
LensFlare = RKN (name + ".lens_flare"),
LensGhost = RKN (name + ".lens_ghost"),
LensShaft = RKN (name + ".lens_shaft"),
};
}
@@ -192,8 +198,8 @@ namespace KKdMainLib
{
name = "ambient." + i0;
dict.FV(out Data.Ambient[i0].Name, name + ".name");
Data.Ambient[i0]. LightDiffuse = RRGBAK(name + ".light.Diffuse");
Data.Ambient[i0].RimLightDiffuse = RRGBAK(name + ".rimlight.Diffuse");
Data.Ambient[i0]. LightDiffuse = RRGBAKN(name + ".light.Diffuse");
Data.Ambient[i0].RimLightDiffuse = RRGBAKN(name + ".rimlight.Diffuse");
}
}
@@ -269,10 +275,10 @@ namespace KKdMainLib
name = "fog." + i0;
dict.FV(out Data.Fog[i0].Id, name + ".id");
Data.Fog[i0].Density = RK (name + ".density");
Data.Fog[i0].Diffuse = RRGBAK(name + ".Diffuse");
Data.Fog[i0].End = RK (name + ".end");
Data.Fog[i0].Start = RK (name + ".start");
Data.Fog[i0].Density = RKN (name + ".density");
Data.Fog[i0].Diffuse = RRGBAKN(name + ".Diffuse");
Data.Fog[i0].End = RKN (name + ".end");
Data.Fog[i0].Start = RKN (name + ".start");
}
}
@@ -287,19 +293,19 @@ namespace KKdMainLib
dict.FV(out Data.Light[i0].Name, name + ".name");
dict.FV(out Data.Light[i0].Type, name + ".type");
Data.Light[i0].Ambient = RRGBAK(name + ".Ambient");
Data.Light[i0].ConeAngle = RKN (name + ".ConeAngle");
Data.Light[i0].Constant = RKN (name + ".CONSTANT");
Data.Light[i0].Diffuse = RRGBAK(name + ".Diffuse");
Data.Light[i0].DropOff = RKN (name + ".DropOff");
Data.Light[i0].Far = RKN (name + ".FAR");
Data.Light[i0].Incandescence = RRGBAK(name + ".Incandescence");
Data.Light[i0].Intensity = RKN (name + ".Intensity");
Data.Light[i0].Linear = RKN (name + ".LINEAR");
Data.Light[i0].Quadratic = RKN (name + ".QUADRATIC");
Data.Light[i0].Specular = RRGBAK(name + ".Specular");
Data.Light[i0].Position = RMT (name + ".position");
Data.Light[i0].SpotDirection = RMT (name + ".spot_direction");
Data.Light[i0].Ambient = RRGBAKN(name + ".Ambient");
Data.Light[i0].ConeAngle = RKN (name + ".ConeAngle");
Data.Light[i0].Constant = RKN (name + ".CONSTANT");
Data.Light[i0].Diffuse = RRGBAKN(name + ".Diffuse");
Data.Light[i0].DropOff = RKN (name + ".DropOff");
Data.Light[i0].Far = RKN (name + ".FAR");
Data.Light[i0].Incandescence = RRGBAKN(name + ".Incandescence");
Data.Light[i0].Intensity = RKN (name + ".Intensity");
Data.Light[i0].Linear = RKN (name + ".LINEAR");
Data.Light[i0].Quadratic = RKN (name + ".QUADRATIC");
Data.Light[i0].Specular = RRGBAKN(name + ".Specular");
Data.Light[i0].Position = RMT (name + ".position");
Data.Light[i0].SpotDirection = RMT (name + ".spot_direction");
}
}
@@ -314,11 +320,11 @@ namespace KKdMainLib
if (dict.SW(name + ".joint_orient"))
{
Data.MObjectHRC[i0].JointOrient = new Vec3<float?>();
dict.FV(out Data.MObjectHRC[i0].JointOrient.X, name + ".joint_orient.x");
dict.FV(out Data.MObjectHRC[i0].JointOrient.Y, name + ".joint_orient.y");
dict.FV(out Data.MObjectHRC[i0].JointOrient.Z, name + ".joint_orient.z");
Head.Format = Format.X;
Vec3 jointOrient = new Vec3();
dict.FV(out jointOrient.X, name + ".joint_orient.x");
dict.FV(out jointOrient.Y, name + ".joint_orient.y");
dict.FV(out jointOrient.Z, name + ".joint_orient.z");
Data.MObjectHRC[i0].JointOrient = jointOrient;
}
if (dict.FV(out value, name + ".instance.length"))
@@ -371,8 +377,7 @@ namespace KKdMainLib
for (i0 = 0; i0 < Data.MaterialList.Length; i0++)
{
name = "material_list." + i0;
dict.FV(out Data.MaterialList[i0].HashName, name + ".hash_name");
dict.FV(out Data.MaterialList[i0]. Name, name + ".name");
dict.FV(out Data.MaterialList[i0].Name, name + ".name");
Data.MaterialList[i0].BlendColor = RRGBAK(name + ".blend_color");
Data.MaterialList[i0].GlowIntensity = RK (name + ".glow_intensity");
@@ -451,10 +456,11 @@ namespace KKdMainLib
if (dict.SW(name + ".joint_orient"))
{
Data.ObjectHRC[i0].JointOrient = new Vec3<float?>();
dict.FV(out Data.ObjectHRC[i0].JointOrient.X, name + ".joint_orient.x");
dict.FV(out Data.ObjectHRC[i0].JointOrient.Y, name + ".joint_orient.y");
dict.FV(out Data.ObjectHRC[i0].JointOrient.Z, name + ".joint_orient.z");
Vec3 jointOrient = new Vec3();
dict.FV(out jointOrient.X, name + ".joint_orient.x");
dict.FV(out jointOrient.Y, name + ".joint_orient.y");
dict.FV(out jointOrient.Z, name + ".joint_orient.z");
Data.ObjectHRC[i0].JointOrient = jointOrient;
}
dict.FV(out Data.ObjectHRC[i0]. Name, name + ".name");
dict.FV(out Data.ObjectHRC[i0].UIDName, name + ".uid_name");
@@ -536,11 +542,15 @@ namespace KKdMainLib
{
name = "camera_auxiliary";
CameraAuxiliary ca = Data.CameraAuxiliary.Value;
W(ref ca.AutoExposure , name + ".auto_exposure" );
W(ref ca. Exposure , name + ".exposure" );
if (Head.Format == Format.X || Head.Format == Format.XHD)
if (Head.Format != Format.F && (Head.Format <= Format.AFT || Head.Format >= Format.FT))
{
W(ref ca.AutoExposure , name + ".auto_exposure" );
W(ref ca. Exposure , name + ".exposure" );
}
if (Head.Format == Format.F || (Head.Format > Format.AFT && Head.Format < Format.FT))
W(ref ca. ExposureRate, name + ".exposure_rate");
W(ref ca.Gamma , name + ".gamma" );
if (Head.Format != Format.F && (Head.Format <= Format.AFT || Head.Format >= Format.FT))
W(ref ca.Gamma , name + ".gamma" );
if (Head.Format == Format.F || (Head.Format > Format.AFT && Head.Format < Format.FT))
W(ref ca.GammaRate , name + ".gamma_rate" );
W(ref ca.Saturate , name + ".saturate" );
@@ -694,12 +704,12 @@ namespace KKdMainLib
name = "m_objhrc." + soi0;
ref MObjectHRC mObjectHRC = ref Data.MObjectHRC[soi0];
if (mObjectHRC.JointOrient.NotNull && (Head.Format ==
Format.X || Head.Format == Format.XHD))
if (mObjectHRC.JointOrient.HasValue)
{
W(name + ".joint_orient.x", mObjectHRC.JointOrient.X);
W(name + ".joint_orient.y", mObjectHRC.JointOrient.Y);
W(name + ".joint_orient.z", mObjectHRC.JointOrient.Z);
Vec3 jointOrient = mObjectHRC.JointOrient.Value;
W(name + ".joint_orient.x", jointOrient.X);
W(name + ".joint_orient.y", jointOrient.Y);
W(name + ".joint_orient.z", jointOrient.Z);
}
if (mObjectHRC.Instances != null)
@@ -767,9 +777,9 @@ namespace KKdMainLib
W(ref ml.BlendColor , name + ".blend_color" );
W(ref ml.GlowIntensity, name + ".glow_intensity");
W(name + ".hash_name", ml.HashName);
W(name + ".hash_name", HashExt.HashMurmurHash(ml.Name.ToUTF8()));
W(ref ml.Incandescence, name + ".incandescence" );
W(name + ".name", ml. Name);
W(name + ".name", ml.Name);
}
W("material_list.length", Data.MaterialList.Length);
}
@@ -872,12 +882,12 @@ namespace KKdMainLib
W(name + ".name", objectHRC.Name);
if (objectHRC.JointOrient.NotNull && (Head.Format ==
Format.X || Head.Format == Format.XHD))
if (objectHRC.JointOrient.HasValue)
{
W(name + ".joint_orient.x", objectHRC.JointOrient.X);
W(name + ".joint_orient.y", objectHRC.JointOrient.Y);
W(name + ".joint_orient.z", objectHRC.JointOrient.Z);
Vec3 jointOrient = objectHRC.JointOrient.Value;
W(name + ".joint_orient.x", jointOrient.X);
W(name + ".joint_orient.y", jointOrient.Y);
W(name + ".joint_orient.z", jointOrient.Z);
}
if (objectHRC.Node != null)
@@ -963,11 +973,15 @@ namespace KKdMainLib
return mt;
}
private Vec4<Key?>? RRGBAK(string str) =>
private Vec4<Key?>? RRGBAKN(string str) =>
dict.FV(out bool b, str + ".") ? b ?
(Vec4<Key?>?)new Vec4<Key?> { W = RKNS(str + ".a"), Z = RKNS(str + ".b"),
Y = RKNS(str + ".g"), X = RKNS(str + ".r") } : null : null;
private Vec4<Key?> RRGBAK(string str) =>
new Vec4<Key?> { W = RKNS(str + ".a"), Z = RKNS(str + ".b"),
Y = RKNS(str + ".g"), X = RKNS(str + ".r") };
private Vec3<Key> RV3(string str) =>
new Vec3<Key> { X = RK(str + ".x"), Y = RK(str + ".y"), Z = RK(str + ".z") };
@@ -1077,6 +1091,16 @@ namespace KKdMainLib
rgba = rgbav;
}
private void W(ref Vec4<Key?> rgba, string str)
{
bool a3dc = Head.Format != Format.AFT && this.a3dc; // A3DC reading is bugged in AFT
if (rgba.W.HasValue) { Key k = rgba.W.Value; W(ref k, str + ".a", a3dc); rgba.W = k; }
if (rgba.Z.HasValue) { Key k = rgba.Z.Value; W(ref k, str + ".b", a3dc); rgba.Z = k; }
if (rgba.Y.HasValue) { Key k = rgba.Y.Value; W(ref k, str + ".g", a3dc); rgba.Y = k; }
if (rgba.X.HasValue) { Key k = rgba.X.Value; W(ref k, str + ".r", a3dc); rgba.X = k; }
}
private void W(ref Vec3<Key> key, string str)
{ W(ref key.X, str + ".x", a3dc); W(ref key.Y, str + ".y", a3dc); W(ref key.Z, str + ".z", a3dc); }
@@ -1179,8 +1203,8 @@ namespace KKdMainLib
if (Data.Ambient != null)
for (i0 = 0; i0 < Data.Ambient.Length; i0++)
{
RRGBAK(ref Data.Ambient[i0]. LightDiffuse);
RRGBAK(ref Data.Ambient[i0].RimLightDiffuse);
RRGBAKN(ref Data.Ambient[i0]. LightDiffuse);
RRGBAKN(ref Data.Ambient[i0].RimLightDiffuse);
}
if (Data.CameraAuxiliary != null)
@@ -1224,38 +1248,38 @@ namespace KKdMainLib
if (Data.Fog != null)
for (i0 = 0; i0 < Data.Fog.Length; i0++)
{
RKN (ref Data.Fog[i0].Density);
RRGBAK(ref Data.Fog[i0].Diffuse);
RKN (ref Data.Fog[i0].End );
RKN (ref Data.Fog[i0].Start );
RKN (ref Data.Fog[i0].Density);
RRGBAKN(ref Data.Fog[i0].Diffuse);
RKN (ref Data.Fog[i0].End );
RKN (ref Data.Fog[i0].Start );
}
if (Data.Light != null)
for (i0 = 0; i0 < Data.Light.Length; i0++)
{
RRGBAK(ref Data.Light[i0].Ambient );
RRGBAKN(ref Data.Light[i0].Ambient );
if (Head.Format == Format.XHD)
{
RKN (ref Data.Light[i0].ConeAngle );
RKN (ref Data.Light[i0].Constant );
RKN (ref Data.Light[i0].ConeAngle );
RKN (ref Data.Light[i0].Constant );
}
RRGBAK(ref Data.Light[i0].Diffuse );
RRGBAKN(ref Data.Light[i0].Diffuse );
if (Head.Format == Format.XHD)
{
RKN (ref Data.Light[i0].DropOff );
RKN (ref Data.Light[i0].Far );
RKN (ref Data.Light[i0].DropOff );
RKN (ref Data.Light[i0].Far );
}
RRGBAK(ref Data.Light[i0].Incandescence);
RRGBAKN(ref Data.Light[i0].Incandescence);
if (Head.Format == Format.XHD)
{
RKN (ref Data.Light[i0].Intensity );
RKN (ref Data.Light[i0].Linear );
RKN (ref Data.Light[i0].Intensity );
RKN (ref Data.Light[i0].Linear );
}
RMT (ref Data.Light[i0].Position );
RMT (ref Data.Light[i0].Position );
if (Head.Format == Format.XHD)
RKN (ref Data.Light[i0].Quadratic );
RRGBAK(ref Data.Light[i0].Specular );
RMT (ref Data.Light[i0].SpotDirection);
RKN (ref Data.Light[i0].Quadratic );
RRGBAKN(ref Data.Light[i0].Specular );
RMT (ref Data.Light[i0].SpotDirection);
}
if (Data.MObjectHRC != null)
@@ -1314,18 +1338,19 @@ namespace KKdMainLib
if (Data.PostProcess != null)
{
PostProcess pp = Data.PostProcess.Value;
RRGBAK(ref pp.Ambient );
RRGBAK(ref pp.Diffuse );
RRGBAK(ref pp.Specular );
RKN (ref pp.LensFlare);
RKN (ref pp.LensGhost);
RKN (ref pp.LensShaft);
RRGBAKN(ref pp.Ambient );
RRGBAKN(ref pp.Diffuse );
RRGBAKN(ref pp.Specular );
RKN (ref pp.LensFlare);
RKN (ref pp.LensGhost);
RKN (ref pp.LensShaft);
Data.PostProcess = pp;
}
}
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;
@@ -1597,7 +1622,7 @@ namespace KKdMainLib
RK (ref mt.Visibility);
}
private void RRGBAK(ref Vec4<Key?>? rgba)
private void RRGBAKN(ref Vec4<Key?>? rgba)
{
if (!rgba.HasValue) return;
Vec4<Key?> rgbav = rgba.Value;
@@ -1606,6 +1631,12 @@ namespace KKdMainLib
rgba = rgbav;
}
private void RRGBAK(ref Vec4<Key?> rgba)
{
RKN(ref rgba.X); RKN(ref rgba.Y);
RKN(ref rgba.Z); RKN(ref rgba.W);
}
private void RV3(ref Vec3<Key> key, bool f16 = false)
{ RK(ref key.X, f16); RK(ref key.Y, f16); RK(ref key.Z, f16); }
@@ -1675,6 +1706,14 @@ namespace KKdMainLib
rgba = rgbav;
}
private void W(ref Vec4<Key?> rgba)
{
if (Head.Format == Format.AFT) return;
W(ref rgba.X); W(ref rgba.Y);
W(ref rgba.Z); W(ref rgba.W);
}
private void W(ref Vec3<Key> key, bool f16 = false)
{ W(ref key.X, f16); W(ref key.Y, f16); W(ref key.Z, f16); }
@@ -1709,9 +1748,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<int, float> kvp = new KeyValuePair<int, float>((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);
}
}
}
@@ -1720,8 +1774,8 @@ namespace KKdMainLib
if (Data.Ambient != null && mData.Ambient != null)
for (i0 = 0; i0 < Data.Ambient.Length && i0 < mData.Ambient.Length; i0++)
{
MRGBAK(ref Data.Ambient[i0]. LightDiffuse, ref mData.Ambient[i0]. LightDiffuse);
MRGBAK(ref Data.Ambient[i0].RimLightDiffuse, ref mData.Ambient[i0].RimLightDiffuse);
MRGBAKN(ref Data.Ambient[i0]. LightDiffuse, ref mData.Ambient[i0]. LightDiffuse);
MRGBAKN(ref Data.Ambient[i0].RimLightDiffuse, ref mData.Ambient[i0].RimLightDiffuse);
}
if (Data.CameraAuxiliary != null && mData.CameraAuxiliary != null)
@@ -1769,38 +1823,38 @@ namespace KKdMainLib
if (Data.Fog != null && mData.Fog != null)
for (i0 = 0; i0 < Data.Fog.Length && i0 < Data.Fog.Length; i0++)
{
MKN (ref Data.Fog[i0].Density, ref mData.Fog[i0].Density);
MRGBAK(ref Data.Fog[i0].Diffuse, ref mData.Fog[i0].Diffuse);
MKN (ref Data.Fog[i0].End , ref mData.Fog[i0].End );
MKN (ref Data.Fog[i0].Start , ref mData.Fog[i0].Start );
MKN (ref Data.Fog[i0].Density, ref mData.Fog[i0].Density);
MRGBAKN(ref Data.Fog[i0].Diffuse, ref mData.Fog[i0].Diffuse);
MKN (ref Data.Fog[i0].End , ref mData.Fog[i0].End );
MKN (ref Data.Fog[i0].Start , ref mData.Fog[i0].Start );
}
if (Data.Light != null && mData.Light != null)
for (i0 = 0; i0 < Data.Light.Length; i0++)
{
MRGBAK(ref Data.Light[i0].Ambient , ref mData.Light[i0].Ambient );
MRGBAKN(ref Data.Light[i0].Ambient , ref mData.Light[i0].Ambient );
if (Head.Format == Format.XHD)
{
MKN (ref Data.Light[i0].ConeAngle , ref mData.Light[i0].ConeAngle );
MKN (ref Data.Light[i0].Constant , ref mData.Light[i0].Constant );
MKN (ref Data.Light[i0].ConeAngle , ref mData.Light[i0].ConeAngle );
MKN (ref Data.Light[i0].Constant , ref mData.Light[i0].Constant );
}
MRGBAK(ref Data.Light[i0].Diffuse , ref mData.Light[i0].Diffuse );
MRGBAKN(ref Data.Light[i0].Diffuse , ref mData.Light[i0].Diffuse );
if (Head.Format == Format.XHD)
{
MKN (ref Data.Light[i0].DropOff , ref mData.Light[i0].DropOff );
MKN (ref Data.Light[i0].Far , ref mData.Light[i0].Far );
MKN (ref Data.Light[i0].DropOff , ref mData.Light[i0].DropOff );
MKN (ref Data.Light[i0].Far , ref mData.Light[i0].Far );
}
MRGBAK(ref Data.Light[i0].Incandescence, ref mData.Light[i0].Incandescence);
MRGBAKN(ref Data.Light[i0].Incandescence, ref mData.Light[i0].Incandescence);
if (Head.Format == Format.XHD)
{
MKN (ref Data.Light[i0].Intensity , ref mData.Light[i0].Intensity );
MKN (ref Data.Light[i0].Linear , ref mData.Light[i0].Linear );
MKN (ref Data.Light[i0].Intensity , ref mData.Light[i0].Intensity );
MKN (ref Data.Light[i0].Linear , ref mData.Light[i0].Linear );
}
MMT (ref Data.Light[i0].Position , ref mData.Light[i0].Position );
MMT (ref Data.Light[i0].Position , ref mData.Light[i0].Position );
if (Head.Format == Format.XHD)
MKN (ref Data.Light[i0].Quadratic , ref mData.Light[i0].Quadratic);
MRGBAK(ref Data.Light[i0].Specular , ref mData.Light[i0].Specular );
MMT (ref Data.Light[i0].SpotDirection, ref mData.Light[i0].SpotDirection);
MKN (ref Data.Light[i0].Quadratic , ref mData.Light[i0].Quadratic);
MRGBAKN(ref Data.Light[i0].Specular , ref mData.Light[i0].Specular );
MMT (ref Data.Light[i0].SpotDirection, ref mData.Light[i0].SpotDirection);
}
if (Data.MObjectHRC != null && mData.MObjectHRC != null)
@@ -1877,12 +1931,12 @@ namespace KKdMainLib
{
PostProcess mPP = mData.PostProcess.Value;
PostProcess pp = Data.PostProcess.Value;
MRGBAK(ref pp.Ambient , ref mPP.Ambient );
MRGBAK(ref pp.Diffuse , ref mPP.Diffuse );
MRGBAK(ref pp.Specular , ref mPP.Specular );
MKN (ref pp.LensFlare, ref mPP.LensFlare);
MKN (ref pp.LensGhost, ref mPP.LensGhost);
MKN (ref pp.LensShaft, ref mPP.LensShaft);
MRGBAKN(ref pp.Ambient , ref mPP.Ambient );
MRGBAKN(ref pp.Diffuse , ref mPP.Diffuse );
MRGBAKN(ref pp.Specular , ref mPP.Specular );
MKN (ref pp.LensFlare, ref mPP.LensFlare);
MKN (ref pp.LensGhost, ref mPP.LensGhost);
MKN (ref pp.LensShaft, ref mPP.LensShaft);
Data.PostProcess = pp;
mData.PostProcess = mPP;
}
@@ -1896,7 +1950,7 @@ namespace KKdMainLib
MK (ref mt.Visibility, ref mMT.Visibility);
}
private void MRGBAK(ref Vec4<Key?>? rgba, ref Vec4<Key?>? mRGBA)
private void MRGBAKN(ref Vec4<Key?>? rgba, ref Vec4<Key?>? mRGBA)
{
if (!rgba.HasValue) return;
@@ -1907,6 +1961,12 @@ namespace KKdMainLib
mRGBA = mrgbav;
}
private void MRGBAK(ref Vec4<Key?> rgba, ref Vec4<Key?> mRGBA)
{
MKN(ref rgba.X, ref mRGBA.X); MKN(ref rgba.Y, ref mRGBA.Y);
MKN(ref rgba.Z, ref mRGBA.Z); MKN(ref rgba.W, ref mRGBA.W);
}
private void MV3(ref Vec3<Key> key, ref Vec3<Key> mKey)
{ MK(ref key.X, ref mKey.X); MK(ref key.Y, ref mKey.Y); MK(ref key.Z, ref mKey.Z); }
@@ -1986,9 +2046,9 @@ namespace KKdMainLib
for (i = 0; i < Data.Ambient.Length; i++)
Data.Ambient[i] = new Ambient
{
Name = temp[i].RS ( "Name"),
LightDiffuse = temp[i].RRGBAK( "LightDiffuse"),
RimLightDiffuse = temp[i].RRGBAK("RimLightDiffuse"),
Name = temp[i].RS ( "Name"),
LightDiffuse = temp[i].RRGBAKN( "LightDiffuse"),
RimLightDiffuse = temp[i].RRGBAKN("RimLightDiffuse"),
};
}
@@ -2078,11 +2138,11 @@ namespace KKdMainLib
for (i = 0; i < Data.Fog.Length; i++)
Data.Fog[i] = new Fog
{
Id = temp[i].RnI32 ("Id" ),
Density = temp[i].RK ("Density"),
Diffuse = temp[i].RRGBAK("Diffuse"),
End = temp[i].RK ("End" ),
Start = temp[i].RK ("Start" ),
Id = temp[i].RnI32 ("Id" ),
Density = temp[i].RKN ("Density"),
Diffuse = temp[i].RRGBAKN("Diffuse"),
End = temp[i].RKN ("End" ),
Start = temp[i].RKN ("Start" ),
};
}
@@ -2092,22 +2152,22 @@ namespace KKdMainLib
for (i = 0; i < Data.Light.Length; i++)
Data.Light[i] = new Light
{
Id = temp[i].RnI32 ("Id" ),
Name = temp[i].RS ("Name" ),
Type = temp[i].RS ("Type" ),
Ambient = temp[i].RRGBAK("Ambient" ),
ConeAngle = temp[i].RKN ("ConeAngle" ),
Constant = temp[i].RKN ("Constant" ),
Diffuse = temp[i].RRGBAK("Diffuse" ),
DropOff = temp[i].RKN ("DropOff" ),
Far = temp[i].RKN ("Far" ),
Incandescence = temp[i].RRGBAK("Incandescence"),
Intensity = temp[i].RKN ("Intensity" ),
Linear = temp[i].RKN ("Linear" ),
Position = temp[i].RMT ("Position" ),
Quadratic = temp[i].RKN ("Quadratic" ),
Specular = temp[i].RRGBAK("Specular" ),
SpotDirection = temp[i].RMT ("SpotDirection"),
Id = temp[i].RnI32 ("Id" ),
Name = temp[i].RS ("Name" ),
Type = temp[i].RS ("Type" ),
Ambient = temp[i].RRGBAKN("Ambient" ),
ConeAngle = temp[i].RKN ("ConeAngle" ),
Constant = temp[i].RKN ("Constant" ),
Diffuse = temp[i].RRGBAKN("Diffuse" ),
DropOff = temp[i].RKN ("DropOff" ),
Far = temp[i].RKN ("Far" ),
Incandescence = temp[i].RRGBAKN("Incandescence"),
Intensity = temp[i].RKN ("Intensity" ),
Linear = temp[i].RKN ("Linear" ),
Position = temp[i].RMT ("Position" ),
Quadratic = temp[i].RKN ("Quadratic" ),
Specular = temp[i].RRGBAKN("Specular" ),
SpotDirection = temp[i].RMT ("SpotDirection"),
};
}
@@ -2117,7 +2177,6 @@ namespace KKdMainLib
for (i = 0; i < Data.MaterialList.Length; i++)
Data.MaterialList[i] = new MaterialList
{
HashName = temp[i].RU64 ( "HashName"),
Name = temp[i].RS ( "Name"),
BlendColor = temp[i].RRGBAK( "BlendColor"),
GlowIntensity = temp[i].RK ("GlowIntensity"),
@@ -2137,11 +2196,11 @@ namespace KKdMainLib
};
if ((temp1 = temp[i0]["JointOrient"]).NotNull)
Data.MObjectHRC[i0].JointOrient = new Vec3<float?>
Data.MObjectHRC[i0].JointOrient = new Vec3
{
X = temp1.RnF32("X"),
Y = temp1.RnF32("Y"),
Z = temp1.RnF32("Z"),
X = temp1.RF32("X"),
Y = temp1.RF32("Y"),
Z = temp1.RF32("Z"),
};
if ((temp1 = temp[i0]["Instance", true]).NotNull)
@@ -2269,7 +2328,7 @@ namespace KKdMainLib
};
if ((temp1 = temp[i0]["JointOrient"]).NotNull)
Data.ObjectHRC[i0].JointOrient = new Vec3<float?>
Data.ObjectHRC[i0].JointOrient = new Vec3
{
X = temp1.RF32("X"),
Y = temp1.RF32("Y"),
@@ -2324,12 +2383,12 @@ namespace KKdMainLib
if ((temp = a3d["PostProcess"]).NotNull)
Data.PostProcess = new PostProcess
{
Ambient = temp.RRGBAK("Ambient" ),
Diffuse = temp.RRGBAK("Diffuse" ),
LensFlare = temp.RKN ("LensFlare"),
LensGhost = temp.RKN ("LensGhost"),
LensShaft = temp.RKN ("LensShaft"),
Specular = temp.RRGBAK("Specular" ),
Ambient = temp.RRGBAKN("Ambient" ),
Diffuse = temp.RRGBAKN("Diffuse" ),
LensFlare = temp.RKN ("LensFlare"),
LensGhost = temp.RKN ("LensGhost"),
LensShaft = temp.RKN ("LensShaft"),
Specular = temp.RRGBAKN("Specular" ),
};
temp1.Dispose();
@@ -2466,12 +2525,14 @@ namespace KKdMainLib
{
MsgPack _mObjectHRC = MsgPack.New.Add("Name", Data.MObjectHRC[i0].Name);
if (Data.MObjectHRC[i0].JointOrient.NotNull &&
(Head.Format == Format.X || Head.Format == Format.XHD))
if (Data.MObjectHRC[i0].JointOrient.HasValue)
{
Vec3 jointOrient = Data.MObjectHRC[i0].JointOrient.Value;
_mObjectHRC.Add(new MsgPack("JointOrient")
.Add("X", Data.MObjectHRC[i0].JointOrient.X)
.Add("Y", Data.MObjectHRC[i0].JointOrient.Y)
.Add("Z", Data.MObjectHRC[i0].JointOrient.Z));
.Add("X", jointOrient.X)
.Add("Y", jointOrient.Y)
.Add("Z", jointOrient.Z));
}
if (Data.MObjectHRC[i0].Instances != null)
{
@@ -2512,12 +2573,16 @@ namespace KKdMainLib
{
MsgPack materialList = new MsgPack(Data.MaterialList.Length, "MaterialList");
for (i = 0; i < Data.MaterialList.Length; i++)
materialList[i] = new MsgPack("Material")
.Add("HashName" , Data.MaterialList[i].HashName )
.Add( "Name" , Data.MaterialList[i]. Name )
.Add("BlendColor" , ref Data.MaterialList[i].BlendColor )
.Add("GlowIntensity", ref Data.MaterialList[i].GlowIntensity)
.Add("Incandescence", ref Data.MaterialList[i].Incandescence);
{
MsgPack material = new MsgPack("Material")
.Add("Name", Data.MaterialList[i].Name)
.Add("BlendColor", ref Data.MaterialList[i].BlendColor);
if (Data.MaterialList[i].GlowIntensity.Type != KeyType.None)
material.Add("GlowIntensity", ref Data.MaterialList[i].GlowIntensity);
materialList[i] = material.Add("Incandescence", ref Data.MaterialList[i].Incandescence);
}
a3d.Add(materialList);
}
@@ -2583,12 +2648,14 @@ namespace KKdMainLib
.Add("Shadow" , Data.ObjectHRC[i0].Shadow )
.Add("UIDName", Data.ObjectHRC[i0].UIDName);
if (Data.ObjectHRC[i0].JointOrient.NotNull &&
(Head.Format == Format.X || Head.Format == Format.XHD))
if (Data.ObjectHRC[i0].JointOrient.HasValue)
{
Vec3 jointOrient = Data.ObjectHRC[i0].JointOrient.Value;
_objectHRC.Add(new MsgPack("JointOrient")
.Add("X", Data.ObjectHRC[i0].JointOrient.X)
.Add("Y", Data.ObjectHRC[i0].JointOrient.Y)
.Add("Z", Data.ObjectHRC[i0].JointOrient.Z));
.Add("X", jointOrient.X)
.Add("Y", jointOrient.Y)
.Add("Z", jointOrient.Z));
}
if (Data.ObjectHRC[i0].Node != null)
{
@@ -2670,9 +2737,12 @@ namespace KKdMainLib
new ModelTransform { Rot = msgPack.RV3("Rot" ), Scale = msgPack.RV3("Scale" ),
Trans = msgPack.RV3("Trans"), Visibility = msgPack.RK ("Visibility") };
public static Vec4<Key?>? RRGBAK(this MsgPack msgPack, string name) =>
public static Vec4<Key?>? RRGBAKN(this MsgPack msgPack, string name) =>
msgPack[name].NotNull ? (Vec4<Key?>?)msgPack[name].RRGBAK() : null;
public static Vec4<Key?> RRGBAK(this MsgPack msgPack, string name) =>
msgPack[name].RRGBAK();
public static Vec4<Key?> RRGBAK(this MsgPack msgPack) =>
new Vec4<Key?> { X = msgPack.RKN("R"), Y = msgPack.RKN("G"),
Z = msgPack.RKN("B"), W = msgPack.RKN("A") };
@@ -2714,7 +2784,7 @@ namespace KKdMainLib
if (msgPack.RB("RawData")) key.RawData = new Key.RawD() { KeyType = -1, ValueType = "float" };
MsgPack trans;
if ((trans = msgPack["Trans", true]).IsNull) return key;
if ((trans = msgPack["Keys", true]).IsNull && (trans = msgPack["Trans", true]).IsNull) return key;
int length = trans.Array.Length;
key.Keys = new KFT3[length];
@@ -2761,6 +2831,13 @@ namespace KKdMainLib
return msgPack;
}
public static MsgPack Add(this MsgPack msgPack, string name, ref Vec4<Key?> rgba)
{
if (!rgba.X.HasValue && !rgba.Y.HasValue && !rgba.Z.HasValue && !rgba.W.HasValue) return msgPack;
return msgPack.Add(new MsgPack(name).Add("R", ref rgba.X).Add("G", ref rgba.Y)
.Add("B", ref rgba.Z).Add("A", ref rgba.W));
}
public static MsgPack Add(this MsgPack msgPack, string name, ref Vec3<Key> key)
{
MsgPack m = new MsgPack(name).Add("X", ref key.X).Add("Y", ref key.Y).Add("Z", ref key.Z);
@@ -2791,20 +2868,20 @@ namespace KKdMainLib
if (key.RawData.KeyType != 0) keys.Add("RawData", true);
int length = key.Keys.Length;
MsgPack Trans = new MsgPack(length, "Trans");
MsgPack Keys = new MsgPack(length, "Keys");
for (int i = 0; i < length; i++)
{
IKF kf = key.Keys[i].Check();
if (kf is KFT0 kft0) Trans[i] = new MsgPack(null,
if (kf is KFT0 kft0) Keys[i] = new MsgPack(null,
new MsgPack[] { kft0.F });
else if (kf is KFT1 kft1) Trans[i] = new MsgPack(null,
else if (kf is KFT1 kft1) Keys[i] = new MsgPack(null,
new MsgPack[] { kft1.F, kft1.V });
else if (kf is KFT2 kft2) Trans[i] = new MsgPack(null,
else if (kf is KFT2 kft2) Keys[i] = new MsgPack(null,
new MsgPack[] { kft2.F, kft2.V, kft2.T });
else if (kf is KFT3 kft3) Trans[i] = new MsgPack(null,
else if (kf is KFT3 kft3) Keys[i] = new MsgPack(null,
new MsgPack[] { kft3.F, kft3.V, kft3.T1, kft3.T2, });
}
keys.Add(Trans);
keys.Add(Keys);
}
else if (key.Type != KeyType.None) keys.Add("Value", key.Value);
msgPack.Add(keys);
-146
View File
@@ -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;
}
}
}
}
+11 -4
View File
@@ -248,7 +248,10 @@ namespace KKdMainLib
}
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;
@@ -256,9 +259,13 @@ namespace KKdMainLib
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 seed = 0,
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;
@@ -267,7 +274,7 @@ namespace KKdMainLib
const uint m = 0x7FD652AD;
const int r = 16;
hash = seed + 0xDEADBEEF;
hash = salt + 0xDEADBEEF;
if (alreadyUpper)
{
if (bigEndian)
+2 -2
View File
@@ -6,12 +6,12 @@
<Configuration></Configuration>
<Copyright>korenkonder (C) 2018-2021</Copyright>
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files</Description>
<FileVersion>0.4.10.2</FileVersion>
<FileVersion>0.4.10.5</FileVersion>
<PackageId>KKdMainLib</PackageId>
<Product>KKdMainLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdMainLib</Title>
<Version>0.4.10.2</Version>
<Version>0.4.10.5</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
-1
View File
@@ -40,7 +40,6 @@
</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" />
+18 -22
View File
@@ -218,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);
@@ -235,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')
@@ -312,8 +310,6 @@ namespace PD_Tool
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", "json", "mp") +
@@ -350,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 -2
View File
@@ -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.5")]
[assembly: AssemblyFileVersion("0.4.10.5")]
+46 -28
View File
@@ -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,33 +76,33 @@ 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)
if (choose == "9") a3da.MsgPackWriter(filepath, json);
if (choose == "F") 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())
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();
-37
View File
@@ -1,37 +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())
{
filepath = Path.RemoveExtension(file);
ext = Path.GetExtension(file).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);
}
}
}
}
}