Added missing summeries #1
This commit is contained in:
parent
03d99ea28e
commit
8665b5b709
104 changed files with 1165 additions and 821 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue