-
Book Overview & Buying
-
Table Of Contents
OpenSceneGraph 3.0: Beginner's Guide
The picking functionality allows users to move the mouse over a portion of a rendered scene and click a button. The result may be an action of opening or closing a door, or shooting on an intruding alien in the 3D world. There are three main steps required to perform these kinds of actions.
Firstly, we use an event handler to receive mouse events. For example, a mouse push event comes along with the X and Y positions of the cursor, which are of course the most important factors of the picking operation.
Secondly, we have to determine which part of the scene graph is under the mouse cursor. This can be done by using the intersection tools provided by the osgUtil library. The result is a set of intersections that includes the picked drawable, its parent node path, the intersecting point, and so on.
Finally, we are going to make use of the intersection result to achieve our goals of picking objects or making them fight.
Change the font size
Change margin width
Change background colour