Find what ViewPort your cursor is currently in

Is there a way to find out what viewport your cursor is in if you have multiple viewport visible?

The mouse cursor? or a 3d cursor that is a scene object?



For the mouse cursor, you can grab your viewports and get their dimensions, then get the mouse coordinates and intersect them to see what one(s) it is in. Remember that viewports can overlap.



For a 3d object you can get the frustum of the camera and intersect the 3d-spatial cursor object with it.

FrustumIntersect result = camera.contains(boundingVolumnOf3dCursor)



Do that for each viewport.

How would I go about getting the dimensions of the viewport?



I can have a different number of viewports (ex. 1, 2 ,3 or 4) and I am assigning a ChaseCamera to each Camera of each ViewPort.



I am looking for a way to toggle the mouse triggers to the camera in which my mouse is currently in the corresponding ViewPort.

List viewports = renderManager.getMainViews();

for each viewport

// get the coordinates

viewport.getCamera().getViewPortBottom(), getViewPortTop()…

// check min/max for intersection with mouse