Example 2: Mouse interactions in Open Inventor
Introduction
In this example, we implement some image or object interactions. We will create a 3D scene, in which we display a cube and change its size using the mouse. We also get to know another viewer, the module SoExaminerViewer
. This viewer is important. It enables the rendering of Open Inventor scenes and allows interactions with the Open Inventor scenes.
Steps to do
Develop your network
For implementing the example, build the following network. We already know the module SoCube
, which builds a 3D scene object forming a cube. In addition to that, add the module SoMouseGrabber
. Connect the modules as shown below.
SoMouseGrabber
can be found here:
SoMouseGrabberConfigure mouse interactions
Now, open the panels of the module SoMouseGrabber
and the module SoExaminerViewer
, which displays a cube. In the Viewer, press the right key of your mouse
and move the mouse around. This action can be seen in the panel of the module SoMouseGrabber.
SoMouseGrabber
fields as seen below.You can see:
- Button 3, the right mouse button , is tagged as being pressed
- Changes of the mouse coordinates are displayed in the box Output.
Resize cube via mouse interactions
We like to use the detected mouse-movements to change the size of our cube. In order to that, open the panel of SoCube
. Build parameter connections from the mouse coordinates to the width and depth of the cube.
If you now press the right mouse key inside the Viewer and move the mouse around, the size of the cube changes.
Exercises
- Change location of the cube via Mouse Interactions by using the Module
SoTransform
- Add more objects to the scene and interact with them
Summary
- The module
SoExaminerViewer
enables the rendering of Open Inventor scenes and allows interactions with the Open Inventor scenes. - Mouse interactions can be applied to the objects in the scene.