Class SoSceneManager
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.SoSceneManager
-
public class SoSceneManager extends Inventor
Manages scene graph rendering and event handling.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. TheSoWinRenderArea
class employs anSoSceneManager
, 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. TheSoSceneManager
class is available for programmers not using the SoXt /SoWin
orSoQt
libraries.- See Also:
SoWinRenderArea
,SoGLRenderAction
,SoHandleEventAction
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SoSceneManager.AbortRenderTask
static class
SoSceneManager.AntialiasingModes
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 Constructor Description SoSceneManager()
Constructor.SoSceneManager(int nb)
Deprecated.As of Open Inventor 2024.2.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
activate()
Activates the scene manager.void
deactivate()
Deactivates the scene manager.static void
enableRealTimeUpdate(boolean flag)
Enables the realTime global field update which normally happen right after a redraw.SiAntialiasingEventListener
getAntialiasingEventListener()
SoSceneManager.AntialiasingModes
getAntialiasingMode()
Returns the antialiasing mode set using thesetAntialiasing(float,AntialiasingMode)
method.SoAntialiasingParameters
getAntialiasingParameters()
Returns the antialiasing parameters set using thesetAntialiasing(SoAntialiasingParameters*)
method.float
getAntialiasingQuality()
Returns the antialiasing quality set using thesetAntialiasing(float,AntialiasingMode)
method.SbColor
getBackgroundColor()
SbColorRGBA
getBackgroundColorRGBA()
int
getBackgroundIndex()
float
getClearDepth()
static int
getDefaultRedrawPriority()
Gets the default priority of the redraw sensor.int
getFloatingPointRenderingPrecision()
Internal usage.SoGLRenderAction
getGLRenderAction()
SoHandleEventAction
getHandleEventAction()
SbVec2s
getOrigin()
int
getRedrawPriority()
SoNode
getSceneGraph()
SbVec2s
getSize()
float
getStillSuperSamplingDelay()
float
getStillSuperSamplingQuality()
SbViewportRegion
getViewportRegion()
SbVec2s
getWindowSize()
boolean
isAutoInteractiveMode()
boolean
isAutoRedraw()
Returns true if there is currently a render callback registered.static boolean
isRealTimeUpdateEnabled()
boolean
isRGBMode()
boolean
processEvent(SoEvent event)
Processes the passed event by applying anSoHandleEventAction
to the scene graph managed here.void
reinitialize()
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
scheduleForcedRedraw()
Internal usage.void
scheduleRedraw()
Schedules a redraw for some time in the near future.void
setAbortRenderTask(SoSceneManager.AbortRenderTask task)
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
setAntialiasingEventListener(SiAntialiasingEventListener listener)
Sets an event listener which is called when the antialiasing configuration is modified.void
setAutoInteractiveMode(boolean flag)
Defines the auto interactive mode.void
setBackgroundColor(SbColor c)
Defines the window background color when in RGB mode.void
setBackgroundColorRGBA(SbColorRGBA color)
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
setGLRenderAction(SoGLRenderAction ra)
User supplied render action.void
setHandleEventAction(SoHandleEventAction hea)
User supplied handle event action.void
setInteractive(boolean flag)
Indicates that the scene manager is in interactive mode or not.void
setOrigin(SbVec2s newOrigin)
Defines the origin of the viewport within the window.void
setRedrawPriority(int priority)
Sets the priority of the redraw sensor.void
setRenderTask(java.lang.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
setShareContext(SbGLShareContext sc)
Calls setShareContext(sc, true).void
setShareContext(SbGLShareContext sc, boolean issc)
Sets the OpenGL context to be shared by the scene manager.void
setSize(SbVec2s newSize)
Calls setSize(newSize, (float)1.0).void
setSize(SbVec2s newSize, float newScale)
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
updateRealTimeSensor()
Internal usage.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Constructor Detail
-
SoSceneManager
@Deprecated(since="2024.2") public SoSceneManager(int nb)
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 Detail
-
setRenderTask
public void setRenderTask(java.lang.Runnable renderTask)
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
public void setAbortRenderTask(SoSceneManager.AbortRenderTask task)
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.
-
setWindowSize
public void setWindowSize(SbVec2s newSize)
Calls setWindowSize(newSize, (float)1.0).
-
render
@Deprecated(since="10.1.0.0") public void render(boolean clearWindow)
Deprecated.Calls render(clearWindow, true).
-
setShareContext
public void setShareContext(SbGLShareContext sc)
Calls setShareContext(sc, true).
-
setAntialiasing
public void setAntialiasing(float quality)
Calls setAntialiasing(quality, SoSceneManager.AntialiasingModes.valueOf( SoSceneManager.AntialiasingModes.AUTO.getValue() )).
-
setSize
public void setSize(SbVec2s newSize)
Calls setSize(newSize, (float)1.0).
-
setGLRenderAction
public void setGLRenderAction(SoGLRenderAction ra)
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
-
processEvent
public boolean processEvent(SoEvent event)
Processes the passed event by applying anSoHandleEventAction
to the scene graph managed here. Returns true if the event was handled by a node.
-
render
@Deprecated(since="10.1.0.0") public void render(boolean clearWindow, boolean clearZbuffer)
Deprecated.As of Open Inventor 10.1.0.0. No longer used and the parameters are ignored. Use render() instead.
-
getGLRenderAction
public SoGLRenderAction getGLRenderAction()
- Since:
- Open Inventor 9.2
- See Also:
setGLRenderAction()
-
setHandleEventAction
public void setHandleEventAction(SoHandleEventAction hea)
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
public void setSceneGraph(SoNode newScene)
Defines the scene graph which is managed here. This is the Open Inventor scene which will be traversed for rendering and event processing.
-
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.
-
reinitialize
public void reinitialize()
Reinitializes graphics. This should be called, for instance, when there is a new window.
-
getHandleEventAction
public SoHandleEventAction getHandleEventAction()
- Since:
- Open Inventor 9.2
- See Also:
setHandleEventAction()
-
enableRealTimeUpdate
public static void enableRealTimeUpdate(boolean flag)
Enables the realTime global field update which normally happen right after a redraw.
-
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
-
isRealTimeUpdateEnabled
public static boolean isRealTimeUpdateEnabled()
- See Also:
enableRealTimeUpdate()
-
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
-
setAntialiasing
@Deprecated(since="9.1.0.0") public void setAntialiasing(boolean smoothing, int numPasses)
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.
-
getDefaultRedrawPriority
public static int getDefaultRedrawPriority()
Gets the default priority of the redraw sensor.
-
getBackgroundColorRGBA
public SbColorRGBA getBackgroundColorRGBA()
- See Also:
setBackgroundColorRGBA()
-
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.
-
setBackgroundColorRGBA
public void setBackgroundColorRGBA(SbColorRGBA color)
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
-
setShareContext
public void setShareContext(SbGLShareContext sc, boolean issc)
Sets the OpenGL context to be shared by the scene manager. This avoids the necessity to re-generate textures and display lists if they are already available in another OpenGL context (another viewer context, for instance).
-
setBackgroundColor
public void setBackgroundColor(SbColor c)
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.
-
getRedrawPriority
public int getRedrawPriority()
- See Also:
setRedrawPriority()
-
getBackgroundColor
public SbColor getBackgroundColor()
- See Also:
setBackgroundColor()
-
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].
-
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.
-
getClearDepth
public float getClearDepth()
- See Also:
setClearDepth()
-
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
-
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.
-
getBackgroundIndex
public int getBackgroundIndex()
- See Also:
setBackgroundIndex()
-
isRGBMode
public boolean isRGBMode()
- See Also:
setRGBMode()
-
isAutoInteractiveMode
public boolean isAutoInteractiveMode()
- Since:
- Open Inventor 9.2
- See Also:
setAutoInteractiveMode()
-
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
-
getAntialiasingParameters
public SoAntialiasingParameters 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.
-
getWindowSize
public SbVec2s getWindowSize()
- See Also:
setWindowSize()
-
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.
-
setSize
public void setSize(SbVec2s newSize, float newScale)
Defines the size of the viewport within the window. Default is to render the entire window region.
-
getAntialiasingMode
public SoSceneManager.AntialiasingModes 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.
-
getSceneGraph
public SoNode getSceneGraph()
- See Also:
setSceneGraph()
-
getAntialiasingEventListener
public SiAntialiasingEventListener getAntialiasingEventListener()
- Returns:
- A pointer on the current antialiasing event listener, NULL if there is no listener.
- See Also:
setAntialiasingEventListener()
-
setWindowSize
public void setWindowSize(SbVec2s newSize, float newScale)
Defines the size of the window in which the scene manager should render. This size must be set beforerender()
andprocessEvent()
are called.
-
setAntialiasingEventListener
public void setAntialiasingEventListener(SiAntialiasingEventListener listener)
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.
-
setViewportRegion
public void setViewportRegion(SbViewportRegion newRegion)
Defines current viewport region to use for rendering. This can be used instead of setting the size and origin separately.
-
getStillSuperSamplingDelay
public float getStillSuperSamplingDelay()
- See Also:
setStillSuperSampling()
-
getViewportRegion
public SbViewportRegion getViewportRegion()
- See Also:
setViewportRegion()
-
getStillSuperSamplingQuality
public float getStillSuperSamplingQuality()
- See Also:
setStillSuperSampling()
-
getOrigin
public SbVec2s getOrigin()
- See Also:
setOrigin()
-
setAntialiasing
public void setAntialiasing(SoAntialiasingParameters advancedParameters)
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
-
setAntialiasing
public void setAntialiasing(float quality, SoSceneManager.AntialiasingModes mode)
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.
-
setOrigin
public void setOrigin(SbVec2s newOrigin)
Defines the origin of the viewport within the window. The origin (0,0) is the lower left corner of the window.
-
-