Added shapes to debug renderer

This commit is contained in:
Antoine Pilote
2024-08-16 17:55:35 -04:00
parent 1685921a5a
commit 4d1feb9802
19 changed files with 36028 additions and 200 deletions

View File

@@ -1,10 +1,11 @@
using Coral.Managed.Interop;
using Nuake.Net.Physics.Shapes;
using Nuake.Net.Shapes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -12,79 +13,79 @@ using System.Threading.Tasks;
namespace Nuake.Net
{
namespace Physics
namespace Shapes
{
namespace Shapes
[StructLayout(LayoutKind.Sequential)]
public class Box
{
public class Box
public float Width { get; set; } = 1.0f;
public float Height { get; set; } = 1.0f;
public float Depth { get; set; } = 1.0f;
public Box(float width, float height, float depth)
{
public float Width { get; set; } = 1.0f;
public float Height { get; set; } = 1.0f;
public float Depth { get; set; } = 1.0f;
public Box(float width, float height, float depth)
{
Width = width;
Height = height;
Depth = depth;
}
public Box(Vector3 size)
{
Width = size.X;
Height = size.Y;
Depth = size.Z;
}
public Vector3 GetSize()
{
return new Vector3(Width, Height, Depth);
}
public void SetSize(Vector3 size)
{
Width = size.X;
Height = size.Y;
Depth = size.Z;
}
Width = width;
Height = height;
Depth = depth;
}
public class Sphere
public Box(Vector3 size)
{
public float Radius { get; set; } = 0.5f;
public Sphere(float radius)
{
Radius = radius;
}
Width = size.X;
Height = size.Y;
Depth = size.Z;
}
public class Capsule
public Vector3 GetSize()
{
public float Radius { get; set; } = 0.5f;
public float Height { get; set; } = 1.0f;
public Capsule(float radius, float height)
{
Radius = radius;
Height = height;
}
return new Vector3(Width, Height, Depth);
}
public class Cylinder
public void SetSize(Vector3 size)
{
public float Radius { get; set; } = 0.5f;
public float Height { get; set; } = 1.0f;
Width = size.X;
Height = size.Y;
Depth = size.Z;
}
}
public Cylinder(float radius, float height)
{
Radius = radius;
Height = height;
}
[StructLayout(LayoutKind.Sequential)]
public class Sphere
{
public float Radius { get; set; } = 0.5f;
public Sphere(float radius)
{
Radius = radius;
}
}
public class Capsule
{
public float Radius { get; set; } = 0.5f;
public float Height { get; set; } = 1.0f;
public Capsule(float radius, float height)
{
Radius = radius;
Height = height;
}
}
[StructLayout(LayoutKind.Sequential)]
public class Cylinder
{
public float Radius { get; set; } = 0.5f;
public float Height { get; set; } = 1.0f;
public Cylinder(float radius, float height)
{
Radius = radius;
Height = height;
}
}
}
public class Physic
{
public struct ShapeCastResult

View File

@@ -1,6 +1,7 @@
using Coral.Managed.Interop;
using Nuake.Net.Shapes;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Numerics;
@@ -39,21 +40,85 @@ namespace Nuake.Net
internal static unsafe delegate*</* start */ float, float, float,
/* end */ float, float, float,
/* color */ float, float, float, float,
/* life */ float,
/* life */ float,
float,
void> DrawLineIcall;
internal static unsafe delegate*</* position */ Vector3,
/* rotation */ Quaternion,
/* shape */ Vector3,
/* color */ Vector4,
/* life */ float,
float,
void> DrawShapeBoxIcall;
internal static unsafe delegate*</* position */ Vector3,
/* rotation */ Quaternion,
/* shape */ float,
/* color */ Vector4,
/* life */ float,
float,
void> DrawShapeSphereIcall;
internal static unsafe delegate*</* position */ Vector3,
/* rotation */ Quaternion,
/* shape */ float, float,
/* color */ Vector4,
/* life */ float,
float,
void> DrawShapeCylinderIcall;
internal static unsafe delegate*</* position */ Vector3,
/* rotation */ Quaternion,
/* shape */ float, float,
/* color */ Vector4,
/* life */ float,
float,
void> DrawShapeCapsuleIcall;
public Debug() { }
public static void DrawLine(Vector3 start, Vector3 end, Vector4 color, float life = 0.0f)
public static void DrawLine(Vector3 start, Vector3 end, Vector4 color, float life = 0.0f, float width = 1.0f)
{
unsafe
{
DrawLineIcall(start.X, start.Y, start.Z, end.X, end.Y, end.Z, color.X, color.Y, color.Z, color.W, life);
DrawLineIcall(start.X, start.Y, start.Z, end.X, end.Y, end.Z, color.X, color.Y, color.Z, color.W, life, width);
}
}
public static void DrawShape(Vector3 position, Quaternion rotation, Shapes.Box shape, Vector4 color, float life = 0.0f, float width = 1.0f)
{
unsafe
{
DrawShapeBoxIcall(position, rotation, new Vector3(shape.Width, shape.Height, shape.Depth), color, life, width);
}
}
public static void DrawShape(Vector3 position, Quaternion rotation, Shapes.Sphere shape, Vector4 color, float life = 0.0f, float width = 1.0f)
{
unsafe
{
DrawShapeSphereIcall(position, rotation, shape.Radius, color, life, width);
}
}
public static void DrawShape(Vector3 position, Quaternion rotation, Shapes.Cylinder shape, Vector4 color, float life = 0.0f, float width = 1.0f)
{
unsafe
{
DrawShapeCylinderIcall(position, rotation, shape.Radius, shape.Height, color, life, width);
}
}
public static void DrawShape(Vector3 position, Quaternion rotation, Shapes.Capsule shape, Vector4 color, float life = 0.0f, float width = 1.0f)
{
unsafe
{
DrawShapeCapsuleIcall(position, rotation, shape.Radius, shape.Height, color, life, width);
}
}
}
}