camera tweak + fix capitalization

shadows
cosmonaut 2020-08-05 23:58:18 -07:00
parent 2419a89d32
commit 4c41506204
3 changed files with 7 additions and 28 deletions

View File

@ -2,43 +2,22 @@ using Microsoft.Xna.Framework;
namespace Kav
{
public class Camera
public struct Camera
{
public Matrix Transform { get; set; }
public Matrix Projection { get; set; }
public Matrix Transform { get; }
public Matrix View
{
get
{
return Matrix.CreateLookAt(Transform.Translation, Transform.Forward, Transform.Up);
return Matrix.CreateLookAt(Transform.Translation, Transform.Translation + Transform.Forward, Transform.Up);
}
}
public Matrix Projection { get; }
public float FOV { get; set; } = MathHelper.PiOver4;
public float AspectRatio { get; set; } = 1920f / 1080f;
public float NearPlane { get; set; } = 0.1f;
public float FarPlane { get; set; } = 200f;
public Camera(Vector3 position, Quaternion orientation)
{
Transform = Matrix.CreateFromQuaternion(orientation) * Matrix.CreateTranslation(position.X, position.Y, position.Z);
Projection = Matrix.CreatePerspectiveFieldOfView(
FOV,
AspectRatio,
NearPlane,
FarPlane
);
}
public Camera(Matrix transform)
public Camera(Matrix transform, Matrix projection)
{
Transform = transform;
Projection = Matrix.CreatePerspectiveFieldOfView(
FOV,
AspectRatio,
NearPlane,
FarPlane
);
Projection = projection;
}
}
}

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kav", "kav.csproj", "{34C1B784-AE9C-4EBC-A03A-AC401CB1219A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kav", "Kav.csproj", "{34C1B784-AE9C-4EBC-A03A-AC401CB1219A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution