Online demos

Viewing Cube

The SoViewingCube class is a new user interface component that provides visual feedback about the current orientation of the scene camera and also gives the user a convenient way to select predefined camera orientations.

With Open Inventor 10, we are continuing to provide new and improved tools to enhance the user experience for Open Inventor based applications.  Another example is the Halo Highlighting feature that provides an elegant visual indication for selected objects.

Camera Orientation

Many 3D applications need a "compass" or "gnomon" object that dynamically updates to show the user the current orientation of the scene camera, as shown in this animation. 

SoViewingCube tracking the current camera orientation.

The SoViewingCube node is easy to use.  You just add it to the scene graph, like any other shape, and attach it to the scene camera (SoCamera).  Of course, you can specify which corner of the window ('position' field), the size of the viewport ('size' field), and other options we will describe later.

Camera Interaction

But SoViewingCube is much more than a passive display object!  It also provides a convenient and powerful way for users to interact with the scene camera.  3D applications often present the user with a selection of predefined views.  They may be called front and back, posterior and anterior, or other industry-specific names.  In any case, these buttons or menu items use a lot of screen space, clutter the user interface, and may be hard to find.  We can do better than this:

A typical view selection menu.

⇒ Clicking on any part of the viewing cube makes the camera rotate (around its current focal point ) until the camera is facing the corresponding part of the scene.

In this way, the viewing cube provides the same options as the predefined view buttons while using much less screen space and reducing the complexity of the user interface.  This animation shows the viewing cube in action:

Using SoViewingCube to animate the camera to a predefined orientation.

Notice that the viewing cube provides many more options than just the primary axes.  Clicking on an "edge" of the cube orients the camera between the two associated faces.  Clicking on a "corner" of the cube orients the camera between the three associated faces.

Also, note that the viewing cube has a built-in animation that provides a smooth transition between camera orientations.  The 'animationDuration' field allows you to specify the duration of the animation.  Setting this field to zero causes the camera to move immediately to the new orientation.


The viewing cube's appearance can be customized by specifying a texture image for each of the six faces.  For example:

Customized SoViewingCube

If you need a completely customized orientation indicator, please take a look at the Gnomon node in the Medical utility library.  Source code is provided for this node in the source/Medical/nodes directory.  The gnomon geometry can be any Open Inventor scene graph with geometry defined inside a -1 to 1 bounding box.

When the mouse cursor is over the viewing cube, the part (face, edge, or corner) that is under the cursor is highlighted with the color specified in the 'selectionColor' field. When the left mouse button (button 1) is clicked (pressed and released), the selected part of the viewing cube is used to define the new orientation. The appearance of the viewing cube can be customized in various ways, as shown here:

Edge Style optionsSelection colorSelection color


SoViewingCube is designed to be used with the Open Inventor "viewer components" classes.  The viewer components are a modern alternative to the classic Open Inventor viewer classes like SoXtExaminerViewer.  Viewer component classes come with source code and can be customized to match your application's requirements.  SoViewingCube can also be used with viewer classes.  In this case, the camera orientation will be correctly indicated, but it will be less convenient for the user to use the viewing cube's interaction features.  That's because the classic viewers are modal and the viewing cube will only respond to mouse clicks in selection mode.  For a modeless viewer interaction, try the SceneOrbiter viewer component.