Blue Brain BioExplorer
core::Scene Class Referenceabstract

Scene object This object contains collections of geometries, materials and light sources that are used to describe the 3D scene to be rendered. Scene is the base class for rendering-engine-specific inherited scenes. More...

#include <Scene.h>

Inheritance diagram for core::Scene:
Collaboration diagram for core::Scene:

Public Member Functions

virtual PLATFORM_API void commit ()
 Called after scene-related changes have been made before rendering the scene. More...
 
virtual PLATFORM_API bool commitLights ()=0
 Commits lights to renderers. More...
 
virtual PLATFORM_API ModelPtr createModel () const =0
 Factory method to create an engine-specific model. More...
 
PLATFORM_API Scene (AnimationParameters &animationParameters, GeometryParameters &geometryParameters, VolumeParameters &volumeParameters, FieldParameters &fieldParameters)
 Creates a scene object responsible for handling models, simulations and light sources. More...
 
PLATFORM_API const BoxdgetBounds () const
 Returns the bounding box of the scene. More...
 
PLATFORM_API LightManagergetLightManager ()
 Gets the light manager. More...
 
PLATFORM_API size_t addModel (ModelDescriptorPtr model)
 Adds a model to the scene. More...
 
PLATFORM_API bool removeModel (const size_t id)
 Removes a model from the scene. More...
 
PLATFORM_API const ModelDescriptorsgetModelDescriptors () const
 Get all model descriptors. More...
 
PLATFORM_API ModelDescriptorPtr getModel (const size_t id) const
 Get a model descriptor given its ID. More...
 
PLATFORM_API void buildDefault ()
 Builds a default scene made of a Cornell box, a reflective cube, and a transparent sphere. More...
 
PLATFORM_API bool empty () const
 Checks whether the scene is empty. More...
 
PLATFORM_API size_t addClipPlane (const Plane &plane)
 Add a clip plane to the scene. More...
 
PLATFORM_API ClipPlanePtr getClipPlane (const size_t id) const
 Get a clip plane by its ID. More...
 
PLATFORM_API void removeClipPlane (const size_t id)
 Remove a clip plane by its ID, or no-op if not found. More...
 
PLATFORM_API const ClipPlanesgetClipPlanes () const
 Get all clip planes in the scene. More...
 
PLATFORM_API size_t getSizeInBytes () const
 Get the current size in bytes of the loaded geometry. More...
 
PLATFORM_API size_t getNumModels () const
 Get the current number of models in the scene. More...
 
PLATFORM_API void setMaterialsColorMap (MaterialsColorMap colorMap)
 Initializes materials for all models in the scene. More...
 
PLATFORM_API bool setEnvironmentMap (const std::string &envMap)
 Set a new environment map as the background image. More...
 
PLATFORM_API const std::string & getEnvironmentMap () const
 Get the current environment map texture file, or empty if no environment is set. More...
 
PLATFORM_API bool hasEnvironmentMap () const
 Check if an environment map is currently set in the scene. More...
 
PLATFORM_API MaterialPtr getBackgroundMaterial () const
 Get the background material. More...
 
PLATFORM_API ModelDescriptorPtr loadModel (Blob &&blob, const ModelParams &params, LoaderProgress cb)
 Load a model from the given blob. More...
 
PLATFORM_API ModelDescriptorPtr loadModel (const std::string &path, const ModelParams &params, LoaderProgress cb)
 Load a model from the given file. More...
 
PLATFORM_API void visitModels (const std::function< void(Model &)> &functor)
 Apply the given functor to every model in the scene. More...
 
PLATFORM_API LoaderRegistrygetLoaderRegistry ()
 Get the registry for all supported loaders of this scene. More...
 
PLATFORM_API auto acquireReadAccess () const
 
PLATFORM_API void copyFrom (const Scene &rhs)
 Copy the scene from another scene. More...
 
PLATFORM_API void computeBounds ()
 Compute the bounds of the geometry handled by the scene. More...
 
- Public Member Functions inherited from core::BaseObject
 BaseObject ()=default
 
virtual ~BaseObject ()=default
 
 BaseObject (const BaseObject &)
 
BaseObjectoperator= (const BaseObject &rhs)
 
bool isModified () const
 
void resetModified ()
 
void markModified (const bool triggerCallback=true)
 
void onModified (const ModifiedCallback &callback)
 
void clearModifiedCallback ()
 

Protected Member Functions

virtual bool supportsConcurrentSceneUpdates () const
 Check whether this scene supports scene updates from any thread. More...
 
void _loadIBLMaps (const std::string &envMap)
 
- Protected Member Functions inherited from core::BaseObject
template<typename T >
void _updateValue (T &member, const T &newValue, const bool triggerCallback=true)
 
template<class T >
bool _isEqual (const T &a, const T &b, typename std::enable_if< std::is_floating_point< T >::value >::type *=0)
 
template<class T >
bool _isEqual (const T &a, const T &b, typename std::enable_if<!std::is_floating_point< T >::value >::type *=0)
 

Protected Attributes

AnimationParameters_animationParameters
 
GeometryParameters_geometryParameters
 
VolumeParameters_volumeParameters
 
FieldParameters_fieldParameters
 
MaterialPtr _backgroundMaterial {nullptr}
 
std::string _environmentMap
 
size_t _modelID {0}
 
ModelDescriptors _modelDescriptors
 
std::shared_timed_mutex _modelMutex
 
LightManager _lightManager
 
ClipPlanes _clipPlanes
 
LoaderRegistry _loaderRegistry
 
Boxd _bounds
 

Additional Inherited Members

- Public Types inherited from core::BaseObject
using ModifiedCallback = std::function< void(const BaseObject &)>
 

Detailed Description

Scene object This object contains collections of geometries, materials and light sources that are used to describe the 3D scene to be rendered. Scene is the base class for rendering-engine-specific inherited scenes.

Definition at line 42 of file Scene.h.

Constructor & Destructor Documentation

◆ Scene()

core::Scene::Scene ( AnimationParameters animationParameters,
GeometryParameters geometryParameters,
VolumeParameters volumeParameters,
FieldParameters fieldParameters 
)

Creates a scene object responsible for handling models, simulations and light sources.

Definition at line 65 of file Scene.cpp.

Member Function Documentation

◆ _loadIBLMaps()

void core::Scene::_loadIBLMaps ( const std::string &  envMap)
protected

Definition at line 455 of file Scene.cpp.

◆ acquireReadAccess()

PLATFORM_API auto core::Scene::acquireReadAccess ( ) const
inline

Definition at line 217 of file Scene.h.

◆ addClipPlane()

size_t core::Scene::addClipPlane ( const Plane plane)

Add a clip plane to the scene.

Parameters
planeThe coefficients of the clip plane equation.
Returns
The clip plane ID.

Definition at line 194 of file Scene.cpp.

◆ addModel()

size_t core::Scene::addModel ( ModelDescriptorPtr  model)

Adds a model to the scene.

Parameters
modelThe model to add
Exceptions
std::runtime_errorif model is empty
Returns
The ID of the added model

Definition at line 116 of file Scene.cpp.

◆ buildDefault()

void core::Scene::buildDefault ( )

Builds a default scene made of a Cornell box, a reflective cube, and a transparent sphere.

Definition at line 250 of file Scene.cpp.

◆ commit()

void core::Scene::commit ( )
virtual

Called after scene-related changes have been made before rendering the scene.

Reimplemented in core::engine::ospray::OSPRayScene, and core::engine::optix::OptiXScene.

Definition at line 99 of file Scene.cpp.

◆ commitLights()

virtual PLATFORM_API bool core::Scene::commitLights ( )
pure virtual

Commits lights to renderers.

Returns
True if lights were committed, false otherwise

Implemented in core::engine::ospray::OSPRayScene, and core::engine::optix::OptiXScene.

