I meant the camera associated to that viewport. If the viewport is using only a portion of the screen, the problem is that inside that viewport (and that viewport having it own rootNode and, this one being rendered on the Gui-bucket), if you put something at 0,0, it will be shown at the bottom left corner but the cursor position given by lemur would be another value than 0,0 for that corner (relative to it visual screen position).
Lets say that we have the “visual” case:
0,1080 1920,1080
0,800 ._____.
| |
._____.
0,0 800,0 1920,0
Where the “square” is the viewport. If you have a display ofr 1920x1080, the viewport there, somehow because of the gui-bucket, is managing also it coords from 0x → 1920x, 0y → 1080y. However, the x and y being passed by the cursor are from 800x → 1920x, 800y → 1080y.
Doing the mentioned subtract on the inside-viewport-events I can get the values for it in the desired range (which I think is the default desire but I can be wrong). This doesn’t fix the other problem though, in where the event isn’t being fired when the spatial inside the viewport is clicked but in an offset, even if that offset is outside the viewport (it seems that has something to do with the rays and I think that has something to do with the same coord things).
EDIT: The piece of code to be changed to this offset problem maybe would be:
protected Ray getPickRay( RootEntry rootEntry, Vector2f cursor ) {
......
if( rootEntry.root instanceof Spatial && ((Spatial)rootEntry.root).getQueueBucket() == Bucket.Gui ) {
// Special case for Gui Bucket nodes since they are always in screen space
result = new Ray(new Vector3f(cursor.x, cursor.y, 1000), new Vector3f(0, 0, -1));
}
......
}
to:
protected Ray getPickRay( RootEntry rootEntry, Vector2f cursor ) {
......
if( rootEntry.root instanceof Spatial && ((Spatial)rootEntry.root).getQueueBucket() == Bucket.Gui ) {
// Special case for Gui Bucket nodes since they are always in screen space
result = new Ray(new Vector3f(cursor.x - Display.getWidth() * cam.getViewPortLeft(),
cursor.y - Display.getHeight() * cam.getViewPortTop(), 1000),
new Vector3f(0, 0, -1));
}
......