Manages scene graph rendering and event handling. More...
#include <Inventor/SoSceneManager.h>
Public Types | |
enum | AntialiasingMode { AUTO , FXAA , SMAA , FSAA , SUPERSAMPLING , ACCUM_BUFFERS = SUPERSAMPLING , NO_ANTIALIASING } |
Enum which indicates the desired antialiasing algorithm. More... | |
Public Member Functions | |
SoSceneManager (int nb=1) | |
Constructor. | |
virtual | ~SoSceneManager () |
Destructor. | |
virtual void | render () |
Applies an SoGLRenderAction to the scene graph managed here. | |
virtual SbBool | processEvent (const SoEvent *event) |
Processes the passed event by applying an SoHandleEventAction to the scene graph managed here. | |
void | reinitialize () |
Reinitializes graphics. | |
void | scheduleRedraw () |
Schedules a redraw for some time in the near future. | |
virtual void | setSceneGraph (SoNode *newScene) |
Defines the scene graph which is managed here. | |
virtual SoNode * | getSceneGraph () const |
void | setWindowSize (const SbVec2s &newSize, const float &newScale=1.0) |
Defines the size of the window in which the scene manager should render. | |
const SbVec2s & | getWindowSize () const |
void | setSize (const SbVec2s &newSize, const float &newScale=1.0) |
Defines the size of the viewport within the window. | |
const SbVec2s & | getSize () const |
void | setOrigin (const SbVec2s &newOrigin) |
Defines the origin of the viewport within the window. | |
const SbVec2s & | getOrigin () const |
void | setViewportRegion (const SbViewportRegion &newRegion) |
Defines current viewport region to use for rendering. | |
const SbViewportRegion & | getViewportRegion () const |
void | setBackgroundColor (const SbColor &c) |
Defines the window background color when in RGB mode. | |
SbColor | getBackgroundColor () const |
void | setBackgroundColorRGBA (const SbColorRGBA &color) |
Defines the window background color when in RGBA mode. | |
SbColorRGBA | getBackgroundColorRGBA () const |
void | setBackgroundIndex (int index) |
Defines the window background color when in color index mode. | |
int | getBackgroundIndex () const |
void | setRGBMode (SbBool onOrOff) |
Defines the color mode (TRUE - RGB mode, FALSE - color map mode). | |
SbBool | isRGBMode () const |
void | setClearDepth (float depth) |
Defines the depth value used when the depth buffer is cleared. | |
float | getClearDepth () const |
virtual void | activate () |
Activates the scene manager. | |
virtual void | deactivate () |
Deactivates the scene manager. | |
void | setAutoInteractiveMode (SbBool flag) |
Defines the auto interactive mode. | |
SbBool | isAutoInteractiveMode () const |
void | setInteractive (SbBool flag) |
Indicates that the scene manager is in interactive mode or not. | |
void | 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. | |
SbBool | isAutoRedraw () const |
Returns TRUE if there is currently a render callback registered. | |
void | setRedrawPriority (uint32_t priority) |
Sets the priority of the redraw sensor. | |
uint32_t | getRedrawPriority () const |
void | setShareContext (SbGLShareContext sc, SbBool issc=TRUE) |
Sets the OpenGL context to be shared by the scene manager. | |
void | setStillSuperSampling (float quality, float delay) |
Set options for supersampling when "still" (not interacting). | |
float | getStillSuperSamplingQuality () |
float | getStillSuperSamplingDelay () |
void | setAntialiasing (const float quality, const AntialiasingMode mode=AUTO) |
Enable (or disable) antialiasing with specified quality and mode. | |
void | setAntialiasing (SoAntialiasingParameters *advancedParameters) |
Enable (or disable) antialiasing with specific parameters. | |
float | getAntialiasingQuality () const |
Returns the antialiasing quality set using the setAntialiasing(float,AntialiasingMode) method. | |
SoAntialiasingParameters * | getAntialiasingParameters () const |
Returns the antialiasing parameters set using the setAntialiasing(SoAntialiasingParameters*) method. | |
AntialiasingMode | getAntialiasingMode () const |
Returns the antialiasing mode set using the setAntialiasing(float,AntialiasingMode) method. | |
void | setAntialiasingEventListener (SiAntialiasingEventListener *listener) |
Sets an event listener which is called when the antialiasing configuration is modified. | |
SiAntialiasingEventListener * | getAntialiasingEventListener () const |
void | setHandleEventAction (SoHandleEventAction *hea) |
User supplied handle event action. | |
SoHandleEventAction * | getHandleEventAction () const |
void | setGLRenderAction (SoGLRenderAction *ra) |
User supplied render action. | |
SoGLRenderAction * | getGLRenderAction () const |
void | setAbortRenderCallback (SoAbortRenderCB *callback, void *userData=NULL) |
Setup a callback that returns TRUE if rendering should be aborted. | |
Deprecated | |
virtual SoDEPRECATED void | render (SbBool clearWindow, SbBool clearZbuffer=TRUE) |
SoDEPRECATED void | setAntialiasing (SbBool smoothing, int numPasses) |
Enables smoothing and/or multi-pass antialiasing for rendering. | |
SoDEPRECATED void | getAntialiasing (SbBool &smoothing, int &numPasses) const |
Static Public Member Functions | |
static uint32_t | getDefaultRedrawPriority () |
Gets the default priority of the redraw sensor. | |
static void | enableRealTimeUpdate (SbBool flag) |
Enables the realTime global field update which normally happen right after a redraw. | |
static SbBool | isRealTimeUpdateEnabled () |
Friends | |
class | SoGuiRenderArea |
class | SoRenderAreaCoreImpl |
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.
SoWinRenderArea, SoGLRenderAction, SoHandleEventAction
Definition at line 144 of file SoSceneManager.h.
Enum which indicates the desired antialiasing algorithm.
This is used by the antialiasing API.
Enumerator | |
---|---|
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. |
Definition at line 488 of file SoSceneManager.h.
SoSceneManager::SoSceneManager | ( | int | nb = 1 | ) |
Constructor.
|
virtual |
Destructor.
|
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 |
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 |
Enables the realTime global field update which normally happen right after a redraw.
SoDEPRECATED void SoSceneManager::getAntialiasing | ( | SbBool & | smoothing, |
int & | numPasses | ||
) | const |
SiAntialiasingEventListener * SoSceneManager::getAntialiasingEventListener | ( | ) | const |
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.
SbColor SoSceneManager::getBackgroundColor | ( | ) | const |
SbColorRGBA SoSceneManager::getBackgroundColorRGBA | ( | ) | const |
int SoSceneManager::getBackgroundIndex | ( | ) | const |
float SoSceneManager::getClearDepth | ( | ) | const |
|
inlinestatic |
Gets the default priority of the redraw sensor.
Definition at line 462 of file SoSceneManager.h.
SoGLRenderAction * SoSceneManager::getGLRenderAction | ( | ) | const |
SoHandleEventAction * SoSceneManager::getHandleEventAction | ( | ) | const |
const SbVec2s & SoSceneManager::getOrigin | ( | ) | const |
uint32_t SoSceneManager::getRedrawPriority | ( | ) | const |
|
virtual |
float SoSceneManager::getStillSuperSamplingDelay | ( | ) |
float SoSceneManager::getStillSuperSamplingQuality | ( | ) |
const SbViewportRegion & SoSceneManager::getViewportRegion | ( | ) | const |
const SbVec2s & SoSceneManager::getWindowSize | ( | ) | const |
SbBool SoSceneManager::isAutoInteractiveMode | ( | ) | const |
SbBool SoSceneManager::isAutoRedraw | ( | ) | const |
Returns TRUE if there is currently a render callback registered.
|
static |
SbBool SoSceneManager::isRGBMode | ( | ) | const |
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 |
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.
|
virtual |
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.
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. |
SoDEPRECATED 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::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 | ) |
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.
void SoSceneManager::setBackgroundColor | ( | const 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.
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. 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. 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.
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.
void 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.
void 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).
void SoSceneManager::setOrigin | ( | const SbVec2s & | newOrigin | ) |
Defines 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 | ) |
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.
|
virtual |
Defines 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 |
||
) |
Defines 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 | ) |
Defines 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 |
||
) |
Defines the size of the window in which the scene manager should render.
This size must be set before render() and processEvent() are called.
|
friend |
Definition at line 772 of file SoSceneManager.h.
|
friend |
Definition at line 773 of file SoSceneManager.h.