◆ computeBounds()

void core::Scene::computeBounds ( )

Compute the bounds of the geometry handled by the scene.

Definition at line 427 of file Scene.cpp.

◆ copyFrom()

void core::Scene::copyFrom ( const Scene rhs)

Copy the scene from another scene.

Parameters
rhsScene to copy from

Definition at line 74 of file Scene.cpp.

◆ createModel()

virtual PLATFORM_API ModelPtr core::Scene::createModel ( ) const
pure virtual

Factory method to create an engine-specific model.

Implemented in core::engine::ospray::OSPRayScene, and core::engine::optix::OptiXScene.

◆ empty()

bool core::Scene::empty ( ) const

Checks whether the scene is empty.

Returns
True if the scene does not contain any geometry, false otherwise

Definition at line 185 of file Scene.cpp.

◆ getBackgroundMaterial()

PLATFORM_API MaterialPtr core::Scene::getBackgroundMaterial ( ) const
inline

Get the background material.

Returns
The background material

Definition at line 184 of file Scene.h.

◆ getBounds()

PLATFORM_API const Boxd& core::Scene::getBounds ( ) const
inline

Returns the bounding box of the scene.

Definition at line 69 of file Scene.h.

◆ getClipPlane()

ClipPlanePtr core::Scene::getClipPlane ( const size_t  id) const

Get a clip plane by its ID.

Parameters
idThe ID of the clip plane
Returns
A pointer to the clip plane or null if not found.

Definition at line 203 of file Scene.cpp.

◆ getClipPlanes()

PLATFORM_API const ClipPlanes& core::Scene::getClipPlanes ( ) const
inline

Get all clip planes in the scene.

Returns
The clip planes

Definition at line 141 of file Scene.h.

◆ getEnvironmentMap()

PLATFORM_API const std::string& core::Scene::getEnvironmentMap ( ) const
inline

Get the current environment map texture file, or empty if no environment is set.

Returns
The environment map texture file, or empty if no environment is set

Definition at line 172 of file Scene.h.

◆ getLightManager()

PLATFORM_API LightManager& core::Scene::getLightManager ( )
inline

Gets the light manager.

Definition at line 74 of file Scene.h.

◆ getLoaderRegistry()

PLATFORM_API LoaderRegistry& core::Scene::getLoaderRegistry ( )
inline

Get the registry for all supported loaders of this scene.

Returns
The loader registry

Definition at line 214 of file Scene.h.

◆ getModel()

ModelDescriptorPtr core::Scene::getModel ( const size_t  id) const

Get a model descriptor given its ID.

Parameters
idThe ID of the model descriptor
Returns
The model descriptor

Definition at line 179 of file Scene.cpp.

◆ getModelDescriptors()

PLATFORM_API const ModelDescriptors& core::Scene::getModelDescriptors ( ) const
inline

Get all model descriptors.

Returns
The model descriptors

Definition at line 96 of file Scene.h.

◆ getNumModels()

size_t core::Scene::getNumModels ( ) const

Get the current number of models in the scene.

Returns
The current number of models in the scene

Definition at line 110 of file Scene.cpp.

◆ getSizeInBytes()

size_t core::Scene::getSizeInBytes ( ) const

Get the current size in bytes of the loaded geometry.

Returns
The current size in bytes of the loaded geometry

Definition at line 101 of file Scene.cpp.

◆ hasEnvironmentMap()

bool core::Scene::hasEnvironmentMap ( ) const

Check if an environment map is currently set in the scene.

Returns
True if an environment map is currently set in the scene, false otherwise

Definition at line 422 of file Scene.cpp.

◆ loadModel() [1/2]

ModelDescriptorPtr core::Scene::loadModel ( Blob &&  blob,
const ModelParams params,
LoaderProgress  cb 
)

Load a model from the given blob.

Parameters
blobThe blob containing the data to import
paramsParameters for the model to be loaded
cbThe callback for progress updates from the loader
Returns
The model that has been added to the scene

