Loads and loads of small improvements I added while developing on my game
This commit is contained in:
parent
41421b1df9
commit
a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
using SM.Base.Windows;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -11,48 +12,44 @@ namespace SM.Base.Scene
|
|||
/// </summary>
|
||||
public abstract class GenericCamera
|
||||
{
|
||||
/// <summary>
|
||||
/// The matrix for the orthographic world.
|
||||
/// </summary>
|
||||
public static Matrix4 OrthographicWorld { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The matrix for the perspective world.
|
||||
/// </summary>
|
||||
public static Matrix4 PerspectiveWorld { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// This defines what is up. (Normalized)
|
||||
/// <para>Default: <see cref="Vector3.UnitY" /></para>
|
||||
/// </summary>
|
||||
public static Vector3 UpVector { get; set; } = Vector3.UnitY;
|
||||
public Vector3 UpVector { get; set; } = Vector3.UnitY;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the world matrix that is connected to this camera.
|
||||
/// </summary>
|
||||
public Matrix4 World { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the view matrix of this camera.
|
||||
/// <para>Default: <see cref="Matrix4.Identity" /></para>
|
||||
/// </summary>
|
||||
public Matrix4 ViewMatrix { get; protected set; } = Matrix4.Identity;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the world matrix that is connected to this camera.
|
||||
/// </summary>
|
||||
public Matrix4 World => Orthographic ? OrthographicWorld : PerspectiveWorld;
|
||||
public Matrix4 View { get; protected set; } = Matrix4.Identity;
|
||||
|
||||
/// <summary>
|
||||
/// Represents if the camera is orthographic.
|
||||
/// </summary>
|
||||
public abstract bool Orthographic { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Exposure defines the exposure to the Scene.
|
||||
/// </summary>
|
||||
public float Exposure = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the view matrix.
|
||||
/// </summary>
|
||||
/// <returns>The calculated view matrix. Same as <see cref="ViewMatrix" /></returns>
|
||||
internal Matrix4 CalculateViewMatrix()
|
||||
/// <returns>The calculated view matrix. Same as <see cref="View" /></returns>
|
||||
internal void CalculateViewMatrix(IGenericWindow window)
|
||||
{
|
||||
ViewMatrix = ViewCalculation();
|
||||
return ViewMatrix;
|
||||
View = ViewCalculation(window);
|
||||
if (WorldCalculation(window, out Matrix4 world))
|
||||
{
|
||||
World = world;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -60,16 +57,10 @@ namespace SM.Base.Scene
|
|||
/// </summary>
|
||||
/// <returns>
|
||||
/// The new view matrix. This is the returns for <see cref="CalculateViewMatrix" /> and the next value for
|
||||
/// <see cref="ViewMatrix" />.
|
||||
/// <see cref="View" />.
|
||||
/// </returns>
|
||||
protected abstract Matrix4 ViewCalculation();
|
||||
protected abstract Matrix4 ViewCalculation(IGenericWindow window);
|
||||
|
||||
/// <summary>
|
||||
/// This will calculate the world.
|
||||
/// <para>This is called on <see cref="GenericWindow{TScene,TCamera}.ViewportCamera" /> to calculate the world.</para>
|
||||
/// </summary>
|
||||
/// <param name="world">The world scale</param>
|
||||
/// <param name="aspect">The aspect ratio from the window.</param>
|
||||
public abstract void RecalculateWorld(Vector2 world, float aspect);
|
||||
protected abstract bool WorldCalculation(IGenericWindow window, out Matrix4 world);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue