smrendererv3/SMCode/SM2D/Drawing/DrawParticles.cs
Michel Fedde beb9c19081 28.10.2020
SM.Core:
+ Particle System
+ scriptable system for scripts

~ Moved Texts- and Particles-namespace to SM.Base.Drawing
~ Changed how you tell the stopwatch to pause. (From method to property)
~ Fixed Randomize.GetFloat(min, max)
~ Now automaticly adds the DrawingBase.Transformation to DrawContext.ModelMatrix. No need to change DrawContext.Instances[0], anymore.

SM.OGL:
+ "one-file-shader"-support

SM2D:
+ DrawParticles (Control for Texture and Color not there yet)

~ Changed coordnate system to upper-right as (1,1)
~ Changed default shader to "one-file-shader"
2020-10-28 18:19:15 +01:00

34 lines
No EOL
1.1 KiB
C#

using System;
using OpenTK;
using SM.Base.Drawing.Particles;
using SM.Utility;
using SM2D.Scene;
using SM2D.Types;
namespace SM2D.Drawing
{
public class DrawParticles : ParticleDrawingBasis<Transformation, Vector2>, I2DShowItem
{
public int ZIndex { get; set; }
public override Func<Vector2, ParticleContext, Vector2> MovementCalculation { get; set; } = ParticleMovement.Default2D;
public DrawParticles(TimeSpan duration) : base(duration)
{
}
protected override ParticleStruct<Vector2> CreateObject(int index)
{
return new ParticleStruct<Vector2>()
{
Matrix = Matrix4.CreateScale(1),
Direction = new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1)),
Speed = Randomize.GetFloat(MaxSpeed)
};
}
protected override Matrix4 CreateMatrix(ParticleStruct<Vector2> Struct, Vector2 direction)
{
return Struct.Matrix * Matrix4.CreateTranslation(direction.X, direction.Y, 0);
}
}
}