mouse click on Vsg::node #1391
-
Hello, I want to detect which Vsg ::node is clicked when I click on a specific Vsg::node on the screen using the mouse. Additionally, I want to perform a specific action, such as printing a message like "Node X clicked." My model represents the Earth, and my nodes are objects created using the Node class in VSG |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Maybe this example can help you:vsgintersection |
Beta Was this translation helpful? Give feedback.
-
The vsg::LineSegmentIntersector and vsg::PolytopeIntersector classes provide intersection with scene graph support. As @jacky-wang7 mentioned the vsgintersection example illustrates how these are used. |
Beta Was this translation helpful? Give feedback.
-
Another option which is to use a label image, where you produce an offline rendering of your scene where you give a flat "label color" to each visual node. By referencing this label image in your mouse event callback you can get the underlying object in O(1) by simply querying the image. I have succesfully implemented such a scheme with VSG. It was much more complex to set up than using the intersectors, but for my complex CAD based project it was the difference between the application being unusably slow and the application being much snappier than expensive commercial applications. |
Beta Was this translation helpful? Give feedback.
The vsg::LineSegmentIntersector and vsg::PolytopeIntersector classes provide intersection with scene graph support. As @jacky-wang7 mentioned the vsgintersection example illustrates how these are used.