smrendererv3/SMCode/SM.Base/Drawing/GenericTransformation.cs
Michel Fedde 2e7051d800 + AxisHelper
~ Transformation can now set to be ignored. (Sending a Identity, when requested)
~ Changed how Meshes store Attributes
2020-12-13 13:03:57 +01:00

49 lines
No EOL
1.2 KiB
C#

#region usings
using OpenTK;
#endregion
namespace SM.Base.Drawing
{
/// <summary>
/// Contains methods for using transformations right.
/// </summary>
public abstract class GenericTransformation
{
public bool Ignore = false;
/// <summary>
/// Contains the current model matrix.
/// </summary>
protected Matrix4 _modelMatrix { get; private set; }
/// <summary>
/// Contains the last frame the matrix was calculated.
/// </summary>
protected ulong _lastFrame { get; private set; }
/// <summary>
/// Returns the current model matrix.
/// </summary>
/// <returns></returns>
public Matrix4 GetMatrix()
{
if (Ignore) return Matrix4.Identity;
if (_lastFrame != SMRenderer.CurrentFrame)
{
_lastFrame = SMRenderer.CurrentFrame;
_modelMatrix = RequestMatrix();
}
return _modelMatrix;
}
/// <summary>
/// Calculates the current matrix.
/// </summary>
/// <returns>The current matrix.</returns>
protected abstract Matrix4 RequestMatrix();
}
}