Added Ufbx
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Test\Ghost.Test.Core\Ghost.Test.Core.csproj" />
|
||||
<ProjectReference Include="..\..\ThridParty\Ghost.Nvtt\Ghost.Nvtt.csproj" />
|
||||
<ProjectReference Include="..\..\ThridParty\Ghost.Ufbx\Ghost.Ufbx.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Ghost.Nvtt;
|
||||
using Ghost.Nvtt.Native;
|
||||
using Ghost.Nvtt.Warper;
|
||||
using Ghost.Test.Core;
|
||||
|
||||
namespace Ghost.MicroTest;
|
||||
@@ -22,7 +22,7 @@ namespace Ghost.MicroTest;
|
||||
/// </summary>
|
||||
internal sealed unsafe class NvttBindingTest : ITest
|
||||
{
|
||||
private const string _IMAGE_PATH = @"C:\Users\Misaki\Downloads\Screenshot 2024-07-20 035047.png";
|
||||
private const string _IMAGE_PATH = @"C:/Users/Misaki/Downloads/Screenshot 2024-07-20 035047.png";
|
||||
|
||||
private string _outputDdsPath = string.Empty;
|
||||
|
||||
@@ -53,7 +53,7 @@ internal sealed unsafe class NvttBindingTest : ITest
|
||||
using (var token = NvttGlobal.SetMessageCallback((severity, error, msg) =>
|
||||
{
|
||||
callbackFired++;
|
||||
Console.WriteLine($"\n [NVTT] [{severity}] {error}: {msg}");
|
||||
Console.WriteLine($"/n [NVTT] [{severity}] {error}: {msg}");
|
||||
}))
|
||||
{
|
||||
// Just install + dispose — no assertion needed; must not throw.
|
||||
@@ -124,7 +124,7 @@ internal sealed unsafe class NvttBindingTest : ITest
|
||||
endImage: null
|
||||
);
|
||||
outOpts.SetErrorHandler(err =>
|
||||
Console.WriteLine($"\n [NVTT Error] {err}"));
|
||||
Console.WriteLine($"/n [NVTT Error] {err}"));
|
||||
|
||||
using var ctx = new NvttContextHandle();
|
||||
ctx.SetCudaAcceleration(false); // CPU only for the test
|
||||
@@ -184,13 +184,13 @@ internal sealed unsafe class NvttBindingTest : ITest
|
||||
Assert(fileSize > 128, $"DDS file suspiciously small: {fileSize} bytes");
|
||||
Console.WriteLine($"OK ({fileSize:N0} bytes → {_outputDdsPath})");
|
||||
|
||||
Console.WriteLine("\n[NvttBindingTest] All tests PASSED.");
|
||||
Console.WriteLine("/n[NvttBindingTest] All tests PASSED.");
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
// Leave the DDS file in place so you can inspect it.
|
||||
Console.WriteLine($"\n[NvttBindingTest] Output DDS left at: {_outputDdsPath}");
|
||||
Console.WriteLine($"/n[NvttBindingTest] Output DDS left at: {_outputDdsPath}");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ghost.MicroTest;
|
||||
using Ghost.Test.Core;
|
||||
|
||||
TestRunner.Run<NvttBindingTest>();
|
||||
TestRunner.Run<UfbxBindingTest>();
|
||||
|
||||
55
src/Test/Ghost.MicroTest/UfbxBindingTest.cs
Normal file
55
src/Test/Ghost.MicroTest/UfbxBindingTest.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Ghost.Test.Core;
|
||||
using Ghost.Ufbx;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using static Ghost.Ufbx.Api;
|
||||
|
||||
namespace Ghost.MicroTest;
|
||||
|
||||
internal unsafe class UfbxBindingTest : ITest
|
||||
{
|
||||
private static ReadOnlySpan<byte> TestFilePath => "F:/c/Third Parties/ufbx/data/blender_340_z_up_7400_binary.fbx"u8;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
ufbx_load_opts opts = default;
|
||||
ufbx_error error;
|
||||
ufbx_scene* pScene;
|
||||
|
||||
var path = TestFilePath;
|
||||
fixed (byte* p = path)
|
||||
{
|
||||
pScene = ufbx_load_file((sbyte*)p, &opts, &error);
|
||||
}
|
||||
|
||||
if (pScene == null)
|
||||
{
|
||||
Debug.Fail($"Failed to load scene: {Encoding.UTF8.GetString((byte*)error.description.data, (int)error.description.length)}");
|
||||
}
|
||||
|
||||
for (nuint i = 0; i < pScene->nodes.count; i++)
|
||||
{
|
||||
var node = pScene->nodes.data[i];
|
||||
if (node->is_root)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Console.WriteLine($"Object: {Encoding.UTF8.GetString((byte*)node->name.data, (int)node->name.length)}");
|
||||
if (node->mesh != null)
|
||||
{
|
||||
Console.WriteLine($"-> mesh with {node->mesh->faces.count} faces");
|
||||
}
|
||||
}
|
||||
|
||||
ufbx_free_scene(pScene);
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user