How can I get the mouse position (and where z hits the camera plane), inside the transformation.
So I need this before the popMatrix().
void setup() {
size(600, 600, P3D);
}
public void draw() {
background(0);
translate(width/2, height/2, -100);
pushMatrix();
float rot_y = map(mouseX, 0, width, 0, TWO_PI);
rotateY(rot_y);
int dim = min(width, height) / 2;
noFill();
stroke(255);
box(dim);
// now what is the mouseX, mouseY position (and z, where it hits the near plane of the camera)
// with the current transformation?
// float x = ???;
// float y = ???;
// float z = ???;
popMatrix();
}
I tried things with getting the matrix and inverting it and multiplying the mouse coordinates with it, but no luck.