#region usings
using OpenTK;
#endregion
namespace SM.Base.Drawing
{
///
/// Contains methods for using transformations right.
///
public abstract class GenericTransformation
{
///
/// If true, ignores the transformation and sends , when requested.
///
public bool Ignore = false;
public Matrix4 LastMaster { get; internal set; }
public Matrix4 InWorldSpace => MergeMatrix(LastMaster);
///
/// Contains the current model matrix.
///
protected Matrix4 _modelMatrix { get; private set; }
///
/// Contains the last frame the matrix was calculated.
///
protected ulong _lastFrame { get; private set; }
///
/// Returns the current model matrix.
///
///
public Matrix4 GetMatrix()
{
if (Ignore) return Matrix4.Identity;
if (_lastFrame != SMRenderer.CurrentFrame)
{
_lastFrame = SMRenderer.CurrentFrame;
_modelMatrix = RequestMatrix();
}
return _modelMatrix;
}
public Matrix4 MergeMatrix(Matrix4 matrix)
{
return GetMatrix() * matrix;
}
///
/// Calculates the current matrix.
///
/// The current matrix.
protected abstract Matrix4 RequestMatrix();
}
}