#region usings
using System.Collections.Generic;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.OGL.Mesh;
#endregion
namespace SM.Base.Drawing
{
///
/// Contains general basis systems for drawing objects.
///
public abstract class DrawingBasis : IShowItem
{
///
/// The material it should use.
///
protected Material _material = new Material();
///
/// The mesh it should use.
///
protected GenericMesh _mesh = SMRenderer.DefaultMesh;
///
public object Parent { get; set; }
///
public string Name { get; set; } = "Unnamed draw object";
///
public ICollection Flags { get; set; }
///
/// This value determents if the object should draw something.
///
public bool Active = true;
///
public void Draw(DrawContext context)
{
if (!Active) return;
context.Material = _material;
context.Mesh = _mesh;
DrawContext(ref context);
}
///
public virtual void OnAdded(object sender)
{
}
///
public virtual void OnRemoved(object sender)
{
}
///
/// Draws the context, that was given to them.
///
///
protected virtual void DrawContext(ref DrawContext context)
{
}
}
///
/// Contains general basis systems for drawing objects.
///
/// The transformation type
public abstract class DrawingBasis : DrawingBasis
where TTransformation : GenericTransformation, new()
{
///
/// The current transformation.
///
public TTransformation Transform = new TTransformation();
///
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);
context.ModelMaster *= Transform.GetMatrix();
}
}
}