[PREVIEW] Tool class for building a basic interactive OpenInventor application with mode-less scene "orbiter" viewing behavior. More...
#include <Inventor/ViewerComponents/nodes/SceneOrbiter.h>
Public Types | |
enum | RotationMethod { TURNTABLE, TRACKBALL } |
Public Member Functions | |
SceneOrbiter () | |
virtual | ~SceneOrbiter () |
void | setConstraintLevel (float level) |
float | getConstraintLevel () |
void | setRotationMethod (RotationMethod method) |
RotationMethod | getRotationMethod () |
void | setUpAxis (openinventor::inventor::Axis::Type axis) |
openinventor::inventor::Axis::Type | getUpAxis () |
void | enableViewingCube (bool enabled) |
bool | isViewingCubeEnabled () const |
SoViewingCube * | getViewingCube () |
virtual void | setCameraMode (SceneInteractor::CameraMode mode) |
The SceneOrbiter is an extension of the SceneInteractor node that provides camera and headlight manipulations like panning, zooming and orbiting similar to the classic Open Inventor "Examiner" viewer classes (e.g. SoWinExaminerViewer) and the SceneExaminer (in Orbit navigation mode).
The SceneOrbiter provides a "mode-less" viewer which is very convenient for users. The Examiner viewer and SceneExaminer viewers are always in either viewing mode (mouse events control the camera) or in selection mode (mouse events are sent to the scene graph and objects can be selected). This often requires the user to frequently switch between viewing and selection mode (for example by pressing the ESC key) while interacting with the scene. SceneOrbiter does not have modes. For example, a mouse click without moving the mouse is interpreted as a selection and the event is sent to the scene graph, but a mouse click and "drag" is interpreted as controlling the camera.
The SceneOrbiter provides two different methods to control the rotation of the camera around the scene : trackball and turntable, see RotationMethod enum.
The trackball method allows the camera to move along any circular orbit around the scene and look in the direction of its center. The orbit orientation can change at any time while interpreting a mouse drag. Thus the trackball is known as an unconstrained orbiting mode. The trackball is the unique method used by the historical examiner viewer and by the SceneExaminer.
The additional turntable method is a more constrained orbiting mode. It lets the camera move only along vertical orbits such as the earth meridians, and along horizontal circles such as the earth parallels. The vertical orbits and the horizontal circles are related to an up axis, which can be changed calling setUpAxis. The horizontal circles are centered around this up axis, and the vertical orbits share their south and north pole on this up axis. As the camera cannot move along any other circle, this mode is more constrained compared to the trackball mode. However, it provides a more natural navigation experience when viewing a scene that has strong vertical and horizontal references. For instance, when orbiting in turntable mode around a scene representing the Eiffel tower, this one always looks vertical on your screen. Compared to the trackball mode, the turntable mode does not need any tedious small mousemove correction to keep the scene well aligned with the borders of the screen.
The 'headlight', an SoDirectionalLight node, is automatically aligned with the camera's view direction.
An SoViewingCube node is automatically added to the scene. The viewing cube can be hidden by calling the enableViewingCube() method. Note that the up axis of the viewing cube is synchronized with the up axis of the SceneOrbiter.
See parent class SceneInteractor for more details about the structure of the internal scene graph.
The SceneOrbiter uses an instance of SoCameraInteractor to manipulate the camera in response to OpenInventor events.
Notes:
SceneInteractor, SoCameraInteractor, SiInteractionModeListener
Defines how the mouse events or touch events control the rotations of the scene.
SceneOrbiter::SceneOrbiter | ( | ) |
Constructor.
virtual SceneOrbiter::~SceneOrbiter | ( | ) | [virtual] |
Destructor.
void SceneOrbiter::enableViewingCube | ( | bool | enabled | ) |
Enables or disables viewing cube.
Default is true.
float SceneOrbiter::getConstraintLevel | ( | ) |
Returns the current constraint level which limits the turntable rotation.
RotationMethod SceneOrbiter::getRotationMethod | ( | ) |
Returns the current scene rotation method.
openinventor::inventor::Axis::Type SceneOrbiter::getUpAxis | ( | ) |
Returns the current up axis of the scene.
SoViewingCube* SceneOrbiter::getViewingCube | ( | ) |
Returns the viewing cube object.
bool SceneOrbiter::isViewingCubeEnabled | ( | ) | const |
Returns if viewing cube is enabled.
virtual void SceneOrbiter::setCameraMode | ( | SceneInteractor::CameraMode | mode | ) | [virtual] |
Selects perspective or orthographic camera.
Default is perspective.
Reimplemented from SceneInteractor.
void SceneOrbiter::setConstraintLevel | ( | float | level | ) |
Sets the constraint level to limit the turntable rotation.
The level is a value between [0,1] used to adjust the constraint on the turntable rotation according to the speed of movement :
This prevents unexpected changes in the axis of rotation during fast movements. Default is 0 which means no constraint on the rotation.
level | the constraint level. |
void SceneOrbiter::setRotationMethod | ( | RotationMethod | method | ) |
Sets the scene rotation method.
Default is TURNTABLE.
void SceneOrbiter::setUpAxis | ( | openinventor::inventor::Axis::Type | axis | ) |
Sets the up axis of the scene.
Default is Y. Note that the up axis of the viewing cube is synchronized with the up axis of the SceneOrbiter.