mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
- remove SlimDX namespace
This commit is contained in:
parent
8f15e8d5e7
commit
c665bfca86
35 changed files with 780 additions and 293 deletions
|
@ -220,7 +220,12 @@
|
|||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SlimDX.cs" />
|
||||
<Compile Include="Rendering\Color3.cs" />
|
||||
<Compile Include="Rendering\Color4.cs" />
|
||||
<Compile Include="Rendering\Matrix.cs" />
|
||||
<Compile Include="Rendering\Vector2.cs" />
|
||||
<Compile Include="Rendering\Vector3.cs" />
|
||||
<Compile Include="Rendering\Vector4.cs" />
|
||||
<Compile Include="Windows\ThingStatisticsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -21,7 +21,7 @@ using System.ComponentModel;
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
using CodeImp.DoomBuilder.ZDoom;
|
||||
using SlimDX;
|
||||
using Matrix = SlimDX.Matrix;
|
||||
using Matrix = CodeImp.DoomBuilder.Rendering.Matrix;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -26,7 +26,6 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
namespace CodeImp.DoomBuilder.GZBuilder.Data
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
using System.Collections.Generic;
|
||||
using CodeImp.DoomBuilder.GZBuilder.MD3;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ using CodeImp.DoomBuilder.IO;
|
|||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -26,7 +26,6 @@ using CodeImp.DoomBuilder.Map;
|
|||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.VisualModes;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using System.Collections.ObjectModel;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
64
Source/Core/Rendering/Color3.cs
Normal file
64
Source/Core/Rendering/Color3.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public struct Color3
|
||||
{
|
||||
public Color3(float r, float g, float b)
|
||||
{
|
||||
Red = r;
|
||||
Green = g;
|
||||
Blue = b;
|
||||
}
|
||||
|
||||
public Color3(Vector3 c)
|
||||
{
|
||||
Red = c.X;
|
||||
Green = c.Y;
|
||||
Blue = c.Z;
|
||||
}
|
||||
|
||||
public Color3(System.Drawing.Color c)
|
||||
{
|
||||
Red = c.R / 255.0f;
|
||||
Green = c.G / 255.0f;
|
||||
Blue = c.B / 255.0f;
|
||||
}
|
||||
|
||||
public float Red;
|
||||
public float Green;
|
||||
public float Blue;
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Color3)
|
||||
{
|
||||
Color3 v = (Color3)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Red.GetHashCode() + Green.GetHashCode() + Blue.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Color3 left, Color3 right)
|
||||
{
|
||||
return left.Red == right.Red && left.Green == right.Green && left.Blue == right.Blue;
|
||||
}
|
||||
|
||||
public static bool operator !=(Color3 left, Color3 right)
|
||||
{
|
||||
return left.Red != right.Red || left.Green != right.Green || left.Blue != right.Blue;
|
||||
}
|
||||
}
|
||||
}
|
106
Source/Core/Rendering/Color4.cs
Normal file
106
Source/Core/Rendering/Color4.cs
Normal file
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public struct Color4
|
||||
{
|
||||
public Color4(int argb)
|
||||
{
|
||||
uint v = (uint)argb;
|
||||
Alpha = ((v >> 24) & 0xff) / 255.0f;
|
||||
Red = ((v >> 16) & 0xff) / 255.0f;
|
||||
Green = ((v >> 8) & 0xff) / 255.0f;
|
||||
Blue = (v & 0xff) / 255.0f;
|
||||
}
|
||||
|
||||
public Color4(float r, float g, float b, float a)
|
||||
{
|
||||
Red = r;
|
||||
Green = g;
|
||||
Blue = b;
|
||||
Alpha = a;
|
||||
}
|
||||
|
||||
public Color4(Vector4 c)
|
||||
{
|
||||
Red = c.X;
|
||||
Green = c.Y;
|
||||
Blue = c.Z;
|
||||
Alpha = c.W;
|
||||
}
|
||||
|
||||
public Color4(System.Drawing.Color c)
|
||||
{
|
||||
Red = c.R / 255.0f;
|
||||
Green = c.G / 255.0f;
|
||||
Blue = c.B / 255.0f;
|
||||
Alpha = c.A / 255.0f;
|
||||
}
|
||||
|
||||
public float Red;
|
||||
public float Green;
|
||||
public float Blue;
|
||||
public float Alpha;
|
||||
|
||||
public int ToArgb()
|
||||
{
|
||||
uint r = (uint)Math.Max(Math.Min(Red * 255.0f, 255.0f), 0.0f);
|
||||
uint g = (uint)Math.Max(Math.Min(Green * 255.0f, 255.0f), 0.0f);
|
||||
uint b = (uint)Math.Max(Math.Min(Blue * 255.0f, 255.0f), 0.0f);
|
||||
uint a = (uint)Math.Max(Math.Min(Alpha * 255.0f, 255.0f), 0.0f);
|
||||
return (int)((a << 24) | (r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
||||
public System.Drawing.Color ToColor()
|
||||
{
|
||||
return System.Drawing.Color.FromArgb(ToArgb());
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Color4)
|
||||
{
|
||||
Color4 v = (Color4)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color4 operator +(Color4 left, Color4 right)
|
||||
{
|
||||
return new Color4(left.Red + right.Red, left.Green + right.Green, left.Blue + right.Blue, left.Alpha + right.Alpha);
|
||||
}
|
||||
|
||||
public static Color4 operator -(Color4 left, Color4 right)
|
||||
{
|
||||
return new Color4(left.Red - right.Red, left.Green - right.Green, left.Blue - right.Blue, left.Alpha - right.Alpha);
|
||||
}
|
||||
|
||||
public static Color4 operator -(Color4 v)
|
||||
{
|
||||
return new Color4(-v.Red, -v.Green, -v.Blue, -v.Alpha);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Red.GetHashCode() + Green.GetHashCode() + Blue.GetHashCode() + Alpha.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Color4 left, Color4 right)
|
||||
{
|
||||
return left.Red == right.Red && left.Green == right.Green && left.Blue == right.Blue && left.Alpha == right.Alpha;
|
||||
}
|
||||
|
||||
public static bool operator !=(Color4 left, Color4 right)
|
||||
{
|
||||
return left.Red != right.Red || left.Green != right.Green || left.Blue != right.Blue || left.Alpha != right.Alpha;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Drawing;
|
||||
using SlimDX;
|
||||
using Configuration = CodeImp.DoomBuilder.IO.Configuration;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -22,7 +22,6 @@ using System.Drawing;
|
|||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
278
Source/Core/Rendering/Matrix.cs
Normal file
278
Source/Core/Rendering/Matrix.cs
Normal file
|
@ -0,0 +1,278 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public struct Matrix
|
||||
{
|
||||
public float M11, M12, M13, M14;
|
||||
public float M21, M22, M23, M24;
|
||||
public float M31, M32, M33, M34;
|
||||
public float M41, M42, M43, M44;
|
||||
|
||||
public static Matrix Null
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix m = new Matrix();
|
||||
m.M11 = 0.0f;
|
||||
m.M12 = 0.0f;
|
||||
m.M13 = 0.0f;
|
||||
m.M14 = 0.0f;
|
||||
m.M21 = 0.0f;
|
||||
m.M22 = 0.0f;
|
||||
m.M23 = 0.0f;
|
||||
m.M24 = 0.0f;
|
||||
m.M31 = 0.0f;
|
||||
m.M32 = 0.0f;
|
||||
m.M33 = 0.0f;
|
||||
m.M34 = 0.0f;
|
||||
m.M41 = 0.0f;
|
||||
m.M42 = 0.0f;
|
||||
m.M43 = 0.0f;
|
||||
m.M44 = 0.0f;
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix Identity
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix m = Null;
|
||||
m.M11 = 1.0f;
|
||||
m.M22 = 1.0f;
|
||||
m.M33 = 1.0f;
|
||||
m.M44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix Translation(Vector3 v)
|
||||
{
|
||||
Matrix m = Identity;
|
||||
m.M41 = v.X;
|
||||
m.M42 = v.Y;
|
||||
m.M43 = v.Z;
|
||||
return m;
|
||||
}
|
||||
|
||||
public static Matrix Translation(float x, float y, float z)
|
||||
{
|
||||
Matrix m = Identity;
|
||||
m.M41 = x;
|
||||
m.M42 = y;
|
||||
m.M43 = z;
|
||||
return m;
|
||||
}
|
||||
|
||||
public static Matrix RotationX(float angle)
|
||||
{
|
||||
float cos = (float)Math.Cos(angle);
|
||||
float sin = (float)Math.Sin(angle);
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = 1.0f;
|
||||
result.M22 = cos;
|
||||
result.M23 = sin;
|
||||
result.M32 = -sin;
|
||||
result.M33 = cos;
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix RotationY(float angle)
|
||||
{
|
||||
float cos = (float)Math.Cos(angle);
|
||||
float sin = (float)Math.Sin(angle);
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = cos;
|
||||
result.M13 = -sin;
|
||||
result.M22 = 1.0f;
|
||||
result.M31 = sin;
|
||||
result.M33 = cos;
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix RotationZ(float angle)
|
||||
{
|
||||
float cos = (float)Math.Cos(angle);
|
||||
float sin = (float)Math.Sin(angle);
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = cos;
|
||||
result.M12 = sin;
|
||||
result.M21 = -sin;
|
||||
result.M22 = cos;
|
||||
result.M33 = 1.0f;
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix Scaling(float x, float y, float z)
|
||||
{
|
||||
Matrix result = Null;
|
||||
result.M11 = x;
|
||||
result.M22 = y;
|
||||
result.M33 = z;
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix Scaling(Vector3 v)
|
||||
{
|
||||
Matrix result = Null;
|
||||
result.M11 = v.X;
|
||||
result.M22 = v.Y;
|
||||
result.M33 = v.Z;
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix LookAtLH(Vector3 eye, Vector3 target, Vector3 up)
|
||||
{
|
||||
Vector3 zaxis = Vector3.Normalize(target - eye);
|
||||
Vector3 xaxis = Vector3.Cross(up, zaxis);
|
||||
Vector3 yaxis = Vector3.Cross(zaxis, xaxis);
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = xaxis.X;
|
||||
result.M12 = yaxis.X;
|
||||
result.M13 = zaxis.X;
|
||||
result.M21 = xaxis.Y;
|
||||
result.M22 = yaxis.Y;
|
||||
result.M23 = zaxis.Y;
|
||||
result.M31 = xaxis.Z;
|
||||
result.M32 = yaxis.Z;
|
||||
result.M33 = zaxis.Z;
|
||||
result.M41 = -Vector3.Dot(xaxis, eye);
|
||||
result.M42 = -Vector3.Dot(yaxis, eye);
|
||||
result.M43 = -Vector3.Dot(zaxis, eye);
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix LookAtRH(Vector3 eye, Vector3 target, Vector3 up)
|
||||
{
|
||||
Vector3 zaxis = Vector3.Normalize(target - eye);
|
||||
Vector3 xaxis = Vector3.Cross(up, zaxis);
|
||||
Vector3 yaxis = Vector3.Cross(zaxis, xaxis);
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = xaxis.X;
|
||||
result.M12 = yaxis.X;
|
||||
result.M13 = zaxis.X;
|
||||
result.M21 = xaxis.Y;
|
||||
result.M22 = yaxis.Y;
|
||||
result.M23 = zaxis.Y;
|
||||
result.M31 = xaxis.Z;
|
||||
result.M32 = yaxis.Z;
|
||||
result.M33 = zaxis.Z;
|
||||
result.M41 = Vector3.Dot(xaxis, eye);
|
||||
result.M42 = Vector3.Dot(yaxis, eye);
|
||||
result.M43 = Vector3.Dot(zaxis, eye);
|
||||
result.M44 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix PerspectiveFovLH(float fov, float aspect, float znear, float zfar)
|
||||
{
|
||||
float yScale = (float)(1.0 / Math.Tan(fov * 0.5f));
|
||||
float xScale = yScale / aspect;
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = xScale;
|
||||
result.M22 = yScale;
|
||||
result.M33 = zfar / (znear - zfar);
|
||||
result.M43 = -znear * zfar / (znear - zfar);
|
||||
result.M34 = 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix PerspectiveFovRH(float fov, float aspect, float znear, float zfar)
|
||||
{
|
||||
float yScale = (float)(1.0 / Math.Tan(fov * 0.5f));
|
||||
float xScale = yScale / aspect;
|
||||
|
||||
Matrix result = Null;
|
||||
result.M11 = xScale;
|
||||
result.M22 = yScale;
|
||||
result.M33 = zfar / (znear - zfar);
|
||||
result.M43 = znear * zfar / (znear - zfar);
|
||||
result.M34 = -1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix Multiply(Matrix left, Matrix right)
|
||||
{
|
||||
Matrix result = new Matrix();
|
||||
result.M11 = (left.M11 * right.M11) + (left.M12 * right.M21) + (left.M13 * right.M31) + (left.M14 * right.M41);
|
||||
result.M12 = (left.M11 * right.M12) + (left.M12 * right.M22) + (left.M13 * right.M32) + (left.M14 * right.M42);
|
||||
result.M13 = (left.M11 * right.M13) + (left.M12 * right.M23) + (left.M13 * right.M33) + (left.M14 * right.M43);
|
||||
result.M14 = (left.M11 * right.M14) + (left.M12 * right.M24) + (left.M13 * right.M34) + (left.M14 * right.M44);
|
||||
result.M21 = (left.M21 * right.M11) + (left.M22 * right.M21) + (left.M23 * right.M31) + (left.M24 * right.M41);
|
||||
result.M22 = (left.M21 * right.M12) + (left.M22 * right.M22) + (left.M23 * right.M32) + (left.M24 * right.M42);
|
||||
result.M23 = (left.M21 * right.M13) + (left.M22 * right.M23) + (left.M23 * right.M33) + (left.M24 * right.M43);
|
||||
result.M24 = (left.M21 * right.M14) + (left.M22 * right.M24) + (left.M23 * right.M34) + (left.M24 * right.M44);
|
||||
result.M31 = (left.M31 * right.M11) + (left.M32 * right.M21) + (left.M33 * right.M31) + (left.M34 * right.M41);
|
||||
result.M32 = (left.M31 * right.M12) + (left.M32 * right.M22) + (left.M33 * right.M32) + (left.M34 * right.M42);
|
||||
result.M33 = (left.M31 * right.M13) + (left.M32 * right.M23) + (left.M33 * right.M33) + (left.M34 * right.M43);
|
||||
result.M34 = (left.M31 * right.M14) + (left.M32 * right.M24) + (left.M33 * right.M34) + (left.M34 * right.M44);
|
||||
result.M41 = (left.M41 * right.M11) + (left.M42 * right.M21) + (left.M43 * right.M31) + (left.M44 * right.M41);
|
||||
result.M42 = (left.M41 * right.M12) + (left.M42 * right.M22) + (left.M43 * right.M32) + (left.M44 * right.M42);
|
||||
result.M43 = (left.M41 * right.M13) + (left.M42 * right.M23) + (left.M43 * right.M33) + (left.M44 * right.M43);
|
||||
result.M44 = (left.M41 * right.M14) + (left.M42 * right.M24) + (left.M43 * right.M34) + (left.M44 * right.M44);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Matrix operator *(Matrix a, Matrix b)
|
||||
{
|
||||
return Matrix.Multiply(a, b);
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Matrix)
|
||||
{
|
||||
Matrix v = (Matrix)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return
|
||||
M11.GetHashCode() + M12.GetHashCode() + M13.GetHashCode() + M14.GetHashCode() +
|
||||
M21.GetHashCode() + M22.GetHashCode() + M23.GetHashCode() + M24.GetHashCode() +
|
||||
M31.GetHashCode() + M32.GetHashCode() + M33.GetHashCode() + M34.GetHashCode() +
|
||||
M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + M44.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Matrix left, Matrix right)
|
||||
{
|
||||
return
|
||||
left.M11 == right.M11 && left.M12 == right.M12 && left.M13 == right.M13 && left.M14 == right.M14 &&
|
||||
left.M21 == right.M21 && left.M22 == right.M22 && left.M23 == right.M23 && left.M24 == right.M24 &&
|
||||
left.M31 == right.M31 && left.M32 == right.M32 && left.M33 == right.M33 && left.M34 == right.M34 &&
|
||||
left.M41 == right.M41 && left.M42 == right.M42 && left.M43 == right.M43 && left.M44 == right.M44;
|
||||
}
|
||||
|
||||
public static bool operator !=(Matrix left, Matrix right)
|
||||
{
|
||||
return
|
||||
left.M11 != right.M11 || left.M12 != right.M12 || left.M13 != right.M13 || left.M14 != right.M14 ||
|
||||
left.M21 != right.M21 || left.M22 != right.M22 || left.M23 != right.M23 || left.M24 != right.M24 ||
|
||||
left.M31 != right.M31 || left.M32 != right.M32 || left.M33 != right.M33 || left.M34 != right.M34 ||
|
||||
left.M41 != right.M41 || left.M42 != right.M42 || left.M43 != right.M43 || left.M44 != right.M44;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Net;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
|
|
|
@ -25,7 +25,6 @@ using CodeImp.DoomBuilder.GZBuilder.Data;
|
|||
using CodeImp.DoomBuilder.GZBuilder.MD3;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.VisualModes;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.GZBuilder;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -22,7 +22,6 @@ using System.Drawing;
|
|||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ using System.Drawing.Imaging;
|
|||
using System.Drawing.Text;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using Font = System.Drawing.Font;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
82
Source/Core/Rendering/Vector2.cs
Normal file
82
Source/Core/Rendering/Vector2.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public struct Vector2
|
||||
{
|
||||
public Vector2(float v)
|
||||
{
|
||||
X = v;
|
||||
Y = v;
|
||||
}
|
||||
|
||||
public Vector2(float x, float y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public float X;
|
||||
public float Y;
|
||||
|
||||
public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount)
|
||||
{
|
||||
float squared = amount * amount;
|
||||
float cubed = amount * squared;
|
||||
float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;
|
||||
float part2 = (-2.0f * cubed) + (3.0f * squared);
|
||||
float part3 = (cubed - (2.0f * squared)) + amount;
|
||||
float part4 = cubed - squared;
|
||||
return new Vector2(
|
||||
(((value1.X * part1) + (value2.X * part2)) + (tangent1.X * part3)) + (tangent2.X * part4),
|
||||
(((value1.Y * part1) + (value2.Y * part2)) + (tangent1.Y * part3)) + (tangent2.Y * part4));
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Vector2)
|
||||
{
|
||||
Vector2 v = (Vector2)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() + Y.GetHashCode();
|
||||
}
|
||||
|
||||
public static Vector2 operator +(Vector2 left, Vector2 right)
|
||||
{
|
||||
return new Vector2(left.X + right.X, left.Y + right.Y);
|
||||
}
|
||||
|
||||
public static Vector2 operator -(Vector2 left, Vector2 right)
|
||||
{
|
||||
return new Vector2(left.X - right.X, left.Y - right.Y);
|
||||
}
|
||||
|
||||
public static Vector2 operator -(Vector2 v)
|
||||
{
|
||||
return new Vector2(-v.X, -v.Y);
|
||||
}
|
||||
|
||||
public static bool operator ==(Vector2 left, Vector2 right)
|
||||
{
|
||||
return left.X == right.X && left.Y == right.Y;
|
||||
}
|
||||
|
||||
public static bool operator !=(Vector2 left, Vector2 right)
|
||||
{
|
||||
return left.X != right.X || left.Y != right.Y;
|
||||
}
|
||||
}
|
||||
}
|
144
Source/Core/Rendering/Vector3.cs
Normal file
144
Source/Core/Rendering/Vector3.cs
Normal file
|
@ -0,0 +1,144 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public struct Vector3
|
||||
{
|
||||
public Vector3(float v)
|
||||
{
|
||||
X = v;
|
||||
Y = v;
|
||||
Z = v;
|
||||
}
|
||||
|
||||
public Vector3(Vector2 xy, float z)
|
||||
{
|
||||
X = xy.X;
|
||||
Y = xy.Y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public Vector3(float x, float y, float z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
|
||||
public static Vector4 Transform(Vector3 vector, Matrix transform)
|
||||
{
|
||||
return new Vector4(
|
||||
(((vector.X * transform.M11) + (vector.Y * transform.M21)) + (vector.Z * transform.M31)) + transform.M41,
|
||||
(((vector.X * transform.M12) + (vector.Y * transform.M22)) + (vector.Z * transform.M32)) + transform.M42,
|
||||
(((vector.X * transform.M13) + (vector.Y * transform.M23)) + (vector.Z * transform.M33)) + transform.M43,
|
||||
(((vector.X * transform.M14) + (vector.Y * transform.M24)) + (vector.Z * transform.M34)) + transform.M44);
|
||||
}
|
||||
|
||||
public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
|
||||
{
|
||||
float squared = amount * amount;
|
||||
float cubed = amount * squared;
|
||||
float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;
|
||||
float part2 = (-2.0f * cubed) + (3.0f * squared);
|
||||
float part3 = (cubed - (2.0f * squared)) + amount;
|
||||
float part4 = cubed - squared;
|
||||
return new Vector3(
|
||||
(((value1.X * part1) + (value2.X * part2)) + (tangent1.X * part3)) + (tangent2.X * part4),
|
||||
(((value1.Y * part1) + (value2.Y * part2)) + (tangent1.Y * part3)) + (tangent2.Y * part4),
|
||||
(((value1.Z * part1) + (value2.Z * part2)) + (tangent1.Z * part3)) + (tangent2.Z * part4));
|
||||
}
|
||||
|
||||
public static float DistanceSquared(Vector3 a, Vector3 b)
|
||||
{
|
||||
Vector3 c = b - a;
|
||||
return Vector3.Dot(c, c);
|
||||
}
|
||||
|
||||
public static float Dot(Vector3 a, Vector3 b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y + a.Z * b.Z;
|
||||
}
|
||||
|
||||
public static Vector3 Cross(Vector3 left, Vector3 right)
|
||||
{
|
||||
Vector3 result = new Vector3();
|
||||
result.X = left.Y * right.Z - left.Z * right.Y;
|
||||
result.Y = left.Z * right.X - left.X * right.Z;
|
||||
result.Z = left.X * right.Y - left.Y * right.X;
|
||||
return result;
|
||||
}
|
||||
|
||||
public float Length()
|
||||
{
|
||||
return (float)Math.Sqrt(Vector3.Dot(this, this));
|
||||
}
|
||||
|
||||
public static Vector3 Normalize(Vector3 v)
|
||||
{
|
||||
v.Normalize();
|
||||
return v;
|
||||
}
|
||||
|
||||
public void Normalize()
|
||||
{
|
||||
float len = Length();
|
||||
if (len > 0.0f)
|
||||
{
|
||||
X /= len;
|
||||
Y /= len;
|
||||
Z /= len;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Vector3)
|
||||
{
|
||||
Vector3 v = (Vector3)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode();
|
||||
}
|
||||
|
||||
public static Vector3 operator +(Vector3 left, Vector3 right)
|
||||
{
|
||||
return new Vector3(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
|
||||
}
|
||||
|
||||
public static Vector3 operator -(Vector3 left, Vector3 right)
|
||||
{
|
||||
return new Vector3(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
|
||||
}
|
||||
|
||||
public static Vector3 operator -(Vector3 v)
|
||||
{
|
||||
return new Vector3(-v.X, -v.Y, -v.Z);
|
||||
}
|
||||
|
||||
public static bool operator ==(Vector3 left, Vector3 right)
|
||||
{
|
||||
return left.X == right.X && left.Y == right.Y && left.Z == right.Z;
|
||||
}
|
||||
|
||||
public static bool operator !=(Vector3 left, Vector3 right)
|
||||
{
|
||||
return left.X != right.X || left.Y != right.Y || left.Z != right.Z;
|
||||
}
|
||||
}
|
||||
}
|
91
Source/Core/Rendering/Vector4.cs
Normal file
91
Source/Core/Rendering/Vector4.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public struct Vector4
|
||||
{
|
||||
public Vector4(float v)
|
||||
{
|
||||
X = v;
|
||||
Y = v;
|
||||
Z = v;
|
||||
W = v;
|
||||
}
|
||||
|
||||
public Vector4(Vector2 xy, float z, float w)
|
||||
{
|
||||
X = xy.X;
|
||||
Y = xy.Y;
|
||||
Z = z;
|
||||
W = w;
|
||||
}
|
||||
|
||||
public Vector4(Vector3 xyz, float w)
|
||||
{
|
||||
X = xyz.X;
|
||||
Y = xyz.Y;
|
||||
Z = xyz.Z;
|
||||
W = w;
|
||||
}
|
||||
|
||||
public Vector4(float x, float y, float z, float w)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
W = w;
|
||||
}
|
||||
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public float W;
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Vector4)
|
||||
{
|
||||
Vector4 v = (Vector4)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector4 operator +(Vector4 left, Vector4 right)
|
||||
{
|
||||
return new Vector4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
|
||||
}
|
||||
|
||||
public static Vector4 operator -(Vector4 left, Vector4 right)
|
||||
{
|
||||
return new Vector4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
|
||||
}
|
||||
|
||||
public static Vector4 operator -(Vector4 v)
|
||||
{
|
||||
return new Vector4(-v.X, -v.Y, -v.Z, -v.W);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Vector4 left, Vector4 right)
|
||||
{
|
||||
return left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W;
|
||||
}
|
||||
|
||||
public static bool operator !=(Vector4 left, Vector4 right)
|
||||
{
|
||||
return left.X != right.X || left.Y != right.Y || left.Z != right.Z || left.W != right.W;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -1,264 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace SlimDX
|
||||
{
|
||||
#region Matrix, vector, color
|
||||
public struct Matrix
|
||||
{
|
||||
public float M11, M12, M13, M14;
|
||||
public float M21, M22, M23, M24;
|
||||
public float M31, M32, M33, M34;
|
||||
public float M41, M42, M43, M44;
|
||||
|
||||
public static Matrix Null { get; }
|
||||
public static Matrix Identity { get { Matrix m = Null; m.M11 = 1.0f; m.M22 = 1.0f; m.M33 = 1.0f; m.M44 = 1.0f; return m; } }
|
||||
public static Matrix Translation(Vector3 v) { Matrix m = Null; m.M11 = v.X; m.M22 = v.Y; m.M33 = v.Z; m.M44 = 1.0f; return m; }
|
||||
public static Matrix Translation(float x, float y, float z) { Matrix m = Null; m.M11 = x; m.M22 = y; m.M33 = z; m.M44 = 1.0f; return m; }
|
||||
public static Matrix RotationX(float angle) { throw new NotImplementedException(); }
|
||||
public static Matrix RotationY(float angle) { throw new NotImplementedException(); }
|
||||
public static Matrix RotationZ(float angle) { throw new NotImplementedException(); }
|
||||
public static Matrix Scaling(float x, float y, float z) { throw new NotImplementedException(); }
|
||||
public static Matrix Scaling(Vector3 v) { throw new NotImplementedException(); }
|
||||
public static Matrix LookAtLH(Vector3 eye, Vector3 target, Vector3 up) { throw new NotImplementedException(); }
|
||||
public static Matrix LookAtRH(Vector3 eye, Vector3 target, Vector3 up) { throw new NotImplementedException(); }
|
||||
public static Matrix PerspectiveFovLH(float fov, float aspect, float znear, float zfar) { throw new NotImplementedException(); }
|
||||
public static Matrix PerspectiveFovRH(float fov, float aspect, float znear, float zfar) { throw new NotImplementedException(); }
|
||||
public static Matrix Multiply(Matrix a, Matrix b) { throw new NotImplementedException(); }
|
||||
|
||||
public static Matrix operator *(Matrix a, Matrix b) { throw new NotImplementedException(); }
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Matrix)
|
||||
{
|
||||
Matrix v = (Matrix)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return
|
||||
M11.GetHashCode() + M12.GetHashCode() + M13.GetHashCode() + M14.GetHashCode() +
|
||||
M21.GetHashCode() + M22.GetHashCode() + M23.GetHashCode() + M24.GetHashCode() +
|
||||
M31.GetHashCode() + M32.GetHashCode() + M33.GetHashCode() + M34.GetHashCode() +
|
||||
M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + M44.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Matrix left, Matrix right)
|
||||
{
|
||||
return
|
||||
left.M11 == right.M11 && left.M12 == right.M12 && left.M13 == right.M13 && left.M14 == right.M14 &&
|
||||
left.M21 == right.M21 && left.M22 == right.M22 && left.M23 == right.M23 && left.M24 == right.M24 &&
|
||||
left.M31 == right.M31 && left.M32 == right.M32 && left.M33 == right.M33 && left.M34 == right.M34 &&
|
||||
left.M41 == right.M41 && left.M42 == right.M42 && left.M43 == right.M43 && left.M44 == right.M44;
|
||||
}
|
||||
|
||||
public static bool operator !=(Matrix left, Matrix right)
|
||||
{
|
||||
return
|
||||
left.M11 != right.M11 || left.M12 != right.M12 || left.M13 != right.M13 || left.M14 != right.M14 ||
|
||||
left.M21 != right.M21 || left.M22 != right.M22 || left.M23 != right.M23 || left.M24 != right.M24 ||
|
||||
left.M31 != right.M31 || left.M32 != right.M32 || left.M33 != right.M33 || left.M34 != right.M34 ||
|
||||
left.M41 != right.M41 || left.M42 != right.M42 || left.M43 != right.M43 || left.M44 != right.M44;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Color3
|
||||
{
|
||||
public Color3(float r, float g, float b) { Red = r; Green = g; Blue = b; }
|
||||
public Color3(Vector3 c) { Red = c.X; Green = c.Y; Blue = c.Z; }
|
||||
public Color3(System.Drawing.Color c) { Red = c.R / 255.0f; Green = c.G / 255.0f; Blue = c.B / 255.0f; }
|
||||
public float Red, Green, Blue;
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Color3)
|
||||
{
|
||||
Color3 v = (Color3)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return Red.GetHashCode() + Green.GetHashCode() + Blue.GetHashCode(); }
|
||||
public static bool operator ==(Color3 left, Color3 right) { return left.Red == right.Red && left.Green == right.Green && left.Blue == right.Blue; }
|
||||
public static bool operator !=(Color3 left, Color3 right) { return left.Red != right.Red || left.Green != right.Green || left.Blue != right.Blue; }
|
||||
}
|
||||
|
||||
public struct Color4
|
||||
{
|
||||
public Color4(int argb)
|
||||
{
|
||||
uint v = (uint)argb;
|
||||
Alpha = ((v >> 24) & 0xff) / 255.0f;
|
||||
Red = ((v >> 16) & 0xff) / 255.0f;
|
||||
Green = ((v >> 8) & 0xff) / 255.0f;
|
||||
Blue = (v & 0xff) / 255.0f;
|
||||
}
|
||||
|
||||
public Color4(float r, float g, float b, float a) { Red = r; Green = g; Blue = b; Alpha = a; }
|
||||
public Color4(Vector4 c) { Red = c.X; Green = c.Y; Blue = c.Z; Alpha = c.W; }
|
||||
public Color4(System.Drawing.Color c) { Red = c.R / 255.0f; Green = c.G / 255.0f; Blue = c.B / 255.0f; Alpha = c.A / 255.0f; }
|
||||
public float Red, Green, Blue, Alpha;
|
||||
|
||||
public int ToArgb()
|
||||
{
|
||||
uint r = (uint)Math.Max(Math.Min(Red * 255.0f, 255.0f), 0.0f);
|
||||
uint g = (uint)Math.Max(Math.Min(Green * 255.0f, 255.0f), 0.0f);
|
||||
uint b = (uint)Math.Max(Math.Min(Blue * 255.0f, 255.0f), 0.0f);
|
||||
uint a = (uint)Math.Max(Math.Min(Alpha * 255.0f, 255.0f), 0.0f);
|
||||
return (int)((a << 24) | (r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
||||
public System.Drawing.Color ToColor()
|
||||
{
|
||||
return System.Drawing.Color.FromArgb(ToArgb());
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Color4)
|
||||
{
|
||||
Color4 v = (Color4)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color4 operator +(Color4 left, Color4 right) { return new Color4(left.Red + right.Red, left.Green + right.Green, left.Blue + right.Blue, left.Alpha + right.Alpha); }
|
||||
public static Color4 operator -(Color4 left, Color4 right) { return new Color4(left.Red - right.Red, left.Green - right.Green, left.Blue - right.Blue, left.Alpha - right.Alpha); }
|
||||
public static Color4 operator -(Color4 v) { return new Color4(-v.Red, -v.Green, -v.Blue, -v.Alpha); }
|
||||
|
||||
public override int GetHashCode() { return Red.GetHashCode() + Green.GetHashCode() + Blue.GetHashCode() + Alpha.GetHashCode(); }
|
||||
public static bool operator ==(Color4 left, Color4 right) { return left.Red == right.Red && left.Green == right.Green && left.Blue == right.Blue && left.Alpha == right.Alpha; }
|
||||
public static bool operator !=(Color4 left, Color4 right) { return left.Red != right.Red || left.Green != right.Green || left.Blue != right.Blue || left.Alpha != right.Alpha; }
|
||||
}
|
||||
|
||||
public struct Vector2
|
||||
{
|
||||
public Vector2(float v) { X = v; Y = v; }
|
||||
public Vector2(float x, float y) { X = x; Y = y; }
|
||||
public float X;
|
||||
public float Y;
|
||||
|
||||
public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount) { throw new NotImplementedException(); }
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Vector2)
|
||||
{
|
||||
Vector2 v = (Vector2)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return X.GetHashCode() + Y.GetHashCode(); }
|
||||
|
||||
public static Vector2 operator +(Vector2 left, Vector2 right) { return new Vector2(left.X + right.X, left.Y + right.Y); }
|
||||
public static Vector2 operator -(Vector2 left, Vector2 right) { return new Vector2(left.X - right.X, left.Y - right.Y); }
|
||||
public static Vector2 operator -(Vector2 v) { return new Vector2(-v.X, -v.Y); }
|
||||
|
||||
public static bool operator ==(Vector2 left, Vector2 right) { return left.X == right.X && left.Y == right.Y; }
|
||||
public static bool operator !=(Vector2 left, Vector2 right) { return left.X != right.X || left.Y != right.Y; }
|
||||
}
|
||||
|
||||
public struct Vector3
|
||||
{
|
||||
public Vector3(float v) { X = v; Y = v; Z = v; }
|
||||
public Vector3(Vector2 xy, float z) { X = xy.X; Y = xy.Y; Z = z; }
|
||||
public Vector3(float x, float y, float z) { X = x; Y = y; Z = z; }
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
|
||||
public static Vector4 Transform(Vector3 v, Matrix m) { throw new NotImplementedException(); }
|
||||
public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount) { throw new NotImplementedException(); }
|
||||
|
||||
public static float DistanceSquared(Vector3 a, Vector3 b) { Vector3 c = b - a; return Vector3.Dot(c, c); }
|
||||
public static float Dot(Vector3 a, Vector3 b) { return a.X * b.X + a.Y * b.Y + a.Z * b.Z; }
|
||||
|
||||
public float Length() { return (float)Math.Sqrt(Vector3.Dot(this, this)); }
|
||||
|
||||
public void Normalize()
|
||||
{
|
||||
float len = Length();
|
||||
if (len > 0.0f)
|
||||
{
|
||||
X /= len;
|
||||
Y /= len;
|
||||
Z /= len;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Vector3)
|
||||
{
|
||||
Vector3 v = (Vector3)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode(); }
|
||||
|
||||
public static Vector3 operator +(Vector3 left, Vector3 right) { return new Vector3(left.X + right.X, left.Y + right.Y, left.Z + right.Z); }
|
||||
public static Vector3 operator -(Vector3 left, Vector3 right) { return new Vector3(left.X - right.X, left.Y - right.Y, left.Z - right.Z); }
|
||||
public static Vector3 operator -(Vector3 v) { return new Vector3(-v.X, -v.Y, -v.Z); }
|
||||
|
||||
public static bool operator ==(Vector3 left, Vector3 right) { return left.X == right.X && left.Y == right.Y && left.Z == right.Z; }
|
||||
public static bool operator !=(Vector3 left, Vector3 right) { return left.X != right.X || left.Y != right.Y || left.Z != right.Z; }
|
||||
}
|
||||
|
||||
public struct Vector4
|
||||
{
|
||||
public Vector4(float v) { X = v; Y = v; Z = v; W = v; }
|
||||
public Vector4(Vector2 xy, float z, float w) { X = xy.X; Y = xy.Y; Z = z; W = w; }
|
||||
public Vector4(Vector3 xyz, float w) { X = xyz.X; Y = xyz.Y; Z = xyz.Z; W = w; }
|
||||
public Vector4(float x, float y, float z, float w) { X = x; Y = y; Z = z; W = w; }
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public float W;
|
||||
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o is Vector4)
|
||||
{
|
||||
Vector4 v = (Vector4)o;
|
||||
return this == v;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector4 operator +(Vector4 left, Vector4 right) { return new Vector4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); }
|
||||
public static Vector4 operator -(Vector4 left, Vector4 right) { return new Vector4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); }
|
||||
public static Vector4 operator -(Vector4 v) { return new Vector4(-v.X, -v.Y, -v.Z, -v.W); }
|
||||
|
||||
public override int GetHashCode() { return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode(); }
|
||||
public static bool operator ==(Vector4 left, Vector4 right) { return left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; }
|
||||
public static bool operator !=(Vector4 left, Vector4 right) { return left.X != right.X || left.Y != right.Y || left.Z != right.Z || left.W != right.W; }
|
||||
}
|
||||
#endregion
|
||||
}
|
|
@ -23,7 +23,6 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -24,7 +24,6 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX;
|
||||
using Plane = CodeImp.DoomBuilder.Geometry.Plane;
|
||||
using CodeImp.DoomBuilder.GZBuilder;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
namespace CodeImp.DoomBuilder.VisualModes
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ using CodeImp.DoomBuilder.Config;
|
|||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using CodeImp.DoomBuilder.Config;
|
|||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
Loading…
Reference in a new issue