Skip to content

Commit

Permalink
Merge pull request #22 from PassiveModding/feature/dalamud-sdk
Browse files Browse the repository at this point in the history
Feature/dalamud sdk
  • Loading branch information
PassiveModding authored Nov 19, 2024
2 parents 81a0373 + e6a4463 commit f195e96
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 79 deletions.
39 changes: 2 additions & 37 deletions Meddle/Meddle.Plugin/Meddle.Plugin.csproj
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
<PropertyGroup>
<Version>0.0.1</Version>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>Meddle.Plugin</RootNamespace>
<LangVersion>12</LangVersion>
</PropertyGroup>

<PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
</PropertyGroup>

<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0"/>
<PackageReference Include="Vortice.Direct3D11" Version="3.5.0"/>
<Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
<Private>false</Private>
</Reference>
<PackageReference Include="Vortice.Direct3D11" Version="3.5.0"/>
<Reference Include="OtterTex">
<HintPath>..\Meddle.Utils\Lib\OtterTex.dll</HintPath>
</Reference>
Expand Down
58 changes: 58 additions & 0 deletions Meddle/Meddle.Plugin/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
"resolved": "11.0.0",
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
},
"DotNet.ReproducibleBuilds": {
"type": "Direct",
"requested": "[1.1.1, )",
"resolved": "1.1.1",
"contentHash": "+H2t/t34h6mhEoUvHi8yGXyuZ2GjSovcGYehJrS2MDm2XgmPfZL2Sdxg+uL2lKgZ4M6tTwKHIlxOob2bgh0NRQ==",
"dependencies": {
"Microsoft.SourceLink.AzureRepos.Git": "1.1.1",
"Microsoft.SourceLink.Bitbucket.Git": "1.1.1",
"Microsoft.SourceLink.GitHub": "1.1.1",
"Microsoft.SourceLink.GitLab": "1.1.1"
}
},
"Microsoft.Extensions.DependencyInjection": {
"type": "Direct",
"requested": "[8.0.0, )",
Expand Down Expand Up @@ -57,6 +69,11 @@
"Vortice.DXGI": "3.5.0"
}
},
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "AT3HlgTjsqHnWpBHSNeR0KxbLZD7bztlZVj7I8vgeYG9SYqbeFGh0TM/KVtC6fg53nrWHl3VfZFvb5BiQFcY6Q=="
},
"Microsoft.Extensions.Configuration": {
"type": "Transitive",
"resolved": "8.0.0",
Expand Down Expand Up @@ -302,6 +319,47 @@
"resolved": "8.0.0",
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g=="
},
"Microsoft.SourceLink.AzureRepos.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "qB5urvw9LO2bG3eVAkuL+2ughxz2rR7aYgm2iyrB8Rlk9cp2ndvGRCvehk3rNIhRuNtQaeKwctOl1KvWiklv5w==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.Bitbucket.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "cDzxXwlyWpLWaH0em4Idj0H3AmVo3L/6xRXKssYemx+7W52iNskj/SQ4FOmfCb8YQt39otTDNMveCZzYtMoucQ==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "WMcGpWKrmJmzrNeuaEb23bEMnbtR/vLmvZtkAP5qWu7vQsY59GqfRJd65sFpBszbd2k/bQ8cs8eWawQKAabkVg=="
},
"Microsoft.SourceLink.GitHub": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.GitLab": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "tvsg47DDLqqedlPeYVE2lmiTpND8F0hkrealQ5hYltSmvruy/Gr5nHAKSsjyw5L3NeM/HLMI5ORv7on/M4qyZw==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"SharpGen.Runtime": {
"type": "Transitive",
"resolved": "2.1.2-beta",
Expand Down
40 changes: 14 additions & 26 deletions Meddle/Meddle.Utils/Files/PbdFile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using System.Runtime.InteropServices;
using FFXIVClientStructs.Havok.Common.Base.Math.QsTransform;

namespace Meddle.Utils.Files;

Expand Down Expand Up @@ -57,7 +56,7 @@ public struct Link
public ushort HeaderIdx;
}

/*public readonly struct DeformMatrix4x4
public readonly struct DeformMatrix4x4
{
private readonly float[] matrix;

Expand All @@ -81,26 +80,20 @@ public DeformMatrix4x4(float[] matrix)
this.matrix = matrix;
}

public static DeformMatrix4x4 Identity => new([
0, 0, 0, 0, // Translation (vec3 + unused)
0, 0, 0, 1, // Rotation (vec4)
1, 1, 1, 0, // Scale (vec3 + unused)
]);
// https://github.com/TexTools/xivModdingFramework/blob/459b863fdacf291ee0817feef379a18275f33010/xivModdingFramework/Models/Helpers/ModelModifiers.cs#L1202
public Vector3 TransformCoordinate(Vector3 vector) =>
new(
(vector.X * matrix[0]) + (vector.Y * matrix[1]) + (vector.Z * matrix[2]) + (1.0f * matrix[3]),
(vector.X * matrix[4]) + (vector.Y * matrix[5]) + (vector.Z * matrix[6]) + (1.0f * matrix[7]),
(vector.X * matrix[8]) + (vector.Y * matrix[9]) + (vector.Z * matrix[10]) + (1.0f * matrix[11])
);
}*/
}

public struct Deformer
{
public int BoneCount;
public string[] BoneNames;
public hkQsTransformf?[] DeformMatrices;
public DeformMatrix4x4?[] DeformMatrices;

public static Deformer Read(SpanBinaryReader reader)
{
Expand All @@ -120,11 +113,14 @@ public static Deformer Read(SpanBinaryReader reader)
var padding = boneCount * 2 % 4;
reader.Read<byte>(padding);

var matrixArray = new hkQsTransformf?[boneCount];
var matrixArray = new DeformMatrix4x4?[boneCount];
for (var i = 0; i < boneCount; i++)
{
var matrix = reader.Read<hkQsTransformf>();
matrixArray[i] = matrix;
var matrix = reader.Read<float>(12);
var buf = new float[16];
matrix.CopyTo(buf);
buf[15] = 1.0f;
matrixArray[i] = new DeformMatrix4x4(buf);
}

return new Deformer
Expand All @@ -135,7 +131,7 @@ public static Deformer Read(SpanBinaryReader reader)
};
}

public static unsafe hkQsTransformf Identity()
public static DeformMatrix4x4 Identity()
{
var buf = new float[]
{
Expand All @@ -144,20 +140,12 @@ public static unsafe hkQsTransformf Identity()
1, 1, 1, 0, // Scale (vec3 + unused)
0, 0, 0, 1, // Affine
};

// marshal the buffer to a struct
fixed (float* ptr = buf)
{
return *(hkQsTransformf*)ptr;
}

return new DeformMatrix4x4(buf);
}

public static Vector3 TransformCoordinate(Vector3 vector, hkQsTransformf matrix) =>
new(
(vector.X * matrix.Translation.X) + (vector.Y * matrix.Translation.Y) + (vector.Z * matrix.Translation.Z) + (1.0f * matrix.Translation.W),
(vector.X * matrix.Rotation.X) + (vector.Y * matrix.Rotation.Y) + (vector.Z * matrix.Rotation.Z) + (1.0f * matrix.Rotation.W),
(vector.X * matrix.Scale.X) + (vector.Y * matrix.Scale.Y) + (vector.Z * matrix.Scale.Z) + (1.0f * matrix.Scale.W)
);
public static Vector3 TransformCoordinate(Vector3 vector, DeformMatrix4x4 matrix) =>
matrix.TransformCoordinate(vector);
}

public IEnumerable<Deformer> GetDeformers(ushort from, ushort to)
Expand Down
13 changes: 0 additions & 13 deletions Meddle/Meddle.Utils/Meddle.Utils.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -19,24 +18,12 @@
<HintPath>Lib\OtterTex.dll</HintPath>
</Reference>
</ItemGroup>

<PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
</PropertyGroup>

<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="SharpGLTF.Core" Version="1.0.2" />
<PackageReference Include="SharpGLTF.Toolkit" Version="1.0.2" />
<PackageReference Include="SkiaSharp" Version="2.88.8"/>
<PackageReference Include="System.IO.Hashing" Version="8.0.0"/>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions Meddle/Meddle.Utils/RaceDeformer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Numerics;
using System.Text.RegularExpressions;
using FFXIVClientStructs.Havok.Common.Base.Math.QsTransform;
using Meddle.Utils.Constants;
using Meddle.Utils.Export;
using Meddle.Utils.Files;

