Workspace 6.21.5
|
Abstract base class for all objects that can process a Scene. More...
#include <Rendering/SceneComponents/sceneprocessor.h>
Public Member Functions | |
~SceneProcessor () override | |
bool | process (Scene &scene) |
bool | process (Transform &transform) |
bool | visit (Annotation &annotation) |
bool | visit (Camera &camera) |
bool | visit (ClipRegion &clipRegion) |
bool | visit (Light &light) |
bool | visit (MeshModelInstance &model) |
bool | visit (SceneItemInstance &sceneItemInstance) |
bool | visit (Transform &transform) |
Public Member Functions inherited from Observable | |
virtual | ~Observable () |
void | attachObserver (Observer &observer) |
void | destroy () |
void | detachObserver (Observer &observer) |
void | notifyEvent (const ObservableEvent &event) |
Static Public Attributes | |
static const Application::LogManager::MessageCategory | LOG_SCENEPROCESSOR |
Protected Member Functions | |
SceneProcessor () | |
SceneProcessor (const SceneProcessor &p) | |
SceneProcessor & | operator= (const SceneProcessor &p) |
virtual bool | postVisits (Scene &scene) |
virtual bool | preVisits (Scene &scene) |
virtual bool | traverseScene (Scene &scene) |
virtual bool | visitImpl (Annotation &annotation) |
virtual bool | visitImpl (Camera &camera) |
virtual bool | visitImpl (ClipRegion &clipRegion) |
virtual bool | visitImpl (Light &light) |
virtual bool | visitImpl (MeshModelInstance &modelInstance) |
virtual bool | visitImpl (SceneItemInstance &sceneItemInstance) |
virtual bool | visitImpl (Transform &transform) |
Protected Member Functions inherited from Observable | |
Observable () | |
Observable (const Observable &) | |
A SceneProcessor object can do more or less anything with the Scene. This base class exists to allow novel use of things like the visitor design pattern with arbitrary operations on scene objects. A common subclass implementation would be to render the scene somehow, but other operations such as applying some kind of movement to the scene or updating certain properties of objects in the scene would be just as valid.
See process() for more details about how the scene processor is intended to be implemented and used.
|
protected |
|
protected |
|
override |
|
protected |
p | The scene processor to copy from. |
This assignment operator must not be called while executing a call to process(). It is allowable though for p to be currently executing such a call.
|
protectedvirtual |
scene | The scene being visited. |
This function should only ever be called by process(). Client code should not call it directly. The default implementation performs a check on this condition and returns true
if the function is being called within a call to process(), or false
otherwise. The default implementation performs no other action.
Subclasses may wish to provide their own implementation for postVisits() in order to clean up internal data structures or finalize some aspect of the processing. They are not required to call this base class implementation if they do so.
Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.
|
protectedvirtual |
scene | The scene being visited. |
This function should only ever be called by process(). Client code should not call it directly. The default implementation performs a check on this condition and returns true
if the function is being called within a call to process(), or false
otherwise. The default implementation performs no other action.
Subclasses may wish to provide their own implementation for preVisits() in order to set up their own internal data structures. They are not required to call this base class implementation if they do so.
Reimplemented in WSGLRenderQueueBuilder, SceneBoundingBoxCalculator, and SceneTransformProcessor.
bool process | ( | Scene & | scene | ) |
scene | The scene to be processed. |
Clients should call this function when they want to invoke the scene processor on scene. It will first call preVisits() to give the processor a chance to set internal data structures in preparation for a pass over the scene. If this returns false
, process() fails and also returns false
immediately.
If preVisits() succeeds, the function then calls visit() on the root transform of the scene. Again, if this returns false
, then process() fails and returns false immediately.
If the call to visit() also succeeds, then the function calls postVisits() and returns its result. The purpose of postVisits() is to give the scene processor a chance to clean up after its pass over the scene. Another common use is to use the pass over the scene as a means of gathering information about the scene and then in the call to postVisits(), the processor carries out the main task because it has all the information about the scene at that point.
bool process | ( | Transform & | transform | ) |
|
protectedvirtual |
scene | The scene to traverse |
Traverse the scene in some way. The default implementation will simply visit the root-group.
Reimplemented in SceneTransformProcessor.
bool visit | ( | Annotation & | annotation | ) |
annotation | The annotation to visit. |
This function will only ever be called by the annotation being visited. If the annotation is not enabled, or the scene processor is not currently 'processing' items, the call will fail.
bool visit | ( | Camera & | camera | ) |
camera | The camera scene item to visit. |
This function should only ever be called by the camera object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.
After checking whether this call is part of a call to process(), the function then checks if camera is currently enabled. If it is, then it calls the virtual visitImpl(Camera&) function. Subclasses must provide their own implementation for visitImpl(Camera &) if they can process camera scene items.
Enabling a camera is not the same as using it. Many scene processors will not provide their own implementation of visitImpl(Camera&), so the enable/disable state for a camera often has little effect. For those scene processors that do process cameras, it is up to them what enabling or disabling a camera means. Quite often, for a renderer this will correspond to whether or not some visual representation of the camera should be included in the render, but you should consult the documentation of the scene processor you are interested in before relying on this.
bool visit | ( | ClipRegion & | clipRegion | ) |
clipRegion | The clipRegion scene item to visit. |
This function should only ever by called by the clipRegion object being passed as the parameter, and only as part of the call to process(). Any attempt to call the function outside of process() will fail.
After checking whether this call is part of a call to process(), the function then checks if clipRegion is currently visible or enabled. If it is, then it calls the virtual visitImpl(ClipRegion&) function. Subclasses must provide their own implementation for visitImpl(ClipRegion&) if they can process clipRegion scene items.
bool visit | ( | Light & | light | ) |
light | The light scene item to visit. |
This function should only ever be called by the light object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.
After checking whether this call is part of a call to process(), the function then checks if light is currently enabled. If it is, then it calls the virtual visitImpl(Light&) function. Subclasses must provide their own implementation for visitImpl(Light&) if they can process light scene items.
bool visit | ( | MeshModelInstance & | model | ) |
model | The model scene item to visit. |
This function should only ever be called by the model object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.
After checking whether this call is part of a call to process(), the function then checks if model is currently enabled. If it is, then it calls the virtual visitImpl(MeshModelInstance&) function. Subclasses must provide their own implementation for visitImpl(MeshModelInstance&) if they can process model scene items. Since models are usually the main objects in a scene, it would be unusual for a scene processor to not provide their own implementation for visitImpl(MeshModelInstance&).
bool visit | ( | SceneItemInstance & | sceneItemInstance | ) |
sceneItemInstance | The sceneItemInstance scene item to visit. |
This function should only ever by called by the sceneItemInstance object being passed as the parameter, and only as part of the call to process(). Any attempt to call the function outside of process() will fail.
After checking whether this call is part of a call to process(), the function then checks if sceneItemInstance is currently enabled. If it is, then it calls the virtual visitImpl(SceneItemInstance&) function. Subclasses must provide their own implementation for visitImpl(SceneItemInstance&) if they can process sceneItemInstance scene items.
bool visit | ( | Transform & | transform | ) |
transform | The transform to visit. |
This function should only ever be called by the transform object being passed as the parameter, and only as part of a call to process(). Any attempt to call the function outside of process() will fail.
After checking whether this call is part of a call to process(), the function then checks if transform is currently enabled. If it is, then it calls the virtual visitImpl(Transform&) function. Subclasses can provide their own implementation for visitImpl(Transform&) to handle transforms in some custom way, but the default implementation will often be sufficient. Note that if transform is not enabled, visitImpl(Transform&) is not called and this normally means that all children of transform are also not visited.
|
protectedvirtual |
annotation | The annotation to visit. |
The default implementation does nothing.
Reimplemented in WSGLRenderQueueBuilder.
|
protectedvirtual |
camera | The camera to visit. |
The default implementation does nothing.
Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.
|
protectedvirtual |
clipRegion | The clip region to visit. |
The default implementation does nothing.
Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.
|
protectedvirtual |
light | The light to visit. |
The default implementation does nothing.
Reimplemented in WSGLRenderQueueBuilder.
|
protectedvirtual |
modelInstance | The model to visit. |
The default implementation does nothing. Most subclasses will override this function.
Reimplemented in WSGLRenderQueueBuilder, and SceneBoundingBoxCalculator.
|
protectedvirtual |
sceneItemInstance | The sceneItemInstance to visit. |
The default implementation does nothing.
Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.
|
protectedvirtual |
transform | The transform to visit. |
The default implementation visits each of the transform's immediate children. If subclasses need to record under what transform they are currently processing, they will most likely need to override this function. If doing so, subclasses should endeavour to implement their overridden function in terms of the default implementation specified here, since this gives consistent behavior and also provides the benefit of a few consistency checks.
Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.
|
static |