Added basic world scale variable.

This commit is contained in:
Harrison Deng 2019-03-10 00:46:28 -06:00
parent c59252dbbf
commit 5080deed02
2 changed files with 8 additions and 3 deletions

View File

@ -9,7 +9,6 @@ namespace RecrownedAthenaeum.Camera
/// </summary>
public class Camera2D : Camera3D
{
/// <summary>
/// The 2D position.
/// </summary>

View File

@ -13,6 +13,11 @@ namespace RecrownedAthenaeum.Camera
/// </summary>
public class Camera3D
{
/// <summary>
/// The zoom of the camera.
/// </summary>
public float worldScale = 1f;
/// <summary>
/// Current position in the world.
/// </summary>
@ -36,7 +41,7 @@ namespace RecrownedAthenaeum.Camera
/// <summary>
/// The view matrix that describes where the camera looks.
/// </summary>
public Matrix ViewMatrix { get; private set; }
public Matrix ViewMatrix { get; protected set; }
/// <summary>
/// The projection matrix.
@ -51,7 +56,7 @@ namespace RecrownedAthenaeum.Camera
/// <summary>
/// The basic effect that contains the transformations.
/// </summary>
public BasicEffect BasicEffect { get; private set; }
public BasicEffect BasicEffect { get; protected set; }
/// <summary>
/// Constructs 3D camera with an orthographic projection matrix with dimensions of graphics devices viewport. All changes to matrices should have apply called after changes.
@ -79,6 +84,7 @@ namespace RecrownedAthenaeum.Camera
public virtual void Apply()
{
ViewMatrix = Matrix.CreateLookAt(position, lookAt, upDirection);
worldMatrix *= Matrix.CreateScale(worldScale);
BasicEffect.World = worldMatrix;
BasicEffect.View = ViewMatrix;