Class Projector
java.lang.Object
lol.trq.helios.math.Projector
Projects 3D points to screen coordinates, as
gluProject does, without allocating.
Capture the matrices where the 3D scene is drawn (in a world render hook, where Minecraft's matrices are
camera-relative), then project points during GUI drawing. Results are in drawing units with the origin at the top
left: framebuffer pixels times pixel, which is 1 / guiScale on a GUI screen.
// world render hook:
projector.capture(helios.gl(), 1f / scaledResolution.getScaleFactor());
// GUI draw:
float[] box = new float[4];
if (projector.projectBox(minX, minY, minZ, maxX, maxY, maxZ, box)) {
batch.outline(box[0], box[1], box[2] - box[0], box[3] - box[1], 0, 1, Paint.solid(0xFFFF4040));
}
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a projector with identity matrices and an empty viewport. -
Method Summary
Modifier and TypeMethodDescriptionCaptures the host's current model-view and projection matrices and the viewport.booleanproject(double x, double y, double z, float[] out) Projects a point.booleanprojectBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float[] out) Projects an axis-aligned box and returns its screen bounds: the 2D box for ESP.set(float[] modelView, float[] projection, int[] viewport, float pixel) Sets the matrices and viewport directly.
-
Constructor Details
-
Projector
public Projector()Creates a projector with identity matrices and an empty viewport.
-
-
Method Details
-
capture
-
set
Sets the matrices and viewport directly.- Parameters:
modelView- the model-view matrix, column-major; copiedprojection- the projection matrix, column-major; copiedviewport-x, y, width, heightin framebuffer pixels; copiedpixel- one framebuffer pixel in output units- Returns:
- this projector
-
project
public boolean project(double x, double y, double z, float[] out) Projects a point.- Parameters:
x- x in the captured model spacey- yz- zout- receives screen x, screen y (drawing units, top-left origin) and depth (0 near, 1 far)- Returns:
- false when the point is behind the camera, leaving
outunspecified
-
projectBox
public boolean projectBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float[] out) Projects an axis-aligned box and returns its screen bounds: the 2D box for ESP.- Parameters:
minX- box min xminY- box min yminZ- box min zmaxX- box max xmaxY- box max ymaxZ- box max zout- receives left, top, right, bottom in drawing units- Returns:
- false when no corner is in front of the camera within the depth range
-