Added missing summeries #1

This commit is contained in:
Michel Fedde 2021-03-17 17:09:59 +01:00
parent 03d99ea28e
commit 8665b5b709
104 changed files with 1165 additions and 821 deletions

View file

@ -1,7 +1,7 @@
#region usings
using OpenTK;
using SM.Base.Windows;
using SM.Base.Window;
#endregion
@ -12,6 +12,11 @@ namespace SM.Base.Scene
/// </summary>
public abstract class GenericCamera
{
/// <summary>
/// Exposure defines the exposure to the Scene.
/// </summary>
public float Exposure = 1;
/// <summary>
/// This defines what is up. (Normalized)
/// <para>Default: <see cref="Vector3.UnitY" /></para>
@ -34,11 +39,6 @@ namespace SM.Base.Scene
/// </summary>
public abstract bool Orthographic { get; }
/// <summary>
/// Exposure defines the exposure to the Scene.
/// </summary>
public float Exposure = 1;
/// <summary>
/// Calculates the view matrix.
/// </summary>
@ -46,10 +46,7 @@ namespace SM.Base.Scene
internal void CalculateViewMatrix(IGenericWindow window)
{
View = ViewCalculation(window);
if (WorldCalculation(window, out Matrix4 world))
{
World = world;
}
if (WorldCalculation(window, out Matrix4 world)) World = world;
}
/// <summary>
@ -61,6 +58,12 @@ namespace SM.Base.Scene
/// </returns>
protected abstract Matrix4 ViewCalculation(IGenericWindow window);
/// <summary>
/// This calculates the world.
/// </summary>
/// <param name="window"></param>
/// <param name="world"></param>
/// <returns></returns>
protected abstract bool WorldCalculation(IGenericWindow window, out Matrix4 world);
}
}

View file

