style: apply code-style cleanup (explicit types, this-qualification, switch expressions)
This commit is contained in:
@@ -8,8 +8,8 @@ public sealed class Camera
|
||||
|
||||
public Vector3 Position { get; private set; }
|
||||
public float Yaw { get; private set; } = -90f; // degrees; -90 looks down -Z
|
||||
public float Pitch { get; private set; } = 0f; // degrees
|
||||
public float Fov { get; set; } = 60f; // degrees
|
||||
public float Pitch { get; private set; } // degrees
|
||||
public float Fov { get; set; } = 60f; // degrees
|
||||
public float AspectRatio { get; set; }
|
||||
|
||||
public Vector3 Front { get; private set; } = -Vector3.UnitZ;
|
||||
@@ -18,37 +18,37 @@ public sealed class Camera
|
||||
|
||||
public Camera(Vector3 position, float aspectRatio)
|
||||
{
|
||||
Position = position;
|
||||
AspectRatio = aspectRatio;
|
||||
UpdateVectors();
|
||||
this.Position = position;
|
||||
this.AspectRatio = aspectRatio;
|
||||
this.UpdateVectors();
|
||||
}
|
||||
|
||||
public void Move(Vector3 delta) => Position += delta;
|
||||
public void Move(Vector3 delta) => this.Position += delta;
|
||||
|
||||
public void AddRotation(float yawDelta, float pitchDelta)
|
||||
{
|
||||
Yaw += yawDelta;
|
||||
Pitch = MathHelper.Clamp(Pitch + pitchDelta, -89f, 89f);
|
||||
UpdateVectors();
|
||||
this.Yaw += yawDelta;
|
||||
this.Pitch = MathHelper.Clamp(this.Pitch + pitchDelta, -89f, 89f);
|
||||
this.UpdateVectors();
|
||||
}
|
||||
|
||||
public Matrix4 GetViewMatrix() => Matrix4.LookAt(Position, Position + Front, Up);
|
||||
public Matrix4 GetViewMatrix() => Matrix4.LookAt(this.Position, this.Position + this.Front, this.Up);
|
||||
|
||||
public Matrix4 GetProjectionMatrix() =>
|
||||
Matrix4.CreatePerspectiveFieldOfView(
|
||||
MathHelper.DegreesToRadians(Fov), AspectRatio, 0.1f, 100f);
|
||||
MathHelper.DegreesToRadians(this.Fov), this.AspectRatio, 0.1f, 100f);
|
||||
|
||||
private void UpdateVectors()
|
||||
{
|
||||
float yaw = MathHelper.DegreesToRadians(Yaw);
|
||||
float pitch = MathHelper.DegreesToRadians(Pitch);
|
||||
float yaw = MathHelper.DegreesToRadians(this.Yaw);
|
||||
float pitch = MathHelper.DegreesToRadians(this.Pitch);
|
||||
|
||||
Front = Vector3.Normalize(new Vector3(
|
||||
this.Front = Vector3.Normalize(new Vector3(
|
||||
MathF.Cos(yaw) * MathF.Cos(pitch),
|
||||
MathF.Sin(pitch),
|
||||
MathF.Sin(yaw) * MathF.Cos(pitch)));
|
||||
|
||||
Right = Vector3.Normalize(Vector3.Cross(Front, WorldUp));
|
||||
Up = Vector3.Normalize(Vector3.Cross(Right, Front));
|
||||
this.Right = Vector3.Normalize(Vector3.Cross(this.Front, Camera.WorldUp));
|
||||
this.Up = Vector3.Normalize(Vector3.Cross(this.Right, this.Front));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user