MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / project

Method project

src/main/java/field/linalg/Mat4.java:447–457  ·  view source on GitHub ↗

Project the given (x, y, z) position via the given view and projection matrices using the specified viewport and store the resulting window coordinates in winCoordsDest . This method transforms the given coordinates by projection view i

(double x, double y, double z, Mat4 projection, Mat4 view, IntBuffer viewport, Vec4 winCoordsDest)

Source from the content-addressed store, hash-verified

445 * @param winCoordsDest will hold the projected window coordinates
446 */
447 public static void project(double x, double y, double z, Mat4 projection, Mat4 view, IntBuffer viewport, Vec4 winCoordsDest) {
448 winCoordsDest.set(x, y, z, 1.0);
449 Vec4 v = view.transform(winCoordsDest);
450 v = projection.transform(v);
451 int pos = viewport.position();
452 v.div(v.w);
453 v.x = (v.x * 0.5 + 0.5) * viewport.get(pos + 2) + viewport.get(pos);
454 v.y = (v.y * 0.5 + 0.5) * viewport.get(pos + 3) + viewport.get(pos + 1);
455 v.z = (1.0 + v.z) * 0.5;
456 winCoordsDest.set(v);
457 }
458
459
460

Callers 1

Calls 6

divMethod · 0.95
setMethod · 0.65
transformMethod · 0.65
positionMethod · 0.65
getMethod · 0.65
divMethod · 0.45

Tested by

no test coverage detected