Workspace 6.21.5
Public Member Functions | List of all members
Scene Class Reference

Scene class which can hold lights, cameras and transforms. More...

#include <Rendering/SceneComponents/scene.h>

Inheritance diagram for Scene:
[legend]

Public Member Functions

 Scene ()
 
 ~Scene () override
 
void add (SceneOverlay &overlay)
 
void added (Camera &camera)
 
void added (Light &light)
 
void addInternalSource (Mesh::MeshModelSource &source)
 
void clear ()
 
void deregisterSceneItem (const SceneItem &item)
 
CameragetCamera (const QString &name="Default", bool enabledOnly=false)
 
CameragetCamera (unsigned i)
 
const RenderSettingsgetDefaultRenderSettings () const
 
LightgetLight (unsigned i)
 
Mesh::MeshModelLibrarygetMeshModelLibrary ()
 
unsigned getNumSceneOverlays () const
 
TransformgetRootTransform ()
 
const TransformgetRootTransform () const
 
SceneItemLibrarygetSceneItemLibrary ()
 
const QString & getSceneItemOpIdPath (const SceneItem &item) const
 
const SceneItemgetSceneItemWithOpIdPath (const QString &opIdPath) const
 
const SceneOverlaygetSceneOverlay (unsigned index) const
 
ShaderLibrarygetShaderLibrary ()
 
bool hasSceneOverlays () const
 
unsigned numCameras () const
 
unsigned numLights () const
 
void registerSceneItem (const SceneItem &item, const QString &opIdPath)
 
void remove (SceneOverlay &overlay)
 
void removed (Camera &camera)
 
void removed (Light &light)
 
void removeInternalSource (Mesh::MeshModelSource &source)
 
void setDefaultRenderSettings (const RenderSettings &settings)
 
void setMeshModelLibrary (Mesh::MeshModelLibrary *library)
 
void setSceneItemLibrary (SceneItemLibrary *library)
 
void setShaderLibrary (ShaderLibrary *library)
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 

Additional Inherited Members

- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

A Scene does not hold models directly, but rather models must be added as children of a transform to place them in the scene.

Constructor & Destructor Documentation

◆ Scene()

Scene ( )

◆ ~Scene()

~Scene ( )
override

Member Function Documentation

◆ add()

void add ( SceneOverlay overlay)
Parameters
overlayThe image overlay being added to the scene.

Image overlays are not really part of the scene itself, but rather they are intended to be overlaid in front of the rendered image when the scene is being rendered. They will be overlaid in the order in which they are added to the scene, so clients should be careful about how they add and remove image overlays.

◆ added() [1/2]

void added ( Camera camera)
Parameters
cameraThe camera being added to the scene.

◆ added() [2/2]

void added ( Light light)
Parameters
lightThe light being added to the scene.

◆ addInternalSource()

void addInternalSource ( Mesh::MeshModelSource source)
Parameters
sourceA model source to be added to the scene's internal list of sources.

This function should only be called by MeshModelInstance. It will be called when the private model source for the proxy is set or changed or when the proxy is added to the scene.

◆ clear()

void clear ( )

Clears all SceneItem objects and image overlays from the scene. Nothing is deleted - this function merely clears the list of scene items and image overlays. It is up to the caller to look after ownership of the items and overlays themselves.

◆ deregisterSceneItem()

void deregisterSceneItem ( const SceneItem item)

◆ getCamera() [1/2]

Camera * getCamera ( const QString &  name = "Default",
bool  enabledOnly = false 
)
Parameters
nameThe name of the camera to try to find
enabledOnlyRetrieve only cameras that are enabled.
Returns
A camera stored in the scene with the specified name, or a null pointer if no camera with the specified name could be found. If more than one camera has the specified name, it is undefined which one will be returned (but it is guaranteed that one of them will be).

◆ getCamera() [2/2]

