Workspace 7.1.0
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
SceneProcessor Class Reference

Abstract base class for all objects that can process a Scene. More...

#include <Rendering/SceneComponents/sceneprocessor.h>

Inheritance diagram for SceneProcessor:
[legend]

Public Member Functions

 ~SceneProcessor () override
 
bool visit (Annotation &annotation) override final
 
bool visit (Camera &camera) override final
 
bool visit (ClipRegion &clipRegion) override final
 
bool visit (Light &light) override final
 
bool visit (MeshModelInstance &model) override final
 
bool visit (SceneItemInstance &sceneItemInstance) override final
 
bool visit (Transform &transform) override final
 
- Public Member Functions inherited from SceneItemProcessor
 ~SceneItemProcessor () override
 
bool process (Scene &scene)
 
bool process (Transform &transform)
 
virtual bool visit (Annotation &annotation)
 
virtual bool visit (Camera &camera)
 
virtual bool visit (ClipRegion &clipRegion)
 
virtual bool visit (Light &light)
 
virtual bool visit (MeshModelInstance &model)
 
virtual bool visit (SceneItemInstance &sceneItemInstance)
 
virtual 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
 
- Static Public Attributes inherited from SceneItemProcessor
static const Application::LogManager::MessageCategory LOG_SCENEITEMPROCESSOR
 

Protected Member Functions

 SceneProcessor ()
 
 SceneProcessor (const SceneProcessor &p)
 
SceneProcessoroperator= (const SceneProcessor &p)
 
bool postVisits (Scene &scene) override
 
bool preVisits (Scene &scene) override
 
bool traverseScene (Scene &scene) override
 
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 SceneItemProcessor
 SceneItemProcessor ()
 
 SceneItemProcessor (const SceneItemProcessor &p)
 
bool isProcessing () const
 
SceneItemProcessoroperator= (const SceneItemProcessor &p)
 
virtual bool postVisits (Scene &scene)
 
virtual bool preVisits (Scene &scene)
 
virtual bool traverseScene (Scene &scene)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

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.

SceneProcessor is a specialization of SceneItemProcessor (which does very little without specialization). SceneProcessor makes some assumptions about how the user wants to process a scene, specifically in that it assumes that we wish to skip any scene item which is not enabled. A disabled item's children will also not be parsed. The visitImpl methods should be overriden to implement custom behaviour based on this premise.

Constructor & Destructor Documentation

◆ SceneProcessor() [1/2]

SceneProcessor ( )
protected

◆ SceneProcessor() [2/2]

SceneProcessor ( const SceneProcessor p)
protected

◆ ~SceneProcessor()

~SceneProcessor ( )
override

Member Function Documentation

◆ operator=()

SceneProcessor & operator= ( const SceneProcessor p)
protected
Parameters
pThe 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.

◆ postVisits()

bool postVisits ( Scene scene)
overrideprotectedvirtual
Parameters
sceneThe 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 from SceneItemProcessor.

Reimplemented in SceneTransformProcessor.

◆ preVisits()

bool preVisits ( Scene scene)
overrideprotectedvirtual
Parameters
sceneThe 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 from SceneItemProcessor.

Reimplemented in SceneTransformProcessor.

◆ traverseScene()

bool traverseScene ( Scene scene)
overrideprotectedvirtual
Parameters
sceneThe scene to traverse

Traverse the scene in some way. The default implementation will simply visit the root-group.

Reimplemented from SceneItemProcessor.

Reimplemented in SceneTransformProcessor.

◆ visit() [1/7]

bool visit ( Annotation annotation)
finaloverridevirtual
Parameters
annotationThe 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.

Reimplemented from SceneItemProcessor.

◆ visit() [2/7]

bool visit ( Camera camera)
finaloverridevirtual
Parameters
cameraThe 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.

Reimplemented from SceneItemProcessor.

◆ visit() [3/7]

bool visit ( ClipRegion clipRegion)
finaloverridevirtual
Parameters
clipRegionThe 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.

Reimplemented from SceneItemProcessor.

◆ visit() [4/7]

bool visit ( Light light)
finaloverridevirtual
Parameters
lightThe 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.

Reimplemented from SceneItemProcessor.

◆ visit() [5/7]

bool visit ( MeshModelInstance model)
finaloverridevirtual
Parameters
modelThe 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&).

Reimplemented from SceneItemProcessor.

◆ visit() [6/7]

bool visit ( SceneItemInstance sceneItemInstance)
finaloverridevirtual
Parameters
sceneItemInstanceThe 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.

Reimplemented from SceneItemProcessor.

◆ visit() [7/7]

bool visit ( Transform transform)
finaloverridevirtual
Parameters
transformThe 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.

Reimplemented from SceneItemProcessor.

◆ visitImpl() [1/7]

bool visitImpl ( Annotation annotation)
protectedvirtual
Parameters
annotationThe annotation to visit.
Note
This function will only be called if sceneItemInstance is enabled (this is controlled by the visit(Annotation&) function which is the only place visitImpl should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder.

◆ visitImpl() [2/7]

bool visitImpl ( Camera camera)
protectedvirtual
Parameters
cameraThe camera to visit.
Note
This function will only be called if camera is enabled (this is controlled by the visit(Camera &) function which is the only place visitImpl(Camera&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ visitImpl() [3/7]

bool visitImpl ( ClipRegion clipRegion)
protectedvirtual
Parameters
clipRegionThe clip region to visit.
Note
This function will only be called if clipRegion is enabled (this is controlled by the visit(ClipRegion&) function which is the only place visitImpl(ClipRegion&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ visitImpl() [4/7]

bool visitImpl ( Light light)
protectedvirtual
Parameters
lightThe light to visit.
Note
This function will only be called if light is enabled (this is controlled by the visit(Light&) function which is the only place visitImpl(Light&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder.

◆ visitImpl() [5/7]

bool visitImpl ( MeshModelInstance modelInstance)
protectedvirtual
Parameters
modelInstanceThe model to visit.
Note
This function will only be called if modelInstance is enabled (this is controlled by the visit(MeshModelInstance&) function which is the only place visitImpl(MeshModelInstance&) should be called from).

The default implementation does nothing. Most subclasses will override this function.

Reimplemented in WSGLRenderQueueBuilder, and SceneBoundingBoxCalculator.

◆ visitImpl() [6/7]

bool visitImpl ( SceneItemInstance sceneItemInstance)
protectedvirtual
Parameters
sceneItemInstanceThe sceneItemInstance to visit.
Note
This function will only be called if sceneItemInstance is enabled (this is controlled by the visit(SceneItemInstance&) function which is the only place visitImpl(SceneItemInstance&) should be called from).

The default implementation does nothing.

Reimplemented in WSGLRenderQueueBuilder, and SceneTransformProcessor.

◆ visitImpl() [7/7]

bool visitImpl ( Transform transform)
protectedvirtual
Parameters
transformThe transform to visit.
Note
This function will only be called if transform is enabled (this is controlled by the visit(Transform&) function which is the only place visitImpl(Transform&) should be called from).

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.

Member Data Documentation

◆ LOG_SCENEPROCESSOR

const Application::LogManager::MessageCategory LOG_SCENEPROCESSOR
static