2022-02-23 05:14:32 +00:00
|
|
|
|
namespace MoonWorks
|
2021-01-20 03:33:27 +00:00
|
|
|
|
{
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public static class Conversions
|
|
|
|
|
{
|
|
|
|
|
public static byte BoolToByte(bool b)
|
|
|
|
|
{
|
|
|
|
|
return (byte) (b ? 1 : 0);
|
|
|
|
|
}
|
2021-01-22 22:41:34 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public static bool ByteToBool(byte b)
|
|
|
|
|
{
|
2022-02-25 05:34:36 +00:00
|
|
|
|
return b != 0;
|
2022-02-23 05:14:32 +00:00
|
|
|
|
}
|
2022-03-02 21:57:30 +00:00
|
|
|
|
|
|
|
|
|
public static Graphics.VertexElementFormat TypeToVertexElementFormat(System.Type type)
|
|
|
|
|
{
|
2022-03-17 21:42:30 +00:00
|
|
|
|
if (type == typeof(uint))
|
|
|
|
|
{
|
|
|
|
|
return Graphics.VertexElementFormat.UInt;
|
|
|
|
|
}
|
2022-03-02 21:57:30 +00:00
|
|
|
|
if (type == typeof(float))
|
|
|
|
|
{
|
2022-03-17 21:42:30 +00:00
|
|
|
|
return Graphics.VertexElementFormat.Float;
|
2022-03-02 21:57:30 +00:00
|
|
|
|
}
|
2022-05-11 17:34:09 +00:00
|
|
|
|
else if (type == typeof(Math.Float.Vector2))
|
2022-03-02 21:57:30 +00:00
|
|
|
|
{
|
|
|
|
|
return Graphics.VertexElementFormat.Vector2;
|
|
|
|
|
}
|
2022-05-11 17:34:09 +00:00
|
|
|
|
else if (type == typeof(Math.Float.Vector3))
|
2022-03-02 21:57:30 +00:00
|
|
|
|
{
|
|
|
|
|
return Graphics.VertexElementFormat.Vector3;
|
|
|
|
|
}
|
2022-05-11 17:34:09 +00:00
|
|
|
|
else if (type == typeof(Math.Float.Vector4))
|
2022-03-02 21:57:30 +00:00
|
|
|
|
{
|
|
|
|
|
return Graphics.VertexElementFormat.Vector4;
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeof(Graphics.Color))
|
|
|
|
|
{
|
|
|
|
|
return Graphics.VertexElementFormat.Color;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new System.ArgumentException(
|
|
|
|
|
"Cannot automatically convert this type to a VertexElementFormat!"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-23 05:14:32 +00:00
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
}
|