Added missing summeries #2

This commit is contained in:
Michel Fedde 2021-03-18 10:13:43 +01:00
parent 31777faa11
commit c8db1ce8bc
26 changed files with 261 additions and 36 deletions

View file

@ -32,6 +32,7 @@ namespace SM.Base.Controls
/// The event to update the values.
/// </summary>
/// <param name="mmea">The event args.</param>
/// <param name="window">The window where the mouse is checked</param>
internal static void MouseMoveEvent(MouseMoveEventArgs mmea, IGenericWindow window)
{
InScreen = new Vector2(mmea.X, mmea.Y);

View file

@ -53,6 +53,11 @@ namespace SM.Base.Drawing
return _modelMatrix;
}
/// <summary>
/// This combines the current matrix with the provided one.
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public Matrix4 MergeMatrix(Matrix4 matrix)
{
return GetMatrix() * matrix;

View file

@ -13,6 +13,9 @@ namespace SM.Base.Drawing
/// </summary>
public class Material
{
/// <summary>
/// A setting to enable Blending.
/// </summary>
public bool Blending = false;
/// <summary>

View file

@ -12,6 +12,13 @@ namespace SM.Base.Objects
/// </summary>
public class InstancedMesh : Mesh
{
/// <summary>
/// Generates a mesh, with a primitive and attributes, that are required.
/// </summary>
/// <param name="type">The mesh type</param>
/// <param name="enabledAttibute">A list of (additional) attributes.
/// <para> Possible values: uv, normals and color </para>
/// </param>
public InstancedMesh(PrimitiveType type, string[] enabledAttibute) : base(type)
{
Attributes["vertex"] = Vertex = new VBO();

View file

@ -13,6 +13,9 @@ using SM.OGL.Texture;
namespace SM.Base.PostEffects
{
/// <summary>
/// A bloom post process effect.
/// </summary>
public class BloomEffect : PostProcessEffect
{
private static BezierCurve _defaultCurve = new BezierCurve(Vector2.UnitY, Vector2.Zero, new Vector2(0.4f, 0), new Vector2(.5f,0));
@ -39,31 +42,50 @@ namespace SM.Base.PostEffects
private ColorAttachment _xBuffer;
private ColorAttachment _yBuffer;
/// <summary>
/// A texture where you can define the amount of the bloom effect at each pixel.
/// </summary>
public TextureBase AmountMap;
/// <summary>
/// The transformation for the amount map.
/// </summary>
public TextureTransformation AmountTransform = new TextureTransformation();
public int Iterations = 8;
public float Threshold = .8f;
public float Power = 1;
public bool Enable = true;
/// <summary>
/// The maximal amount the amount map is clamped to.
/// <para>Default: 1</para>
/// </summary>
public float MaxAmount = 1;
/// <summary>
/// The minimal amount the amount map is clamped to.
/// <para>Default: 0</para>
/// </summary>
public float MinAmount = 0;
public int WeightCurvePickAmount = 4;
/// <summary>
/// The defines how often the x-y-flipflop happens.
/// <para>Default: 8</para>
/// </summary>
public int Iterations = 8;
/// <summary>
/// The Threshold for the bloom effect.
/// <para>Default: .8f</para>
/// </summary>
public float Threshold = .8f;
/// <summary>
/// Increases the brightness of the resulting effect.
/// <para>Default: 1</para>
/// </summary>
public float Power = 1;
/// <summary>
/// This can disable the bloom calculation.
/// <para>Default: true</para>
/// </summary>
public bool Enable = true;
public BloomEffect(Framebuffer source = null, bool hdr = false, float? textureScale = null)
{
_source = source;
_hdr = hdr;
_textureScale = textureScale.GetValueOrDefault(_defaultTextureScale);
WeightCurve = _defaultCurve;
}
/// <summary>
/// This defines the weight curve.
/// </summary>
public BezierCurve WeightCurve
{
get => _weightCurve;
@ -73,6 +95,25 @@ namespace SM.Base.PostEffects
UpdateWeights();
}
}
/// <summary>
/// This defines how many picks the effect should pick from the weight curve.
/// </summary>
public int WeightCurvePickAmount = 4;
/// <summary>
/// This creates a bloom effect.
/// </summary>
/// <param name="source">This can specify a own source framebuffer. If not set, it will take the Pipeline MainFramebuffer.</param>
/// <param name="hdr">This allows to enable hdr returns.</param>
/// <param name="textureScale">This allows for a increase in performance, by lowering the calculating texture scale.</param>
public BloomEffect(Framebuffer source = null, bool hdr = false, float? textureScale = null)
{
_source = source;
_hdr = hdr;
_textureScale = textureScale.GetValueOrDefault(_defaultTextureScale);
WeightCurve = _defaultCurve;
}
private void UpdateWeights()
@ -83,7 +124,7 @@ namespace SM.Base.PostEffects
_weights[i] = _weightCurve.CalculatePoint((float) (i + 1) / (WeightCurvePickAmount + 1)).Y;
}
/// <inheritdoc/>
protected override void InitProcess()
{
_source = Pipeline.MainFramebuffer;
@ -107,6 +148,7 @@ namespace SM.Base.PostEffects
Pipeline.Framebuffers.Add(_bloomBuffer2);
}
/// <inheritdoc/>
public override void Draw(DrawContext context)
{
if (Enable)

View file

@ -13,8 +13,14 @@ namespace SM.Base.PostProcess
/// </summary>
public abstract class PostProcessEffect
{
/// <summary>
/// This contains the transformation matrix for post process effects.
/// </summary>
public static Matrix4 Mvp = Matrix4.Identity;
/// <summary>
/// This contains the pipeline this instance is currently active.
/// </summary>
protected RenderPipeline Pipeline;
/// <summary>

View file

@ -54,7 +54,6 @@ namespace SM.Base.PostProcess
/// <summary>
/// Draws the shader with special uniforms.
/// </summary>
/// <param name="color"></param>
/// <param name="setUniformAction"></param>
public void Draw(Action<UniformCollection> setUniformAction)
{

View file

@ -109,7 +109,6 @@
<Compile Include="Utility\Deltatime.cs" />
<Compile Include="Utility\Randomize.cs" />
<Compile Include="Utility\RotationUtility.cs" />
<Compile Include="Utility\ShaderUtility.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scene\GenericCamera.cs" />
<Compile Include="Scene\GenericScene.cs" />

View file

@ -92,11 +92,12 @@ namespace SM.Base.Scene
/// </summary>
public bool IsInitialized { get; set; }
/// <inheritdoc/>
public virtual void Activate()
{
}
/// <inheritdoc/>
public virtual void Initialization()
{
}
@ -111,6 +112,9 @@ namespace SM.Base.Scene
_hud?.Update(context);
}
/// <summary>
/// Executes a fixed update for this scene.
/// </summary>
public virtual void FixedUpdate(FixedUpdateContext context)
{
_objectCollection?.FixedUpdate(context);

View file

@ -7,8 +7,15 @@ using System.Threading.Tasks;
namespace SM.Base.Scene
{
/// <summary>
/// This interface allows for a object to implerment a fixed update.
/// </summary>
public interface IFixedScriptable
{
/// <summary>
/// Executes a fixed update.
/// </summary>
/// <param name="context"></param>
void FixedUpdate(FixedUpdateContext context);
}

View file

@ -29,7 +29,13 @@ namespace SM.Base.Scene
/// </summary>
ICollection<string> Flags { get; set; }
/// <summary>
/// If true it will ignore the object.
/// </summary>
bool Active { get; set; }
/// <summary>
/// Íf true it will ignore the object when rendering.
/// </summary>
bool RenderActive { get; set; }
/// <summary>

View file

@ -70,7 +70,6 @@ namespace SM.Base.Types
/// <summary>
/// Sets the X-Component.
/// </summary>
/// <param name="x">X-Component</param>
public virtual void Set(float uniform, bool triggerChanged = true)
{
X = uniform;
@ -80,8 +79,6 @@ namespace SM.Base.Types
/// <summary>
/// Adds the value to the components.
/// </summary>
/// <param name="uniform"></param>
/// <param name="triggerChanged"></param>
public virtual void Add(float uniform, bool triggerChanged = true)
{
X += uniform;

View file

@ -49,7 +49,6 @@ namespace SM.Base.Types
/// <summary>
/// Sets each component to the same value
/// </summary>
/// <param name="uniform"></param>
public override void Set(float uniform, bool triggerChanged = true)
{
Y = uniform;

View file

@ -65,7 +65,6 @@ namespace SM.Base.Types
/// <summary>
/// Sets each component to the <see cref="Vector3" /> counter-part.
/// </summary>
/// <param name="vector"></param>
public void Set(Vector3 vector, bool triggerChanged = true)
{
Set(vector.X, vector.Y, vector.Z, triggerChanged);

View file

@ -23,6 +23,9 @@
/// </summary>
public static float UpdateDelta { get; internal set; }
/// <summary>
/// The current fixed update delta time.
/// </summary>
public static float FixedUpdateDelta { get; set; }
/// <summary>

View file

@ -5,9 +5,18 @@
/// </summary>
public interface IInitializable
{
/// <summary>
/// If true, its already initialized.
/// </summary>
bool IsInitialized { get; set; }
/// <summary>
/// A event when the object was activated.
/// </summary>
void Activate();
/// <summary>
/// A event, when the object was first initialized.
/// </summary>
void Initialization();
}
}

View file

@ -8,17 +8,38 @@ using SM.OGL.Mesh;
namespace SM.Base.Utility
{
/// <summary>
/// A utility class to calculate rays.
/// </summary>
public struct Ray
{
/// <summary>
/// The position of the ray.
/// </summary>
public Vector3 Position;
/// <summary>
/// The direction of the ray.
/// </summary>
public Vector3 Direction;
/// <summary>
/// Constructs a ray.
/// </summary>
/// <param name="position">The position of the ray</param>
/// <param name="direction">The direction of the ray.</param>
public Ray(Vector3 position, Vector3 direction)
{
Position = position;
Direction = direction.Normalized();
}
/// <summary>
/// Calculates a object intersection with OBB.
/// </summary>
/// <param name="box">The bounding box of the object</param>
/// <param name="modelMatrix">The model matrix of the object</param>
/// <param name="distance">Distance to the object.</param>
/// <returns>If true, it intersects with the object.</returns>
public bool ObjectIntersection(BoundingBox box, Matrix4 modelMatrix, out float distance)
{
distance = 0.0f;

View file

@ -1,6 +0,0 @@
namespace SM.Base.Utility
{
public class ShaderUtility
{
}
}

View file

@ -6,8 +6,15 @@ using System;
namespace SM.Base.Utility
{
/// <summary>
/// Utility-Functions that are too small for a own class.
/// </summary>
public class Util
{
/// <summary>
/// Activates a <see cref="IInitializable"/>
/// </summary>
/// <param name="obj"></param>
public static void Activate(IInitializable obj)
{
if (!obj.IsInitialized)
@ -19,6 +26,9 @@ namespace SM.Base.Utility
obj.Activate();
}
/// <summary>
/// Calls a garbage collector.
/// </summary>
public static void CallGarbageCollector()
{
GC.Collect();

View file

@ -12,26 +12,76 @@ using SM.OGL.Mesh;
namespace SM.Base.Window
{
/// <summary>
/// The draw context contains (more or less) important information for drawing a object.
/// </summary>
public struct DrawContext
{
/// <summary>
/// The window, the context came origionally.
/// </summary>
public IGenericWindow Window { get; internal set; }
/// <summary>
/// The scene, the context was send to.
/// </summary>
public GenericScene Scene { get; internal set; }
/// <summary>
/// The render pipeline, the context is using.
/// </summary>
public RenderPipeline RenderPipeline { get; internal set; }
/// <summary>
/// The last object it came though.
/// <para>Debugging pourpose.</para>
/// </summary>
public object LastObject { get; internal set; }
/// <summary>
/// The camera the context is using.
/// </summary>
public GenericCamera UseCamera { get; internal set; }
/// <summary>
/// The world matrix.
/// </summary>
public Matrix4 World => UseCamera.World;
/// <summary>
/// The view matrix.
/// </summary>
public Matrix4 View => UseCamera.View;
/// <summary>
/// The mesh, that is rendered.
/// </summary>
public GenericMesh Mesh { get; set; }
/// <summary>
/// If set, it will force the mesh to render with that primitive type.
/// </summary>
public PrimitiveType? ForcedType { get; set; }
/// <summary>
/// The material the mesh is going to use.
/// </summary>
public Material Material { get; set; }
/// <summary>
/// The shader the mesh is going to use.
/// </summary>
public MaterialShader Shader => Material.CustomShader ?? RenderPipeline.DefaultShader;
/// <summary>
/// The master model matrix.
/// </summary>
public Matrix4 ModelMatrix;
/// <summary>
/// The master texture matrix.
/// </summary>
public Matrix3 TextureMatrix;
/// <summary>
/// Instances
/// </summary>
public IList<Instance> Instances;
/// <summary>
/// This sets the camera of the context.
/// </summary>
/// <param name="camera"></param>
public void SetCamera(GenericCamera camera)
{
UseCamera = camera;

View file

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace SM.Base.Window.Contexts
{
/// <summary>
/// A context for the fixed update.
/// </summary>
public struct FixedUpdateContext
{

View file

@ -52,8 +52,8 @@ namespace SM.Base.Window
public Vector2 WindowSize { get; set; }
public ISetup AppliedSetup { get; private set; }
public event Action<IGenericWindow> Resize;
public event Action<IGenericWindow> Load;
public new event Action<IGenericWindow> Resize;
public new event Action<IGenericWindow> Load;
public GenericScene CurrentScene { get; private set; }
public RenderPipeline CurrentRenderPipeline { get; private set; }

View file

@ -21,8 +21,6 @@ namespace SM.Base.Window
bool DrawWhileUnfocused { get; set; }
bool UpdateWhileUnfocused { get; set; }
int Width { get; }
int Height { get; }
Vector2 WindowSize { get; set; }
Rectangle ClientRectangle { get; }

View file

@ -1,10 +1,25 @@
namespace SM.Base.Window
{
/// <summary>
/// A interface to implerment a window setup.
/// </summary>
public interface ISetup
{
/// <summary>
/// This fires when the setup is applied the window.
/// </summary>
void Applied(IGenericWindow window);
/// <summary>
/// This fires when the window is currently loading.
/// </summary>
void Load(IGenericWindow window);
/// <summary>
/// This fires when the window is done loading.
/// </summary>
void Loaded(IGenericWindow window);
/// <summary>
/// This fires when the window was resized.
/// </summary>
void Resize(IGenericWindow window);
}
}

View file

@ -12,23 +12,45 @@ using SM.OGL.Texture;
namespace SM.Base.Window
{
/// <summary>
/// This represents a render pipeline.
/// </summary>
public abstract class RenderPipeline : IInitializable
{
/// <summary>
/// This contains the windows its connected to.
/// </summary>
public IGenericWindow ConnectedWindow { get; internal set; }
/// <summary>
/// This should contains the framebuffer, when any back buffer effects are used.
/// </summary>
public Framebuffer MainFramebuffer { get; protected set; }
/// <summary>
/// This list contains all framebuffers that are required to update.
/// </summary>
public List<Framebuffer> Framebuffers { get; } = new List<Framebuffer>();
/// <summary>
/// This contains the default shader.
/// <para>Default: <see cref="SMRenderer.DefaultMaterialShader"/></para>
/// </summary>
public virtual MaterialShader DefaultShader { get; protected set; } = SMRenderer.DefaultMaterialShader;
/// <summary>
/// Here you can set a default material.
/// </summary>
public virtual Material DefaultMaterial { get; protected set; }
/// <inheritdoc/>
public bool IsInitialized { get; set; }
/// <inheritdoc/>
public virtual void Activate()
{
}
/// <inheritdoc/>
public virtual void Initialization()
{
if (MainFramebuffer != null) Framebuffers.Add(MainFramebuffer);
@ -40,8 +62,14 @@ namespace SM.Base.Window
RenderProcess(ref context);
}
/// <summary>
/// The process of rendering.
/// </summary>
protected abstract void RenderProcess(ref DrawContext context);
/// <summary>
/// The event when resizing.
/// </summary>
public virtual void Resize()
{
if (Framebuffers == null) return;
@ -54,6 +82,11 @@ namespace SM.Base.Window
framebuffer.Compile();
}
/// <summary>
/// This creates a finished setup for a framebuffer.
/// </summary>
/// <param name="multisamples"></param>
/// <returns></returns>
public Framebuffer CreateWindowFramebuffer(int multisamples = 0)
{
Framebuffer framebuffer = new Framebuffer(ConnectedWindow);

View file

@ -1,9 +1,24 @@
namespace SM.Base.Window
{
/// <summary>
/// Flags how the window is shown.
/// </summary>
public enum WindowFlags
{
/// <summary>
/// As default window.
/// </summary>
Window = 0,
/// <summary>
/// As a borderless window.
/// <para>
/// WARNING! This automaticly fits the window to the screen and is not movable.
/// </para>
/// </summary>
BorderlessWindow = 2,
/// <summary>
/// Contents are shown in fullscreen.
/// </summary>
ExclusiveFullscreen = 1
}
}