fixed movement

This commit is contained in:
maxwes08
2025-10-07 10:37:46 +02:00
parent bd2c87ddd1
commit 7835ade2c1
6 changed files with 91 additions and 30 deletions

View File

@@ -9,9 +9,14 @@ namespace Voxel
public static float Pitch = -22.5f;
public static float Yaw = 0f;
public static float FOV = 60f;
public static float TargetFOV = FOV;
public static float FOVLerpSpeed = 10f;
public static float Speed = 5f;
public static float ShiftSpeed = 20f;
private static int _width;
private static int _height;
public static Matrix4 view =>
Matrix4.LookAt(Position, Position + Front, Vector3.UnitY);
@@ -39,14 +44,28 @@ namespace Voxel
Pitch = MathHelper.Clamp(Pitch, -89f, 89f);
}
public static void UpdateProjection(int width, int height)
public static void UpdateProjection()
{
float fov = MathHelper.DegreesToRadians(FOV);
float aspectRatio = width / (float)height;
float aspectRatio = _width / (float)_height;
float near = 0.1f;
float far = 1000f;
projection = Matrix4.CreatePerspectiveFieldOfView(fov, aspectRatio, near, far);
}
public static void UpdateSize(int width, int height)
{
_width = width;
_height = height;
UpdateProjection();
}
public static void UpdateFOV(float deltaTime, float alpha)
{
float currentFOV = MathHelper.Lerp(FOV, TargetFOV, FOVLerpSpeed * deltaTime);
Camera.FOV = currentFOV;
Camera.UpdateProjection();
}
}
}