Class SceneOrbiter
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.misc.SoBase
-
- com.openinventor.inventor.fields.SoFieldContainer
-
- com.openinventor.inventor.nodes.SoNode
-
- com.openinventor.inventor.nodes.SoGroup
-
- com.openinventor.inventor.nodes.SoSeparator
-
- com.openinventor.inventor.viewercomponents.nodes.SceneInteractor
-
- com.openinventor.inventor.viewercomponents.nodes.SceneOrbiter
-
- All Implemented Interfaces:
SafeDisposable
public class SceneOrbiter extends SceneInteractor
(Preview Feature) Tool class for building a basic interactive OpenInventor application with mode-less scene "orbiter" viewing behavior.Preview Feature means this class is fully supported and can be used in Open Inventor applications. Being tagged as a Preview Feature just means that the implementation is still subject to API changes and adjustments based on feedback from early adopters. Please be also aware that source compatibility might be broken regardless of the Open Inventor compatibility changes policy due to our commitment to bring needed changes to make sure that the specifications of this Preview Feature match the expectations of our customers.
The SceneOrbiter is an extension of the
SceneInteractor
node that provides camera and headlight manipulations like panning, zooming and orbiting similar to the SceneExaminer (in Orbit navigation mode).The SceneOrbiter provides a "mode-less" viewer which is very convenient for users. The 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
SceneOrbiter.RotationMethods
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 allows the camera to move only along vertical orbits such as the earth meridians, and along horizontal circles such as the earth parallels. The vertical orbits and horizontal circles are related to an up axis, that can be changed callingsetUpAxis(Axis)
. 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, that gives 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(boolean)
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 ofSoCameraInteractor
to manipulate the camera in response to OpenInventor events.Notes:
- Window system integration
The SceneOrbiter needs a component that integrates the Open Inventor 3D rendering window with the native window system. System dependent tasks include creating a window, placing the window in the application's user interface, initializing OpenGL and processing the native event/message loop. System independent support for this is provided by theSoRenderAreaCore
class. Example components are provided for AWT and SWT toolkits. - Event handling
The SceneOrbiter needs a component that builds OpenInventor events (SoEvent) from native system events. System independent support for this is provided by theSoEventBuilder
class. Example components are provided for AWT and SWT toolkits: AWTEventToSoEvent and SWTEventToSoEvent. - Library
A basic version of SceneOrbiter is a supported part of the Open Inventor API and a prebuilt jar is provided. - Source code
The basic version of SceneOrbiter is also provided as source code in the sources folder to allow applications to customize and build their own interactive tool class.
See $OIVJHOME/source/com/openinventor/inventor/viewercomponents/nodes. - Scene graph
The application scene graph should be the last child of the SceneOrbiter. The initial application scene graph can be added by simply calling the inherited method addChild(). But note that if you need to replace the application scene graph, for example loading a new data set, do not call removeAllChildren(). That would also remove the SceneOrbiter's camera, headlight and event handler nodes. Add an SoSeparator to the SceneOrbiter to serve as the "scene graph holder", then add and remove the application scene graph from this node. - Clip planes
SceneOrbiter automatically adjusts the 'near' and 'far' clipping planes when events modifying the camera are handled. This adjustment, based on the bounding box of the scene, ensures that shapes will not be clipped as the camera orbits and also that depth buffer precision is maximized.
Note: Updating clipping planes after a camera move can be insufficient. If the scene graph is modified or if a dragger or a rendered shape is moved, they can disappear or become partially clipped. A classic implementation of a render area must adjust clipping planes before each rendering by calling the provided methodSceneInteractor.adjustClippingPlanes(SbViewportRegion)
. See render area's implementations available in $OIVJHOME/examples/inventor/viewercomponents/awt and $OIVJHOME/examples/inventor/viewercomponents/swt folders for examples ofadjustClippingPlanes
use. - Compatibility with classical viewers
Please note that some interaction behaviors are different than the classic Open Inventor viewer classes :- Left Mouse + Shift does Zoom in/out.
- Mouse wheel performs a dolly relative to the cursor position, not the center of the viewport.
- The classic ESC key behavior is not implemented.
(Not necessary because viewing and selection are supported without separate modes.) - The classic Alt key behavior is not implemented. This key is reserved for application use.
- The Right Mouse button does not display a pop-up menu. This button is reserved for application use.
- Seek mode is not supported.
- Compatibility with SceneExaminer
- Only the left mouse button has defined behaviors.
Pan and zoom behaviors require pressing a keyboard key while dragging the mouse. - Touch events are not currently handled.
- Only the left mouse button has defined behaviors.
Usage:
- Left Mouse: Rotate the scene
- Left Mouse + Ctrl: Pan the scene.
- Left Mouse + Shift: Zoom in/out the scene.
- Mouse Wheel: Zoom in/out (zoom center is the mouse cursor location).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SceneOrbiter.RotationMethods
Defines how the mouse events or touch events control the rotations of the scene.-
Nested classes/interfaces inherited from class com.openinventor.inventor.viewercomponents.nodes.SceneInteractor
SceneInteractor.CameraMode
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoSeparator
SoSeparator.Cachings, SoSeparator.FastEditings, SoSeparator.RenderUnitIds
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.nodes.SoSeparator
boundingBoxCaching, fastEditing, pickCulling, renderCaching, renderCulling, renderUnitId
-
Fields inherited from class com.openinventor.inventor.nodes.SoGroup
boundingBoxIgnoring
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SceneOrbiter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enableViewingCube(boolean enabled)
Enables or disables the viewing cube.float
getConstraintLevel()
Returns the current constraint level which limits the turntable rotation.SceneOrbiter.RotationMethods
getRotationMethod()
Returns the current scene rotation method.Axis
getUpAxis()
Returns the current up axis of the scene.SoViewingCube
getViewingCube()
Returns the viewing cube object.boolean
isViewingCubeEnabled()
Returns if viewing cube is enabled.void
setCameraMode(SceneInteractor.CameraMode mode)
Set camera mode to perspective or orthographic.void
setConstraintLevel(float level)
Sets the constraint level to limit the turntable rotation.void
setRotationMethod(SceneOrbiter.RotationMethods method)
Sets the scene rotation method.void
setUpAxis(Axis axis)
Sets the up axis of the scene.-
Methods inherited from class com.openinventor.inventor.viewercomponents.nodes.SceneInteractor
adjustClippingPlanes, enableHeadlight, getCamera, getCameraInteractor, getCameraMode, getRenderEngineMode, isHeadlightEnabled, viewAll, viewAxis
-
Methods inherited from class com.openinventor.inventor.nodes.SoGroup
addChild, findChild, getChild, getNumChildren, insertChild, removeAllChildren, removeChild, removeChild, replaceChild, replaceChild
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Method Detail
-
setConstraintLevel
public void 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 :
- 0 means no constraint on the rotation, regardless of the interaction speed
- 1 means very strongly constrained even if interaction is slow.
Default is 0 which means no constraint on the rotation.- Parameters:
level
- the constraint level.
-
getConstraintLevel
public float getConstraintLevel()
Returns the current constraint level which limits the turntable rotation.- Returns:
- the constraint level.
-
setRotationMethod
public void setRotationMethod(SceneOrbiter.RotationMethods method)
Sets the scene rotation method.Default is TURNTABLE.
- Parameters:
method
- the new scene rotation method.
-
getRotationMethod
public SceneOrbiter.RotationMethods getRotationMethod()
Returns the current scene rotation method.- Returns:
- the scene rotation method
-
setUpAxis
public void setUpAxis(Axis 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.- Parameters:
axis
- the new up axis of the scene
-
getUpAxis
public Axis getUpAxis()
Returns the current up axis of the scene.- Returns:
- the up axis of the scene.
-
enableViewingCube
public void enableViewingCube(boolean enabled)
Enables or disables the viewing cube. Default is true.
-
isViewingCubeEnabled
public boolean isViewingCubeEnabled()
Returns if viewing cube is enabled.
-
getViewingCube
public SoViewingCube getViewingCube()
Returns the viewing cube object.
-
setCameraMode
public void setCameraMode(SceneInteractor.CameraMode mode)
Description copied from class:SceneInteractor
Set camera mode to perspective or orthographic.- Overrides:
setCameraMode
in classSceneInteractor
-
-