namespace Meddle.Utils;
Expand All @@ -13,7 +11,7 @@ public partial class RaceDeformer(PbdFile pbd, IReadOnlyList<BoneNodeBuilder> bo
public PbdFile PbdFile { get; } = pbd;
private IReadOnlyList<BoneNodeBuilder> BoneMap { get; } = boneMap;

private hkQsTransformf? ResolveDeformation(PbdFile.Deformer deformer, string name)
private PbdFile.DeformMatrix4x4? ResolveDeformation(PbdFile.Deformer deformer, string name)
{
// Try and fetch it from the PBD
var boneNames = deformer.BoneNames;
Expand Down
70 changes: 70 additions & 0 deletions Meddle/Meddle.Utils/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version": 1,
"dependencies": {
"net8.0-windows7.0": {
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Direct",
"requested": "[8.0.1, )",
"resolved": "8.0.1",
"contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1"
}
},
"SharpGLTF.Core": {
"type": "Direct",
"requested": "[1.0.2, )",
"resolved": "1.0.2",
"contentHash": "FhTVtpzhlL7J836t+BuGr7kMylpV1KoEFMfuSRGJ4ut/Hw7dMJYon2yvs9/jEaTCstZa0Nam4lp3CkizSz5/+w=="
},
"SharpGLTF.Toolkit": {
"type": "Direct",
"requested": "[1.0.2, )",
"resolved": "1.0.2",
"contentHash": "N71Oa5+V/ByOTiOemQG77Uvo7zlROLdqJik2LTkYcrRObe23fIB8Qoj2Cn/Xi0o4ZSCpwtEmxH+dz/Hg4/x/SQ==",
"dependencies": {
"SharpGLTF.Runtime": "1.0.2"
}
},
"SkiaSharp": {
"type": "Direct",
"requested": "[2.88.8, )",
"resolved": "2.88.8",
"contentHash": "bRkp3uKp5ZI8gXYQT57uKwil1uobb2p8c69n7v5evlB/2JNcMAXVcw9DZAP5Ig3WSvgzGm2YSn27UVeOi05NlA==",
"dependencies": {
"SkiaSharp.NativeAssets.Win32": "2.88.8",
"SkiaSharp.NativeAssets.macOS": "2.88.8"
}
},
"System.IO.Hashing": {
"type": "Direct",
"requested": "[8.0.0, )",
"resolved": "8.0.0",
"contentHash": "ne1843evDugl0md7Fjzy6QjJrzsjh46ZKbhf8GwBXb5f/gw97J4bxMs0NQKifDuThh/f0bZ0e62NPl1jzTuRqA=="
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Transitive",
"resolved": "8.0.1",
"contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA=="
},
"SharpGLTF.Runtime": {
"type": "Transitive",
"resolved": "1.0.2",
"contentHash": "IVWirVtBX1nOUwDCYwDwbNsRUzNfMTJSkszTvte9X11whr2JhrxtRnuWQIhGiY3hkrvDXW6eCQ+GumVOIAuKgg==",
"dependencies": {
"SharpGLTF.Core": "1.0.2"
}
},
"SkiaSharp.NativeAssets.macOS": {
"type": "Transitive",
"resolved": "2.88.8",
"contentHash": "6Kn5TSkKlfyS6azWHF3Jk2sW5C4jCE5uSshM/5AbfFrR+5n6qM5XEnz9h4VaVl7LTxBvHvMkuPb/3bpbq0vxTw=="
},
"SkiaSharp.NativeAssets.Win32": {
"type": "Transitive",
"resolved": "2.88.8",
"contentHash": "O9QXoWEXA+6cweR4h3BOnwMz+pO9vL9mXdjLrpDd0w1QzCgWmLQBxa1VgySDITiH7nQndrDG1h6937zm9pLj1Q=="
}
}
}
}

0 comments on commit f195e96

Please sign in to comment.