Camera * getCamera ( unsigned  i)
Parameters
iThe index of the camera to retrieve. No check is performed on whether this index is valid (that is the caller's responsibility).
Returns
The camera at the specified index.

◆ getDefaultRenderSettings()

const RenderSettings & getDefaultRenderSettings ( ) const
Returns
settings The default render settings to use for rendering the scene.

◆ getLight()

Light & getLight ( unsigned  i)
Parameters
iThe index of the light to retrieve. It is the caller's responsibility to ensure that this is strictly less than the number of lights in the scene as returned from numLights().
Returns
The light at the specified index, i.

◆ getMeshModelLibrary()

Mesh::MeshModelLibrary & getMeshModelLibrary ( )
Returns
The MeshModelLibrary used by the scene.

It should be noted that this will never be the same library as any library passed to setMeshModelLibrary(). This is because the scene has its own internal model library which it uses to hold model sources it manages for itself. Any library passed to setMeshModelLibrary() will be included as a sub-library of the return value of getMeshModelLibrary().

See also
setMeshModelLibrary()

◆ getNumSceneOverlays()

unsigned getNumSceneOverlays ( ) const
Returns
The number of image overlays currently added to the scene.
See also
getImageOverlay(), add(), remove()

◆ getRootTransform() [1/2]

Transform & getRootTransform ( )
Returns
The root transform of the scene. All scene items will be children of the root transform to some level of recursion. A scene can have only one root transform.

◆ getRootTransform() [2/2]

const Transform & getRootTransform ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getSceneItemLibrary()

SceneItemLibrary & getSceneItemLibrary ( )
Returns
The SceneItemLibrary to use with the scene.
Note
This will never be the same as any library passed to setSceneItemLibrary. Any such libraries will be added as sub-libraries of the Scene's own internal SceneItemLibrary.
See also
setSceneItemLibrary

◆ getSceneItemOpIdPath()

const QString & getSceneItemOpIdPath ( const SceneItem item) const
Parameters
itemThe SceneItem we wish to retrieve its OpIdPath

◆ getSceneItemWithOpIdPath()

const SceneItem * getSceneItemWithOpIdPath ( const QString &  opIdPath) const
Parameters
opIdPathThe operation Id path to use to find the specified scene item.
Returns
pointer to the scene item with the specified opidpath, 0 if it hasn't been registered with the scene.

◆ getSceneOverlay()

const SceneOverlay & getSceneOverlay ( unsigned  index) const
Parameters
indexThe index of the image overlay to retrieve. It must be less than the number of image overlays as returned by getNumImageOverlays().
Returns
The requested image overlay.

◆ getShaderLibrary()

ShaderLibrary & getShaderLibrary ( )
Returns
The shader library to use with the scene.
Note
This will never be the same as any library passed to setShaderLibrary. Any such libraries will be added as sub-libraries of the Scene's own internal ShaderLibrary.
See also
setShaderLibrary

◆ hasSceneOverlays()

bool hasSceneOverlays ( ) const

Included because it is generally faster to determine whether a container is empty than to count all of the items it contains in the case it is non-empty.

Returns
true if the scene contains overlays, false otherwise.

◆ numCameras()

unsigned numCameras ( ) const
Returns
The number of cameras stored in the scene.

◆ numLights()

unsigned numLights ( ) const
Returns
The number of lights contained in the scene. This total will always include every light regardless of whether the light is active or not (as determined by its intensity being non-zero).

◆ registerSceneItem()

void registerSceneItem ( const SceneItem item,
const QString &  opIdPath 
)
Parameters
itemThe SceneItem we are registering.
opIdPathThe IDPath of the operation that produced the SceneItem.

◆ remove()

void remove ( SceneOverlay overlay)
Parameters
overlayThe image overlay being removed from the scene.

◆ removed() [1/2]

void removed ( Camera camera)
Parameters
cameraThe camera being removed from the scene.

◆ removed() [2/2]

void removed ( Light light)
Parameters
lightThe light being removed from the scene.

◆ removeInternalSource()

void removeInternalSource ( Mesh::MeshModelSource source)
Parameters
sourceA model source to be removed from the scene's internal list of sources.

This function should only be called by MeshModelInstance. It will be called when the private model source for the proxy is cleared or changed, or when the proxy is removed from the scene.

◆ setDefaultRenderSettings()

void setDefaultRenderSettings ( const RenderSettings settings)
Parameters
settingsThe settings to use by default when the scene is rendered, assuming there are no overrides from the rendering widget.

◆ setMeshModelLibrary()

void setMeshModelLibrary ( Mesh::MeshModelLibrary library)
Parameters
libraryThe new library to use with the scene. The old library is no longer used, but it is not deleted.

The scene does not take ownership of the library. Rather, it simply keeps a reference to it so that SceneProcessor implementations can access the library when needed. If there was already a library assigned to the scene, it will no longer be used. If library is a null pointer, only those model sources managed internally by the scene will be available.

Note also that the library passed in will not be the same as the one returned by getMeshModelLibrary(). See the documentation for that function for the reasons why.

◆ setSceneItemLibrary()

void setSceneItemLibrary ( SceneItemLibrary library)
Parameters
libraryThe new SceneItemLibrary to use with the scene. The old library is no longer used but is not deleted.

A scene can have a scene item library associated with it. This scene item library will be used by renderers to retrieve scene items associated with a sceneiteminstance.

See also
getSceneItemLibrary

◆ setShaderLibrary()

void setShaderLibrary ( ShaderLibrary library)
Parameters
libraryThe new ShaderLibrary to use with the scene. The old library is no longer used but is not deleted.

A scene can have a shader library associated with it. This shader library will be used by renderers to retrieve shaders associated with meshmodelinstances.

See also
getShaderLibrary