Basic rendering with camera controls are functional.

This commit is contained in:
2020-06-23 20:07:12 -05:00
parent 1c4ca6c97b
commit 6a19d1f5c7
58 changed files with 8386 additions and 2224 deletions

View 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;
}
}
}

View File

@@ -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;
}
}
}

View 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
};
}
}
}

View 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;
}
}
}