Class SceneInteractor
- 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
-
- All Implemented Interfaces:
SafeDisposable
- Direct Known Subclasses:
SceneExaminer
,SceneOrbiter
public class SceneInteractor extends SoSeparator
Tool class for easily building a basic OpenInventor application without using existing viewer classes.The SceneInteractor is a simple extension of the
SoSeparator
node that allows handling of Open Inventor events. This class should be overridden as it provides only empty event handlers.
This node is intended to be used as the root of a scene graph. The SceneInteractor is a custom SoSeparator whose children are:
- an SoEventCallback node that handles keyboard, mouse and touch events
- a camera (switch between perspective and orthographic camera)
- a headlight
- the application's scene graph, which should be the last child.
SoCameraInteractor
in order to manipulate the camera in response to OpenInventor events.Class diagram of the SceneInteractor showing the relationship between the SoEventCallback, the SoCamera, the SoDirectionalLight (used as headlight) and the SoCameraInteractor.
Detail of the scene graph rooted by a SceneInteractor:
Notes:
- A basic version of SceneInteractor is a supported part of the OpenInventor API, the prebuilt jar is located in the usual folder $OIVJHOME/jre/lib/ext.
- The basic version of SceneInteractor is also provided as source code in the sources folder to allow applications to customize and build their own interactive tool class. See $OIVJHOME/sources/com/openinventor/inventor/viewercomponents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
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 SceneInteractor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adjustClippingPlanes(SbViewportRegion vpRegion)
Adjust near and far clipping planes to minimize clipping of objects in the scene.boolean
dispose()
Explicitly call this method to force object to dispose its unmanaged resources.void
enableHeadlight(boolean enabled)
Enable or disable headlight.SoCamera
getCamera()
Returns the current camera.SoCameraInteractor
getCameraInteractor()
SceneInteractor.CameraMode
getCameraMode()
Get the current camera mode.SoNode.RenderModes
getRenderEngineMode()
Returns the supported Render engine mode.boolean
isHeadlightEnabled()
Return if headlight is enabled.void
setCameraMode(SceneInteractor.CameraMode mode)
Set camera mode to perspective or orthographic.void
viewAll(SbViewportRegion vpRegion)
Set the camera to view all the scene.void
viewAxis(SbVec3f direction, SbVec3f up)
Moves the camera to be aligned with the given direction vector while keeping the "up" direction of the camera parallel to the specified up vector.-
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
getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Method Detail
-
dispose
public boolean dispose()
Description copied from class:Inventor
Explicitly call this method to force object to dispose its unmanaged resources. The object may not be reused in the application code after this call.- Specified by:
dispose
in interfaceSafeDisposable
- Overrides:
dispose
in classSoBase
- Returns:
true
if this object native resources were successfully disposed;false
if it was already disposed or no native resources has been registered for this object.
-
getRenderEngineMode
public SoNode.RenderModes getRenderEngineMode()
Description copied from class:SoNode
Returns the supported Render engine mode.For custom node, this method returns by default
SoNode.RenderModes.OIV_UNKNOWN_RENDERING_MODE
, override this method to specify the Render engine mode supported by your custom node.- Overrides:
getRenderEngineMode
in classSoNode
- Returns:
- the supported Render engine mode for this node.
-
setCameraMode
public void setCameraMode(SceneInteractor.CameraMode mode)
Set camera mode to perspective or orthographic.
-
getCameraMode
public SceneInteractor.CameraMode getCameraMode()
Get the current camera mode.
-
getCameraInteractor
public SoCameraInteractor getCameraInteractor()
- Returns:
- the current camera interactor
-
getCamera
public SoCamera getCamera()
Returns the current camera.- Returns:
- the current camera
-
adjustClippingPlanes
public void adjustClippingPlanes(SbViewportRegion vpRegion)
Adjust near and far clipping planes to minimize clipping of objects in the scene. This adjustment, based on the bounding box of the scene, ensures that shapes will not be clipped and also that depth buffer precision is maximized. This method should be called before each render traversal.
-
viewAll
public void viewAll(SbViewportRegion vpRegion)
Set the camera to view all the scene.
-
viewAxis
public void viewAxis(SbVec3f direction, SbVec3f up)
Moves the camera to be aligned with the given direction vector while keeping the "up" direction of the camera parallel to the specified up vector.- Parameters:
direction
- the new view direction vectorup
- the new "up" direction
-
enableHeadlight
public void enableHeadlight(boolean enabled)
Enable or disable headlight.
-
isHeadlightEnabled
public boolean isHeadlightEnabled()
Return if headlight is enabled.
-
-