30.09.2020

+ Mouse support
+ Started to add summaries to SM.Base
This commit is contained in:
Michel Fedde 2020-09-30 21:26:42 +02:00
parent 16366fa015
commit 7acdba92f8
21 changed files with 325 additions and 58 deletions

View file

@ -4,9 +4,18 @@ using SM.OGL.Mesh;
namespace SM.Base.Scene
{
/// <summary>
/// Contains general basis systems for drawing objects.
/// </summary>
public abstract class DrawingBasis : IShowItem
{
/// <summary>
/// The material it should use.
/// </summary>
protected Material _material = new Material();
/// <summary>
/// The mesh it should use.
/// </summary>
protected GenericMesh _mesh = Defaults.DefaultMesh;
public virtual void Update(UpdateContext context)
{
@ -14,14 +23,25 @@ namespace SM.Base.Scene
}
public virtual void Draw(DrawContext context)
{ }
{
}
/// <summary>
/// Applies the current settings to the context.
/// </summary>
/// <param name="context"></param>
protected void ApplyContext(ref DrawContext context)
{
_material.Shader ??= Defaults.DefaultShader;
context.Material = _material;
context.Mesh = _mesh;
}
}
/// <summary>
/// Contains general basis systems for drawing objects.
/// </summary>
/// <typeparam name="TTransformation">The transformation type</typeparam>
public abstract class DrawingBasis<TTransformation> : DrawingBasis
where TTransformation : GenericTransformation, new()
{

View file

@ -2,8 +2,15 @@
namespace SM.Base.Scene
{
/// <summary>
/// Contains methods for using transformations right.
/// </summary>
public abstract class GenericTransformation
{
/// <summary>
/// Calculates the current matrix.
/// </summary>
/// <returns>The current matrix.</returns>
public abstract Matrix4 GetMatrix();
}
}

View file

@ -4,8 +4,15 @@ using SM.Base.Contexts;
namespace SM.Base.Scene
{
/// <summary>
/// A general interface to work with material shaders properly.
/// </summary>
public interface IShader
{
/// <summary>
/// Draws the context.
/// </summary>
/// <param name="context">The context</param>
void Draw(DrawContext context);
}
}

View file

@ -2,10 +2,22 @@
namespace SM.Base.Scene
{
/// <summary>
/// This represens a drawing instance.
/// </summary>
public struct Instance
{
/// <summary>
/// The model matrix.
/// </summary>
public Matrix4 ModelMatrix;
/// <summary>
/// The texture offset.
/// </summary>
public Vector2 TexturePosition;
/// <summary>
/// The texture scale.
/// </summary>
public Vector2 TextureScale;
}
}

View file

@ -3,11 +3,24 @@ using SM.OGL.Texture;
namespace SM.Base.Scene
{
/// <summary>
/// Represents a material.
/// </summary>
public class Material
{
/// <summary>
/// The base texture. (aka. Diffuse Texture)
/// </summary>
public TextureBase Texture;
/// <summary>
/// The tint or color.
/// </summary>
public Color4 Tint = Color4.White;
/// <summary>
/// A shader, that is used to draw this material.
/// <para>Default: Defaults.DefaultShaders </para>
/// </summary>
public IShader Shader = Defaults.DefaultShader;
}
}