Detecting hovering over objects

Hi! I’m beginning the exciting adventure of using Panda3D with C++, and I would have 2 questions:

  1. How can I detect on which object, and on which coordinates over the visible face of that object, is the mouse currently hovering?
    I’ve seen that in the Chessboard sample some sort of geometrical reasoning was carried out, but in that case there was just a plane and a very regular setting (e.g. equally sized squares and a fixed camera).

  2. Where can I retrieve some documentation about input and event handling with Panda and C++?

Any help is very appreciated!

  1. There are lots of examples of “picking” in the manual and the forums, though most of these are illustrated in Python. Basically there are two approaches: (a) use the collision system to detect what objects are intersecting with the ray corresponding to the mouse’s position over the window, or (b) pre-construct a series of onscreen regions for the objects you are interested in (using MouseWatcherRegion) and use the MouseWatcher class to detect which regions the mouse is over.

The solution (a) seems to be more popular here, as it’s a little simpler to set up and easier to understand.

  1. Most of this is handled by the “data graph”, which is unfortunately poorly documented. There are a few posts in which I’ve described it at a high level, though. The key nodes are things like the MouseAndKeyboard, the Trackball, and the MouseWatcher and ButtonThrower, all of which inherit from DataNode. Try searching the forums for these concepts.

David

I realized I was just missing the right vocabulary to find what I was looking for!
Thanks!