Updated api
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SimpleRayTracer.Interop;
|
||||
@@ -22,6 +21,8 @@ internal static unsafe class SrtNative
|
||||
internal struct Vec2
|
||||
{
|
||||
public float x, y;
|
||||
|
||||
public static Vec2 Of(float x, float y) => new() { x = x, y = y };
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -60,8 +61,8 @@ internal static unsafe class SrtNative
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CameraParams
|
||||
{
|
||||
public Vector3 position;
|
||||
public Quaternion rotation;
|
||||
public Vec3 position;
|
||||
public Quat rotation;
|
||||
|
||||
public float focal_length;
|
||||
public float size_x;
|
||||
@@ -71,8 +72,8 @@ internal static unsafe class SrtNative
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DirectionalLight
|
||||
{
|
||||
public Vector3 direction;
|
||||
public Vector3 color;
|
||||
public Vec3 direction;
|
||||
public Vec3 color;
|
||||
public float intensity;
|
||||
public float angular_diameter;
|
||||
}
|
||||
@@ -94,7 +95,7 @@ internal static unsafe class SrtNative
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct StandardLitProperties
|
||||
{
|
||||
public Vector3 albedo;
|
||||
public Vec3 albedo;
|
||||
public float diffuse_roughness;
|
||||
public float roughness;
|
||||
public float metallic;
|
||||
@@ -137,11 +138,11 @@ internal static unsafe class SrtNative
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct Vertex
|
||||
{
|
||||
public Vector3 position;
|
||||
public Vector3 normal;
|
||||
public Vector3 tangent;
|
||||
public Vector3 color;
|
||||
public Vector2 uv;
|
||||
public Vec3 position;
|
||||
public Vec3 normal;
|
||||
public Vec3 tangent;
|
||||
public Vec3 color;
|
||||
public Vec2 uv;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -153,6 +154,47 @@ internal static unsafe class SrtNative
|
||||
public uint material_id;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MeshHandle
|
||||
{
|
||||
public uint model_id;
|
||||
public uint instance_id;
|
||||
|
||||
public ulong triangle_id;
|
||||
public ulong triangle_count;
|
||||
public ushort material_id;
|
||||
public ushort material_count;
|
||||
}
|
||||
|
||||
internal enum SkyKind : uint
|
||||
{
|
||||
None = 0,
|
||||
Constant = 1,
|
||||
Hdr = 2,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SkyDesc
|
||||
{
|
||||
public uint kind;
|
||||
public uint data_size;
|
||||
public void* data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SkyConstantDesc
|
||||
{
|
||||
public Vec3 color;
|
||||
public float intensity;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct SkyHdrDesc
|
||||
{
|
||||
public TextureHandle hdri;
|
||||
public float intensity;
|
||||
}
|
||||
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr srt_scene_create(ulong triangle_count, ushort texture_count, byte material_count, uint punctual_light_count);
|
||||
|
||||
@@ -180,6 +222,9 @@ internal static unsafe class SrtNative
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Result srt_scene_set_sky_none(IntPtr scene);
|
||||
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Result srt_scene_set_sky(IntPtr scene, SkyDesc* desc);
|
||||
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Result srt_scene_set_sky_constant(IntPtr scene, Vec3 color, float intensity);
|
||||
|
||||
@@ -195,6 +240,9 @@ internal static unsafe class SrtNative
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Result srt_scene_add_mesh_instance(IntPtr scene, uint model_id, Mat4* local_to_world, out uint instance_id);
|
||||
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Result srt_scene_load_mesh(IntPtr scene, [MarshalAs(UnmanagedType.LPUTF8Str)] string filename_utf8, out MeshHandle mesh);
|
||||
|
||||
[DllImport(_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Result srt_render_job_create(
|
||||
IntPtr scene,
|
||||
|
||||
Reference in New Issue
Block a user