2 public struct Viewport : IEquatable<Viewport> {
19 public Viewport(
int x,
int y,
int width,
int height,
float minDepth = 0f,
float maxDepth = 1f) {
30 &&
Width == other.Width
44 public override string ToString() => $
"{X}, {Y}, {Width}, {Height}, {MinDepth}, {MaxDepth}";
48 result /= source.X * worldViewProjection.M14
49 + source.Y * worldViewProjection.M24
50 + source.Z * worldViewProjection.M34
51 + worldViewProjection.
M44;
52 result.X = (result.X + 1f) * 0.5f *
Width +
X;
53 result.Y = (0f - result.Y + 1f) * 0.5f *
Height +
Y;
62 source.X = (source.X -
X) /
Width * 2f - 1f;
63 source.Y = 0f - ((source.Y -
Y) /
Height * 2f - 1f);
65 return Vector3.
Transform(source, m) / (source.X * m.M14 + source.Y * m.M24 + source.Z * m.M34 + m.
M44);
override string ToString()
Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
bool Equals(Viewport other)
static bool operator!=(Viewport v1, Viewport v2)
static bool operator==(Viewport v1, Viewport v2)
override bool Equals(object obj)
Viewport(int x, int y, int width, int height, float minDepth=0f, float maxDepth=1f)
Vector3 Unproject(Vector3 source, Matrix worldViewProjection)
override int GetHashCode()
Vector3 Project(Vector3 source, Matrix worldViewProjection)
static Matrix Invert(Matrix m)
static Vector3 Transform(Vector3 v, Matrix m)