Hello!
Usually, for zooming and panning I’m using gicentreUtils library which is great but still has an issue - small additional zooming is added at the end of the corresponding mouse gesture (SHIFT+mouseDrag). Therefore, in the new project which requires CAD-related features, I decided to use Proscene library.
Zooming&panning works great, but now I can’t figure out how to obtain information about the coordinates of the mouse pointer relative to the scene’s plane.
I would greatly appreciate if anyone could suggest an easy way of converting mouseX
and mouseY
values of the mouse pointer on the screen into X
and Y
values on the given frame (scene’s grid plane in particular).
The following is a non-working attempt to obtain the desired values:
import remixlab.proscene.*;
import remixlab.dandelion.geom.Vec;
Scene scene;
InteractiveFrame frame;
void setup() {
size(800, 600, P3D);
scene = new Scene(this);
frame = new InteractiveFrame(scene);
}
void draw() {
background(230);
}
void mousePressed() {
// prints mouse pointer coordinates relative to SCREEN frame
PVector screenPoint = new PVector( mouseX, mouseY );
println( "screen:" + screenPoint );
// prints mouse pointer coordinates relative to SCENE frame
Vec worldPoint = scene.projectedCoordinatesOf( Scene.toVec( screenPoint ) );
println( "world:" + worldPoint.toString() );
}