Manages scene graph rendering and event handling. More...
#include <Inventor/SoSceneManager.h>
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 / SoQt or SoWx libraries.
SoWinRenderArea, SoGLRenderAction, SoHandleEventAction
Enum which indicates the desired antialiasing algorithm.
This is used by the antialiasing API.
AUTO |
This is the default mode for antialiasing. The different algorithms are tested in the following order and the first available is used: SMAA, FSAA, SUPERSAMPLING. |
FXAA |
FXAA is a screen space antialiasing algorithm which uses shaders and is applied after the rendering. The main advantages of this technique are reduced memory footprint and cost. |
SMAA |
SMAA is a screen space antialiasing algorithm which uses shaders and is applied after the rendering. The main advantages of this technique are reduced memory footprint and cost with better quality result than FXAA algorithm. |
FSAA |
FSAA is a full-screen antialiasing algorithm based on super-sampling. The main advantage is the quality of the antialiasing but the memory and speed cost can be huge.
|
SUPERSAMPLING |
The advantage of this algorithm is it gives high quality images even on lines. However multiple rendering passes are required, which reduces performance. (Old name was ACCUM_BUFFERS.) |
ACCUM_BUFFERS |
Deprecated name of SUPERSAMPLING.
|
NO_ANTIALIASING |
Turn off antialiasing. |
SoSceneManager::SoSceneManager | ( | int | nb = 1 |
) |
Constructor.
virtual SoSceneManager::~SoSceneManager | ( | ) | [virtual] |
Destructor.
virtual void SoSceneManager::activate | ( | ) | [virtual] |
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.
virtual void SoSceneManager::deactivate | ( | ) | [virtual] |
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.
static void SoSceneManager::enableRealTimeUpdate | ( | SbBool | flag | ) | [static] |
Enables the realTime global field update which normally happen right after a redraw.
SoDEPRECATED void SoSceneManager::getAntialiasing | ( | SbBool & | smoothing, | |
int & | numPasses | |||
) | const |
Gets the antialiasing used for rendering.
SiAntialiasingEventListener* SoSceneManager::getAntialiasingEventListener | ( | ) | const |
Returns the current antialiasing listener.
AntialiasingMode SoSceneManager::getAntialiasingMode | ( | ) | const |
Returns the antialiasing mode set using the setAntialiasing(float,AntialiasingMode) method.
Returns AUTO by default. Parameters set using the setAntialiasing(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.
SoAntialiasingParameters* SoSceneManager::getAntialiasingParameters | ( | ) | const |
Returns the antialiasing parameters set using the setAntialiasing(SoAntialiasingParameters*) method.
Returns null by default. A quality value set using the setAntialiasing(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.
float SoSceneManager::getAntialiasingQuality | ( | ) | const |
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.
const SbColor& SoSceneManager::getBackgroundColor | ( | ) | const |
Gets the window background color when in RGB mode.
SbColorRGBA SoSceneManager::getBackgroundColorRGBA | ( | ) | const |
int SoSceneManager::getBackgroundIndex | ( | ) | const |
Gets the window background color when in color index mode.
float SoSceneManager::getClearDepth | ( | ) | const |
static uint32_t SoSceneManager::getDefaultRedrawPriority | ( | ) | [inline, static] |
Gets the default priority of the redraw sensor.
SoGLRenderAction* SoSceneManager::getGLRenderAction | ( | ) | const |
Gets the GLRenderAction used for rendering. Since Open Inventor 9.2
SoHandleEventAction* SoSceneManager::getHandleEventAction | ( | ) | const |
Gets the HandleEventAction used. Since Open Inventor 9.2
const SbVec2s& SoSceneManager::getOrigin | ( | ) | const |
Gets the origin of the viewport within the window.
uint32_t SoSceneManager::getRedrawPriority | ( | ) | const |
Gets the priority of the redraw sensor.
virtual SoNode* SoSceneManager::getSceneGraph | ( | ) | const [virtual] |
Gets the scene graph which is managed here.
This is the Open Inventor scene which will be traversed for rendering and event processing.
const SbVec2s& SoSceneManager::getSize | ( | ) | const |
Gets the size of the viewport within the window.
float SoSceneManager::getStillSuperSamplingDelay | ( | ) |
float SoSceneManager::getStillSuperSamplingQuality | ( | ) |
const SbViewportRegion& SoSceneManager::getViewportRegion | ( | ) | const |
Gets current viewport region used for rendering.
const SbVec2s& SoSceneManager::getWindowSize | ( | ) | const |
Gets the size of the window in which the scene manager should render.
SbBool SoSceneManager::isAutoInteractiveMode | ( | ) | const |
Returns TRUE if auto interactive mode is enabled. Since Open Inventor 9.2
SbBool SoSceneManager::isAutoRedraw | ( | ) | const |
Returns TRUE if there is currently a render callback registered.
static SbBool SoSceneManager::isRealTimeUpdateEnabled | ( | ) | [static] |
Returns whether realTime global field updating is enabled.
SbBool SoSceneManager::isRGBMode | ( | ) | const |
Gets the color mode (TRUE - RGB mode, FALSE - color map mode).
Processes the passed event by applying an SoHandleEventAction to the scene graph managed here.
Returns TRUE if the event was handled by a node.
void SoSceneManager::reinitialize | ( | ) |
Reinitializes graphics.
This should be called, for instance, when there is a new window.
virtual void SoSceneManager::render | ( | SbBool | clearWindow = TRUE , |
|
SbBool | clearZbuffer = TRUE | |||
) | [virtual] |
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.
viewer->bindNormalContext(); viewer->getSceneManager()->render(); viewer->unbindNormalContext();
SoGLContext* ctx = SoGLContext::getCurrent( true ); ctx->bind(); viewer->getSceneManager()->render( FALSE, FALSE ); ctx->unbind();
clearWindow | If TRUE clears the graphics window before rendering. | |
clearZbuffer | If TRUE clears the depth buffer before rendering. |
void SoSceneManager::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.
void SoSceneManager::setAbortRenderCallback | ( | SoAbortRenderCB * | callback, | |
void * | userData = NULL | |||
) |
Setup a callback that returns TRUE if rendering should be aborted.
It allows some Open Inventor nodes to stop their work, if requested, in order to keep reasonable interactivity.
When using Open Inventor standard GUI classes, the callback is setup by default to return TRUE if MousePress events are pending during a STILL frame.
Since Open Inventor 9.5SoDEPRECATED void SoSceneManager::setAntialiasing | ( | SbBool | smoothing, | |
int | numPasses | |||
) |
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.
void SoSceneManager::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.
advancedParameters | Provides specific parameters for an antialiasing mode. Use a null parameter to turn off antialiasing or use one of the subclasses of SoAntialiasingParameters. |
void SoSceneManager::setAntialiasing | ( | const float | quality, | |
const AntialiasingMode | mode = AUTO | |||
) |
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).
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. |
void SoSceneManager::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).
listener | The listener object. |
void SoSceneManager::setAutoInteractiveMode | ( | SbBool | flag | ) |
Activate 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.2void SoSceneManager::setBackgroundColor | ( | const SbColor & | c | ) |
Sets the window background color when in RGB mode.
This is the color the scene manager viewport is cleared to when render() is called with its clearWindow parameter set to TRUE . 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.
void SoSceneManager::setBackgroundColorRGBA | ( | const 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 with its clearWindow parameter set to TRUE . 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().
color | RGBA background color |
void SoSceneManager::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 with its clearWindow parameter set to TRUE . Default is black (index 0).
void SoSceneManager::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 with its clearZbuffer parameter set to TRUE .
depth | value used to clear the depth buffer. Value is clamped to the range [0,1]. |
void SoSceneManager::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.2void SoSceneManager::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.2void SoSceneManager::setInteractive | ( | SbBool | 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.2void SoSceneManager::setOrigin | ( | const SbVec2s & | newOrigin | ) |
Sets the origin of the viewport within the window.
The origin (0,0) is the lower left corner of the window.
void SoSceneManager::setRedrawPriority | ( | uint32_t | 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.
void SoSceneManager::setRenderCallback | ( | SoSceneManagerRenderCB * | f, | |
void * | userData = NULL | |||
) |
The render callback provides a mechanism for automatically redrawing the scene in response to changes in the scene graph.
The scene manager employs a sensor to detect scene graph changes. When the sensor is triggered, the render callback registered here is invoked. If the callback is set to NULL (the default), auto-redraw is turned off.
If the application is not using an Open Inventor render area or viewer, the callback should make sure that an OpenGL render context is current, then call the scene manager render() method. See the render() method for more information.
If the application is using an Open Inventor render area or viewer, then the callback should call render() method on the render area or viewer object.
The callback should not modify any nodes in the scene graph before or after calling the render() method. The modification will be detected by the scene manager, which will schedule another call to the render callback, resulting in continuous calls to the render callback. If necessary the callback can temporarily disable notification by calling enableNotify() on the node that will be modified.
void SoSceneManager::setRGBMode | ( | SbBool | onOrOff | ) |
Sets 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.
virtual void SoSceneManager::setSceneGraph | ( | SoNode * | newScene | ) | [virtual] |
Sets the scene graph which is managed here.
This is the Open Inventor scene which will be traversed for rendering and event processing.
void SoSceneManager::setShareContext | ( | SbGLShareContext | sc, | |
SbBool | issc = TRUE | |||
) |
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).
void SoSceneManager::setSize | ( | const SbVec2s & | newSize, | |
const float & | newScale = 1.0 | |||
) |
Sets the size of the viewport within the window.
Default is to render the entire window region.
void SoSceneManager::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.
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 |
void SoSceneManager::setViewportRegion | ( | const SbViewportRegion & | newRegion | ) |
Sets current viewport region to use for rendering.
This can be used instead of setting the size and origin separately.
void SoSceneManager::setWindowSize | ( | const SbVec2s & | newSize, | |
const float & | newScale = 1.0 | |||
) |
Sets the size of the window in which the scene manager should render.
This size must be set before render() and processEvent() are called.
friend class SoGuiRenderArea [friend] |
friend class SoRenderAreaCoreImpl [friend] |