You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The system that translates the mouse's position to a location in aspect2d in order to interact with DirectGUI objects is not coupled with ShowBase.cam2d and its transformation.
As a result, modifying the camera or its lens node leads to a visually inverse transformation of the mouse position for detecting interactions with DirectGUI object.
E.g. if we create a DirectButton and leave it centered on aspect2d, then displace the camera with cam2d.set_pos(-.5,0,0), the button will not react with the mouse over its model. The user has to place the mouse on the center of the window, where the button would be without the camera's displacement, for the button to react.
Similar effects are observed when scaling or rotating the camera, or when modifying the lenses film size or film offset.
Here is an example file illustrating the effect, with additional interactions provided as commented code: REPORT_cam2d_collision.zip
The text was updated successfully, but these errors were encountered:
Hmm, this is a little trickier than I thought at first, because PGui (the GUI system underlying DirectGUI) relies on each item having a known position on screen. If we have to take the camera position into account, we can no longer know the position on screen for an item since the same GUI might be rendered by any number of cameras. So, when an item receives a mouse event, it has no way of knowing which camera. Worse than that, the camera may be associated with any number of (possibly overlapping) display regions on screen, so that's yet another way in which the mouse position can be misaligned with the position of the rendered button.
I think the only way of fixing this properly is to restructure Panda's code such that the mouse watcher is aware of the display regions on the window, and can therefore translate the mouse position appropriately based on the camera rendering to a region. Unfortunately, the input and rendering systems in Panda are separate components and not integrated to this degree. That said, we've been doing a lot of thinking lately about how we want to restructure Panda's windowing system, and such a change would fit in well with those plans.
For what it's worth, instead of moving the camera, moving a parent node of the GUI itself should still work fine.
@rdb Yea, I thought it'd probably be a harder thing to change than it seems.
If it's any reassurance, the reasons why I brought this up as a problem was mainly a matter of convenience; modifying the camera would have been a faster way to solve some issues with DirectGUI objects than modifying each of them instead. So, nothing unsolvable, just a bit more work.
The system that translates the mouse's position to a location in
aspect2d
in order to interact with DirectGUI objects is not coupled withShowBase.cam2d
and its transformation.As a result, modifying the camera or its lens node leads to a visually inverse transformation of the mouse position for detecting interactions with DirectGUI object.
E.g. if we create a DirectButton and leave it centered on
aspect2d
, then displace the camera withcam2d.set_pos(-.5,0,0)
, the button will not react with the mouse over its model. The user has to place the mouse on the center of the window, where the button would be without the camera's displacement, for the button to react.Similar effects are observed when scaling or rotating the camera, or when modifying the lenses film size or film offset.
Here is an example file illustrating the effect, with additional interactions provided as commented code:
REPORT_cam2d_collision.zip
The text was updated successfully, but these errors were encountered: