From c8db1ce8bc8d4b85dafb321a9cbd317140663c55 Mon Sep 17 00:00:00 2001 From: Michel Fedde Date: Thu, 18 Mar 2021 10:13:43 +0100 Subject: [PATCH] Added missing summeries #2 --- SMCode/SM.Base/Controls/Mouse.cs | 1 + .../SM.Base/Drawing/GenericTransformation.cs | 5 ++ SMCode/SM.Base/Drawing/Material.cs | 3 + SMCode/SM.Base/Objects/InstancedMesh.cs | 7 ++ SMCode/SM.Base/PostEffects/BloomEffect.cs | 78 ++++++++++++++----- .../SM.Base/PostProcess/PostProcessEffect.cs | 6 ++ .../SM.Base/PostProcess/PostProcessShader.cs | 1 - SMCode/SM.Base/SM.Base.csproj | 1 - SMCode/SM.Base/Scene/GenericScene.cs | 6 +- SMCode/SM.Base/Scene/IFixedScriptable.cs | 7 ++ SMCode/SM.Base/Scene/IShowItem.cs | 6 ++ SMCode/SM.Base/Types/CVector1.cs | 3 - SMCode/SM.Base/Types/CVector2.cs | 1 - SMCode/SM.Base/Types/CVector3.cs | 1 - SMCode/SM.Base/Utility/Deltatime.cs | 3 + SMCode/SM.Base/Utility/IInitializable.cs | 9 +++ SMCode/SM.Base/Utility/Ray.cs | 21 +++++ SMCode/SM.Base/Utility/ShaderUtility.cs | 6 -- SMCode/SM.Base/Utility/Util.cs | 10 +++ SMCode/SM.Base/Window/Contexts/DrawContext.cs | 50 ++++++++++++ .../Window/Contexts/FixedUpdateContext.cs | 3 + SMCode/SM.Base/Window/GLWindow.cs | 4 +- SMCode/SM.Base/Window/IGenericWindow.cs | 2 - SMCode/SM.Base/Window/ISetup.cs | 15 ++++ SMCode/SM.Base/Window/RenderPipeline.cs | 33 ++++++++ SMCode/SM.Base/Window/WindowFlags.cs | 15 ++++ 26 files changed, 261 insertions(+), 36 deletions(-) delete mode 100644 SMCode/SM.Base/Utility/ShaderUtility.cs diff --git a/SMCode/SM.Base/Controls/Mouse.cs b/SMCode/SM.Base/Controls/Mouse.cs index ed60f9e..19e5061 100644 --- a/SMCode/SM.Base/Controls/Mouse.cs +++ b/SMCode/SM.Base/Controls/Mouse.cs @@ -32,6 +32,7 @@ namespace SM.Base.Controls /// The event to update the values. /// /// The event args. + /// The window where the mouse is checked internal static void MouseMoveEvent(MouseMoveEventArgs mmea, IGenericWindow window) { InScreen = new Vector2(mmea.X, mmea.Y); diff --git a/SMCode/SM.Base/Drawing/GenericTransformation.cs b/SMCode/SM.Base/Drawing/GenericTransformation.cs index 64d4e3b..5ddac89 100644 --- a/SMCode/SM.Base/Drawing/GenericTransformation.cs +++ b/SMCode/SM.Base/Drawing/GenericTransformation.cs @@ -53,6 +53,11 @@ namespace SM.Base.Drawing return _modelMatrix; } + /// + /// This combines the current matrix with the provided one. + /// + /// + /// public Matrix4 MergeMatrix(Matrix4 matrix) { return GetMatrix() * matrix; diff --git a/SMCode/SM.Base/Drawing/Material.cs b/SMCode/SM.Base/Drawing/Material.cs index 8b1d993..3f14675 100644 --- a/SMCode/SM.Base/Drawing/Material.cs +++ b/SMCode/SM.Base/Drawing/Material.cs @@ -13,6 +13,9 @@ namespace SM.Base.Drawing /// public class Material { + /// + /// A setting to enable Blending. + /// public bool Blending = false; /// diff --git a/SMCode/SM.Base/Objects/InstancedMesh.cs b/SMCode/SM.Base/Objects/InstancedMesh.cs index 90147f4..102b359 100644 --- a/SMCode/SM.Base/Objects/InstancedMesh.cs +++ b/SMCode/SM.Base/Objects/InstancedMesh.cs @@ -12,6 +12,13 @@ namespace SM.Base.Objects /// public class InstancedMesh : Mesh { + /// + /// Generates a mesh, with a primitive and attributes, that are required. + /// + /// The mesh type + /// A list of (additional) attributes. + /// Possible values: uv, normals and color + /// public InstancedMesh(PrimitiveType type, string[] enabledAttibute) : base(type) { Attributes["vertex"] = Vertex = new VBO(); diff --git a/SMCode/SM.Base/PostEffects/BloomEffect.cs b/SMCode/SM.Base/PostEffects/BloomEffect.cs index 25325de..f5926ca 100644 --- a/SMCode/SM.Base/PostEffects/BloomEffect.cs +++ b/SMCode/SM.Base/PostEffects/BloomEffect.cs @@ -13,6 +13,9 @@ using SM.OGL.Texture; namespace SM.Base.PostEffects { + /// + /// A bloom post process effect. + /// 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; + /// + /// A texture where you can define the amount of the bloom effect at each pixel. + /// public TextureBase AmountMap; + /// + /// The transformation for the amount map. + /// public TextureTransformation AmountTransform = new TextureTransformation(); - + /// + /// The maximal amount the amount map is clamped to. + /// Default: 1 + /// + public float MaxAmount = 1; + /// + /// The minimal amount the amount map is clamped to. + /// Default: 0 + /// + public float MinAmount = 0; + + /// + /// The defines how often the x-y-flipflop happens. + /// Default: 8 + /// public int Iterations = 8; + /// + /// The Threshold for the bloom effect. + /// Default: .8f + /// public float Threshold = .8f; + /// + /// Increases the brightness of the resulting effect. + /// Default: 1 + /// public float Power = 1; + /// + /// This can disable the bloom calculation. + /// Default: true + /// public bool Enable = true; - public float MaxAmount = 1; - - public float MinAmount = 0; - - public int WeightCurvePickAmount = 4; - - - public BloomEffect(Framebuffer source = null, bool hdr = false, float? textureScale = null) - { - _source = source; - _hdr = hdr; - _textureScale = textureScale.GetValueOrDefault(_defaultTextureScale); - - WeightCurve = _defaultCurve; - } - + /// + /// This defines the weight curve. + /// public BezierCurve WeightCurve { get => _weightCurve; @@ -73,6 +95,25 @@ namespace SM.Base.PostEffects UpdateWeights(); } } + /// + /// This defines how many picks the effect should pick from the weight curve. + /// + public int WeightCurvePickAmount = 4; + + /// + /// This creates a bloom effect. + /// + /// This can specify a own source framebuffer. If not set, it will take the Pipeline MainFramebuffer. + /// This allows to enable hdr returns. + /// This allows for a increase in performance, by lowering the calculating texture scale. + 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; } - + /// protected override void InitProcess() { _source = Pipeline.MainFramebuffer; @@ -107,6 +148,7 @@ namespace SM.Base.PostEffects Pipeline.Framebuffers.Add(_bloomBuffer2); } + /// public override void Draw(DrawContext context) { if (Enable) diff --git a/SMCode/SM.Base/PostProcess/PostProcessEffect.cs b/SMCode/SM.Base/PostProcess/PostProcessEffect.cs index cb6f750..5a522cb 100644 --- a/SMCode/SM.Base/PostProcess/PostProcessEffect.cs +++ b/SMCode/SM.Base/PostProcess/PostProcessEffect.cs @@ -13,8 +13,14 @@ namespace SM.Base.PostProcess /// public abstract class PostProcessEffect { + /// + /// This contains the transformation matrix for post process effects. + /// public static Matrix4 Mvp = Matrix4.Identity; + /// + /// This contains the pipeline this instance is currently active. + /// protected RenderPipeline Pipeline; /// diff --git a/SMCode/SM.Base/PostProcess/PostProcessShader.cs b/SMCode/SM.Base/PostProcess/PostProcessShader.cs index 5b92c19..c364588 100644 --- a/SMCode/SM.Base/PostProcess/PostProcessShader.cs +++ b/SMCode/SM.Base/PostProcess/PostProcessShader.cs @@ -54,7 +54,6 @@ namespace SM.Base.PostProcess /// /// Draws the shader with special uniforms. /// - /// /// public void Draw(Action setUniformAction) { diff --git a/SMCode/SM.Base/SM.Base.csproj b/SMCode/SM.Base/SM.Base.csproj index a94f33e..f5f1d37 100644 --- a/SMCode/SM.Base/SM.Base.csproj +++ b/SMCode/SM.Base/SM.Base.csproj @@ -109,7 +109,6 @@ - diff --git a/SMCode/SM.Base/Scene/GenericScene.cs b/SMCode/SM.Base/Scene/GenericScene.cs index e93bae4..bda2ee8 100644 --- a/SMCode/SM.Base/Scene/GenericScene.cs +++ b/SMCode/SM.Base/Scene/GenericScene.cs @@ -92,11 +92,12 @@ namespace SM.Base.Scene /// public bool IsInitialized { get; set; } - + /// public virtual void Activate() { } + /// public virtual void Initialization() { } @@ -111,6 +112,9 @@ namespace SM.Base.Scene _hud?.Update(context); } + /// + /// Executes a fixed update for this scene. + /// public virtual void FixedUpdate(FixedUpdateContext context) { _objectCollection?.FixedUpdate(context); diff --git a/SMCode/SM.Base/Scene/IFixedScriptable.cs b/SMCode/SM.Base/Scene/IFixedScriptable.cs index e29f4ac..046528b 100644 --- a/SMCode/SM.Base/Scene/IFixedScriptable.cs +++ b/SMCode/SM.Base/Scene/IFixedScriptable.cs @@ -7,8 +7,15 @@ using System.Threading.Tasks; namespace SM.Base.Scene { + /// + /// This interface allows for a object to implerment a fixed update. + /// public interface IFixedScriptable { + /// + /// Executes a fixed update. + /// + /// void FixedUpdate(FixedUpdateContext context); } diff --git a/SMCode/SM.Base/Scene/IShowItem.cs b/SMCode/SM.Base/Scene/IShowItem.cs index 748534e..899f9e6 100644 --- a/SMCode/SM.Base/Scene/IShowItem.cs +++ b/SMCode/SM.Base/Scene/IShowItem.cs @@ -29,7 +29,13 @@ namespace SM.Base.Scene /// ICollection Flags { get; set; } + /// + /// If true it will ignore the object. + /// bool Active { get; set; } + /// + /// Íf true it will ignore the object when rendering. + /// bool RenderActive { get; set; } /// diff --git a/SMCode/SM.Base/Types/CVector1.cs b/SMCode/SM.Base/Types/CVector1.cs index a5d2642..a4c3b42 100644 --- a/SMCode/SM.Base/Types/CVector1.cs +++ b/SMCode/SM.Base/Types/CVector1.cs @@ -70,7 +70,6 @@ namespace SM.Base.Types /// /// Sets the X-Component. /// - /// X-Component public virtual void Set(float uniform, bool triggerChanged = true) { X = uniform; @@ -80,8 +79,6 @@ namespace SM.Base.Types /// /// Adds the value to the components. /// - /// - /// public virtual void Add(float uniform, bool triggerChanged = true) { X += uniform; diff --git a/SMCode/SM.Base/Types/CVector2.cs b/SMCode/SM.Base/Types/CVector2.cs index 8d4627b..270d810 100644 --- a/SMCode/SM.Base/Types/CVector2.cs +++ b/SMCode/SM.Base/Types/CVector2.cs @@ -49,7 +49,6 @@ namespace SM.Base.Types /// /// Sets each component to the same value /// - /// public override void Set(float uniform, bool triggerChanged = true) { Y = uniform; diff --git a/SMCode/SM.Base/Types/CVector3.cs b/SMCode/SM.Base/Types/CVector3.cs index fb42916..9e43c02 100644 --- a/SMCode/SM.Base/Types/CVector3.cs +++ b/SMCode/SM.Base/Types/CVector3.cs @@ -65,7 +65,6 @@ namespace SM.Base.Types /// /// Sets each component to the counter-part. /// - /// public void Set(Vector3 vector, bool triggerChanged = true) { Set(vector.X, vector.Y, vector.Z, triggerChanged); diff --git a/SMCode/SM.Base/Utility/Deltatime.cs b/SMCode/SM.Base/Utility/Deltatime.cs index 21a0171..27bbd01 100644 --- a/SMCode/SM.Base/Utility/Deltatime.cs +++ b/SMCode/SM.Base/Utility/Deltatime.cs @@ -23,6 +23,9 @@ /// public static float UpdateDelta { get; internal set; } + /// + /// The current fixed update delta time. + /// public static float FixedUpdateDelta { get; set; } /// diff --git a/SMCode/SM.Base/Utility/IInitializable.cs b/SMCode/SM.Base/Utility/IInitializable.cs index f5e0ce4..bacd8bd 100644 --- a/SMCode/SM.Base/Utility/IInitializable.cs +++ b/SMCode/SM.Base/Utility/IInitializable.cs @@ -5,9 +5,18 @@ /// public interface IInitializable { + /// + /// If true, its already initialized. + /// bool IsInitialized { get; set; } + /// + /// A event when the object was activated. + /// void Activate(); + /// + /// A event, when the object was first initialized. + /// void Initialization(); } } \ No newline at end of file diff --git a/SMCode/SM.Base/Utility/Ray.cs b/SMCode/SM.Base/Utility/Ray.cs index eedd076..0b43c5b 100644 --- a/SMCode/SM.Base/Utility/Ray.cs +++ b/SMCode/SM.Base/Utility/Ray.cs @@ -8,17 +8,38 @@ using SM.OGL.Mesh; namespace SM.Base.Utility { + /// + /// A utility class to calculate rays. + /// public struct Ray { + /// + /// The position of the ray. + /// public Vector3 Position; + /// + /// The direction of the ray. + /// public Vector3 Direction; + /// + /// Constructs a ray. + /// + /// The position of the ray + /// The direction of the ray. public Ray(Vector3 position, Vector3 direction) { Position = position; Direction = direction.Normalized(); } + /// + /// Calculates a object intersection with OBB. + /// + /// The bounding box of the object + /// The model matrix of the object + /// Distance to the object. + /// If true, it intersects with the object. public bool ObjectIntersection(BoundingBox box, Matrix4 modelMatrix, out float distance) { distance = 0.0f; diff --git a/SMCode/SM.Base/Utility/ShaderUtility.cs b/SMCode/SM.Base/Utility/ShaderUtility.cs deleted file mode 100644 index e64826f..0000000 --- a/SMCode/SM.Base/Utility/ShaderUtility.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace SM.Base.Utility -{ - public class ShaderUtility - { - } -} \ No newline at end of file diff --git a/SMCode/SM.Base/Utility/Util.cs b/SMCode/SM.Base/Utility/Util.cs index a205074..b62657b 100644 --- a/SMCode/SM.Base/Utility/Util.cs +++ b/SMCode/SM.Base/Utility/Util.cs @@ -6,8 +6,15 @@ using System; namespace SM.Base.Utility { + /// + /// Utility-Functions that are too small for a own class. + /// public class Util { + /// + /// Activates a + /// + /// public static void Activate(IInitializable obj) { if (!obj.IsInitialized) @@ -19,6 +26,9 @@ namespace SM.Base.Utility obj.Activate(); } + /// + /// Calls a garbage collector. + /// public static void CallGarbageCollector() { GC.Collect(); diff --git a/SMCode/SM.Base/Window/Contexts/DrawContext.cs b/SMCode/SM.Base/Window/Contexts/DrawContext.cs index 5b3a5b4..ce98eca 100644 --- a/SMCode/SM.Base/Window/Contexts/DrawContext.cs +++ b/SMCode/SM.Base/Window/Contexts/DrawContext.cs @@ -12,26 +12,76 @@ using SM.OGL.Mesh; namespace SM.Base.Window { + /// + /// The draw context contains (more or less) important information for drawing a object. + /// public struct DrawContext { + /// + /// The window, the context came origionally. + /// public IGenericWindow Window { get; internal set; } + /// + /// The scene, the context was send to. + /// public GenericScene Scene { get; internal set; } + /// + /// The render pipeline, the context is using. + /// public RenderPipeline RenderPipeline { get; internal set; } + /// + /// The last object it came though. + /// Debugging pourpose. + /// public object LastObject { get; internal set; } + /// + /// The camera the context is using. + /// public GenericCamera UseCamera { get; internal set; } + /// + /// The world matrix. + /// public Matrix4 World => UseCamera.World; + /// + /// The view matrix. + /// public Matrix4 View => UseCamera.View; + /// + /// The mesh, that is rendered. + /// public GenericMesh Mesh { get; set; } + /// + /// If set, it will force the mesh to render with that primitive type. + /// public PrimitiveType? ForcedType { get; set; } + /// + /// The material the mesh is going to use. + /// public Material Material { get; set; } + /// + /// The shader the mesh is going to use. + /// public MaterialShader Shader => Material.CustomShader ?? RenderPipeline.DefaultShader; + /// + /// The master model matrix. + /// public Matrix4 ModelMatrix; + /// + /// The master texture matrix. + /// public Matrix3 TextureMatrix; + /// + /// Instances + /// public IList Instances; + /// + /// This sets the camera of the context. + /// + /// public void SetCamera(GenericCamera camera) { UseCamera = camera; diff --git a/SMCode/SM.Base/Window/Contexts/FixedUpdateContext.cs b/SMCode/SM.Base/Window/Contexts/FixedUpdateContext.cs index f2b22e7..ad5b17b 100644 --- a/SMCode/SM.Base/Window/Contexts/FixedUpdateContext.cs +++ b/SMCode/SM.Base/Window/Contexts/FixedUpdateContext.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace SM.Base.Window.Contexts { + /// + /// A context for the fixed update. + /// public struct FixedUpdateContext { diff --git a/SMCode/SM.Base/Window/GLWindow.cs b/SMCode/SM.Base/Window/GLWindow.cs index 14a9f00..6f93b9c 100644 --- a/SMCode/SM.Base/Window/GLWindow.cs +++ b/SMCode/SM.Base/Window/GLWindow.cs @@ -52,8 +52,8 @@ namespace SM.Base.Window public Vector2 WindowSize { get; set; } public ISetup AppliedSetup { get; private set; } - public event Action Resize; - public event Action Load; + public new event Action Resize; + public new event Action Load; public GenericScene CurrentScene { get; private set; } public RenderPipeline CurrentRenderPipeline { get; private set; } diff --git a/SMCode/SM.Base/Window/IGenericWindow.cs b/SMCode/SM.Base/Window/IGenericWindow.cs index a6b0f3a..e96c28a 100644 --- a/SMCode/SM.Base/Window/IGenericWindow.cs +++ b/SMCode/SM.Base/Window/IGenericWindow.cs @@ -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; } diff --git a/SMCode/SM.Base/Window/ISetup.cs b/SMCode/SM.Base/Window/ISetup.cs index 2756f58..4c5c6c4 100644 --- a/SMCode/SM.Base/Window/ISetup.cs +++ b/SMCode/SM.Base/Window/ISetup.cs @@ -1,10 +1,25 @@ namespace SM.Base.Window { + /// + /// A interface to implerment a window setup. + /// public interface ISetup { + /// + /// This fires when the setup is applied the window. + /// void Applied(IGenericWindow window); + /// + /// This fires when the window is currently loading. + /// void Load(IGenericWindow window); + /// + /// This fires when the window is done loading. + /// void Loaded(IGenericWindow window); + /// + /// This fires when the window was resized. + /// void Resize(IGenericWindow window); } } \ No newline at end of file diff --git a/SMCode/SM.Base/Window/RenderPipeline.cs b/SMCode/SM.Base/Window/RenderPipeline.cs index 9c68143..31767aa 100644 --- a/SMCode/SM.Base/Window/RenderPipeline.cs +++ b/SMCode/SM.Base/Window/RenderPipeline.cs @@ -12,23 +12,45 @@ using SM.OGL.Texture; namespace SM.Base.Window { + /// + /// This represents a render pipeline. + /// public abstract class RenderPipeline : IInitializable { + /// + /// This contains the windows its connected to. + /// public IGenericWindow ConnectedWindow { get; internal set; } + /// + /// This should contains the framebuffer, when any back buffer effects are used. + /// public Framebuffer MainFramebuffer { get; protected set; } + /// + /// This list contains all framebuffers that are required to update. + /// public List Framebuffers { get; } = new List(); + /// + /// This contains the default shader. + /// Default: + /// public virtual MaterialShader DefaultShader { get; protected set; } = SMRenderer.DefaultMaterialShader; + /// + /// Here you can set a default material. + /// public virtual Material DefaultMaterial { get; protected set; } + /// public bool IsInitialized { get; set; } + /// public virtual void Activate() { } + /// public virtual void Initialization() { if (MainFramebuffer != null) Framebuffers.Add(MainFramebuffer); @@ -40,8 +62,14 @@ namespace SM.Base.Window RenderProcess(ref context); } + /// + /// The process of rendering. + /// protected abstract void RenderProcess(ref DrawContext context); + /// + /// The event when resizing. + /// public virtual void Resize() { if (Framebuffers == null) return; @@ -54,6 +82,11 @@ namespace SM.Base.Window framebuffer.Compile(); } + /// + /// This creates a finished setup for a framebuffer. + /// + /// + /// public Framebuffer CreateWindowFramebuffer(int multisamples = 0) { Framebuffer framebuffer = new Framebuffer(ConnectedWindow); diff --git a/SMCode/SM.Base/Window/WindowFlags.cs b/SMCode/SM.Base/Window/WindowFlags.cs index 5be3d2f..5ec19c4 100644 --- a/SMCode/SM.Base/Window/WindowFlags.cs +++ b/SMCode/SM.Base/Window/WindowFlags.cs @@ -1,9 +1,24 @@ namespace SM.Base.Window { + /// + /// Flags how the window is shown. + /// public enum WindowFlags { + /// + /// As default window. + /// Window = 0, + /// + /// As a borderless window. + /// + /// WARNING! This automaticly fits the window to the screen and is not movable. + /// + /// BorderlessWindow = 2, + /// + /// Contents are shown in fullscreen. + /// ExclusiveFullscreen = 1 } } \ No newline at end of file