Reimplermented CVectors (except CVector4)
This commit is contained in:
parent
e88d972ecc
commit
1551af28cc
7 changed files with 56 additions and 321 deletions
|
|
@ -75,10 +75,9 @@
|
|||
<Compile Include="Time\Interval.cs" />
|
||||
<Compile Include="Time\Stopwatch.cs" />
|
||||
<Compile Include="Time\Timer.cs" />
|
||||
<Compile Include="Types\CVector.cs" />
|
||||
<Compile Include="Types\CVector1.cs" />
|
||||
<Compile Include="Types\CVector2.cs" />
|
||||
<Compile Include="Types\CVector3.cs" />
|
||||
<Compile Include="Types\CVector4.cs" />
|
||||
<Compile Include="Utility\Assembly.cs" />
|
||||
<Compile Include="Utility\Deltatime.cs" />
|
||||
<Compile Include="Utility\Randomize.cs" />
|
||||
|
|
|
|||
|
|
@ -1,162 +0,0 @@
|
|||
#region usings
|
||||
|
||||
using System.Diagnostics;
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a base vector-class
|
||||
/// </summary>
|
||||
public abstract class CVector
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a vector by setting every component to the same value.
|
||||
/// </summary>
|
||||
protected CVector(float uniform) : this(uniform, uniform, uniform, uniform)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector by setting values for each component.
|
||||
/// </summary>
|
||||
protected CVector(float x, float y, float z, float w)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Z = z;
|
||||
_W = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The X-component.
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
protected float _X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Y-component
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
protected float _Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Z-component.
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
protected float _Z { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The W-component.
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
protected float _W { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a <see cref="CVector" /> to a <see cref="OpenTK.Vector2" />
|
||||
/// </summary>
|
||||
public static implicit operator Vector2(CVector v) => new Vector2(v._X, v._Y);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a <see cref="CVector" /> to a <see cref="OpenTK.Vector3" />
|
||||
/// </summary>
|
||||
public static implicit operator Vector3(CVector v) => new Vector3(v._X, v._Y, v._Z);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a <see cref="CVector" /> to a <see cref="OpenTK.Vector4" />
|
||||
/// </summary>
|
||||
public static implicit operator Vector4(CVector v) => new Vector4(v._X, v._Y, v._Z, v._W);
|
||||
|
||||
#region Set
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X and Y-component.
|
||||
/// </summary>
|
||||
protected void Set(float x, float y)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X and Y-component from a <see cref="OpenTK.Vector2" />
|
||||
/// </summary>
|
||||
protected void Set(Vector2 vector)
|
||||
{
|
||||
Set(vector.X, vector.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y and Z-component.
|
||||
/// </summary>
|
||||
protected void Set(float x, float y, float z)
|
||||
{
|
||||
Set(x, y);
|
||||
_Z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y and Z-component from a <see cref="OpenTK.Vector3" />.
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
protected void Set(Vector3 vector)
|
||||
{
|
||||
Set(vector.X, vector.Y, vector.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y, Z and W-component.
|
||||
/// </summary>
|
||||
protected void Set(float x, float y, float z, float w)
|
||||
{
|
||||
Set(x, y, z);
|
||||
_W = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y, Z and W-component from a <see cref="OpenTK.Vector4" />.
|
||||
/// </summary>
|
||||
protected void Set(Vector4 vector)
|
||||
{
|
||||
Set(vector.X, vector.Y, vector.Z, vector.W);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="OpenTK.Vector2" /> to the X and Y-component.
|
||||
/// </summary>
|
||||
protected void Add(Vector2 vector)
|
||||
{
|
||||
_X += vector.X;
|
||||
_Y += vector.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="OpenTK.Vector3" /> to the X, Y and Z-component.
|
||||
/// </summary>
|
||||
protected void Add(Vector3 vector)
|
||||
{
|
||||
_X += vector.X;
|
||||
_Y += vector.Y;
|
||||
_Z += vector.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="OpenTK.Vector4" /> to the X, Y, Z and W-component.
|
||||
/// </summary>
|
||||
protected void Add(Vector4 vector)
|
||||
{
|
||||
_X += vector.X;
|
||||
_Y += vector.Y;
|
||||
_Z += vector.Z;
|
||||
_W += vector.W;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
20
SMCode/SM.Base/Types/CVector1.cs
Normal file
20
SMCode/SM.Base/Types/CVector1.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
namespace SM.Base.Types
|
||||
{
|
||||
public class CVector1
|
||||
{
|
||||
public float X { get; set; }
|
||||
|
||||
public CVector1(float x)
|
||||
{
|
||||
X = x;
|
||||
}
|
||||
|
||||
public virtual void Set(float x)
|
||||
{
|
||||
X = x;
|
||||
}
|
||||
|
||||
public static implicit operator float(CVector1 vector1) => vector1.X;
|
||||
public static implicit operator CVector1(float f) => new CVector1(f);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +1,39 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
using OpenTK;
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a vector of two floats.
|
||||
/// </summary>
|
||||
public class CVector2 : CVector
|
||||
public class CVector2 : CVector1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public CVector2() : this(0)
|
||||
{
|
||||
}
|
||||
public float Y { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public CVector2(float uniform) : base(uniform)
|
||||
{
|
||||
Y = uniform;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CVector2(float x, float y) : base(x, y, default, default)
|
||||
public CVector2(float x, float y) : base(x)
|
||||
{
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected CVector2(float x, float y, float z, float w) : base(x, y, z, w)
|
||||
public virtual void Set(float uniform)
|
||||
{
|
||||
base.Set(uniform);
|
||||
Y = uniform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X-component
|
||||
/// </summary>
|
||||
public float X
|
||||
public void Set(Vector2 vector)
|
||||
{
|
||||
get => _X;
|
||||
set => _X = value;
|
||||
Set(vector.X, vector.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y-component
|
||||
/// </summary>
|
||||
public float Y
|
||||
public void Set(float x, float y)
|
||||
{
|
||||
get => _Y;
|
||||
set => _Y = value;
|
||||
base.Set(x);
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X and Y-component.
|
||||
/// </summary>
|
||||
public new void Set(float x, float y)
|
||||
{
|
||||
base.Set(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X and Y-component from a <see cref="OpenTK.Vector2" />
|
||||
/// </summary>
|
||||
public new void Set(Vector2 vector)
|
||||
{
|
||||
base.Set(vector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="OpenTK.Vector2" /> to the X and Y-component.
|
||||
/// </summary>
|
||||
public new void Add(Vector2 vector)
|
||||
{
|
||||
base.Add(vector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="OpenTK.Vector2"/> to <see cref="CVector2"/>
|
||||
/// </summary>
|
||||
public static implicit operator CVector2(Vector2 v) => new CVector2(v.X,v.Y);
|
||||
public static implicit operator Vector2(CVector2 vector2) => new Vector2(vector2.X, vector2.Y);
|
||||
public static implicit operator CVector2(Vector2 vector2) => new CVector2(vector2.X, vector2.Y);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +1,39 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
using OpenTK;
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Vector of three floats.
|
||||
/// </summary>
|
||||
public class CVector3 : CVector2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public float Z { get; set; }
|
||||
|
||||
public CVector3(float uniform) : base(uniform)
|
||||
{
|
||||
Z = uniform;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CVector3(float x, float y, float z) : base(x, y, z, default)
|
||||
public CVector3(float x, float y, float z) : base(x, y)
|
||||
{
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected CVector3(float x, float y, float z, float w) : base(x, y, z, w)
|
||||
public override void Set(float uniform)
|
||||
{
|
||||
base.Set(uniform);
|
||||
Z = uniform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Z-component
|
||||
/// </summary>
|
||||
public float Z
|
||||
public void Set(float x, float y, float z)
|
||||
{
|
||||
get => _Z;
|
||||
set => _Z = value;
|
||||
base.Set(x,y);
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y and Z-component.
|
||||
/// </summary>
|
||||
public new void Set(float x, float y, float z)
|
||||
public void Set(Vector3 vector)
|
||||
{
|
||||
base.Set(x, y, z);
|
||||
Set(vector.X, vector.Y, vector.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y and Z-component from a <see cref="OpenTK.Vector3" />.
|
||||
/// </summary>
|
||||
public new void Set(Vector3 vector)
|
||||
{
|
||||
base.Set(vector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="OpenTK.Vector3" /> to the X, Y and Z-component.
|
||||
/// </summary>
|
||||
public new void Add(Vector3 vector)
|
||||
{
|
||||
base.Add(vector);
|
||||
}
|
||||
public static implicit operator Vector3(CVector3 vector) => new Vector3(vector.X, vector.Y, vector.Z);
|
||||
public static implicit operator CVector3(Vector3 vector) => new CVector3(vector.X, vector.Y, vector.Z);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a vector of four floats.
|
||||
/// </summary>
|
||||
public class CVector4 : CVector3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public CVector4(float uniform) : base(uniform)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CVector4(float x, float y, float z, float w) : base(x, y, z, w)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// W-component
|
||||
/// </summary>
|
||||
public float W
|
||||
{
|
||||
get => _W;
|
||||
set => _W = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y, Z and W-component.
|
||||
/// </summary>
|
||||
public new void Set(float x, float y, float z, float w)
|
||||
{
|
||||
base.Set(x, y, z, w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the X, Y, Z and W-component from a <see cref="OpenTK.Vector4" />.
|
||||
/// </summary>
|
||||
public new void Set(Vector4 vector)
|
||||
{
|
||||
base.Set(vector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="OpenTK.Vector4" /> to the X, Y, Z and W-component.
|
||||
/// </summary>
|
||||
public new void Add(Vector4 vector)
|
||||
{
|
||||
base.Add(vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue