smrendererv3/SMCode/SM.Base/Scene/GenericItemCollection.cs
Michel Fedde 820d6ce700 04.10.2020
+ render pipeline system for more control about the renderering.
+ Log system
+ Framebuffer system

~ Default shader was moved to pipelines.
2020-10-04 16:31:48 +02:00

53 lines
No EOL
1.7 KiB
C#

using System.Collections.Generic;
using SM.Base.Contexts;
namespace SM.Base.Scene
{
/// <summary>
/// Contains a list of show items.
/// </summary>
/// <typeparam name="TItem">The type of show items.</typeparam>
public abstract class GenericItemCollection<TItem> : List<TItem>, IShowItem, IShowCollection<TItem>
where TItem : IShowItem
{
/// <inheritdoc />
public List<TItem> Objects => this;
/// <inheritdoc />
public void Update(UpdateContext context)
{
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++)
this[i].Draw(context);
}
}
/// <summary>
/// Contains a list of show items with transformation.
/// </summary>
/// <typeparam name="TItem">The type of show items.</typeparam>
/// <typeparam name="TTransformation">The type of transformation.</typeparam>
public abstract class GenericItemCollection<TItem, TTransformation> : GenericItemCollection<TItem>
where TItem : IShowItem
where TTransformation : GenericTransformation, new()
{
/// <summary>
/// Transformation of the collection
/// </summary>
public TTransformation Transform = new TTransformation();
/// <inheritdoc />
public override void Draw(DrawContext context)
{
context.View = Transform.GetMatrix() * context.View;
base.Draw(context);
}
}
}