07.10.2020

+ Parent, Name and Flags to objects.

~ Improved Matrix calculations
This commit is contained in:
Michel Fedde 2020-10-08 12:25:20 +02:00
parent f865496414
commit 2c00dbd31a
21 changed files with 383 additions and 42 deletions

View file

@ -1,4 +1,5 @@
using SM.Base.Contexts;
using System.Collections.Generic;
using SM.Base.Contexts;
using SM.Base.Objects.Static;
using SM.OGL.Mesh;
@ -16,7 +17,16 @@ namespace SM.Base.Scene
/// <summary>
/// The mesh it should use.
/// </summary>
protected GenericMesh _mesh = Defaults.DefaultMesh;
protected GenericMesh _mesh = SMRenderer.DefaultMesh;
/// <inheritdoc />
public object Parent { get; set; }
/// <inheritdoc />
public string Name { get; set; } = "Unnamed draw object";
/// <inheritdoc />
public ICollection<string> Flags { get; set; }
/// <inheritdoc />
public virtual void Update(UpdateContext context)
@ -33,6 +43,18 @@ namespace SM.Base.Scene
DrawContext(ref context);
}
/// <inheritdoc />
public virtual void OnAdded(object sender)
{
}
/// <inheritdoc />
public virtual void OnRemoved(object sender)
{
}
/// <summary>
/// Draws the context, that was given to them.
/// </summary>

View file

@ -7,10 +7,34 @@ namespace SM.Base.Scene
/// </summary>
public abstract class GenericTransformation
{
/// <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 (_lastFrame != SMRenderer.CurrentFrame)
{
_lastFrame = SMRenderer.CurrentFrame;
_modelMatrix = RequestMatrix();
}
return _modelMatrix;
}
/// <summary>
/// Calculates the current matrix.
/// </summary>
/// <returns>The current matrix.</returns>
public abstract Matrix4 GetMatrix();
protected abstract Matrix4 RequestMatrix();
}
}