player added

This commit is contained in:
maxwes08
2025-09-30 10:58:12 +02:00
parent 38dccf0a84
commit 11f76ca429
11 changed files with 259 additions and 48 deletions

41
AABB.cs Normal file
View File

@@ -0,0 +1,41 @@
using OpenTK.Mathematics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Voxel
{
public struct AABB
{
public Vector3 Min;
public Vector3 Max;
public AABB(Vector3 min, Vector3 max)
{
Min = min;
Max = max;
}
public static AABB FromCenter(Vector3 center, float width, float height, float depth)
{
Vector3 half = new Vector3(width / 2f, 0, depth / 2f);
return new AABB(center - half, center + new Vector3(half.X, height, half.Z));
}
public bool Intersects(AABB other)
{
return (Min.X <= other.Max.X && Max.X >= other.Min.X) &&
(Min.Y <= other.Max.Y && Max.Y >= other.Min.Y) &&
(Min.Z <= other.Max.Z && Max.Z >= other.Min.Z);
}
public bool Contains(Vector3 point)
{
return (point.X >= Min.X && point.X <= Max.X) &&
(point.Y >= Min.Y && point.Y <= Max.Y) &&
(point.Z >= Min.Z && point.Z <= Max.Z);
}
}
}