MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Unproject

Method Unproject

Source/Engine/Core/Math/Vector3.cs:1451–1461  ·  view source on GitHub ↗

Projects a 3D vector from screen space into object space. The vector to project. The X position of the viewport. The Y position of the viewport. The width of the viewport. The height of the viewport. The minimum depth of the v

(ref Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, ref Matrix worldViewProjection, out Vector3 result)

Source from the content-addressed store, hash-verified

1449 /// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
1450 /// <param name="result">When the method completes, contains the vector in object space.</param>
1451 public static void Unproject(ref Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, ref Matrix worldViewProjection, out Vector3 result)
1452 {
1453 Matrix.Invert(ref worldViewProjection, out var matrix);
1454 var v = new Vector3
1455 {
1456 X = (vector.X - x) / width * 2.0f - 1.0f,
1457 Y = -((vector.Y - y) / height * 2.0f - 1.0f),
1458 Z = (vector.Z - minZ) / (maxZ - minZ)
1459 };
1460 TransformCoordinate(ref v, ref matrix, out result);
1461 }
1462
1463 /// <summary>
1464 /// Projects a 3D vector from screen space into object space.

Callers

nothing calls this directly

Calls 1

InvertMethod · 0.45

Tested by

no test coverage detected