@ -2,10 +2,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using OpenTK;
using SM.Base;
using SM.Base.Drawing;
using SM.Base.Windows;
using SM.Base.Window;
#endregion
@ -16,12 +14,17 @@ namespace SM.Base.Scene
/// </summary>
public abstract class GenericItemCollection : List<IShowItem>, IShowItem, IShowCollection, IScriptable
{
private List<IScriptable> _scriptableObjects = new List<IScriptable>();
private readonly List<IScriptable> _scriptableObjects = new List<IScriptable>();
/// <summary>
/// Currently active script objects.
/// </summary>
public ReadOnlyCollection<IScriptable> ScriptableObjects => new ReadOnlyCollection<IScriptable>(_scriptableObjects);
public ReadOnlyCollection<IScriptable> ScriptableObjects =>
new ReadOnlyCollection<IScriptable>(_scriptableObjects);
/// <inheritdoc />
public bool UpdateActive { get; set; } = true;
/// <inheritdoc />
public List<IShowItem> Objects => this;
@ -32,23 +35,13 @@ namespace SM.Base.Scene
public string Name { get; set; } = "Unnamed Item Collection";
/// <inheritdoc />
public ICollection<string> Flags { get; set; } = new List<string>() {"collection"};
public ICollection<string> Flags { get; set; } = new List<string> {"collection"};
/// <inheritdoc cref="IShowItem" />
public bool Active { get; set; } = true;
public bool UpdateActive { get; set; } = true;
public bool RenderActive { get; set; } = true;
/// <inheritdoc />
public virtual void Update(UpdateContext context)
{
if (!Active || !UpdateActive) return;
for (var i = 0; i < _scriptableObjects.Count; i++)
{
if (!_scriptableObjects[i].Active || !_scriptableObjects[i].UpdateActive) continue;
_scriptableObjects[i].Update(context);
}
}
/// <inheritdoc />
public bool RenderActive { get; set; } = true;
/// <inheritdoc cref="IShowCollection.Draw" />
public virtual void Draw(DrawContext context)
@ -62,6 +55,18 @@ namespace SM.Base.Scene
}
}
/// <inheritdoc />
public virtual void Update(UpdateContext context)
{
if (!Active || !UpdateActive) return;
for (var i = 0; i < _scriptableObjects.Count; i++)
{
if (!_scriptableObjects[i].Active || !_scriptableObjects[i].UpdateActive) continue;
_scriptableObjects[i].Update(context);
}
}
/// <inheritdoc />
public virtual void OnAdded(object sender)
{
@ -75,7 +80,7 @@ namespace SM.Base.Scene
/// <summary>
/// Adds a item to the draw and the script collection, when applicable.
/// </summary>
public new void Add(params IShowItem[] items)
public void Add(params IShowItem[] items)
{
foreach (var item in items)
{
@ -87,7 +92,7 @@ namespace SM.Base.Scene
}
/// <summary>
/// Adds the object to the collection.
/// Adds the object to the collection.
/// </summary>
/// <param name="item"></param>
public void AddObject(IShowItem item)
@ -96,8 +101,9 @@ namespace SM.Base.Scene
item.Parent = this;
item.OnAdded(this);
}
/// <summary>
/// Adds the script to the collection.
/// Adds the script to the collection.
/// </summary>
/// <param name="item"></param>
public void AddScript(IScriptable item)
@ -105,7 +111,7 @@ namespace SM.Base.Scene
_scriptableObjects.Add(item);
}
public new void Remove(params IShowItem[] items)
public void Remove(params IShowItem[] items)
{
foreach (var item in items)
{
@ -117,7 +123,7 @@ namespace SM.Base.Scene
}
/// <summary>
/// Remove the object from the draw collection.
/// Remove the object from the draw collection.
/// </summary>
/// <param name="item"></param>
public void RemoveObject(IShowItem item)
@ -128,7 +134,7 @@ namespace SM.Base.Scene
}
/// <summary>
/// Remove the object from the script collection.
/// Remove the object from the script collection.
/// </summary>
/// <param name="item"></param>
public void RemoveScript(IScriptable item)
@ -139,7 +145,7 @@ namespace SM.Base.Scene
public ICollection<IShowItem> GetAllItems(bool includeCollections = false)
{
List<IShowItem> items = new List<IShowItem>();
for (var i = 0; i < this.Count; i++)
for (var i = 0; i < Count; i++)
{
if (!includeCollections && this[i] is IShowCollection) continue;
items.Add(this[i]);
@ -201,7 +207,8 @@ namespace SM.Base.Scene
/// </summary>
/// <typeparam name="TItem">The type of show items.</typeparam>
/// <typeparam name="TTransformation">The type of transformation.</typeparam>
public abstract class GenericItemCollection<TTransformation> : GenericItemCollection, IShowTransformItem<TTransformation>
public abstract class GenericItemCollection<TTransformation> : GenericItemCollection,
IShowTransformItem<TTransformation>
where TTransformation : GenericTransformation, new()
{
/// <summary>

View file

@ -2,12 +2,8 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Windows.Controls;
using SM.Base;
using SM.Base.Drawing;
using SM.Base.Windows;
using SM.Utility;
using SM.Base.Utility;
using SM.Base.Window;
#endregion
@ -18,12 +14,17 @@ namespace SM.Base.Scene
/// </summary>
public abstract class GenericScene : IInitializable
{
private IBackgroundItem _background;
private readonly Dictionary<Type, object> _extensions = new Dictionary<Type, object>();
private GenericItemCollection _hud;
private GenericItemCollection _objectCollection;
private IBackgroundItem _background;
private Dictionary<Type, object> _extensions = new Dictionary<Type, object>();
/// <summary>
/// A collection for cameras to switch easier to different cameras.
/// </summary>
public Dictionary<string, GenericCamera> Cameras = new Dictionary<string, GenericCamera>();
/// <summary>
/// This contains the background.
/// </summary>
@ -63,16 +64,6 @@ namespace SM.Base.Scene
}
}
/// <summary>
/// A collection for cameras to switch easier to different cameras.
/// </summary>
public Dictionary<string, GenericCamera> Cameras = new Dictionary<string, GenericCamera>();
/// <summary>
/// If true, the scene was already initialized.
/// </summary>
public bool IsInitialized { get; set; }
/// <summary>
/// If true, shows a axis helper at (0,0,0)
@ -95,6 +86,20 @@ namespace SM.Base.Scene
/// </summary>
public GenericCamera HUDCamera { get; set; }
/// <summary>
/// If true, the scene was already initialized.
/// </summary>
public bool IsInitialized { get; set; }
public virtual void Activate()
{
}
public virtual void Initialization()
{
}
/// <summary>
/// Updates this scene.
/// </summary>
@ -155,7 +160,6 @@ namespace SM.Base.Scene
/// <param name="context"></param>
public virtual void DrawDebug(DrawContext context)
{
}
/// <summary>
@ -178,25 +182,20 @@ namespace SM.Base.Scene
object ext = _extensions[typeof(T)];
if (ext == null)
{
Log.Write(LogType.Warning, $"Tried to get the extension '{typeof(T).Name}', that doesn't exist in the scene.");
Log.Write(LogType.Warning,
$"Tried to get the extension '{typeof(T).Name}', that doesn't exist in the scene.");
return null;
}
return (T)ext;
return (T) ext;
}
public virtual void Activate()
/// <summary>
/// This is triggered when the scene gets deactivated.
/// </summary>
public virtual void Deactivate()
{
}
public virtual void Initialization()
{
}
public virtual void Deactivate() {}
}
/// <summary>
@ -242,6 +241,5 @@ namespace SM.Base.Scene
get => (TCamera) base.BackgroundCamera;
set => base.BackgroundCamera = value;
}
}
}

View file

@ -1,14 +1,24 @@
using SM.Base;
using SM.Base.Windows;
#region usings
using SM.Base.Window;
#endregion
namespace SM.Base.Scene
{
/// <summary>
/// Defines a object as script.
/// Defines a object as script.
/// </summary>
public interface IScriptable
{
/// <summary>
/// If not active, ItemCollections will ignore them.
/// </summary>
bool Active { get; set; }
/// <summary>
/// If not active, ItemCollections will ignore them.
/// </summary>
bool UpdateActive { get; set; }
/// <summary>

View file

@ -1,8 +1,7 @@
#region usings
using System.Collections.Generic;
using SM.Base;
using SM.Base.Windows;
using SM.Base.Window;
#endregion
@ -11,7 +10,6 @@ namespace SM.Base.Scene
/// <summary>
/// Adds functions, that is required for a collection.
/// </summary>
/// <typeparam name="TItem">The type of show item.</typeparam>
public interface IShowCollection
{
/// <summary>

View file

@ -1,9 +1,8 @@
#region usings
using System.Collections.Generic;
using SM.Base;
using SM.Base.Drawing;
using SM.Base.Windows;
using SM.Base.Window;
using SM.OGL.Mesh;
#endregion
@ -50,7 +49,7 @@ namespace SM.Base.Scene
void OnRemoved(object sender);
}
public interface ITransformItem<TTransform>
public interface ITransformItem<TTransform>
where TTransform : GenericTransformation
{
TTransform Transform { get; set; }
@ -58,7 +57,8 @@ namespace SM.Base.Scene
public interface IShowTransformItem<TTransform> : IShowItem, ITransformItem<TTransform>
where TTransform : GenericTransformation
{}
{
}
public interface IModelItem
{