19.09.2020

+ Vector-classes
+ Added Background
~ Changed OpenTK.Vector2 to SM.Base.Types.Vector2
This commit is contained in:
Michel Fedde 2020-09-19 19:04:19 +02:00
parent a603ecc417
commit acccf5f0e7
22 changed files with 295 additions and 27 deletions

View file

@ -0,0 +1,52 @@
using System;
using OpenTK;
namespace SM.Base.Types
{
public abstract class Vector
{
private float _x = default;
private float _y = default;
private float _z = default;
private float _w = default;
protected float _X
{
get => _x;
set => _x = value;
}
protected float _Y
{
get => _y;
set => _y = value;
}
protected float _Z
{
get => _z;
set => _z = value;
}
protected float _W
{
get => _w;
set => _w = value;
}
protected Vector(float uniform) : this(uniform, uniform, uniform, uniform)
{ }
protected Vector(float x, float y, float z, float w)
{
_x = x;
_y = y;
_z = z;
_w = w;
}
public static implicit operator OpenTK.Vector2(Vector v) => new OpenTK.Vector2(v._x, v._y);
public static implicit operator OpenTK.Vector3(Vector v) => new OpenTK.Vector3(v._x, v._y, v._z);
public static implicit operator OpenTK.Vector4(Vector v) => new OpenTK.Vector4(v._x, v._y, v._z, v._w);
}
}

View file

@ -0,0 +1,29 @@
namespace SM.Base.Types
{
public class Vector2 : Vector
{
public float X
{
get => _X;
set => _X = value;
}
public float Y
{
get => _Y;
set => _Y = value;
}
public Vector2() : this(0)
{}
public Vector2(float uniform) : base(uniform)
{
}
public Vector2(float x, float y) : base(x,y, default, default) {}
protected Vector2(float x, float y, float z, float w) : base(x, y, z, w) {}
public static implicit operator Vector2(OpenTK.Vector2 v) => new Vector2(v.X, v.Y);
}
}

View file

@ -0,0 +1,23 @@
using System.Runtime.InteropServices;
namespace SM.Base.Types
{
public class Vector3 : Vector2
{
public float Z
{
get => _Z;
set => _Z = value;
}
public Vector3(float uniform) : base(uniform)
{ }
public Vector3(float x, float y, float z) : base(x, y, z, default)
{ }
protected Vector3(float x, float y, float z, float w) : base(x, y, z, w) { }
public static implicit operator Vector3(OpenTK.Vector3 v) => new Vector3(v.X, v.Y, v.Z);
}
}

View file

@ -0,0 +1,21 @@
namespace SM.Base.Types
{
public class Vector4 : Vector3
{
public float W
{
get => _W;
set => _W = value;
}
public Vector4(float uniform) : base(uniform)
{
}
public Vector4(float x, float y, float z, float w) : base(x, y, z, w)
{
}
public static implicit operator Vector4(OpenTK.Vector4 v) => new Vector4(v.X, v.Y, v.Z, v.W);
}
}