diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0bf9b65..698185c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,7 +17,7 @@ jobs:
with:
dotnet-version: '7.0.x'
- name: 'Test'
- run: 'dotnet test -v minimal --filter "TestCategory!=Proprietary"'
+ run: 'dotnet test -v minimal --filter "TestCategory!=Proprietary" -s Test.runsettings'
release:
runs-on: 'ubuntu-latest'
steps:
diff --git a/Test.runsettings b/Test.runsettings
new file mode 100644
index 0000000..b13a58c
--- /dev/null
+++ b/Test.runsettings
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+ Debug
+ 1
+
+
diff --git a/ZenKit.Test/TestMaterial.cs b/ZenKit.Test/TestMaterial.cs
index 84e21e0..c730e20 100644
--- a/ZenKit.Test/TestMaterial.cs
+++ b/ZenKit.Test/TestMaterial.cs
@@ -15,63 +15,69 @@ public void SetUp()
[Test]
public void TestLoadG1()
- {
- var mat = new Material("./Samples/G1/DEMON_DIE_BODY.MAT");
- Assert.That(mat.Name, Is.EqualTo("BODY"));
- Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
- Assert.That(mat.Color.R, Is.EqualTo(115));
- Assert.That(mat.Color.G, Is.EqualTo(91));
- Assert.That(mat.Color.B, Is.EqualTo(77));
- Assert.That(mat.Color.A, Is.EqualTo(255));
- Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
- Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
- Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
- Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
- Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
- Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
- Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(9.9999997e-005f));
- Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
- Assert.That(mat.DisableCollision, Is.EqualTo(false));
- Assert.That(mat.DisableLightmap, Is.EqualTo(false));
- Assert.That(mat.DontCollapse, Is.EqualTo(false));
- Assert.That(mat.DetailObject, Is.EqualTo(""));
- Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
- Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
- }
+ {
+ var mat = new Material("./Samples/G1/DEMON_DIE_BODY.MAT");
+ Assert.Multiple(() =>
+ {
+ Assert.That(mat.Name, Is.EqualTo("BODY"));
+ Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
+ Assert.That(mat.Color.R, Is.EqualTo(115));
+ Assert.That(mat.Color.G, Is.EqualTo(91));
+ Assert.That(mat.Color.B, Is.EqualTo(77));
+ Assert.That(mat.Color.A, Is.EqualTo(255));
+ Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
+ Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
+ Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
+ Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
+ Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
+ Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
+ Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(9.9999997e-005f));
+ Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
+ Assert.That(mat.DisableCollision, Is.EqualTo(false));
+ Assert.That(mat.DisableLightmap, Is.EqualTo(false));
+ Assert.That(mat.DontCollapse, Is.EqualTo(false));
+ Assert.That(mat.DetailObject, Is.EqualTo(""));
+ Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
+ Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
+ });
+ }
- [Test]
+ [Test]
public void TestLoadG2()
- {
- var mat = new Material("./Samples/G2/DEMON_DIE_BODY.MAT");
- Assert.That(mat.Name, Is.EqualTo("BODY"));
- Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
- Assert.That(mat.Color.R, Is.EqualTo(115));
- Assert.That(mat.Color.G, Is.EqualTo(91));
- Assert.That(mat.Color.B, Is.EqualTo(77));
- Assert.That(mat.Color.A, Is.EqualTo(255));
- Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
- Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
- Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
- Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
- Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
- Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
- Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(0.0f));
- Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
- Assert.That(mat.DisableCollision, Is.EqualTo(false));
- Assert.That(mat.DisableLightmap, Is.EqualTo(false));
- Assert.That(mat.DontCollapse, Is.EqualTo(false));
- Assert.That(mat.DetailObject, Is.EqualTo(""));
- Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
- Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
- Assert.That(mat.AlphaFunction, Is.EqualTo(AlphaFunction.None));
- Assert.That(mat.DetailObjectScale, Is.EqualTo(1.0f));
- Assert.That(mat.ForceOccluder, Is.EqualTo(false));
- Assert.That(mat.EnvironmentMapping, Is.EqualTo(false));
- Assert.That(mat.EnvironmentMappingStrength, Is.EqualTo(1.0f));
- Assert.That(mat.WaveMode, Is.EqualTo(WaveMode.None));
- Assert.That(mat.WaveSpeed, Is.EqualTo(WaveSpeed.Normal));
- Assert.That(mat.WaveAmplitude, Is.EqualTo(30.0f));
- Assert.That(mat.WaveGridSize, Is.EqualTo(100.0f));
- Assert.That(mat.IgnoreSun, Is.EqualTo(false));
- }
+ {
+ var mat = new Material("./Samples/G2/DEMON_DIE_BODY.MAT");
+ Assert.Multiple(() =>
+ {
+ Assert.That(mat.Name, Is.EqualTo("BODY"));
+ Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
+ Assert.That(mat.Color.R, Is.EqualTo(115));
+ Assert.That(mat.Color.G, Is.EqualTo(91));
+ Assert.That(mat.Color.B, Is.EqualTo(77));
+ Assert.That(mat.Color.A, Is.EqualTo(255));
+ Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
+ Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
+ Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
+ Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
+ Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
+ Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
+ Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(0.0f));
+ Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
+ Assert.That(mat.DisableCollision, Is.EqualTo(false));
+ Assert.That(mat.DisableLightmap, Is.EqualTo(false));
+ Assert.That(mat.DontCollapse, Is.EqualTo(false));
+ Assert.That(mat.DetailObject, Is.EqualTo(""));
+ Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
+ Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
+ Assert.That(mat.AlphaFunction, Is.EqualTo(AlphaFunction.None));
+ Assert.That(mat.DetailObjectScale, Is.EqualTo(1.0f));
+ Assert.That(mat.ForceOccluder, Is.EqualTo(false));
+ Assert.That(mat.EnvironmentMapping, Is.EqualTo(false));
+ Assert.That(mat.EnvironmentMappingStrength, Is.EqualTo(1.0f));
+ Assert.That(mat.WaveMode, Is.EqualTo(WaveMode.None));
+ Assert.That(mat.WaveSpeed, Is.EqualTo(WaveSpeed.Normal));
+ Assert.That(mat.WaveAmplitude, Is.EqualTo(30.0f));
+ Assert.That(mat.WaveGridSize, Is.EqualTo(100.0f));
+ Assert.That(mat.IgnoreSun, Is.EqualTo(false));
+ });
+ }
}
\ No newline at end of file
diff --git a/ZenKit/BspTree.cs b/ZenKit/BspTree.cs
index 7f59544..cd6e887 100644
--- a/ZenKit/BspTree.cs
+++ b/ZenKit/BspTree.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
using ZenKit.Util;
namespace ZenKit
@@ -97,17 +98,19 @@ public interface IBspTree : ICacheable
public List PolygonIndices { get; }
public List LeafPolygonIndices { get; }
public List PortalPolygonIndices { get; }
+ public ulong LightPointCount { get; }
public List LightPoints { get; }
public List LeafNodeIndices { get; }
+ public ulong NodeCount { get; }
public List Nodes { get; }
public List Sectors { get; }
public ulong SectorCount { get; }
- public IBspSector GetSector(ulong i)
- {
- return Sectors[(int)i];
- }
+ public IBspSector GetSector(ulong i);
+
+ public Vector3 GetLightPoint(ulong i);
+ public BspNode GetNode(ulong i);
}
[Serializable]
@@ -117,12 +120,33 @@ public class CachedBspTree : IBspTree
public List PolygonIndices { get; set; }
public List LeafPolygonIndices { get; set; }
public List PortalPolygonIndices { get; set; }
+
+ public ulong LightPointCount => (ulong)LightPoints.LongCount();
+
public List LightPoints { get; set; }
public List LeafNodeIndices { get; set; }
+
+ public ulong NodeCount => (ulong)Nodes.LongCount();
+
public List Nodes { get; set; }
public List Sectors { get; set; }
public ulong SectorCount => (ulong)Sectors.LongCount();
+ public IBspSector GetSector(ulong i)
+ {
+ return Sectors[(int)i];
+ }
+
+ public Vector3 GetLightPoint(ulong i)
+ {
+ return LightPoints[(int)i];
+ }
+
+ public BspNode GetNode(ulong i)
+ {
+ return Nodes[(int)i];
+ }
+
public IBspTree Cache()
{
return this;
@@ -154,13 +178,45 @@ internal BspTree(UIntPtr handle)
public List PortalPolygonIndices =>
Native.ZkBspTree_getPortalPolygonIndices(_handle, out var count).MarshalAsList(count);
- public List LightPoints =>
- Native.ZkBspTree_getLightPoints(_handle, out var count).MarshalAsList(count);
+ public ulong LightPointCount => Native.ZkBspTree_getLightPointCount(_handle);
+
+ public List LightPoints
+ {
+ get
+ {
+ var points = new List();
+
+ Native.ZkBspTree_enumerateLightPoints(_handle, (_, v) =>
+ {
+ points.Add(v);
+ return false;
+ }, UIntPtr.Zero);
+
+ return points;
+ }
+ }
public List LeafNodeIndices =>
Native.ZkBspTree_getLeafNodeIndices(_handle, out var count).MarshalAsList(count);
- public List Nodes => Native.ZkBspTree_getNodes(_handle, out var count).MarshalAsList(count);
+ public ulong NodeCount => Native.ZkBspTree_getNodeCount(_handle);
+
+ public List Nodes
+ {
+ get
+ {
+ var nodes = new List();
+
+ Native.ZkBspTree_enumerateNodes(_handle, (_, node) =>
+ {
+ nodes.Add(Marshal.PtrToStructure(node));
+ return false;
+ }, UIntPtr.Zero);
+
+ return nodes;
+ }
+ }
+
public ulong SectorCount => Native.ZkBspTree_getSectorCount(_handle);
public List Sectors
@@ -204,9 +260,19 @@ public bool IsCached()
return false;
}
- public BspSector GetSector(ulong i)
+ public IBspSector GetSector(ulong i)
{
return new BspSector(Native.ZkBspTree_getSector(_handle, i));
}
+
+ public Vector3 GetLightPoint(ulong i)
+ {
+ return Native.ZkBspTree_getLightPoint(_handle, i);
+ }
+
+ public BspNode GetNode(ulong i)
+ {
+ return Native.ZkBspTree_getNode(_handle, i);
+ }
}
}
\ No newline at end of file
diff --git a/ZenKit/DaedalusInstance.cs b/ZenKit/DaedalusInstance.cs
index 17572a1..29bbc32 100644
--- a/ZenKit/DaedalusInstance.cs
+++ b/ZenKit/DaedalusInstance.cs
@@ -1,6 +1,5 @@
using System;
using ZenKit.Daedalus;
-using ZenKit.Util;
namespace ZenKit
{
@@ -31,31 +30,7 @@ public enum DaedalusInstanceType
Invalid = 21
}
- public interface IDaedalusInstance : ICacheable
- {
- public DaedalusInstanceType Type { get; }
- public uint Index { get; }
- }
-
- [Serializable]
- public class CachedDaedalusInstance : IDaedalusInstance
- {
- public DaedalusInstanceType Type { get; set; }
- public uint Index { get; set; }
-
- public IDaedalusInstance Cache()
- {
- return this;
- }
-
- public bool IsCached()
- {
- return true;
- }
- }
-
-
- public class DaedalusInstance : IDaedalusInstance
+ public class DaedalusInstance
{
protected DaedalusInstance(UIntPtr handle)
{
@@ -67,20 +42,6 @@ protected DaedalusInstance(UIntPtr handle)
public DaedalusInstanceType Type => Native.ZkDaedalusInstance_getType(Handle);
public uint Index => Native.ZkDaedalusInstance_getIndex(Handle);
- public IDaedalusInstance Cache()
- {
- return new CachedDaedalusInstance
- {
- Type = Type,
- Index = Index
- };
- }
-
- public bool IsCached()
- {
- return false;
- }
-
public static DaedalusInstance? FromNative(UIntPtr handle)
{
if (handle == UIntPtr.Zero) return null;
diff --git a/ZenKit/DaedalusVm.cs b/ZenKit/DaedalusVm.cs
index b2098b5..3a89dda 100644
--- a/ZenKit/DaedalusVm.cs
+++ b/ZenKit/DaedalusVm.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using ZenKit.Daedalus;
namespace ZenKit
@@ -20,6 +21,21 @@ public class DaedalusVm : DaedalusScript
public delegate TR ExternalFunc(TP0 p0, TP1 p1, TP2 p2, TP3 p3,
TP4 p4);
+ public delegate TR ExternalFunc(TP0 p0, TP1 p1, TP2 p2,
+ TP3 p3, TP4 p4, TP5 p5);
+
+ public delegate TR ExternalFunc(TP0 p0, TP1 p1,
+ TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6);
+
+ public delegate TR ExternalFunc(TP0 p0,
+ TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7);
+
+ public delegate TR ExternalFunc(
+ TP0 p0, TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8);
+
+ public delegate TR ExternalFunc(TP0 p0, TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8, TP9 p9);
+
public delegate void ExternalFuncV();
public delegate void ExternalFuncV(TP0 p0);
@@ -33,6 +49,26 @@ public delegate TR ExternalFunc(
public delegate void ExternalFuncV(TP0 p0, TP1 p1, TP2 p2, TP3 p3,
TP4 p4);
+ public delegate void ExternalFuncV(TP0 p0, TP1 p1, TP2 p2,
+ TP3 p3, TP4 p4, TP5 p5);
+
+ public delegate void ExternalFuncV(TP0 p0, TP1 p1,
+ TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6);
+
+ public delegate void ExternalFuncV(TP0 p0,
+ TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7);
+
+ public delegate void ExternalFuncV(
+ TP0 p0, TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8);
+
+ public delegate void ExternalFuncV(TP0 p0, TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8, TP9 p9);
+
+ private readonly List _externalCallbacks =
+ new List();
+
+ private Native.Callbacks.ZkDaedalusVmExternalDefaultCallback? _externalDefaultCallback;
+
public DaedalusVm(string path) : base(Native.ZkDaedalusVm_loadPath(path))
{
if (Handle == UIntPtr.Zero) throw new Exception("Failed to load DaedalusVm");
@@ -207,8 +243,8 @@ public void Call(string name, TP0 p0, TP1 p1, TP2 p2, TP3 p3
public void RegisterExternalDefault(ExternalDefaultFunction cb)
{
- Native.ZkDaedalusVm_registerExternalDefault(Handle, (_0, _1, sym) => cb(this, new DaedalusSymbol(sym)),
- UIntPtr.Zero);
+ _externalDefaultCallback = (_0, _1, sym) => cb(this, new DaedalusSymbol(sym));
+ Native.ZkDaedalusVm_registerExternalDefault(Handle, _externalDefaultCallback, UIntPtr.Zero);
}
public void RegisterExternal(string name, ExternalFunc
cb)
@@ -272,6 +308,90 @@ public void RegisterExternal
(string name,
});
}
+ public void RegisterExternal
(string name,
+ ExternalFunc
cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ Push(cb(p0, p1, p2, p3, p4, p5));
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFunc
cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ Push(cb(p0, p1, p2, p3, p4, p5, p6));
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFunc
cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p7 = Pop();
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ Push(cb(p0, p1, p2, p3, p4, p5, p6, p7));
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFunc
cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p8 = Pop();
+ var p7 = Pop();
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ Push(cb(p0, p1, p2, p3, p4, p5, p6, p7, p8));
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFunc
cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p9 = Pop();
+ var p8 = Pop();
+ var p7 = Pop();
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ Push(cb(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));
+ });
+ }
public void RegisterExternal(string name, ExternalFuncV cb)
{
@@ -333,6 +453,91 @@ public void RegisterExternal(string name, ExternalFuncV
});
}
+ public void RegisterExternal(string name,
+ ExternalFuncV cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ cb(p0, p1, p2, p3, p4, p5);
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFuncV cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ cb(p0, p1, p2, p3, p4, p5, p6);
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFuncV cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p7 = Pop();
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ cb(p0, p1, p2, p3, p4, p5, p6, p7);
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFuncV cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p8 = Pop();
+ var p7 = Pop();
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ cb(p0, p1, p2, p3, p4, p5, p6, p7, p8);
+ });
+ }
+
+ public void RegisterExternal(string name,
+ ExternalFuncV cb)
+ {
+ RegisterExternalUnsafe(name, () =>
+ {
+ var p9 = Pop();
+ var p8 = Pop();
+ var p7 = Pop();
+ var p6 = Pop();
+ var p5 = Pop();
+ var p4 = Pop();
+ var p3 = Pop();
+ var p2 = Pop();
+ var p1 = Pop();
+ var p0 = Pop();
+ cb(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ });
+ }
+
private void Push(T value)
{
switch (value)
@@ -381,10 +586,12 @@ private void RegisterExternalUnsafe(string name, ExternalFunc cb)
RegisterExternalUnsafe(sym, cb);
}
-
private void RegisterExternalUnsafe(DaedalusSymbol sym, ExternalFunc cb)
{
- Native.ZkDaedalusVm_registerExternal(Handle, sym.Handle, (_0, _1) => cb(), UIntPtr.Zero);
+ Native.Callbacks.ZkDaedalusVmExternalCallback handle = (_0, _1) => cb();
+ _externalCallbacks.Add(handle);
+
+ Native.ZkDaedalusVm_registerExternal(Handle, sym.Handle, handle, UIntPtr.Zero);
}
private delegate void ExternalFunc();
diff --git a/ZenKit/Logger.cs b/ZenKit/Logger.cs
index aa98b3c..7865520 100644
--- a/ZenKit/Logger.cs
+++ b/ZenKit/Logger.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
namespace ZenKit
{
@@ -15,9 +16,13 @@ public static class Logger
{
public delegate void Callback(LogLevel level, string name, string message);
+ private static List _callbacks = new List();
+
public static void Set(LogLevel lvl, Callback callback)
{
- Native.ZkLogger_set(lvl, (_, level, name, message) => callback(level, name, message), UIntPtr.Zero);
+ Native.Callbacks.ZkLogger cb = (_, level, name, message) => callback(level, name, message);
+ _callbacks.Add(cb);
+ Native.ZkLogger_set(lvl, cb, UIntPtr.Zero);
}
public static void SetDefault(LogLevel level)
diff --git a/ZenKit/Mesh.cs b/ZenKit/Mesh.cs
index 0bd6a1c..6ef15cf 100644
--- a/ZenKit/Mesh.cs
+++ b/ZenKit/Mesh.cs
@@ -185,13 +185,17 @@ public interface IMesh : ICacheable
public List Materials { get; }
public ulong MaterialCount { get; }
public List Positions { get; }
+ public ulong PositionCount { get; }
public List Features { get; }
+ public ulong FeatureCount { get; }
public List LightMap { get; }
public ulong LightMapCount { get; }
public List Polygons { get; }
public ulong PolygonCount { get; }
public IMaterial GetMaterial(ulong i);
+ public Vector3 GetPosition(ulong i);
+ public Vertex GetFeature(ulong i);
public ILightMap GetLightMap(ulong i);
@@ -209,7 +213,9 @@ public class CachedMesh : IMesh
public List Materials { get; set; }
public ulong MaterialCount => (ulong)Materials.LongCount();
public List Positions { get; set; }
+ public ulong PositionCount => (ulong)Positions.LongCount();
public List Features { get; set; }
+ public ulong FeatureCount => (ulong)Features.LongCount();
public List LightMap { get; set; }
public ulong LightMapCount => (ulong)LightMap.LongCount();
public List Polygons { get; set; }
@@ -230,6 +236,16 @@ public IMaterial GetMaterial(ulong i)
return Materials[(int)i];
}
+ public Vector3 GetPosition(ulong i)
+ {
+ return Positions[(int)i];
+ }
+
+ public Vertex GetFeature(ulong i)
+ {
+ return Features[(int)i];
+ }
+
public ILightMap GetLightMap(ulong i)
{
return LightMap[(int)i];
@@ -299,10 +315,41 @@ public List Materials
}
}
- public List Positions =>
- Native.ZkMesh_getPositions(_handle, out var count).MarshalAsList(count);
+ public ulong PositionCount => Native.ZkMesh_getPositionCount(_handle);
+
+ public List Positions
+ {
+ get
+ {
+ var positions = new List();
+
+ Native.ZkMesh_enumeratePositions(_handle, (_, v) =>
+ {
+ positions.Add(v);
+ return false;
+ }, UIntPtr.Zero);
+
+ return positions;
+ }
+ }
+
+ public ulong FeatureCount => Native.ZkMesh_getVertexCount(_handle);
- public List Features => Native.ZkMesh_getVertices(_handle, out var count).MarshalAsList(count);
+ public List Features
+ {
+ get
+ {
+ var features = new List();
+
+ Native.ZkMesh_enumerateVertices(_handle, (_, v) =>
+ {
+ features.Add(Marshal.PtrToStructure(v));
+ return false;
+ }, UIntPtr.Zero);
+
+ return features;
+ }
+ }
public ulong LightMapCount => Native.ZkMesh_getLightMapCount(_handle);
@@ -366,6 +413,16 @@ public IMaterial GetMaterial(ulong i)
return new Material(Native.ZkMesh_getMaterial(_handle, i));
}
+ public Vector3 GetPosition(ulong i)
+ {
+ return Native.ZkMesh_getPosition(_handle, i);
+ }
+
+ public Vertex GetFeature(ulong i)
+ {
+ return Native.ZkMesh_getVertex(_handle, i);
+ }
+
public ILightMap GetLightMap(ulong i)
{
return new LightMap(Native.ZkMesh_getLightMap(_handle, i));
diff --git a/ZenKit/MorphMesh.cs b/ZenKit/MorphMesh.cs
index 8f2181f..f78dc4a 100644
--- a/ZenKit/MorphMesh.cs
+++ b/ZenKit/MorphMesh.cs
@@ -17,7 +17,10 @@ public interface IMorphAnimation : ICacheable
byte Flags { get; }
uint FrameCount { get; }
List Vertices { get; }
+ public ulong SampleCount { get; }
List Samples { get; }
+
+ Vector3 GetSample(ulong i);
}
[Serializable]
@@ -32,8 +35,16 @@ public class CachedMorphAnimation : IMorphAnimation
public byte Flags { get; set; }
public uint FrameCount { get; set; }
public List Vertices { get; set; }
+
+ public ulong SampleCount => (ulong)Samples.LongCount();
+
public List Samples { get; set; }
+ public Vector3 GetSample(ulong i)
+ {
+ return Samples[(int)i];
+ }
+
public IMorphAnimation Cache()
{
return this;
@@ -68,8 +79,23 @@ internal MorphAnimation(UIntPtr handle)
public List Vertices =>
Native.ZkMorphAnimation_getVertices(_handle, out var count).MarshalAsList(count);
- public List Samples =>
- Native.ZkMorphAnimation_getSamples(_handle, out var count).MarshalAsList(count);
+ public ulong SampleCount => Native.ZkMorphAnimation_getSampleCount(_handle);
+
+ public List Samples
+ {
+ get
+ {
+ var samples = new List();
+
+ Native.ZkMorphAnimation_enumerateSamples(_handle, (_, v) =>
+ {
+ samples.Add(v);
+ return false;
+ }, UIntPtr.Zero);
+
+ return samples;
+ }
+ }
public IMorphAnimation Cache()
{
@@ -91,6 +117,11 @@ public bool IsCached()
{
return false;
}
+
+ public Vector3 GetSample(ulong i)
+ {
+ return Native.ZkMorphAnimation_getSample(_handle, i);
+ }
}
public interface IMorphSource : ICacheable
@@ -149,11 +180,13 @@ public interface IMorphMesh : ICacheable
{
string Name { get; }
IMultiResolutionMesh Mesh { get; }
+ public ulong MorphPositionCount { get; }
List MorphPositions { get; }
ulong AnimationCount { get; }
List Animations { get; }
ulong SourceCount { get; }
List Sources { get; }
+ Vector3 GetMorphPosition(ulong i);
IMorphAnimation GetAnimation(ulong i);
IMorphSource GetSource(ulong i);
}
@@ -163,12 +196,20 @@ public struct CachedMorphMesh : IMorphMesh
{
public string Name { get; set; }
public IMultiResolutionMesh Mesh { get; set; }
+
+ public ulong MorphPositionCount => (ulong)MorphPositions.LongCount();
+
public List MorphPositions { get; set; }
public ulong AnimationCount => (ulong)Animations.LongCount();
public List Animations { get; set; }
public ulong SourceCount => (ulong)Sources.LongCount();
public List Sources { get; set; }
+ public Vector3 GetMorphPosition(ulong i)
+ {
+ return MorphPositions[(int)i];
+ }
+
public IMorphAnimation GetAnimation(ulong i)
{
return Animations[(int)i];
@@ -217,8 +258,23 @@ public MorphMesh(Vfs vfs, string name)
public IMultiResolutionMesh Mesh => new MultiResolutionMesh(Native.ZkMorphMesh_getMesh(_handle));
- public List MorphPositions =>
- Native.ZkMorphMesh_getMorphPositions(_handle, out var count).MarshalAsList(count);
+ public ulong MorphPositionCount => Native.ZkMorphMesh_getMorphPositionCount(_handle);
+
+ public List MorphPositions
+ {
+ get
+ {
+ var positions = new List();
+
+ Native.ZkMorphMesh_enumerateMorphPositions(_handle, (_, v) =>
+ {
+ positions.Add(v);
+ return false;
+ }, UIntPtr.Zero);
+
+ return positions;
+ }
+ }
public ulong AnimationCount => Native.ZkMorphMesh_getAnimationCount(_handle);
@@ -273,6 +329,11 @@ public bool IsCached()
return false;
}
+ public Vector3 GetMorphPosition(ulong i)
+ {
+ return Native.ZkMorphMesh_getMorphPosition(_handle, i);
+ }
+
public IMorphAnimation GetAnimation(ulong i)
{
return new MorphAnimation(Native.ZkMorphMesh_getAnimation(_handle, i));
diff --git a/ZenKit/MultiResolutionMesh.cs b/ZenKit/MultiResolutionMesh.cs
index 11a809d..dceda17 100644
--- a/ZenKit/MultiResolutionMesh.cs
+++ b/ZenKit/MultiResolutionMesh.cs
@@ -50,14 +50,19 @@ public interface IMultiResolutionSubMesh : ICacheable
{
IMaterial Material { get; }
List Triangles { get; }
+ public ulong WedgeCount { get; }
List Wedges { get; }
List Colors { get; }
List TrianglePlaneIndices { get; }
+ public ulong TrianglePlaneCount { get; }
List TrianglePlanes { get; }
List TriangleEdges { get; }
List Edges { get; }
List EdgeScores { get; }
List WedgeMap { get; }
+
+ MeshWedge GetWedge(ulong i);
+ MeshPlane GetTrianglePlane(ulong i);
}
[Serializable]
@@ -65,15 +70,31 @@ public class CachedMultiResolutionSubMesh : IMultiResolutionSubMesh
{
public IMaterial Material { get; set; }
public List Triangles { get; set; }
+
+ public ulong WedgeCount => (ulong)Wedges.LongCount();
+
public List Wedges { get; set; }
public List Colors { get; set; }
public List TrianglePlaneIndices { get; set; }
+
+ public ulong TrianglePlaneCount => (ulong)TrianglePlanes.LongCount();
+
public List TrianglePlanes { get; set; }
public List TriangleEdges { get; set; }
public List Edges { get; set; }
public List EdgeScores { get; set; }
public List WedgeMap { get; set; }
+ public MeshWedge GetWedge(ulong i)
+ {
+ return Wedges[(int)i];
+ }
+
+ public MeshPlane GetTrianglePlane(ulong i)
+ {
+ return TrianglePlanes[(int)i];
+ }
+
public IMultiResolutionSubMesh Cache()
{
return this;
@@ -99,16 +120,46 @@ internal MultiResolutionSubMesh(UIntPtr handle)
public List Triangles =>
Native.ZkSubMesh_getTriangles(_handle, out var count).MarshalAsList(count);
- public List Wedges =>
- Native.ZkSubMesh_getWedges(_handle, out var count).MarshalAsList(count);
+ public ulong WedgeCount => Native.ZkSubMesh_getWedgeCount(_handle);
+
+ public List Wedges
+ {
+ get
+ {
+ var wedges = new List();
+
+ Native.ZkSubMesh_enumerateWedges(_handle, (_, wedge) =>
+ {
+ wedges.Add(Marshal.PtrToStructure(wedge));
+ return false;
+ }, UIntPtr.Zero);
+
+ return wedges;
+ }
+ }
public List Colors => Native.ZkSubMesh_getColors(_handle, out var count).MarshalAsList(count);
public List TrianglePlaneIndices => Native.ZkSubMesh_getTrianglePlaneIndices(_handle, out var count)
.MarshalAsList(count);
- public List TrianglePlanes =>
- Native.ZkSubMesh_getTrianglePlanes(_handle, out var count).MarshalAsList(count);
+ public ulong TrianglePlaneCount => Native.ZkSubMesh_getTrianglePlaneCount(_handle);
+
+ public List TrianglePlanes
+ {
+ get
+ {
+ var planes = new List();
+
+ Native.ZkSubMesh_enumerateTrianglePlanes(_handle, (_, plane) =>
+ {
+ planes.Add(Marshal.PtrToStructure(plane));
+ return false;
+ }, UIntPtr.Zero);
+
+ return planes;
+ }
+ }
public List TriangleEdges => Native.ZkSubMesh_getTriangleEdges(_handle, out var count)
.MarshalAsList(count);
@@ -142,11 +193,23 @@ public bool IsCached()
{
return false;
}
+
+ public MeshWedge GetWedge(ulong i)
+ {
+ return Native.ZkSubMesh_getWedge(_handle, i);
+ }
+
+ public MeshPlane GetTrianglePlane(ulong i)
+ {
+ return Native.ZkSubMesh_getTrianglePlane(_handle, i);
+ }
}
public interface IMultiResolutionMesh : ICacheable
{
+ public ulong PositionCount { get; }
List Positions { get; }
+ public ulong NormalCount { get; }
List Normals { get; }
ulong SubMeshCount { get; }
List SubMeshes { get; }
@@ -157,12 +220,16 @@ public interface IMultiResolutionMesh : ICacheable
IOrientedBoundingBox OrientedBoundingBox { get; }
IMultiResolutionSubMesh? GetSubMesh(ulong i);
IMaterial? GetMaterial(ulong i);
+ Vector3 GetPosition(ulong i);
+ Vector3 GetNormal(ulong i);
}
[Serializable]
public class CachedMultiResolutionMesh : IMultiResolutionMesh
{
+ public ulong PositionCount => (ulong)Positions.LongCount();
public List Positions { get; set; }
+ public ulong NormalCount => (ulong)Normals.LongCount();
public List Normals { get; set; }
public ulong SubMeshCount => (ulong)SubMeshes.LongCount();
public List SubMeshes { get; set; }
@@ -182,6 +249,16 @@ public class CachedMultiResolutionMesh : IMultiResolutionMesh
return Materials[(int)i];
}
+ public Vector3 GetPosition(ulong i)
+ {
+ return Positions[(int)i];
+ }
+
+ public Vector3 GetNormal(ulong i)
+ {
+ return Normals[(int)i];
+ }
+
public IMultiResolutionMesh Cache()
{
return this;
@@ -222,11 +299,41 @@ internal MultiResolutionMesh(UIntPtr handle)
_delete = false;
}
- public List Positions =>
- Native.ZkMultiResolutionMesh_getPositions(_handle, out var count).MarshalAsList(count);
+ public ulong PositionCount => Native.ZkMultiResolutionMesh_getPositionCount(_handle);
+
+ public List Positions
+ {
+ get
+ {
+ var positions = new List();
+
+ Native.ZkMultiResolutionMesh_enumeratePositions(_handle, (_, v) =>
+ {
+ positions.Add(v);
+ return false;
+ }, UIntPtr.Zero);
+
+ return positions;
+ }
+ }
+
+ public ulong NormalCount => Native.ZkMultiResolutionMesh_getNormalCount(_handle);
+
+ public List Normals
+ {
+ get
+ {
+ var positions = new List();
+
+ Native.ZkMultiResolutionMesh_enumerateNormals(_handle, (_, v) =>
+ {
+ positions.Add(v);
+ return false;
+ }, UIntPtr.Zero);
- public List Normals =>
- Native.ZkMultiResolutionMesh_getNormals(_handle, out var count).MarshalAsList(count);
+ return positions;
+ }
+ }
public ulong SubMeshCount => Native.ZkMultiResolutionMesh_getSubMeshCount(_handle);
@@ -301,6 +408,16 @@ public bool IsCached()
return mesh == UIntPtr.Zero ? null : new Material(mesh);
}
+ public Vector3 GetPosition(ulong i)
+ {
+ return Native.ZkMultiResolutionMesh_getPosition(_handle, i);
+ }
+
+ public Vector3 GetNormal(ulong i)
+ {
+ return Native.ZkMultiResolutionMesh_getNormal(_handle, i);
+ }
+
~MultiResolutionMesh()
{
if (_delete) Native.ZkMultiResolutionMesh_del(_handle);
diff --git a/ZenKit/Native.cs b/ZenKit/Native.cs
index 737c4bf..c3eae6b 100644
--- a/ZenKit/Native.cs
+++ b/ZenKit/Native.cs
@@ -492,10 +492,24 @@ public static extern void ZkOrientedBoundingBox_enumerateChildren(UIntPtr slf,
public static extern void ZkMultiResolutionMesh_del(UIntPtr slf);
[DllImport(DllName)]
- public static extern IntPtr ZkMultiResolutionMesh_getPositions(UIntPtr slf, out ulong count);
+ public static extern ulong ZkMultiResolutionMesh_getPositionCount(UIntPtr slf);
[DllImport(DllName)]
- public static extern IntPtr ZkMultiResolutionMesh_getNormals(UIntPtr slf, out ulong count);
+ public static extern Vector3 ZkMultiResolutionMesh_getPosition(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void
+ ZkMultiResolutionMesh_enumeratePositions(UIntPtr slf, ZkVec3fEnumerator cb, UIntPtr ctx);
+
+ [DllImport(DllName)]
+ public static extern ulong ZkMultiResolutionMesh_getNormalCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern Vector3 ZkMultiResolutionMesh_getNormal(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void
+ ZkMultiResolutionMesh_enumerateNormals(UIntPtr slf, ZkVec3fEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern ulong ZkMultiResolutionMesh_getSubMeshCount(UIntPtr slf);
@@ -534,7 +548,13 @@ public static extern void
public static extern IntPtr ZkSubMesh_getTriangles(UIntPtr slf, out ulong count);
[DllImport(DllName)]
- public static extern IntPtr ZkSubMesh_getWedges(UIntPtr slf, out ulong count);
+ public static extern ulong ZkSubMesh_getWedgeCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern MeshWedge ZkSubMesh_getWedge(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkSubMesh_enumerateWedges(UIntPtr slf, ZkMeshWedgeEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkSubMesh_getColors(UIntPtr slf, out ulong count);
@@ -543,7 +563,13 @@ public static extern void
public static extern IntPtr ZkSubMesh_getTrianglePlaneIndices(UIntPtr slf, out ulong count);
[DllImport(DllName)]
- public static extern IntPtr ZkSubMesh_getTrianglePlanes(UIntPtr slf, out ulong count);
+ public static extern ulong ZkSubMesh_getTrianglePlaneCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern MeshPlane ZkSubMesh_getTrianglePlane(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkSubMesh_enumerateTrianglePlanes(UIntPtr slf, ZkMeshPlaneEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkSubMesh_getTriangleEdges(UIntPtr slf, out ulong count);
@@ -572,14 +598,27 @@ public static extern void ZkSoftSkinMesh_enumerateBoundingBoxes(UIntPtr slf,
UIntPtr ctx);
[DllImport(DllName)]
- public static extern IntPtr ZkSoftSkinMesh_getWeights(UIntPtr slf, ulong node, out ulong count);
+ public static extern ulong ZkSoftSkinMesh_getWeightTotal(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern ulong ZkSoftSkinMesh_getWeightCount(UIntPtr slf, ulong node);
+
+ [DllImport(DllName)]
+ public static extern SoftSkinWeightEntry ZkSoftSkinMesh_getWeight(UIntPtr slf, ulong node, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkSoftSkinMesh_enumerateWeights(UIntPtr slf, ulong node,
+ ZkSoftSkinWeightEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
- public static extern void ZkSoftSkinMesh_enumerateWeights(UIntPtr slf, ZkSoftSkinWeightEnumerator cb,
- UIntPtr node);
+ public static extern ulong ZkSoftSkinMesh_getWedgeNormalCount(UIntPtr slf);
[DllImport(DllName)]
- public static extern IntPtr ZkSoftSkinMesh_getWedgeNormals(UIntPtr slf, out ulong count);
+ public static extern SoftSkinWedgeNormal ZkSoftSkinMesh_getWedgeNormal(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkSoftSkinMesh_enumerateWedgeNormals(UIntPtr slf, SoftSkinWedgeNormalEnumerator cb,
+ UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkSoftSkinMesh_getNodes(UIntPtr slf, out ulong count);
@@ -677,7 +716,13 @@ public static extern void ZkModelMesh_enumerateAttachments(UIntPtr slf, ZkAttach
public static extern uint ZkTexture_getAverageColor(UIntPtr slf);
[DllImport(DllName)]
- public static extern IntPtr ZkTexture_getPalette(UIntPtr slf, out ulong size);
+ public static extern ulong ZkTexture_getPaletteSize(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern ZkColor ZkTexture_getPaletteItem(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkTexture_enumeratePaletteItems(UIntPtr slf, ZkColorEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkTexture_getMipmapRaw(UIntPtr slf, ulong level, out ulong size);
@@ -712,7 +757,13 @@ public static extern void
public static extern UIntPtr ZkMorphMesh_getMesh(UIntPtr slf);
[DllImport(DllName)]
- public static extern IntPtr ZkMorphMesh_getMorphPositions(UIntPtr slf, out ulong count);
+ public static extern ulong ZkMorphMesh_getMorphPositionCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern Vector3 ZkMorphMesh_getMorphPosition(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkMorphMesh_enumerateMorphPositions(UIntPtr slf, ZkVec3fEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern ulong ZkMorphMesh_getAnimationCount(UIntPtr slf);
@@ -762,7 +813,13 @@ public static extern void ZkMorphMesh_enumerateSources(UIntPtr slf, ZkMorphSourc
public static extern IntPtr ZkMorphAnimation_getVertices(UIntPtr slf, out ulong count);
[DllImport(DllName)]
- public static extern IntPtr ZkMorphAnimation_getSamples(UIntPtr slf, out ulong count);
+ public static extern ulong ZkMorphAnimation_getSampleCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern Vector3 ZkMorphAnimation_getSample(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkMorphAnimation_enumerateSamples(UIntPtr slf, ZkVec3fEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkMorphSource_getFileName(UIntPtr slf);
@@ -805,10 +862,22 @@ public static extern void
ZkMesh_enumerateMaterials(UIntPtr slf, ZkMaterialEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
- public static extern IntPtr ZkMesh_getPositions(UIntPtr slf, out ulong count);
+ public static extern ulong ZkMesh_getPositionCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern Vector3 ZkMesh_getPosition(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkMesh_enumeratePositions(UIntPtr slf, ZkVec3fEnumerator cb, UIntPtr ctx);
+
+ [DllImport(DllName)]
+ public static extern ulong ZkMesh_getVertexCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern Vertex ZkMesh_getVertex(UIntPtr slf, ulong i);
[DllImport(DllName)]
- public static extern IntPtr ZkMesh_getVertices(UIntPtr slf, out ulong count);
+ public static extern void ZkMesh_enumerateVertices(UIntPtr slf, ZkVertexEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern ulong ZkMesh_getLightMapCount(UIntPtr slf);
@@ -1243,13 +1312,25 @@ public static extern void ZkAnimation_enumerateCameraTremors(UIntPtr slf,
public static extern IntPtr ZkBspTree_getPortalPolygonIndices(UIntPtr slf, out ulong count);
[DllImport(DllName)]
- public static extern IntPtr ZkBspTree_getLightPoints(UIntPtr slf, out ulong count);
+ public static extern ulong ZkBspTree_getLightPointCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern Vector3 ZkBspTree_getLightPoint(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkBspTree_enumerateLightPoints(UIntPtr slf, ZkVec3fEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkBspTree_getLeafNodeIndices(UIntPtr slf, out ulong count);
[DllImport(DllName)]
- public static extern IntPtr ZkBspTree_getNodes(UIntPtr slf, out ulong count);
+ public static extern ulong ZkBspTree_getNodeCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern BspNode ZkBspTree_getNode(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkBspTree_enumerateNodes(UIntPtr slf, ZkBspNodeEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern ulong ZkBspTree_getSectorCount(UIntPtr slf);
@@ -1815,8 +1896,16 @@ public static extern void ZkLightPreset_setRangeAnimationScale(UIntPtr slf, floa
[DllImport(DllName)]
public static extern void ZkLightPreset_setRangeAnimationSmooth(UIntPtr slf, bool rangeAnimationSmooth);
+
[DllImport(DllName)]
- public static extern IntPtr ZkLightPreset_getColorAnimationList(UIntPtr slf, out ulong count);
+ public static extern ulong ZkLightPreset_getColorAnimationCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern ZkColor ZkLightPreset_getColorAnimationItem(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkLightPreset_enumerateColorAnimationItems(UIntPtr slf, ZkColorEnumerator cb,
+ UIntPtr ctx);
[DllImport(DllName)]
public static extern void ZkLightPreset_setColorAnimationList(UIntPtr slf, ZkColor[] colorAnimationList,
@@ -1912,8 +2001,15 @@ public static extern void ZkLightPreset_setColorAnimationList(UIntPtr slf, ZkCol
[DllImport(DllName)]
public static extern void ZkLight_setRangeAnimationSmooth(UIntPtr slf, bool rangeAnimationSmooth);
+
[DllImport(DllName)]
- public static extern IntPtr ZkLight_getColorAnimationList(UIntPtr slf, out ulong count);
+ public static extern ulong ZkLight_getColorAnimationCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern ZkColor ZkLight_getColorAnimationItem(UIntPtr slf, ulong i);
+
+ [DllImport(DllName)]
+ public static extern void ZkLight_enumerateColorAnimationItems(UIntPtr slf, ZkColorEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern void
@@ -2658,10 +2754,13 @@ public static extern void ZkInteractiveObject_setOnStateChangeFunction(UIntPtr s
public static extern void ZkMover_setSpeedType(UIntPtr slf, MoverSpeedType speedType);
[DllImport(DllName)]
- public static extern IntPtr ZkMover_getKeyframes(UIntPtr slf, out ulong count);
+ public static extern ulong ZkMover_getKeyframeCount(UIntPtr slf);
+
+ [DllImport(DllName)]
+ public static extern AnimationSample ZkMover_getKeyframe(UIntPtr slf, ulong i);
[DllImport(DllName)]
- public static extern void ZkMover_setKeyframes(UIntPtr slf, out ulong count, string keyframes);
+ public static extern void ZkMover_enumerateKeyframes(UIntPtr slf, ZkAnimationSampleEnumerator cb, UIntPtr ctx);
[DllImport(DllName)]
public static extern IntPtr ZkMover_getSfxOpenStart(UIntPtr slf);
@@ -6556,7 +6655,10 @@ public class Callbacks
public delegate bool ZkSoftSkinMeshEnumerator(UIntPtr ctx, UIntPtr mesh);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate bool ZkSoftSkinWeightEnumerator(UIntPtr ctx, IntPtr entry, ulong count);
+ public delegate bool ZkSoftSkinWeightEnumerator(UIntPtr ctx, IntPtr entry);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool SoftSkinWedgeNormalEnumerator(UIntPtr ctx, SoftSkinWedgeNormal normal);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool ZkStringEnumerator(UIntPtr ctx, IntPtr v);
@@ -6578,17 +6680,35 @@ public class Callbacks
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool ZkWayPointEnumerator(UIntPtr ctx, UIntPtr point);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool ZkVec3fEnumerator(UIntPtr ctx, Vector3 v);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool ZkColorEnumerator(UIntPtr ctx, ZkColor color);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool ZkMeshWedgeEnumerator(UIntPtr ctx, IntPtr wedge);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool ZkMeshPlaneEnumerator(UIntPtr ctx, IntPtr plane);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool ZkVertexEnumerator(UIntPtr ctx, IntPtr vertex);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate bool ZkBspNodeEnumerator(UIntPtr ctx, IntPtr node);
}
public class Structs
{
- [StructLayout(LayoutKind.Explicit)]
+ [StructLayout(LayoutKind.Sequential, Size = 4)]
public struct ZkColor
{
- [FieldOffset(0)] public byte R;
- [FieldOffset(1)] public byte G;
- [FieldOffset(2)] public byte B;
- [FieldOffset(3)] public byte A;
+ public byte R;
+ public byte G;
+ public byte B;
+ public byte A;
public ZkColor(Color c)
{
@@ -6604,18 +6724,7 @@ public Color ToColor()
}
}
- [StructLayout(LayoutKind.Sequential)]
- public struct ZkColorArgb
- {
- public byte A, R, G, B;
-
- public Color ToColor()
- {
- return Color.FromArgb(A, R, G, B);
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
+ [StructLayout(LayoutKind.Sequential, Size = 4 * 9)]
public struct ZkMat3x3
{
public float m00,
@@ -6667,7 +6776,7 @@ public Quaternion ToQuaternion()
}
}
- [StructLayout(LayoutKind.Sequential)]
+ [StructLayout(LayoutKind.Sequential, Size = 4 * 16)]
public struct ZkMat4x4
{
public float m00,
diff --git a/ZenKit/SoftSkinMesh.cs b/ZenKit/SoftSkinMesh.cs
index 11c791d..ef999bf 100644
--- a/ZenKit/SoftSkinMesh.cs
+++ b/ZenKit/SoftSkinMesh.cs
@@ -28,10 +28,12 @@ public interface ISoftSkinMesh : ICacheable
{
ulong NodeCount { get; }
IMultiResolutionMesh Mesh { get; }
+ public ulong WedgeNormalCount { get; }
List WedgeNormals { get; }
List Nodes { get; }
List BoundingBoxes { get; }
List> Weights { get; }
+ SoftSkinWedgeNormal GetWedgeNormal(ulong i);
IOrientedBoundingBox GetBoundingBox(ulong node);
List GetWeights(ulong node);
}
@@ -41,11 +43,19 @@ public class CachedSoftSkinMesh : ISoftSkinMesh
{
public ulong NodeCount => (ulong)Nodes.LongCount();
public IMultiResolutionMesh Mesh { get; set; }
+
+ public ulong WedgeNormalCount => (ulong)WedgeNormals.LongCount();
+
public List WedgeNormals { get; set; }
public List Nodes { get; set; }
public List BoundingBoxes { get; set; }
public List> Weights { get; set; }
+ public SoftSkinWedgeNormal GetWedgeNormal(ulong i)
+ {
+ return WedgeNormals[(int)i];
+ }
+
public IOrientedBoundingBox GetBoundingBox(ulong node)
{
return BoundingBoxes[(int)node];
@@ -79,8 +89,23 @@ internal SoftSkinMesh(UIntPtr handle)
public ulong NodeCount => Native.ZkSoftSkinMesh_getNodeCount(_handle);
public IMultiResolutionMesh Mesh => new MultiResolutionMesh(Native.ZkSoftSkinMesh_getMesh(_handle));
- public List WedgeNormals => Native.ZkSoftSkinMesh_getWedgeNormals(_handle, out var count)
- .MarshalAsList