You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using AOT;
|
|
using UnityEngine;
|
|
|
|
public class RenderModule : CallbackHandler<RenderModule>
|
|
{
|
|
private readonly UniQuake uq;
|
|
|
|
public RenderModule(UniQuake uniQuake)
|
|
{
|
|
uq = uniQuake;
|
|
|
|
var callbacks = new Callbacks
|
|
{
|
|
target = SelfPtr,
|
|
|
|
ModUploadModel = CreateCallback<ModUploadModelCallback>(Callback_ModUploadModel),
|
|
};
|
|
|
|
RegisterCallbacks(callbacks);
|
|
}
|
|
|
|
/// <summary>
|
|
/// This matches struct unity_syscalls_s from uniquake.h in native code.
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Sequential, Pack = 0)]
|
|
private class Callbacks
|
|
{
|
|
public IntPtr target;
|
|
|
|
public IntPtr ModUploadModel;
|
|
}
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
private delegate void ModUploadModelCallback(IntPtr target, QModel model, QAliasHeader header, IntPtr frames);
|
|
|
|
[MonoPInvokeCallback(typeof(ModUploadModelCallback))]
|
|
private static void Callback_ModUploadModel(IntPtr target, QModel model, QAliasHeader header, IntPtr frames)
|
|
{
|
|
if (header != null)
|
|
header.frames = frames.ToStructArray<QAliasFrameDesc>(header.numFrames);
|
|
|
|
GetSelf(target).UploadModel(model, header);
|
|
}
|
|
|
|
private void UploadModel(QModel model, QAliasHeader header)
|
|
{
|
|
Debug.Log($"Model '{model?.name}' of type {model?.type}, num frames = {header?.numFrames}");
|
|
if (header?.frames != null)
|
|
{
|
|
string str = string.Join(", ", header.frames.Select(f => f.name));
|
|
Debug.Log($"Frame list: {str}");
|
|
}
|
|
}
|
|
}
|