Beginner Tutorial Open Inventor 3D Mouse Interactions

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

SoMouseGrabber

Configure 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 Right Mouse Button and move the mouse around. This action can be seen in the panel of the module SoMouseGrabber.

SoMouseGrabber

SoMouseGrabber

You can see:

  1. Button 3, the right mouse button Right Mouse Button , is tagged as being pressed
  2. Changes of the mouse coordinates are displayed in the box Output.

Mouse Interactions

Mouse Interactions

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.

Change Cube size by Mouse Events

Change Cube size by Mouse Events

If you now press the right mouse key Right Mouse Button inside the Viewer and move the mouse around, the size of the cube changes.

Exercises

  1. Change location of the cube via Mouse Interactions by using the Module SoTransform
  2. 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.