Holidays 12.10. -> 25.10.2020
~ Moved code around in files. SM.Base: + PostProcessing-system + OnInitialization() for Scenes. + Shader-Extensions + Added option to not react while unfocused to the window. + Added Screenshots to the window. + Connected the log system to the SM.OGL-action system. ~ Replaced IShader with abstract MaterialShader. ~ When a log compression folder doesn't exist, it will create one. SM.OGL: + Added support for UniformArrays + Added ShaderPreProcessing + Added Shader Extensions. + Added Debug actions. + SM.OGL settings ~ Framebuffer Size is automaticly changed, when the window and scale is set. SM2D: + Added easy shader drawing.
This commit is contained in:
parent
2c00dbd31a
commit
03b3942732
102 changed files with 2683 additions and 1398 deletions
|
|
@ -1,43 +1,60 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains utility functions for handling with assemblies.
|
||||
/// Contains utility functions for handling with assemblies.
|
||||
/// </summary>
|
||||
public class AssemblyUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Read a file that is saved in a assembly
|
||||
/// Read a file that is saved in a assembly
|
||||
/// </summary>
|
||||
/// <param name="ass">The assembly that contains the file</param>
|
||||
/// <param name="path">The path to the file inside the assembly</param>
|
||||
/// <returns></returns>
|
||||
public static string ReadAssemblyFile(Assembly ass, string path) { return new StreamReader(GetAssemblyStream(ass, path)).ReadToEnd(); }
|
||||
public static string ReadAssemblyFile(Assembly ass, string path)
|
||||
{
|
||||
return new StreamReader(GetAssemblyStream(ass, path)).ReadToEnd();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a file that is saved in the calling assembly
|
||||
/// Read a file that is saved in the calling assembly
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the file inside the assembly</param>
|
||||
/// <returns></returns>
|
||||
public static string ReadAssemblyFile(string path) { return ReadAssemblyFile(Assembly.GetCallingAssembly(), path); }
|
||||
public static string ReadAssemblyFile(string path)
|
||||
{
|
||||
return ReadAssemblyFile(Assembly.GetCallingAssembly(), path);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a stream of a requested resource.
|
||||
/// Returns a stream of a requested resource.
|
||||
/// </summary>
|
||||
/// <param name="ass">The assembly the resource is in.</param>
|
||||
/// <param name="path">The path to the resource.</param>
|
||||
/// <returns>The stream</returns>
|
||||
public static Stream GetAssemblyStream(Assembly ass, string path) { return ass.GetManifestResourceStream(path) ?? throw new InvalidOperationException("Assembly couldn't find resource at path '" + path + "'."); }
|
||||
public static Stream GetAssemblyStream(Assembly ass, string path)
|
||||
{
|
||||
return ass.GetManifestResourceStream(path) ??
|
||||
throw new InvalidOperationException("Assembly couldn't find resource at path '" + path + "'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a stream of a requested resource in the calling assembly.
|
||||
/// Returns a stream of a requested resource in the calling assembly.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the resource</param>
|
||||
/// <returns>The stream</returns>
|
||||
public static Stream GetAssemblyStream(string path) { return GetAssemblyStream(Assembly.GetCallingAssembly(), path); }
|
||||
public static Stream GetAssemblyStream(string path)
|
||||
{
|
||||
return GetAssemblyStream(Assembly.GetCallingAssembly(), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +1,49 @@
|
|||
namespace SM.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// A assistant to control the delta time.
|
||||
/// A assistant to control the delta time.
|
||||
/// </summary>
|
||||
public class Deltatime
|
||||
{
|
||||
/// <summary>
|
||||
/// The current update delta time.
|
||||
/// </summary>
|
||||
public static float UpdateDelta { get; internal set; }
|
||||
/// <summary>
|
||||
/// The current render delta time.
|
||||
/// </summary>
|
||||
public static float RenderDelta { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, it uses <see cref="RenderDelta"/>, otherwise <see cref="UpdateDelta"/>.
|
||||
/// <para>Default: false</para>
|
||||
/// </summary>
|
||||
public bool UseRender;
|
||||
/// <summary>
|
||||
/// Scaling of the delta time.
|
||||
/// <para>Default: 1</para>
|
||||
/// Scaling of the delta time.
|
||||
/// <para>Default: 1</para>
|
||||
/// </summary>
|
||||
public float Scale;
|
||||
|
||||
/// <summary>
|
||||
/// The calculated delta time.
|
||||
/// If true, it uses <see cref="RenderDelta" />, otherwise <see cref="UpdateDelta" />.
|
||||
/// <para>Default: false</para>
|
||||
/// </summary>
|
||||
public float DeltaTime => (UseRender ? RenderDelta : UpdateDelta) * Scale;
|
||||
public bool UseRender;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a delta time assistant.
|
||||
/// Creates a delta time assistant.
|
||||
/// </summary>
|
||||
/// <param name="scale">The start scale for the delta time. Default: 1</param>
|
||||
/// <param name="useRender">If true, it uses <see cref="RenderDelta"/>, otherwise <see cref="UpdateDelta"/>. Default: false</param>
|
||||
public Deltatime(float scale = 1, bool useRender = false)
|
||||
/// <param name="useRender">
|
||||
/// If true, it uses <see cref="RenderDelta" />, otherwise <see cref="UpdateDelta" />. Default:
|
||||
/// false
|
||||
/// </param>
|
||||
public Deltatime(float scale = 1, bool useRender = false)
|
||||
{
|
||||
UseRender = useRender;
|
||||
Scale = scale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current update delta time.
|
||||
/// </summary>
|
||||
public static float UpdateDelta { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The current render delta time.
|
||||
/// </summary>
|
||||
public static float RenderDelta { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The calculated delta time.
|
||||
/// </summary>
|
||||
public float DeltaTime => (UseRender ? RenderDelta : UpdateDelta) * Scale;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +1,84 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// A global helper class for randomization.
|
||||
/// A global helper class for randomization.
|
||||
/// </summary>
|
||||
public class Randomize
|
||||
{
|
||||
/// <summary>
|
||||
/// The randomizer.
|
||||
/// The randomizer.
|
||||
/// </summary>
|
||||
public static Random Randomizer = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the seed for the randomizer.
|
||||
/// Sets the seed for the randomizer.
|
||||
/// </summary>
|
||||
/// <param name="seed">The specified seed.</param>
|
||||
public static void SetSeed(int seed) { Randomizer = new Random(seed); }
|
||||
public static void SetSeed(int seed)
|
||||
{
|
||||
Randomizer = new Random(seed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a double and checks if its under the tolerance.
|
||||
/// Generates a double and checks if its under the tolerance.
|
||||
/// </summary>
|
||||
public static bool GetBool(float tolerance) { return Randomizer.NextDouble() < tolerance; }
|
||||
public static bool GetBool(float tolerance)
|
||||
{
|
||||
return Randomizer.NextDouble() < tolerance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a integer.
|
||||
/// Generates a integer.
|
||||
/// </summary>
|
||||
public static int GetInt() { return Randomizer.Next(); }
|
||||
/// <summary>
|
||||
/// Generates a integer with a maximum.
|
||||
/// </summary>
|
||||
public static int GetInt(int max) { return Randomizer.Next(max); }
|
||||
/// <summary>
|
||||
/// Generates a integer with a minimum and maximum
|
||||
/// </summary>
|
||||
public static int GetInt(int min, int max) { return Randomizer.Next(min, max); }
|
||||
public static int GetInt()
|
||||
{
|
||||
return Randomizer.Next();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a float between 0 and 1.
|
||||
/// Generates a integer with a maximum.
|
||||
/// </summary>
|
||||
public static float GetFloat() { return (float)Randomizer.NextDouble(); }
|
||||
/// <summary>
|
||||
/// Generates a float between 0 and the specified maximum.
|
||||
/// </summary>
|
||||
public static float GetFloat(float max) { return (float)Randomizer.NextDouble() * max; }
|
||||
/// <summary>
|
||||
/// Generates a float between the specified minimum and the specified maximum.
|
||||
/// </summary>
|
||||
public static float GetFloat(float min, float max) { return (float)Randomizer.NextDouble() * max + min; }
|
||||
public static int GetInt(int max)
|
||||
{
|
||||
return Randomizer.Next(max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a integer with a minimum and maximum
|
||||
/// </summary>
|
||||
public static int GetInt(int min, int max)
|
||||
{
|
||||
return Randomizer.Next(min, max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a float between 0 and 1.
|
||||
/// </summary>
|
||||
public static float GetFloat()
|
||||
{
|
||||
return (float) Randomizer.NextDouble();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a float between 0 and the specified maximum.
|
||||
/// </summary>
|
||||
public static float GetFloat(float max)
|
||||
{
|
||||
return (float) Randomizer.NextDouble() * max;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a float between the specified minimum and the specified maximum.
|
||||
/// </summary>
|
||||
public static float GetFloat(float min, float max)
|
||||
{
|
||||
return (float) Randomizer.NextDouble() * max + min;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,24 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Utilitys for rotations
|
||||
/// Utilitys for rotations
|
||||
/// </summary>
|
||||
public class RotationUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Angle towards an coordinate.
|
||||
/// Angle towards an coordinate.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static float TurnTowards(Vector2 origin, Vector2 target)
|
||||
{
|
||||
return MathHelper.RadiansToDegrees((float)Math.Atan2(target.Y - origin.Y, target.X - origin.X));
|
||||
return MathHelper.RadiansToDegrees((float) Math.Atan2(target.Y - origin.Y, target.X - origin.X));
|
||||
}
|
||||
}
|
||||
}
|
||||
7
SMCode/SM.Base/Utility/ShaderUtility.cs
Normal file
7
SMCode/SM.Base/Utility/ShaderUtility.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace SM.Utility
|
||||
{
|
||||
public class ShaderUtility
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue