Basic rendering with camera controls are functional.
This commit is contained in:
20
src/SlatedGameToolkit.Framework/Utilities/ColorUtils.cs
Normal file
20
src/SlatedGameToolkit.Framework/Utilities/ColorUtils.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Utilities
|
||||
{
|
||||
public static class ColorUtils
|
||||
{
|
||||
public static float RedAsFloat(this Color color) {
|
||||
return (float) color.R / byte.MaxValue;
|
||||
}
|
||||
public static float GreenAsFloat(this Color color) {
|
||||
return (float) color.G / byte.MaxValue;
|
||||
}
|
||||
public static float BlueAsFloat(this Color color) {
|
||||
return (float) color.B / byte.MaxValue;
|
||||
}
|
||||
public static float AlphaAsFloat(this Color color) {
|
||||
return (float) color.A / byte.MaxValue;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Utilities
|
||||
{
|
||||
public static class EmbeddedResourceUtils
|
||||
{
|
||||
public static string ReadEmbeddedResourceText(string name) {
|
||||
string res;
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("SlatedGameToolkit.Framework.Resources.{0}", name)))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream)) {
|
||||
res = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static byte[] ReadEmbeddedResourceData(string name) {
|
||||
byte[] res;
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("SlatedGameToolkit.Framework.Resources.{0}", name)))
|
||||
{
|
||||
byte[] buffer = new byte[stream.Length];
|
||||
stream.Read(buffer, 0, buffer.Length);
|
||||
res = buffer;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
13
src/SlatedGameToolkit.Framework/Utilities/MatrixUtils.cs
Normal file
13
src/SlatedGameToolkit.Framework/Utilities/MatrixUtils.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Utilities
|
||||
{
|
||||
public static class MatrixUtils
|
||||
{
|
||||
public static float[] ToColumnMajorArray(this Matrix4x4 mat) {
|
||||
return new float[] {
|
||||
mat.M11, mat.M12, mat.M13, mat.M14, mat.M21, mat.M22, mat.M23, mat.M24, mat.M31, mat.M32, mat.M33, mat.M34, mat.M41, mat.M42, mat.M43, mat.M44
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
17
src/SlatedGameToolkit.Framework/Utilities/VectorUtils.cs
Normal file
17
src/SlatedGameToolkit.Framework/Utilities/VectorUtils.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Utilities
|
||||
{
|
||||
public static class VectorUtils
|
||||
{
|
||||
public static Vector3 NormalizeSafe(this Vector3 value, Vector3 alternate) {
|
||||
float l = value.Length();
|
||||
if (l == 0) {
|
||||
return alternate;
|
||||
}
|
||||
value /= l;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user