Class SoSceneManager
SoSceneManager
provides Open Inventor rendering and event handling inside a window provided by the caller. The scene manager is able to render in only a portion of a window if desired. The
invalid reference
SoWinRenderArea
SoSceneManager
, and handles most all the details for setting up a window, converting Windows messages to Open Inventor events, automatically redrawing the scene when necessary, and so on. It is simplest to use a render area when rendering in an entire window. The SoSceneManager
class is available for programmers not using the SoXt /
invalid reference
SoWin
invalid reference
SoQt
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static enum
Enum which indicates the desired antialiasing algorithm.Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Activates the scene manager.void
Deactivates the scene manager.static void
enableRealTimeUpdate
(boolean flag) Enables the realTime global field update which normally happen right after a redraw.Returns the antialiasing mode set using thesetAntialiasing(float,AntialiasingMode)
method.Returns the antialiasing parameters set using thesetAntialiasing(SoAntialiasingParameters*)
method.float
Returns the antialiasing quality set using thesetAntialiasing(float,AntialiasingMode)
method.int
float
static int
Gets the default priority of the redraw sensor.int
Internal usage.int
getSize()
float
float
boolean
boolean
Returns true if there is currently a render callback registered.static boolean
boolean
boolean
processEvent
(SoEvent event) Processes the passed event by applying anSoHandleEventAction
to the scene graph managed here.void
Reinitializes graphics.void
render()
Applies anSoGLRenderAction
to the scene graph managed here.void
render
(boolean clearWindow) Deprecated.void
render
(boolean clearWindow, boolean clearZbuffer) Deprecated.As of Open Inventor 10.1.0.0.void
Internal usage.void
Schedules a redraw for some time in the near future.void
Setup a task that returns true if action should be aborted.void
setAntialiasing
(boolean smoothing, int numPasses) Deprecated.As of Open Inventor 9.1.0.0.void
setAntialiasing
(float quality) Calls setAntialiasing(quality, SoSceneManager.AntialiasingModes.valueOf( SoSceneManager.AntialiasingModes.AUTO.getValue() )).void
setAntialiasing
(float quality, SoSceneManager.AntialiasingModes mode) Enable (or disable) antialiasing with specified quality and mode.void
setAntialiasing
(SoAntialiasingParameters advancedParameters) Enable (or disable) antialiasing with specific parameters.void
Sets an event listener which is called when the antialiasing configuration is modified.void
setAutoInteractiveMode
(boolean flag) Defines the auto interactive mode.void
Defines the window background color when in RGB mode.void
Defines the window background color when in RGBA mode.void
setBackgroundIndex
(int index) Defines the window background color when in color index mode.void
setClearDepth
(float depth) Defines the depth value used when the depth buffer is cleared.void
setFloatingColorBuffer
(boolean enable, int size) Internal usage.void
User supplied render action.void
User supplied handle event action.void
setInteractive
(boolean flag) Indicates that the scene manager is in interactive mode or not.void
Defines the origin of the viewport within the window.void
setRedrawPriority
(int priority) Sets the priority of the redraw sensor.void
setRenderTask
(Runnable renderTask) The render task provides a mechanism for automatically redrawing the scene in response to changes in the scene graph.void
setRGBMode
(boolean onOrOff) Defines the color mode (true - RGB mode, false - color map mode).void
setSceneGraph
(SoNode newScene) Defines the scene graph which is managed here.void
Calls setShareContext(sc, true).void
setShareContext
(SbGLShareContext sc, boolean issc) Sets the OpenGL context to be shared by the scene manager.void
Calls setSize(newSize, (float)1.0).void
Defines the size of the viewport within the window.void
setStillSuperSampling
(float quality, float delay) Set options for supersampling when "still" (not interacting).void
setViewportRegion
(SbViewportRegion newRegion) Defines current viewport region to use for rendering.void
setWindowSize
(SbVec2s newSize) Calls setWindowSize(newSize, (float)1.0).void
setWindowSize
(SbVec2s newSize, float newScale) Defines the size of the window in which the scene manager should render.void
Internal usage.Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Constructor Details
-
SoSceneManager
Deprecated.As of Open Inventor 2024.2. This method should no longer be used. Use constructor SoSceneManager() (without argument) instead.Constructor.Warning Deprecated since Open Inventor 2024.2. This method should no longer be used. Use constructor
SoSceneManager()
(without argument) instead. -
SoSceneManager
public SoSceneManager()Constructor.
-
-
Method Details
-
setRenderTask
The render task provides a mechanism for automatically redrawing the scene in response to changes in the scene graph. The scene manager employs a sensor to monitor scene graph changes. When the sensor is triggered, the render task registered here is invoked. The task should set up its graphics window, then call the scene manager render() method. If the task is set to null (the default), auto-redraw is turned off. -
setAbortRenderTask
Setup a task that returns true if action should be aborted.It allows some Open Inventor nodes to stop their work, if requested, in order to keep reasonable interactivity. For example, the task can be setup to return true if MousePress events are pending during a STILL frame.
-
scheduleForcedRedraw
public void scheduleForcedRedraw()Internal usage. Schedule a forced redraw, which is guaranteed to be done -
setFloatingColorBuffer
public void setFloatingColorBuffer(boolean enable, int size) Internal usage. -
getFloatingPointRenderingPrecision
public int getFloatingPointRenderingPrecision()Internal usage. -
updateRealTimeSensor
public void updateRealTimeSensor()Internal usage. -
setAntialiasing
public void setAntialiasing(float quality) Calls setAntialiasing(quality, SoSceneManager.AntialiasingModes.valueOf( SoSceneManager.AntialiasingModes.AUTO.getValue() )). -
render
Deprecated.Calls render(clearWindow, true). -
setWindowSize
Calls setWindowSize(newSize, (float)1.0). -
setSize
Calls setSize(newSize, (float)1.0). -
scheduleRedraw
public void scheduleRedraw()Schedules a redraw for some time in the near future. If there is no render callback set, or this is not active, no redraw will be scheduled. -
getGLRenderAction
- Since:
- Open Inventor 9.2
- See Also:
-
setAntialiasing
Deprecated.As of Open Inventor 9.1.0.0. To enable smoothing and/or multi-pass antialiasing for rendering use the setAntialiasing(float,AntialiasingMode) method with mode SUPERSAMPLING or use the setAntialiasing(SoAntialiasingParameters*) method with an SoAccumulationAntialiasingParameters object.Enables smoothing and/or multi-pass antialiasing for rendering.
There are two kinds of antialiasing available: smoothing and multipass antialiasing. If smoothing is set to true, smoothing is enabled. Smoothing uses OpenGL's line- and point-smoothing features to provide cheap antialiasing of lines and points. The value of numPasses controls multipass antialiasing. Each time a render action is applied, Open Inventor renders the scene numPasses times from slightly different camera positions, averaging the results. numPasses can be from one to 255, inclusive. Setting numPasses to one disables multipass antialiasing. You can use either, both, or neither of these antialiasing techniques. By default, both smoothing and multipass antialiasing are disabled.
Warning Deprecated since Open Inventor 9100. To enable smoothing and/or multi-pass antialiasing for rendering use the
setAntialiasing(float,AntialiasingMode)
method with mode SUPERSAMPLING or use thesetAntialiasing(SoAntialiasingParameters*)
method with anSoAccumulationAntialiasingParameters
object. -
reinitialize
public void reinitialize()Reinitializes graphics. This should be called, for instance, when there is a new window. -
setGLRenderAction
User supplied render action. Highlights fall into this category. SceneManager will never delete a render action passed to this method. return the renderAction 0.- Since:
- Open Inventor 9.2
-
getSceneGraph
- See Also:
-
setHandleEventAction
User supplied handle event action. This should not be done in the middle of event handling. Passing NULL turns event handling off. SceneManager will never delete a handle event action passed to this method.- Since:
- Open Inventor 9.2
-
setSceneGraph
Defines the scene graph which is managed here. This is the Open Inventor scene which will be traversed for rendering and event processing. -
getHandleEventAction
- Since:
- Open Inventor 9.2
- See Also:
-
isRealTimeUpdateEnabled
public static boolean isRealTimeUpdateEnabled()- See Also:
-
enableRealTimeUpdate
public static void enableRealTimeUpdate(boolean flag) Enables the realTime global field update which normally happen right after a redraw. -
render
public void render()Applies anSoGLRenderAction
to the scene graph managed here. Note that this method just applies anSoGLRenderAction
that traverses the scene graph and makes the necessary rendering calls for each node. It is not the same as calling the render method on an Open Inventor render area or viewer object. The viewer's render method will typically do pre-rendering operations like adjusting the near/far clip planes, as well as post-rendering operations like calling "swap buffers" to make the rendered content visible. Also it is possible to call a viewer's render method without explicitly making an OpenGL render context current (the viewer takes care of that).When calling this method, the application is responsible for providing a current OpenGL render context that is known to Open Inventor through an
SoGLContext
object. If there is no current OpenGL render context, Open Inventor may throw an exception or crash, depending on the API language and system environment.- If the application is using an Open Inventor render area or viewer and wants to render in that window, there may not be an OpenGL render context current. However the viewer's render context can be made current by calling the viewer's bindNormalContext() method. Call the viewer's unbindNormalContext() method after calling
render()
. - This method is more likely to be used in cases where there is no Open Inventor render area or viewer. For example when integrating Open Inventor rendering in an OpenGL application. If the application has its own OpenGL render context that is already current, you can call the static
SoGLContext
method getCurrent(true) to get anSoGLContext
object that wraps the current context. Then call bind and unbind on the returned object. (Note that this method will return null if there is no current context.)
- If the application is using an Open Inventor render area or viewer and wants to render in that window, there may not be an OpenGL render context current. However the viewer's render context can be made current by calling the viewer's bindNormalContext() method. Call the viewer's unbindNormalContext() method after calling
-
processEvent
Processes the passed event by applying anSoHandleEventAction
to the scene graph managed here. Returns true if the event was handled by a node. -
getDefaultRedrawPriority
public static int getDefaultRedrawPriority()Gets the default priority of the redraw sensor. -
render
Deprecated.As of Open Inventor 10.1.0.0. No longer used and the parameters are ignored. Use render() instead.- See Also:
-
setRedrawPriority
public void setRedrawPriority(int priority) Sets the priority of the redraw sensor. Sensors are processed based on priority, with priority values of 0 processed immediately. The default priority for the scene manager redraw sensor is 10000. -
setBackgroundIndex
public void setBackgroundIndex(int index) Defines the window background color when in color index mode. This is the color the scene manager viewport is cleared to whenrender()
is called. Default is black (index 0). -
isAutoRedraw
public boolean isAutoRedraw()Returns true if there is currently a render callback registered. -
getBackgroundIndex
public int getBackgroundIndex()- See Also:
-
getRedrawPriority
public int getRedrawPriority()- See Also:
-
setBackgroundColorRGBA
Defines the window background color when in RGBA mode. This is the color the scene manager viewport is cleared to whenrender()
is called. Default is transparent black (0,0,0,0).The default RGB color (but NOT alpha) can be set using the environment variable OIV_BACKGROUND_COLOR or by calling
setBackgroundColor()
.- Parameters:
color
- RGBA background color
-
setStillSuperSampling
public void setStillSuperSampling(float quality, float delay) Set options for supersampling when "still" (not interacting). When quality is greater than 0, still images will be automatically supersampled.- Parameters:
quality
- The quality is a factor in the range [0.0,1.0].
Use the value 0.0 to turn off still supersampling. 0.5 is a typical value.delay
- The delay is in seconds.
If greater than 0, images will be supersampled after the specified delay
-
getBackgroundColorRGBA
- See Also:
-
getClearDepth
public float getClearDepth()- See Also:
-
setAutoInteractiveMode
public void setAutoInteractiveMode(boolean flag) Defines the auto interactive mode. Default is false.When this mode is activated, the sceneManager will decide depending on scenegraph changes to switch to interactive mode or not.
Default value can be changed through OIV_AUTO_INTERACTIVE_MODE envvar.
- Since:
- Open Inventor 9.2
-
activate
public void activate()Activates the scene manager. The scene manager will only employ sensors for automatic redraw while it is active. Typically, the scene manager should be activated whenever its window is visible on the screen, and deactivated when its window is closed or iconified. -
deactivate
public void deactivate()Deactivates the scene manager. The scene manager will only employ sensors for automatic redraw while it is active. Typically, the scene manager should be activated whenever its window is visible on the screen, and deactivated when its window is closed or iconified. -
setClearDepth
public void setClearDepth(float depth) Defines the depth value used when the depth buffer is cleared. The default value is 1. This is the value used to clear the depth buffer whenrender()
is called.- Parameters:
depth
- value used to clear the depth buffer. Value is clamped to the range [0,1].
-
setInteractive
public void setInteractive(boolean flag) Indicates that the scene manager is in interactive mode or not. This is usually called by Inventor viewer classes, but it is also usefull for custom application viewer.It mainly setup
SoInteractionElement
for all used actions (preRenderAction and renderAction).- Since:
- Open Inventor 9.2
-
setRGBMode
public void setRGBMode(boolean onOrOff) Defines the color mode (true - RGB mode, false - color map mode). Default is RGB mode. Only a subset of Open Inventor nodes will render correctly in color map mode. Basically, when in color index mode, lighting should be turned off (the model field ofSoLightModel
should be set to BASE_COLOR ), and theSoColorIndex
node should be used to specify colors. -
isAutoInteractiveMode
public boolean isAutoInteractiveMode()- Since:
- Open Inventor 9.2
- See Also:
-
isRGBMode
public boolean isRGBMode()- See Also:
-
getBackgroundColor
- See Also:
-
getSize
- See Also:
-
getAntialiasingMode
Returns the antialiasing mode set using thesetAntialiasing(float,AntialiasingMode)
method. Returns AUTO by default. Parameters set using thesetAntialiasing(SoAntialiasingParameters*)
method may change the antialiasing mode, but do not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing mode. -
setOrigin
Defines the origin of the viewport within the window. The origin (0,0) is the lower left corner of the window. -
getAntialiasingParameters
Returns the antialiasing parameters set using thesetAntialiasing(SoAntialiasingParameters*)
method. Returns null by default. A quality value set using thesetAntialiasing(float,AntialiasingMode)
method may modify internal parameters, but does not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing parameters. -
setSize
Defines the size of the viewport within the window. Default is to render the entire window region. -
getAntialiasingEventListener
- Returns:
- A pointer on the current antialiasing event listener, NULL if there is no listener.
- See Also:
-
setWindowSize
Defines the size of the window in which the scene manager should render. This size must be set beforerender()
andprocessEvent()
are called. -
setAntialiasingEventListener
Sets an event listener which is called when the antialiasing configuration is modified. It is useful to define this listener because the scene manager is not responsible for the pixelformat changes required for the FSAA and accumulation algorithms. The Open Inventor viewer classes use the listener to automatically switch the pixel format (not necessary for application to handle this when using a viewer class).- Parameters:
listener
- The listener object.
-
getWindowSize
- See Also:
-
getStillSuperSamplingDelay
public float getStillSuperSamplingDelay()- See Also:
-
getViewportRegion
- See Also:
-
getStillSuperSamplingQuality
public float getStillSuperSamplingQuality()- See Also:
-
setBackgroundColor
Defines the window background color when in RGB mode. This is the color the scene manager viewport is cleared to whenrender()
is called. Default is black (0,0,0). See alsosetBackgroundColorRGBA()
.Setting the background color will automatically call the
scheduleRedraw()
method.The default value can be set using the environment variable OIV_BACKGROUND_COLOR. Specify three floats (R, G, B) in the range 0. to 1., separated by spaces.
-
setAntialiasing
Enable (or disable) antialiasing with specified quality and mode. Specific antialiasing parameters will be set automatically based on the quality value. Note that the quality and mode settings are overridden if specific antialiasing parameters are subsequently set using thesetAntialiasing(SoAntialiasingParameters*)
method.The default mode is AUTO but this may be overridden by setting the environment variable OIV_ANTIALIASING_DEFAULT_MODE (see
SoPreferences
).- Parameters:
quality
- The quality is a factor in the range [0.0,1.0].
Use the value 0.0 to turn off antialiasing. 0.5 is a typical value.mode
- The antialiasing algorithm. Default is AUTO, which means use the best for the current hardware.
Use the value NO_ANTIALIASING to turn off antialiasing.
-
getOrigin
- See Also:
-
getAntialiasingQuality
public float getAntialiasingQuality()Returns the antialiasing quality set using thesetAntialiasing(float,AntialiasingMode)
method. Returns 0.0 by default. Parameters set using thesetAntialiasing(SoAntialiasingParameters*)
method override internal parameters, but do not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing quality. -
setViewportRegion
Defines current viewport region to use for rendering. This can be used instead of setting the size and origin separately. -
setAntialiasing
Enable (or disable) antialiasing with specific parameters. Use one of the subclasses ofSoAntialiasingParameters
. The antialiasing mode is determined by which subclass is used to set the parameters. For example, passing anSoFXAAParameters
object automatically sets FXAA mode. Note that the parameters are overridden if a quality and mode are subsequently set using thesetAntialiasing(float,AntialiasingMode)
method.NOTES - When the antialiasing parameters are modified a listener is called if it has been defined. See also
setAntialiasingEventListener()
.
- Parameters:
advancedParameters
- Provides specific parameters for an antialiasing mode.
Use a null parameter to turn off antialiasing or use one of the subclasses ofSoAntialiasingParameters
.
- When the antialiasing parameters are modified a listener is called if it has been defined. See also
-