Class 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. The SoWinRenderArea class employs an 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 / SoWin or SoQt libraries.

    See Also:
    SoWinRenderArea, SoGLRenderAction, SoHandleEventAction
    • Constructor Detail

      • SoSceneManager

        public SoSceneManager()
        Calls SoSceneManager((int)1).
      • SoSceneManager

        public SoSceneManager​(int nb)
        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.
      • 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).
      • render

        @Deprecated
        public void render​(boolean clearWindow)
        Deprecated.
        Calls render(clearWindow, true).
      • setWindowSize

        public void setWindowSize​(SbVec2s newSize)
        Calls setWindowSize(newSize, (float)1.0).
      • 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.
      • setAntialiasing

        @Deprecated
        public void setAntialiasing​(boolean smoothing,
                                    int numPasses)
        Deprecated.
        As of Open Inventor 9100. 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 the setAntialiasing(SoAntialiasingParameters*) method with an SoAccumulationAntialiasingParameters object.

      • 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.
      • 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

      • 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 before render() and processEvent() are called.
      • 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

      • render

        public void render()
        Applies an SoGLRenderAction to the scene graph managed here. Note that this method just applies an SoGLRenderAction 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 an SoGLContext 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.)
      • enableRealTimeUpdate

        public static void enableRealTimeUpdate​(boolean flag)
        Enables the realTime global field update which normally happen right after a redraw.
      • reinitialize

        public void reinitialize()
        Reinitializes graphics. This should be called, for instance, when there is a new window.
      • getDefaultRedrawPriority

        public static int getDefaultRedrawPriority()
        Gets the default priority of the redraw sensor.
      • processEvent

        public boolean processEvent​(SoEvent event)
        Processes the passed event by applying an SoHandleEventAction to the scene graph managed here. Returns true if the event was handled by a node.
      • 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 of SoLightModel should be set to BASE_COLOR ), and the SoColorIndex node should be used to specify colors.
      • 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 when render() is called. Default is black (index 0).
      • 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
      • 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 when render() 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).
      • 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

      • 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.
      • 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.
      • isRGBMode

        public boolean isRGBMode()
        See Also:
        setRGBMode()
      • isAutoRedraw

        public boolean isAutoRedraw()
        Returns true if there is currently a render callback registered.
      • 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 when render() 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

      • 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.
      • 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.
      • 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.
      • 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 when render() is called. Default is black (0,0,0). See also setBackgroundColorRGBA().

        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

        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 the setAntialiasing(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.
      • 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.
      • getAntialiasingQuality

        public float getAntialiasingQuality()
        Returns the antialiasing quality set using the setAntialiasing(float,AntialiasingMode) method. Returns 0.0 by default. Parameters set using the setAntialiasing(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.
      • setAntialiasing

        public void setAntialiasing​(SoAntialiasingParameters advancedParameters)
        Enable (or disable) antialiasing with specific parameters. Use one of the subclasses of SoAntialiasingParameters. The antialiasing mode is determined by which subclass is used to set the parameters. For example, passing an SoFXAAParameters object automatically sets FXAA mode. Note that the parameters are overridden if a quality and mode are subsequently set using the setAntialiasing(float,AntialiasingMode) method.

        NOTES

        Parameters:
        advancedParameters - Provides specific parameters for an antialiasing mode.
        Use a null parameter to turn off antialiasing or use one of the subclasses of SoAntialiasingParameters.