Compare commits

...
1 Commits
Author SHA1 Message Date
korenkonder 797d0f9467 Release v0.5.0.0
`MotHead`: Fixed names for some Types. Be careful! JSONs generated by versions prior to this one may be incompatible!
Updated libdeflate to 1.24
2025-06-20 11:00:18 +03:00
9 changed files with 132 additions and 122 deletions
+3 -3
View File
@@ -4,14 +4,14 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder (C) 2019-2024</Copyright>
<Copyright>korenkonder (C) 2019-2025</Copyright>
<Description>A base library</Description>
<FileVersion>0.4.11.0</FileVersion>
<FileVersion>0.5.0.0</FileVersion>
<PackageId>KKdBaseLib</PackageId>
<Product>KKdBaseLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdBaseLib</Title>
<Version>0.4.11.0</Version>
<Version>0.5.0.0</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+39 -5
View File
@@ -1,3 +1,4 @@
using System;
using System.Runtime.InteropServices;
namespace KKdBaseLib
@@ -79,7 +80,7 @@ namespace KKdBaseLib
if (trace > 0)
{
double sq = System.Math.Sqrt(trace);
double sq = Math.Sqrt(trace);
q.W = (float)sq;
sq = 1.0 / (4.0 * sq);
@@ -89,7 +90,7 @@ namespace KKdBaseLib
}
else if (row0.X > row1.Y && row0.X > row2.Z)
{
double sq = 2.0 * System.Math.Sqrt(1.0 + row0.X - row1.Y - row2.Z);
double sq = 2.0 * Math.Sqrt(1.0 + row0.X - row1.Y - row2.Z);
q.X = (float)(0.25 * sq);
sq = 1.0 / sq;
@@ -99,7 +100,7 @@ namespace KKdBaseLib
}
else if (row1.Y > row2.Z)
{
double sq = 2.0 * System.Math.Sqrt(1.0 + row1.Y - row0.X - row2.Z);
double sq = 2.0 * Math.Sqrt(1.0 + row1.Y - row0.X - row2.Z);
q.Y = (float)(0.25 * sq);
sq = 1.0 / sq;
@@ -109,7 +110,7 @@ namespace KKdBaseLib
}
else
{
double sq = 2.0 * System.Math.Sqrt(1.0 + row2.Z - row0.X - row1.Y);
double sq = 2.0 * Math.Sqrt(1.0 + row2.Z - row0.X - row1.Y);
q.Z = (float)(0.25 * sq);
sq = 1.0 / sq;
@@ -121,6 +122,33 @@ namespace KKdBaseLib
return q.Normalized;
}
public Vec3 GetRotation()
{
Vec3 rotation;
if (-Row0.Z >= 1.0f)
rotation.Y = (float)(Math.PI / 2.0);
else if (-Row0.Z <= -1.0f)
rotation.Y = (float)(-Math.PI / 2.0);
else
rotation.Y = (float)Math.Asin(-Row0.Z);
if (Math.Abs(Row0.Z) < 0.99999899f) {
rotation.X = (float)Math.Atan2(Row1.Z, Row2.Z);
rotation.Z = (float)Math.Atan2(Row0.Y, Row0.X);
}
else {
rotation.X = 0.0f;
rotation.Z = (float)Math.Atan2(Row2.Y, Row1.Y);
if (Row0.Z > 0.0f)
rotation.Z = -rotation.Z;
}
return rotation;
}
public Vec3 GetScale() => new Vec3(Row0.Length, Row1.Length, Row2.Length);
public Vec3 GetTranslation() => Row3.XYZ;
public Mat4 Invert() => -this;
public Mat4 Translate(Vec3 vec)
@@ -129,7 +157,13 @@ namespace KKdBaseLib
public Mat4 Translate(Vec4 vec)
{ Row3 = vec * this; return this; }
public static Mat4 operator +(Mat4 left, Mat4 right)
public void TransformVector(in Vec3 normal, out Vec3 normalOut) {
normalOut = (Row0 * new Vec4(normal.X) +
Row1 * new Vec4(normal.Y) +
Row2 * new Vec4(normal.Z)).XYZ;
}
public static Mat4 operator +(Mat4 left, Mat4 right)
{ left.Row0 += right.Row0; left.Row1 += right.Row1;
left.Row2 += right.Row2; left.Row3 += right.Row3; return left; }
+35 -67
View File
@@ -45,52 +45,9 @@ namespace KKdBaseLib
public Vec3 XYZ { get => new Vec3(X, Y, Z); set { X = value.X; Y = value.Y; Z = value.Z; } }
public float Length => (X * X + Y * Y + Z * Z + W * W).Sqrt();
public float LengthSquared => X * X + Y * Y + Z * Z + W * W;
public Quat Normalized => new Quat(X, Y, Z, W) * (Length == 0.0f ? 1.0f : (1.0f / Length));
public Vec3 Euler { get
{
if (LengthSquared == 0) return default;
const float SINGULARITY_THRESHOLD = 0.4999995f;
const float HalfPI = (float)(System.Math.PI * 0.5);
float sqx = X * X, sqy = Y * Y, sqz = Z * Z, sqw = W * W;
float unit = sqx + sqy + sqz + sqw;
float singularityTest = X * Z + Y * W;
if (singularityTest > SINGULARITY_THRESHOLD * unit)
return new Vec3(0.0f, HalfPI, (float)(System.Math.Atan2(X, W) * 2.0));
else if (singularityTest < -SINGULARITY_THRESHOLD * unit)
return new Vec3(0.0f, -HalfPI, -(float)(System.Math.Atan2(X, W) * 2.0));
else
return new Vec3((float)System.Math.Atan2(2 * (X * W - Y * Z), sqw - sqx - sqy + sqz),
(float)System.Math.Asin (2 * singularityTest / unit),
(float)System.Math.Atan2(2 * (Z * W - X * Y), sqw + sqx - sqy - sqz));
}
}
public Vec3 EulerDeg { get
{
if (LengthSquared == 0) return default;
const float SINGULARITY_THRESHOLD = 0.4999995f;
const float HalfPI = (float)(System.Math.PI * 0.5);
float sqx = X * X, sqy = Y * Y, sqz = Z * Z, sqw = W * W;
float unit = sqx + sqy + sqz + sqw;
float singularityTest = X * Z + Y * W;
if (singularityTest > SINGULARITY_THRESHOLD * unit)
return new Vec3(0.0f, HalfPI, (float)(System.Math.Atan2(X, W) * 2.0));
else if (singularityTest < -SINGULARITY_THRESHOLD * unit)
return new Vec3(0.0f, -HalfPI, -(float)(System.Math.Atan2(X, W) * 2.0));
else
return new Vec3((float)System.Math.Atan2(2 * (X * W - Y * Z), sqw - sqx - sqy + sqz),
(float)System.Math.Asin (2 * singularityTest / unit),
(float)System.Math.Atan2(2 * (Z * W - X * Y), sqw + sqx - sqy - sqz))
* (float)(180.0 / System.Math.PI);
}
}
public readonly float Length => (X * X + Y * Y + Z * Z + W * W).Sqrt();
public readonly float LengthSquared => X * X + Y * Y + Z * Z + W * W;
public readonly Quat Normalized => this * (Length == 0.0f ? 1.0f : (1.0f / Length));
public static Quat operator +(Quat left, Quat right)
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; left.W += right.W; return left; }
@@ -125,34 +82,45 @@ namespace KKdBaseLib
public Quat Round(int d) =>
new Quat { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
public static Quat Slerp(Quat q1, Quat q2, float blend)
{
q1 = q1.Normalized;
q2 = q2.Normalized;
public static Quat Lerp(Quat left, Quat right, float blend) {
Quat x_t;
Quat y_t;
x_t = left;
y_t = right;
float dot = Dot(q1, q2);
if (Dot(x_t, y_t) < 0.0f)
x_t = -x_t;
return (x_t * (1.0f - blend) + y_t * blend).Normalized;
}
public static Quat Slerp(Quat left, Quat right, float blend)
{
Quat x_t;
Quat y_t;
x_t = left;
y_t = right;
float dot = Dot(x_t, y_t);
if (dot < 0.0f)
{
q2 = -q2;
dot = -dot;
y_t = -y_t;
}
Quat result;
const float DOT_THRESHOLD = 0.9995f;
if (dot <= DOT_THRESHOLD)
{
float theta_0 = (float)System.Math.Acos(dot);
float theta = theta_0 * blend;
float sin_theta = (float)System.Math.Sin(theta);
float sin_theta_0 = (float)System.Math.Sin(theta_0);
if (1.0 - dot <= 0.08f)
return Lerp(x_t, y_t, blend);
float s0 = (float)System.Math.Cos(theta) - dot * sin_theta / sin_theta_0;
float s1 = sin_theta / sin_theta_0;
result = s0 * q1 + s1 * q2;
}
else
result = (1.0f - blend) * q1 + blend * q2;
return result.Normalized;
dot = System.Math.Min(dot, 1.0f);
float theta = (float)System.Math.Acos(dot);
if (theta == 0.0f)
return x_t;
float st = 1.0f / (float)System.Math.Sin(theta);
float s0 = (float)System.Math.Sin((1.0f - blend) * theta) * st;
float s1 = (float)System.Math.Sin(theta * blend) * st;
return (x_t * s0 + y_t * s1).Normalized;
}
public static explicit operator Vec4(Quat quat) =>
+1 -1
View File
@@ -11,7 +11,7 @@ namespace KKdBaseLib
[FieldOffset(0x0C)] public float W;
public Vec4(float val)
{ X = val; Y = val; Z = val; W = 0.0f; }
{ X = val; Y = val; Z = val; W = val; }
public Vec4(float X, float Y)
{ this.X = X; this.Y = Y; Z = 0.0f; W = 0.0f; }
+1 -1
View File
@@ -13,7 +13,7 @@ namespace KKdMainLib
public FARC(string file, bool isDirectory = false)
{ if (isDirectory) DirectoryPath = file; else FilePath = file; NewFARC(); }
private void NewFARC() { Files = KKdList<FARCFile>.New; Signature = Farc.FArC; FT = false; }
private void NewFARC() { Files = KKdList<FARCFile>.New; FT = false; }
public KKdList<FARCFile> Files = KKdList<FARCFile>.New;
public Flags FARCFlags;
+2 -2
View File
@@ -6,12 +6,12 @@
<Configuration></Configuration>
<Copyright>korenkonder (C) 2018-2024</Copyright>
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/XHD/FT/VRFL/M39 files</Description>
<FileVersion>0.4.11.0</FileVersion>
<FileVersion>0.5.0.0</FileVersion>
<PackageId>KKdMainLib</PackageId>
<Product>KKdMainLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdMainLib</Title>
<Version>0.4.11.0</Version>
<Version>0.5.0.0</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+48 -40
View File
@@ -1,6 +1,7 @@
using KKdBaseLib;
using KKdBaseLib.F2;
using KKdMainLib.IO;
using static KKdMainLib.FARC;
namespace KKdMainLib
{
@@ -487,11 +488,11 @@ RETURN:
case 0x3B: // SetRobCharaHeadObject
data.Array.GBy(temp.RI32("Index"), 0x00);
break;
case 0x3C:
data.Array.GBy(temp.RI32("i00"), 0x00);
data.Array.GBy(temp.RF32("f04"), 0x04);
data.Array.GBy(temp.RF32("f08"), 0x08);
data.Array.GBy(temp.RF32("f0C"), 0x0C);
case 0x3C: // SetLookCamera
data.Array.GBy(temp.RI32("Enable"), 0x00);
data.Array.GBy(temp.RF32("HeadRotStrength"), 0x04);
data.Array.GBy(temp.RF32("EyesRotStrength"), 0x08);
data.Array.GBy(temp.RF32("BlendDuration"), 0x0C);
break;
case 0x3D: // SetEyelidMotionFromFace
data.Array.GBy(temp.RI32("i00"), 0x00);
@@ -518,13 +519,15 @@ RETURN:
data.Array.GBy(temp.RF32("Strength"), 0x38);
data.Array.GBy(temp.RI32("StrengthTransition"), 0x3C);
break;
case 0x41: // OsageReset
case 0x40: // OsageReset
break;
case 0x41: // MotionSkinParam
data.Array.GBy(temp.RI32("Iterations"), 0x00);
break;
case 0x42: // OsageStep
data.Array.GBy(temp.RF32("Value"), 0x00);
break;
case 0x43:
case 0x43: // SleeveAdjust
data.Array.GBy(temp.RI32("i00"), 0x00);
data.Array.GBy(temp.RF32("f04"), 0x04);
break;
@@ -532,11 +535,11 @@ RETURN:
data.Array.GBy(temp.RI32("i00"), 0x00);
data.Array.GBy(temp.RF32("f04"), 0x04);
break;
case 0x45:
data.Array.GBy(temp.RI32("i00"), 0x00);
case 0x45: // MotionMaxFrame
data.Array.GBy(temp.RI32("MaxFrame"), 0x00);
break;
case 0x46:
data.Array.GBy(temp.RI32("i00"), 0x00);
case 0x46: // CameraMaxFrame
data.Array.GBy(temp.RI32("MaxFrame"), 0x00);
break;
case 0x47: // OsageMoveCancel
data.Array.GBy(temp.RU8("ID"), 0x00); // 0 - All, 1 - Kami, 2 - Outer
@@ -571,9 +574,9 @@ RETURN:
data.Array.GBy(temp.RF32("ArmLength"), 0x28);
data.Array.GBy(temp.RI32("i2C"), 0x2C);
break;
case 0x4A:
data.Array.GBy(temp.RU8("i00_8"), 0x00);
data.Array.GBy(temp.RU8("i01_8"), 0x01);
case 0x4A: // DisableCollision
data.Array.GBy(temp.RU8("Parts"), 0x00);
data.Array.GBy(temp.RU8("Disable"), 0x01);
break;
case 0x4B: // RobAdjustGlobal
data.Array.GBy(temp.RI32("TransitionDuration"), 0x00);
@@ -616,7 +619,6 @@ RETURN:
case 0x50: // AdjustGetGlobalTrans
data.Array.GBy((byte)(temp.RB("Value") ? 1 : 0), 0x00);
break;
case 0x40: // WindReset
default:
break;
}
@@ -790,12 +792,12 @@ RETURN:
arrayEntry.Add(new MsgPack("Data")
.Add("Index", data.Array.TI32(0x00)));
break;
case 0x3C:
case 0x3C: // SetLookCamera
arrayEntry.Add(new MsgPack("Data")
.Add("i00", data.Array.TI32(0x00))
.Add("f04", data.Array.TF32(0x04))
.Add("f08", data.Array.TF32(0x08))
.Add("f0C", data.Array.TF32(0x0C)));
.Add("Enable", data.Array.TI32(0x00))
.Add("HeadRotStrength", data.Array.TF32(0x04))
.Add("EyesRotStrength", data.Array.TF32(0x08))
.Add("BlendDuration", data.Array.TF32(0x0C)));
break;
case 0x3D: // SetEyelidMotionFromFace
arrayEntry.Add(new MsgPack("Data")
@@ -824,7 +826,9 @@ RETURN:
.Add("Strength", data.Array.TF32(0x38))
.Add("StrengthTransition", data.Array.TI32(0x3C)));
break;
case 0x41: // OsageReset
case 0x40: // OsageReset
break;
case 0x41: // MotionSkinParam
arrayEntry.Add(new MsgPack("Data")
.Add("Iterations", data.Array.TI32(0x00)));
break;
@@ -832,7 +836,7 @@ RETURN:
arrayEntry.Add(new MsgPack("Data")
.Add("Value", data.Array.TF32(0x00)));
break;
case 0x43:
case 0x43: // SleeveAdjust
arrayEntry.Add(new MsgPack("Data")
.Add("i00", data.Array.TI32(0x00))
.Add("f04", data.Array.TF32(0x04)));
@@ -842,13 +846,13 @@ RETURN:
.Add("i00", data.Array.TI32(0x00))
.Add("f04", data.Array.TF32(0x04)));
break;
case 0x45:
case 0x45: // MotionMaxFrame
arrayEntry.Add(new MsgPack("Data")
.Add("i00", data.Array.TI32(0x00)));
.Add("MaxFrame", data.Array.TI32(0x00)));
break;
case 0x46:
case 0x46: // CameraMaxFrame
arrayEntry.Add(new MsgPack("Data")
.Add("i00", data.Array.TI32(0x00)));
.Add("MaxFrame", data.Array.TI32(0x00)));
break;
case 0x47: // OsageMoveCancel
arrayEntry.Add(new MsgPack("Data")
@@ -886,10 +890,10 @@ RETURN:
.Add("ArmLength", data.Array.TF32(0x28))
.Add("i2C", data.Array.TI32(0x2C)));
break;
case 0x4A:
case 0x4A: // DisableCollision
arrayEntry.Add(new MsgPack("Data")
.Add("i00_8", data.Array.TU8(0x00))
.Add("i01_8", data.Array.TU8(0x01)));
.Add("Parts", data.Array.TU8(0x00))
.Add("Disable", data.Array.TU8(0x01)));
break;
case 0x4B: // RobAdjustGlobal
arrayEntry.Add(new MsgPack("Data")
@@ -938,7 +942,6 @@ RETURN:
arrayEntry.Add(new MsgPack("Data")
.Add("Value", data.Array.TU8(0) != 0));
break;
case 0x40: // WindReset
default:
if (data.Array != null && data.Array.Length > 0)
{
@@ -1001,20 +1004,20 @@ RETURN:
0x39 => 0x14, // SetEyesMottblMotion
0x3A => 0x14, // SetEyelidMottblMotion
0x3B => 0x04, // SetRobCharaHeadObject
0x3C => 0x10,
0x3C => 0x10, // SetLookCamera
0x3D => 0x08, // SetEyelidMotionFromFace
0x3E => 0x40, // RobPartsAdjust
0x40 => 0x00, // WindReset
0x41 => 0x04, // OsageReset
0x40 => 0x00, // OsageReset
0x41 => 0x04, // MotionSkinParam
0x42 => 0x04, // OsageStep
0x43 => 0x08,
0x43 => 0x08, // SleeveAdjust
0x44 => 0x08,
0x45 => 0x04,
0x46 => 0x04,
0x45 => 0x04, // MotionMaxFrame
0x46 => 0x04, // CameraMaxFrame
0x47 => 0x08, // OsageMoveCancel
0x48 => 0x1C,
0x49 => 0x30, // RobHandAdjust
0x4A => 0x02,
0x4A => 0x02, // DisableCollision
0x4B => 0x34, // RobAdjustGlobal
0x4C => 0x0C, // RobArmAdjust
0x4D => 0x01, // DisableEyeMotion
@@ -1039,7 +1042,7 @@ RETURN:
_ => 0x00,
};
public void Dispose()
public void Dispose()
{ if (s != null) s.D(); s = null; Header = default; }
public struct HeaderData
@@ -1097,13 +1100,18 @@ RETURN:
SetEyesMottblMotion = 0x39,
SetEyelidMottblMotion = 0x3A,
SetRobCharaHeadObject = 0x3B,
SetLookCamera = 0x3C,
SetEyelidMotionFromFace = 0x3D,
RobPartsAdjust = 0x3E,
WindReset = 0x40,
OsageReset = 0x41,
OsageReset = 0x40,
MotionSkinParam = 0x41,
OsageStep = 0x42,
SleeveAdjust = 0x43,
MotionMaxFrame = 0x45,
CameraMaxFrame = 0x46,
OsageMoveCancel = 0x47,
RobHandAdjust = 0x49,
DisableCollision = 0x4A,
RobAdjustGlobal = 0x4B,
RobArmAdjust = 0x4C,
DisableEyeMotion = 0x4D,
Binary file not shown.
+3 -3
View File
@@ -6,10 +6,10 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PD_Tool")]
[assembly: AssemblyCopyright("korenkonder (C) 2017-2024")]
[assembly: AssemblyCopyright("korenkonder (C) 2017-2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
[assembly: AssemblyVersion("0.4.11.0")]
[assembly: AssemblyFileVersion("0.4.11.0")]
[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]