04.10.2020

+ render pipeline system for more control about the renderering.
+ Log system
+ Framebuffer system

~ Default shader was moved to pipelines.
This commit is contained in:
Michel Fedde 2020-10-04 16:31:48 +02:00
parent 97e638d9d9
commit 820d6ce700
34 changed files with 660 additions and 106 deletions

View file

@ -54,7 +54,7 @@ namespace SM.Base.Scene
public abstract bool Orthographic { get; }
/// <summary>
/// This will calculate the world.
/// <para>This is called on <see cref="GenericWindow{TScene,TItem,TCamera}.ViewportCamera"/> to calculate the world.</para>
/// <para>This is called on <see cref="GenericWindow{TScene,TCamera}.ViewportCamera"/> to calculate the world.</para>
/// </summary>
/// <param name="world">The world scale</param>
/// <param name="aspect">The aspect ratio from the window.</param>

View file

@ -7,23 +7,24 @@ namespace SM.Base.Scene
/// Contains a list of show items.
/// </summary>
/// <typeparam name="TItem">The type of show items.</typeparam>
public abstract class GenericItemCollection<TItem> : IShowItem, IShowCollection<TItem>
public abstract class GenericItemCollection<TItem> : List<TItem>, IShowItem, IShowCollection<TItem>
where TItem : IShowItem
{
/// <inheritdoc />
public List<TItem> Objects { get; } = new List<TItem>();
public List<TItem> Objects => this;
/// <inheritdoc />
public void Update(UpdateContext context)
{
throw new System.NotImplementedException();
for(int i = 0; i < Objects.Count; i++)
this[i].Update(context);
}
/// <inheritdoc cref="IShowCollection{TItem}.Draw" />
public virtual void Draw(DrawContext context)
{
for (int i = 0; i < Objects.Count; i++)
Objects[i].Draw(context);
this[i].Draw(context);
}
}

View file

@ -4,13 +4,48 @@ using SM.Base.Contexts;
namespace SM.Base.Scene
{
/// <summary>
/// A generic scene, that imports functions for scene control.
/// </summary>
public abstract class GenericScene
{
/// <summary>
/// This contains the background.
/// </summary>
protected IBackgroundItem _background;
/// <summary>
/// Draws this scene.
/// </summary>
public virtual void Draw(DrawContext context)
{
}
/// <summary>
/// Called, when the user activates the scene.
/// </summary>
internal void Activate()
{
OnActivating();
}
/// <summary>
/// Called, when the user activates the scene.
/// </summary>
protected virtual void OnActivating()
{ }
}
/// <summary>
/// A generic scene that imports different functions.
/// </summary>
/// <typeparam name="TCamera">The type of cameras.</typeparam>
/// <typeparam name="TItem">The type of show items.</typeparam>
public abstract class GenericScene<TCamera, TItem> : GenericItemCollection<TItem>
/// <typeparam name="TCollection">The type for collections</typeparam>
public abstract class GenericScene<TCamera, TCollection, TItem> : GenericScene
where TCamera : GenericCamera, new()
where TCollection : GenericItemCollection<TItem>, new()
where TItem : IShowItem
{
/// <summary>
@ -28,13 +63,13 @@ namespace SM.Base.Scene
public TCamera HUDCamera { get; set; } = new TCamera();
/// <summary>
/// This contains the background.
/// Objects inside the scene.
/// </summary>
protected IBackgroundItem _background;
public TCollection Objects { get; set; } = new TCollection();
/// <summary>
/// This defines the HUD objects.
/// </summary>
public List<TItem> HUD { get; } = new List<TItem>();
public TCollection HUD { get; } = new TCollection();
/// <summary>
/// A collection for cameras to switch easier to different cameras.
/// </summary>
@ -49,25 +84,10 @@ namespace SM.Base.Scene
backgroundDrawContext.View = BackgroundCamera.CalculateViewMatrix();
_background?.Draw(backgroundDrawContext);
base.Draw(context);
Objects.Draw(context);
context.View = HUDCamera.CalculateViewMatrix();
for (int i = 0; i < HUD.Count; i++)
HUD[i].Draw(context);
HUD.Draw(context);
}
/// <summary>
/// Called, when the user activates the scene.
/// </summary>
internal void Activate()
{
OnActivating();
}
/// <summary>
/// Called, when the user activates the scene.
/// </summary>
protected virtual void OnActivating()
{ }
}
}