feat: add fly-camera with view/projection matrices
This commit is contained in:
43
VoxelEngine.Tests/CameraTests.cs
Normal file
43
VoxelEngine.Tests/CameraTests.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using OpenTK.Mathematics;
|
||||
using VoxelEngine.Rendering;
|
||||
using Xunit;
|
||||
|
||||
namespace VoxelEngine.Tests;
|
||||
|
||||
public class CameraTests
|
||||
{
|
||||
[Fact]
|
||||
public void DefaultFront_PointsTowardNegativeZ()
|
||||
{
|
||||
var camera = new Camera(Vector3.Zero, 16f / 9f);
|
||||
|
||||
Assert.Equal(0f, camera.Front.X, 3);
|
||||
Assert.Equal(0f, camera.Front.Y, 3);
|
||||
Assert.Equal(-1f, camera.Front.Z, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Move_TranslatesPosition()
|
||||
{
|
||||
var camera = new Camera(Vector3.Zero, 1f);
|
||||
camera.Move(new Vector3(1f, 2f, 3f));
|
||||
Assert.Equal(new Vector3(1f, 2f, 3f), camera.Position);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRotation_ClampsPitchTo89Degrees()
|
||||
{
|
||||
var camera = new Camera(Vector3.Zero, 1f);
|
||||
camera.AddRotation(0f, 200f); // try to over-rotate up
|
||||
Assert.True(camera.Pitch <= 89.0001f);
|
||||
camera.AddRotation(0f, -400f);
|
||||
Assert.True(camera.Pitch >= -89.0001f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectionMatrix_IsNotIdentity()
|
||||
{
|
||||
var camera = new Camera(Vector3.Zero, 1.5f);
|
||||
Assert.NotEqual(Matrix4.Identity, camera.GetProjectionMatrix());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user