Added missing summeries #1
This commit is contained in:
parent
03d99ea28e
commit
8665b5b709
104 changed files with 1165 additions and 821 deletions
|
|
@ -1,12 +1,10 @@
|
|||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTK.Graphics.ES11;
|
||||
using SM.Base;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Windows;
|
||||
using SM.Base.Window;
|
||||
using SM.OGL.Mesh;
|
||||
using PrimitiveType = OpenTK.Graphics.OpenGL4.PrimitiveType;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -22,15 +20,27 @@ namespace SM.Base.Drawing
|
|||
/// </summary>
|
||||
public Material Material = new Material();
|
||||
|
||||
/// <summary>
|
||||
/// Transformation for the textures.
|
||||
/// </summary>
|
||||
public TextureTransformation TextureTransform = new TextureTransformation();
|
||||
|
||||
/// <summary>
|
||||
/// This allows custom shaders to add own arguments.
|
||||
/// </summary>
|
||||
public ShaderArguments ShaderArguments => Material.ShaderArguments;
|
||||
|
||||
/// <summary>
|
||||
/// This can force a shader to render the object with the specified mesh type.
|
||||
/// </summary>
|
||||
public PrimitiveType? ForcedMeshType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The mesh it should use.
|
||||
/// </summary>
|
||||
public GenericMesh Mesh { get; set; } = SMRenderer.DefaultMesh;
|
||||
|
||||
public ShaderArguments ShaderArguments => Material.ShaderArguments;
|
||||
public TextureTransformation TextureTransform = new TextureTransformation();
|
||||
|
||||
/// <inheritdoc />
|
||||
public object Parent { get; set; }
|
||||
|
||||
|
|
@ -40,12 +50,11 @@ namespace SM.Base.Drawing
|
|||
/// <inheritdoc />
|
||||
public ICollection<string> Flags { get; set; }
|
||||
|
||||
public PrimitiveType? ForcedMeshType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This value determents if the object should draw something.
|
||||
/// </summary>
|
||||
public bool Active { get; set; } = true;
|
||||
|
||||
public bool RenderActive { get; set; } = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -12,12 +12,18 @@ namespace SM.Base.Drawing
|
|||
public abstract class GenericTransformation
|
||||
{
|
||||
/// <summary>
|
||||
/// If true, ignores the transformation and sends <see cref="Matrix4.Identity"/>, when requested.
|
||||
/// If true, ignores the transformation and sends <see cref="Matrix4.Identity" />, when requested.
|
||||
/// </summary>
|
||||
public bool Ignore = false;
|
||||
|
||||
/// <summary>
|
||||
/// The last matrix that was used to calculate the real world matrix.
|
||||
/// </summary>
|
||||
public Matrix4 LastMaster { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The transformation in world space.
|
||||
/// </summary>
|
||||
public Matrix4 InWorldSpace => MergeMatrix(LastMaster);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ namespace SM.Base.Drawing
|
|||
/// </summary>
|
||||
public Matrix4 ModelMatrix = Matrix4.Identity;
|
||||
|
||||
/// <summary>
|
||||
/// The Texture matrix
|
||||
/// </summary>
|
||||
public Matrix3 TextureMatrix = Matrix3.Identity;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Shaders;
|
||||
using SM.OGL.Texture;
|
||||
|
||||
#endregion
|
||||
|
|
@ -13,6 +13,8 @@ namespace SM.Base.Drawing
|
|||
/// </summary>
|
||||
public class Material
|
||||
{
|
||||
public bool Blending = false;
|
||||
|
||||
/// <summary>
|
||||
/// A custom shader, that is used to draw this material.
|
||||
/// </summary>
|
||||
|
|
@ -28,8 +30,9 @@ namespace SM.Base.Drawing
|
|||
/// </summary>
|
||||
public Color4 Tint = Color4.White;
|
||||
|
||||
/// <summary>
|
||||
/// This allows custom shaders to use own shader arguments.
|
||||
/// </summary>
|
||||
public ShaderArguments ShaderArguments { get; internal set; } = new ShaderArguments();
|
||||
|
||||
public bool Blending = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
using SM.Base.Time;
|
||||
#region usings
|
||||
|
||||
using SM.Base.Time;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Drawing.Particles
|
||||
{
|
||||
|
|
@ -8,11 +12,12 @@ namespace SM.Base.Drawing.Particles
|
|||
public struct ParticleContext
|
||||
{
|
||||
/// <summary>
|
||||
/// The Timer of the particles
|
||||
/// The Timer of the particles
|
||||
/// </summary>
|
||||
public Timer Timer;
|
||||
|
||||
/// <summary>
|
||||
/// The current speed of the particles.
|
||||
/// The current speed of the particles.
|
||||
/// </summary>
|
||||
public float Speed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,42 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using SM.Base;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Time;
|
||||
using SM.Base.Types;
|
||||
using SM.Base.Windows;
|
||||
using SM.OGL.Shaders;
|
||||
using SM.Base.Window;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Drawing.Particles
|
||||
{
|
||||
/// <summary>
|
||||
/// The (drawing) basis for particles
|
||||
/// The (drawing) basis for particles
|
||||
/// </summary>
|
||||
public abstract class ParticleDrawingBasis<TTransform, TDirection> : DrawingBasis<TTransform>, IScriptable
|
||||
where TTransform : GenericTransformation, new()
|
||||
where TDirection : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of particles
|
||||
/// </summary>
|
||||
public int Amount = 32;
|
||||
|
||||
/// <summary>
|
||||
/// This contains the different instances for the particles.
|
||||
/// </summary>
|
||||
protected List<Instance> instances;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum speed of the particles
|
||||
/// </summary>
|
||||
public float MaxSpeed = 1;
|
||||
|
||||
/// <summary>
|
||||
/// This contains all important information for each particle.
|
||||
/// </summary>
|
||||
protected ParticleStruct<TDirection>[] particleStructs;
|
||||
/// <summary>
|
||||
/// This contains the different instances for the particles.
|
||||
/// </summary>
|
||||
protected List<Instance> instances;
|
||||
|
||||
/// <summary>
|
||||
/// The stopwatch of the particles.
|
||||
|
|
@ -33,13 +44,13 @@ namespace SM.Base.Drawing.Particles
|
|||
protected Timer timer;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of particles
|
||||
/// Sets up the timer.
|
||||
/// </summary>
|
||||
public int Amount = 32;
|
||||
/// <summary>
|
||||
/// The maximum speed of the particles
|
||||
/// </summary>
|
||||
public float MaxSpeed = 1;
|
||||
/// <param name="duration">Duration how long the particles should live</param>
|
||||
protected ParticleDrawingBasis(TimeSpan duration)
|
||||
{
|
||||
timer = new Timer(duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/Sets the state of pausing.
|
||||
|
|
@ -55,13 +66,25 @@ namespace SM.Base.Drawing.Particles
|
|||
/// </summary>
|
||||
public abstract Func<TDirection, ParticleContext, TDirection> MovementCalculation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets up the timer.
|
||||
/// </summary>
|
||||
/// <param name="duration">Duration how long the particles should live</param>
|
||||
protected ParticleDrawingBasis(TimeSpan duration)
|
||||
/// <inheritdoc />
|
||||
public bool UpdateActive { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Update(UpdateContext context)
|
||||
{
|
||||
timer = new Timer(duration);
|
||||
if (!timer.Running) return;
|
||||
|
||||
ParticleContext particleContext = new ParticleContext
|
||||
{
|
||||
Timer = timer
|
||||
};
|
||||
|
||||
for (int i = 0; i < Amount; i++)
|
||||
{
|
||||
particleContext.Speed = particleStructs[i].Speed;
|
||||
instances[i].ModelMatrix = CreateMatrix(particleStructs[i],
|
||||
MovementCalculation(particleStructs[i].Direction, particleContext));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -74,30 +97,11 @@ namespace SM.Base.Drawing.Particles
|
|||
CreateParticles();
|
||||
}
|
||||
|
||||
public bool UpdateActive { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Update(UpdateContext context)
|
||||
{
|
||||
if (!timer.Running) return;
|
||||
|
||||
ParticleContext particleContext = new ParticleContext()
|
||||
{
|
||||
Timer = timer,
|
||||
};
|
||||
|
||||
for (int i = 0; i < Amount; i++)
|
||||
{
|
||||
particleContext.Speed = particleStructs[i].Speed;
|
||||
instances[i].ModelMatrix = CreateMatrix(particleStructs[i], MovementCalculation(particleStructs[i].Direction, particleContext));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
if (!timer.Active) return;
|
||||
|
||||
|
||||
base.DrawContext(ref context);
|
||||
|
||||
context.Instances = instances;
|
||||
|
|
@ -124,7 +128,7 @@ namespace SM.Base.Drawing.Particles
|
|||
/// Creates a particle.
|
||||
/// </summary>
|
||||
protected abstract ParticleStruct<TDirection> CreateObject(int index);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Generates the desired matrix for drawing.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
using OpenTK;
|
||||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Drawing.Particles
|
||||
{
|
||||
|
|
@ -10,10 +14,17 @@ namespace SM.Base.Drawing.Particles
|
|||
/// <summary>
|
||||
/// Default movement for 2D.
|
||||
/// </summary>
|
||||
public static Vector2 Default2D(Vector2 direction, ParticleContext context) => direction * (context.Timer.Elapsed * context.Speed);
|
||||
public static Vector2 Default2D(Vector2 direction, ParticleContext context)
|
||||
{
|
||||
return direction * (context.Timer.Elapsed * context.Speed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default movement for 3D.
|
||||
/// </summary>
|
||||
public static Vector3 Default3D(Vector3 direction, ParticleContext context) => direction * (context.Timer.Elapsed * context.Speed);
|
||||
public static Vector3 Default3D(Vector3 direction, ParticleContext context)
|
||||
{
|
||||
return direction * (context.Timer.Elapsed * context.Speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
using OpenTK;
|
||||
using SM.Base.Types;
|
||||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Drawing.Particles
|
||||
{
|
||||
|
|
@ -13,10 +16,12 @@ namespace SM.Base.Drawing.Particles
|
|||
/// A direction, that the particle should travel.
|
||||
/// </summary>
|
||||
public TDirection Direction;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix to store rotation and scale.
|
||||
/// </summary>
|
||||
public Matrix4 Matrix;
|
||||
|
||||
/// <summary>
|
||||
/// Speeeeeeeeeed
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,26 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom dictionary, with a few useful methods.
|
||||
/// </summary>
|
||||
public class ShaderArguments : Dictionary<string, object>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the stored value or the default value if the name doesn't exist.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
/// <returns></returns>
|
||||
public TType Get<TType>(string name, TType defaultValue = default)
|
||||
{
|
||||
return ContainsKey(name) ? (TType)this[name] : defaultValue;
|
||||
return ContainsKey(name) ? (TType) this[name] : defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,8 +32,6 @@ namespace SM.Base.Drawing.Text
|
|||
/// </summary>
|
||||
public float FontSize = 12;
|
||||
|
||||
public float Spacing = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The font style.
|
||||
/// <para>Default: <see cref="System.Drawing.FontStyle.Regular" /></para>
|
||||
|
|
@ -45,6 +43,11 @@ namespace SM.Base.Drawing.Text
|
|||
/// </summary>
|
||||
public Dictionary<char, CharParameter> Positions = new Dictionary<char, CharParameter>();
|
||||
|
||||
/// <summary>
|
||||
/// Allows a font wide spacing option.
|
||||
/// </summary>
|
||||
public float Spacing = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a font from a font family from the specified path.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base;
|
||||
using SM.Base.Windows;
|
||||
using SM.Base.Window;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -27,33 +26,34 @@ namespace SM.Base.Drawing.Text
|
|||
/// </summary>
|
||||
protected string _text;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the text object.
|
||||
/// </summary>
|
||||
public float Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height of the text object.
|
||||
/// </summary>
|
||||
public float Height;
|
||||
|
||||
/// <summary>
|
||||
/// The spacing between numbers.
|
||||
/// <para>Default: 1</para>
|
||||
/// </summary>
|
||||
public float Spacing = 1;
|
||||
|
||||
public float ActualSpacing => Spacing * Font.Spacing;
|
||||
|
||||
public float Width;
|
||||
public float Height;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a text object with a font.
|
||||
/// Calculates the actual spacing for the object.
|
||||
/// </summary>
|
||||
/// <param name="font">The font.</param>
|
||||
protected TextDrawingBasis(Font font)
|
||||
{
|
||||
Material.Texture = font;
|
||||
Material.Blending = true;
|
||||
}
|
||||
public float ActualSpacing => Spacing * Font.Spacing;
|
||||
|
||||
/// <summary>
|
||||
/// The font.
|
||||
/// </summary>
|
||||
public Font Font
|
||||
{
|
||||
get => (Font) Material.Texture;
|
||||
get => (Font)Material.Texture;
|
||||
set
|
||||
{
|
||||
Material.Texture = value;
|
||||
|
|
@ -83,6 +83,16 @@ namespace SM.Base.Drawing.Text
|
|||
set => Material.Tint = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a text object with a font.
|
||||
/// </summary>
|
||||
/// <param name="font">The font.</param>
|
||||
protected TextDrawingBasis(Font font)
|
||||
{
|
||||
Material.Texture = font;
|
||||
Material.Blending = true;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
|
|
@ -137,7 +147,8 @@ namespace SM.Base.Drawing.Text
|
|||
_instances[i] = new Instance
|
||||
{
|
||||
ModelMatrix = matrix,
|
||||
TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(parameter.NormalizedX, 0), new Vector2(parameter.NormalizedWidth, 1), 0),
|
||||
TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(parameter.NormalizedX, 0),
|
||||
new Vector2(parameter.NormalizedWidth, 1), 0)
|
||||
};
|
||||
|
||||
x += parameter.Width * ActualSpacing;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,46 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
using SM.Base.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores transformations for the textures.
|
||||
/// </summary>
|
||||
public class TextureTransformation
|
||||
{
|
||||
/// <summary>
|
||||
/// The offset from the origin.
|
||||
/// </summary>
|
||||
public CVector2 Offset = new CVector2(0);
|
||||
public CVector2 Scale = new CVector2(1);
|
||||
/// <summary>
|
||||
/// The rotation of the texture.
|
||||
/// </summary>
|
||||
public CVector1 Rotation = new CVector1(0);
|
||||
/// <summary>
|
||||
/// The scale of the texture.
|
||||
/// </summary>
|
||||
public CVector2 Scale = new CVector2(1);
|
||||
|
||||
/// <summary>
|
||||
/// Get the texture matrix.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Matrix3 GetMatrix()
|
||||
{
|
||||
return CalculateMatrix(Offset, Scale, Rotation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates a texture matrix.
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="scale"></param>
|
||||
/// <param name="rotation"></param>
|
||||
/// <returns></returns>
|
||||
public static Matrix3 CalculateMatrix(Vector2 offset, Vector2 scale, float rotation)
|
||||
{
|
||||
float radians = MathHelper.DegreesToRadians(rotation);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue