smrendererv3/SMCode/SM.Base/Drawing/GenericTransformation.cs
Michel Fedde 5bb690e45f 2021-15-03
+ GenericTransformation.InWorldSpace (Merges the object transformation and the last master transformation)
+ Ray class for Raycasting (may not work correctly)
+ Util.CallGarbageCollector() can call the garbage collector.
+ GLWindow.WindowFlags allow to easly switch between Window <-> Borderless Window (this will cause the window to fill the entire screen) <-> Exclusive Fullscreen.

~ Made the bloom-texture scale a constructor-parameter.

SM.OGL:
+ OpenGL-GarbageCollector integration.
+ BoundingBox.GetBounds(Matrix4, out Vector3,out Vector3) allows for easy transformation of the bounding box.
+ GLObjects can now marked as not compiled. Where it always returns false at WasCompiled.

SM2D:
~ Improved the Mouse2D.MouseOver Algorithm.
2021-03-15 18:11:58 +01:00

61 lines
No EOL
1.6 KiB
C#

#region usings
using OpenTK;
#endregion
namespace SM.Base.Drawing
{
/// <summary>
/// Contains methods for using transformations right.
/// </summary>
public abstract class GenericTransformation
{
/// <summary>
/// If true, ignores the transformation and sends <see cref="Matrix4.Identity"/>, when requested.
/// </summary>
public bool Ignore = false;
public Matrix4 LastMaster { get; internal set; }
public Matrix4 InWorldSpace => MergeMatrix(LastMaster);
/// <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;
}
public Matrix4 MergeMatrix(Matrix4 matrix)
{
return GetMatrix() * matrix;
}
/// <summary>
/// Calculates the current matrix.
/// </summary>
/// <returns>The current matrix.</returns>
protected abstract Matrix4 RequestMatrix();
}
}