Definition at line 214 of file Scene.cpp.

◆ loadModel() [2/2]

ModelDescriptorPtr core::Scene::loadModel ( const std::string &  path,
const ModelParams params,
LoaderProgress  cb 
)

Load a model from the given file.

Parameters
pathThe file or folder containing the data to import
paramsParameters for the model to be loaded
cbThe callback for progress updates from the loader
Returns
The model that has been added to the scene

Definition at line 229 of file Scene.cpp.

◆ removeClipPlane()

void core::Scene::removeClipPlane ( const size_t  id)

Remove a clip plane by its ID, or no-op if not found.

Parameters
idThe ID of the clip plane to remove

Definition at line 208 of file Scene.cpp.

◆ removeModel()

bool core::Scene::removeModel ( const size_t  id)

Removes a model from the scene.

Parameters
idID of the model to remove
Returns
True if model was found and removed, false otherwise

Definition at line 147 of file Scene.cpp.

◆ setEnvironmentMap()

bool core::Scene::setEnvironmentMap ( const std::string &  envMap)

Set a new environment map as the background image.

Parameters
envMapFilepath to the environment map
Returns
False if the new map could not be set, true otherwise

Definition at line 392 of file Scene.cpp.

◆ setMaterialsColorMap()

void core::Scene::setMaterialsColorMap ( MaterialsColorMap  colorMap)

Initializes materials for all models in the scene.

Parameters
colorMapColor map to use for every individual model

Definition at line 382 of file Scene.cpp.

◆ supportsConcurrentSceneUpdates()

virtual bool core::Scene::supportsConcurrentSceneUpdates ( ) const
inlineprotectedvirtual

Check whether this scene supports scene updates from any thread.

Returns
True if this scene supports scene updates from any thread, false otherwise

Reimplemented in core::engine::ospray::OSPRayScene, and core::engine::optix::OptiXScene.

Definition at line 235 of file Scene.h.

◆ visitModels()

void core::Scene::visitModels ( const std::function< void(Model &)> &  functor)

Apply the given functor to every model in the scene.

Parameters
functorThe functor to be applied

Definition at line 243 of file Scene.cpp.

Member Data Documentation

◆ _animationParameters

AnimationParameters& core::Scene::_animationParameters
protected

Definition at line 239 of file Scene.h.

◆ _backgroundMaterial

MaterialPtr core::Scene::_backgroundMaterial {nullptr}
protected

Definition at line 243 of file Scene.h.

◆ _bounds

Boxd core::Scene::_bounds
protected

Definition at line 254 of file Scene.h.

◆ _clipPlanes

ClipPlanes core::Scene::_clipPlanes
protected

Definition at line 251 of file Scene.h.

◆ _environmentMap

std::string core::Scene::_environmentMap
protected

Definition at line 244 of file Scene.h.

◆ _fieldParameters

FieldParameters& core::Scene::_fieldParameters
protected

Definition at line 242 of file Scene.h.

◆ _geometryParameters

GeometryParameters& core::Scene::_geometryParameters
protected

Definition at line 240 of file Scene.h.

◆ _lightManager

LightManager core::Scene::_lightManager
protected

Definition at line 250 of file Scene.h.

◆ _loaderRegistry

LoaderRegistry core::Scene::_loaderRegistry
protected

Definition at line 253 of file Scene.h.

◆ _modelDescriptors

ModelDescriptors core::Scene::_modelDescriptors
protected

Definition at line 247 of file Scene.h.

◆ _modelID

size_t core::Scene::_modelID {0}
protected

Definition at line 246 of file Scene.h.

◆ _modelMutex

std::shared_timed_mutex core::Scene::_modelMutex
mutableprotected

Definition at line 248 of file Scene.h.

◆ _volumeParameters

VolumeParameters& core::Scene::_volumeParameters
protected

Definition at line 241 of file Scene.h.


The documentation for this class was generated from the following files: