The SLScene class represents the top level instance holding the scene structure.
More...
#include <SLScene.h>
Inherits SLObject.
Inherited by AppDemoScene2Dand3DText, AppDemoSceneAnimNode, AppDemoSceneAnimNodeMass, AppDemoSceneAnimNodeMass2, AppDemoSceneAnimSkinned, AppDemoSceneAnimSkinnedMass, AppDemoSceneAnimSkinnedMass2, AppDemoSceneEmpty, AppDemoSceneErlebARAugustaTmpTht, AppDemoSceneErlebARAventicumAmphitheater, AppDemoSceneErlebARAventicumCigognier, AppDemoSceneErlebARAventicumTheater, AppDemoSceneErlebARBernChristoffel, AppDemoSceneErlebARBielBFH, AppDemoSceneErlebARSutz, AppDemoSceneFigure, AppDemoSceneFrustum, AppDemoSceneGLTF, AppDemoSceneJansUniverse, AppDemoSceneLargeModel, AppDemoSceneLevelOfDetail, AppDemoSceneLotsOfNodes, AppDemoSceneMeshLoad, AppDemoSceneMinimal, AppDemoSceneParticleComplexFire, AppDemoSceneParticleDustStorm, AppDemoSceneParticleFountain, AppDemoSceneParticleMany, AppDemoSceneParticleRingOfFire, AppDemoSceneParticleSimple, AppDemoSceneParticleSun, AppDemoScenePointClouds, AppDemoSceneRTDoF, AppDemoSceneRTLens, AppDemoSceneRTMuttenzerBox, AppDemoSceneRTSpheres, AppDemoSceneRevolver, AppDemoSceneRobot, AppDemoSceneShaderBlinn, AppDemoSceneShaderBump, AppDemoSceneShaderCook, AppDemoSceneShaderEarth, AppDemoSceneShaderIBL, AppDemoSceneShaderParallax, AppDemoSceneShaderSkybox, AppDemoSceneShaderWave, AppDemoSceneShadowBasic, AppDemoSceneShadowCascaded, AppDemoSceneShadowLightPoint, AppDemoSceneShadowLightSpot, AppDemoSceneShadowLightTypes, AppDemoSceneSuzanne, AppDemoSceneTextureBlend, AppDemoSceneTextureCompression, AppDemoSceneTextureFilter, AppDemoSceneVideoSensorAR, AppDemoSceneVideoTexture, AppDemoSceneVideoTrackAruco, AppDemoSceneVideoTrackChessboard, AppDemoSceneVideoTrackFace, AppDemoSceneVideoTrackFeatures, AppDemoSceneVideoTrackMediapipe, AppDemoSceneVideoTrackWAI, AppDemoSceneVolumeRayCast, AppDemoSceneVolumeRayCastLighted, AppDemoSceneZFighting, AppMinimalScene, and AppNodeScene.
The SLScene class represents the top level instance holding the scene structure.
The SLScene class holds everything that is common for all sceneviews such as the pointer (_root3D) to the root node of the scene. The scene loading happens in 3 steps:
1) Registering all expensive assets to load in registerAssetsToLoad.
2) Parallel loading of assets in threads with SLAssetLoader::loadAll.
3) Assembling the scene in assemble.
To load a scene you must therefore inherit from this class and override the methods registerAssetsToLoad and assemble.
Definition at line 46 of file SLScene.h.
◆ SLScene()
SLScene::SLScene |
( |
const SLstring & |
name | ) |
|
The constructor of the scene. There will be only one scene for an application and it gets constructed in the C-interface function slCreateScene in SLInterface.cpp that is called by the platform and UI-toolkit dependent window initialization. As examples you can see it in:
- app_demo_slproject/glfw: glfwMain.cpp in function main()
- app-demo/android: Java_ch_fhnw_comgRT_glES2Lib_onInit()
- app_demo_slproject/ios: ViewController.m in method viewDidLoad()
- _old/app-Demo-Qt: qtGLWidget::initializeGL()
- _old/app-Viewer-Qt: qtGLWidget::initializeGL()
Definition at line 39 of file SLScene.cpp.
SLObject(const SLstring &Name="", const SLstring &url="")
const SLstring & name() const
SLbool _stopAnimations
Global flag for stopping all animations.
SLSkybox * _skybox
pointer to skybox
SLfloat _loadTimeMS
time to load scene in ms
AvgFloat _frameTimesMS
Averaged total time per frame in ms.
SLfloat _frameTimeMS
Last frame time in ms.
AvgFloat _updateDODTimesMS
Averaged time for update the SLEntities graph.
SLNode * _root3D
Root node for 3D scene.
SLAssetManager * _assetManager
Pointer to the external assetManager.
SLstring _info
scene info string
SLfloat _fps
Averaged no. of frames per second.
AvgFloat _updateAABBTimesMS
Averaged time for update the nodes AABB in ms.
SLNode * _root2D
Root node for 2D scene displayed in ortho projection.
SLfloat _lastUpdateTimeMS
Last time after update in ms.
AvgFloat _updateAnimTimesMS
Averaged time for update the animations in ms.
AvgFloat _updateTimesMS
Averaged time for update in ms.
◆ ~SLScene()
The destructor does the final total deallocation of all global resources. The destructor is called in slTerminate.
Definition at line 62 of file SLScene.cpp.
67 SL_LOG_DEBUG(
"------------------------------------------------------------------");
#define SL_LOG_DEBUG(...)
◆ animManager()
Definition at line 97 of file SLScene.h.
SLAnimManager _animManager
Animation manager instance.
◆ assemble()
After parallel loading of the assets the scene gets assembled in here.
Reimplemented in AppNodeScene, AppMinimalScene, AppDemoSceneZFighting, AppDemoSceneVolumeRayCastLighted, AppDemoSceneVolumeRayCast, AppDemoSceneVideoTrackWAI, AppDemoSceneVideoTrackMediapipe, AppDemoSceneVideoTrackFeatures, AppDemoSceneVideoTrackFace, AppDemoSceneVideoTrackChessboard, AppDemoSceneVideoTrackAruco, AppDemoSceneVideoTexture, AppDemoSceneVideoSensorAR, AppDemoSceneTextureFilter, AppDemoSceneTextureCompression, AppDemoSceneTextureBlend, AppDemoSceneSuzanne, AppDemoSceneShadowLightTypes, AppDemoSceneShadowLightSpot, AppDemoSceneShadowLightPoint, AppDemoSceneShadowCascaded, AppDemoSceneShadowBasic, AppDemoSceneShaderWave, AppDemoSceneShaderSkybox, AppDemoSceneShaderParallax, AppDemoSceneShaderIBL, AppDemoSceneShaderEarth, AppDemoSceneShaderCook, AppDemoSceneShaderBump, AppDemoSceneShaderBlinn, AppDemoSceneRTSpheres, AppDemoSceneRTMuttenzerBox, AppDemoSceneRTLens, AppDemoSceneRTDoF, AppDemoSceneRobot, AppDemoSceneRevolver, AppDemoScenePointClouds, AppDemoSceneParticleSun, AppDemoSceneParticleSimple, AppDemoSceneParticleRingOfFire, AppDemoSceneParticleMany, AppDemoSceneParticleFountain, AppDemoSceneParticleDustStorm, AppDemoSceneParticleComplexFire, AppDemoSceneMinimal, AppDemoSceneMeshLoad, AppDemoSceneLotsOfNodes, AppDemoSceneLevelOfDetail, AppDemoSceneLargeModel, AppDemoSceneJansUniverse, AppDemoSceneGLTF, AppDemoSceneFrustum, AppDemoSceneFigure, AppDemoSceneErlebARSutz, AppDemoSceneErlebARBielBFH, AppDemoSceneErlebARBernChristoffel, AppDemoSceneErlebARAventicumTheater, AppDemoSceneErlebARAventicumCigognier, AppDemoSceneErlebARAventicumAmphitheater, AppDemoSceneErlebARAugustaTmpTht, AppDemoSceneEmpty, AppDemoSceneAnimSkinnedMass2, AppDemoSceneAnimSkinnedMass, AppDemoSceneAnimSkinned, AppDemoSceneAnimNodeMass2, AppDemoSceneAnimNodeMass, AppDemoSceneAnimNode, and AppDemoScene2Dand3DText.
Definition at line 75 of file SLScene.h.
◆ assetManager()
◆ deselectAllNodesAndMeshes()
void SLScene::deselectAllNodesAndMeshes |
( |
| ) |
|
Deselects all nodes and its meshes.
Definition at line 338 of file SLScene.cpp.
341 sn->isSelected(
false);
346 sm->deselectPartialSelection();
347 sm->isSelected(
false);
SLVNode _selectedNodes
Vector of selected nodes. See SLMesh::selectNodeMesh.
SLVMesh _selectedMeshes
Vector of selected meshes. See SLMesh::selectNodeMesh.
Collection of classes for a state machine implementation used in the Erleb-AR app.
◆ elapsedTimeMS()
SLfloat SLScene::elapsedTimeMS |
( |
| ) |
const |
|
inline |
◆ elapsedTimeSec()
SLfloat SLScene::elapsedTimeSec |
( |
| ) |
const |
|
inline |
◆ eventHandlers()
Definition at line 105 of file SLScene.h.
SLVEventHandler _eventHandlers
Vector of all event handler.
◆ fps()
◆ frameTimesMS()
◆ info() [1/2]
◆ info() [2/2]
◆ init()
The scene init is called before a new scene is assembled.
Definition at line 72 of file SLScene.cpp.
74 assert(am &&
"No asset manager passed to scene");
static SLfloat gamma
final output gamma value
static SLCol4f globalAmbient
static global ambient light intensity
void set(const T X, const T Y, const T Z, const T W=1)
void init(int numValues, T initValue)
Initializes the average value array to a given value.
◆ initOculus()
Definition at line 391 of file SLScene.cpp.
393 _oculus = std::make_unique<SLGLOculus>(shaderDir);
std::unique_ptr< SLGLOculus > _oculus
Oculus Rift interface.
◆ lights()
Definition at line 107 of file SLScene.h.
SLVLight _lights
Vector of all lights.
◆ loadTimeMS() [1/2]
SLfloat SLScene::loadTimeMS |
( |
| ) |
const |
|
inline |
◆ loadTimeMS() [2/2]
Definition at line 94 of file SLScene.h.
SLfloat loadTimeMS() const
◆ nextCameraInScene()
Returns the next camera in the scene if there is one.
Definition at line 361 of file SLScene.cpp.
367 if (cams.empty())
return nullptr;
368 if (cams.size() == 1)
return cams[0];
370 SLint activeIndex = 0;
371 for (
SLulong i = 0; i < cams.size(); ++i)
373 if (cams[i] == activeSVCam)
375 activeIndex = (
SLint)i;
384 activeIndex = activeIndex > cams.size() - 2 ? 0 : ++activeIndex;
386 !
dynamic_cast<SLKeyframeCamera*
>(cams[(uint)activeIndex])->allowAsActiveCam());
388 return cams[(uint)activeIndex];
Active or visible camera node class.
deque< T * > findChildren(const SLstring &name="", SLbool findRecursive=true, SLbool canContain=false)
◆ numSceneCameras()
SLint SLScene::numSceneCameras |
( |
| ) |
|
Returns the number of camera nodes in the scene.
Definition at line 353 of file SLScene.cpp.
357 return (
SLint)cams.size();
◆ oculus()
◆ onUpdate()
bool SLScene::onUpdate |
( |
bool |
renderTypeIsRT, |
|
|
bool |
voxelsAreShown, |
|
|
bool |
forceCPUSkinning |
|
) |
| |
Updates animations and AABBs.
Updates different updatables in the scene after all views got painted:
1) Calculate frame time
2) Update all animations
3) Update AABBs
- Returns
- true if really something got updated
Definition at line 124 of file SLScene.cpp.
142 if (averagedFrameTimeMS > 0.001f)
149 SLbool sceneHasChanged =
false;
168 if (renderTypeIsRT || voxelsAreShown)
169 forceCPUSkinning =
true;
175 for (
auto* node : nodes)
176 node->needAABBUpdate(); });
178 if (renderTypeIsRT || voxelsAreShown)
197 #ifdef SL_USE_ENTITIES
202 entities.updateWMRec(0, root);
212 return sceneHasChanged;
#define PROFILE_FUNCTION()
deque< SLNode * > SLVNode
SLVNode typedef for a vector of SLNodes.
SLbool update(SLfloat elapsedTimeSec)
Advances the time of all enabled animation plays.
An SLMesh object is a triangulated mesh, drawn with one draw call.
bool updateMeshSkins(bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
Update all skinned meshes recursively.
static SLuint numWMUpdates
NO. of calls to updateWMRec per frame.
void updateMeshAccelStructs()
virtual SLAABBox & updateAABBRec(SLbool updateAlsoAABBinOS)
SLfloat elapsedTimeSec() const
void set(T value)
Sets the current value in the value array and builds the average.
◆ registerAssetsToLoad()
All assets the should be loaded in parallel must be registered in here.
All scene specific assets have to be registered for async loading in here.
Reimplemented in AppNodeScene, AppMinimalScene, AppDemoSceneZFighting, AppDemoSceneVolumeRayCastLighted, AppDemoSceneVolumeRayCast, AppDemoSceneVideoTrackWAI, AppDemoSceneVideoTrackMediapipe, AppDemoSceneVideoTrackFeatures, AppDemoSceneVideoTrackFace, AppDemoSceneVideoTrackChessboard, AppDemoSceneVideoTrackAruco, AppDemoSceneVideoTexture, AppDemoSceneVideoSensorAR, AppDemoSceneTextureFilter, AppDemoSceneTextureCompression, AppDemoSceneTextureBlend, AppDemoSceneSuzanne, AppDemoSceneShadowLightTypes, AppDemoSceneShadowLightSpot, AppDemoSceneShadowLightPoint, AppDemoSceneShadowCascaded, AppDemoSceneShadowBasic, AppDemoSceneShaderWave, AppDemoSceneShaderSkybox, AppDemoSceneShaderParallax, AppDemoSceneShaderIBL, AppDemoSceneShaderEarth, AppDemoSceneShaderCook, AppDemoSceneShaderBump, AppDemoSceneShaderBlinn, AppDemoSceneRTSpheres, AppDemoSceneRTMuttenzerBox, AppDemoSceneRTLens, AppDemoSceneRTDoF, AppDemoSceneRobot, AppDemoSceneRevolver, AppDemoScenePointClouds, AppDemoSceneParticleSun, AppDemoSceneParticleSimple, AppDemoSceneParticleRingOfFire, AppDemoSceneParticleMany, AppDemoSceneParticleFountain, AppDemoSceneParticleDustStorm, AppDemoSceneParticleComplexFire, AppDemoSceneMinimal, AppDemoSceneMeshLoad, AppDemoSceneLotsOfNodes, AppDemoSceneLevelOfDetail, AppDemoSceneLargeModel, AppDemoSceneJansUniverse, AppDemoSceneGLTF, AppDemoSceneFrustum, AppDemoSceneFigure, AppDemoSceneErlebARSutz, AppDemoSceneErlebARBielBFH, AppDemoSceneErlebARBernChristoffel, AppDemoSceneErlebARAventicumTheater, AppDemoSceneErlebARAventicumCigognier, AppDemoSceneErlebARAventicumAmphitheater, AppDemoSceneErlebARAugustaTmpTht, AppDemoSceneEmpty, AppDemoSceneAnimSkinnedMass2, AppDemoSceneAnimSkinnedMass, AppDemoSceneAnimSkinned, AppDemoSceneAnimNodeMass2, AppDemoSceneAnimNodeMass, AppDemoSceneAnimNode, and AppDemoScene2Dand3DText.
Definition at line 63 of file SLScene.h.
◆ root2D() [1/2]
◆ root2D() [2/2]
◆ root3D() [1/2]
◆ root3D() [2/2]
Definition at line 78 of file SLScene.h.
82 #ifdef SL_USE_ENTITIES
83 SLint rootEntityID = SLScene::entities.getEntityID(
root3D);
84 if (rootEntityID == INT32_MIN &&
root3D)
86 else if (rootEntityID > -1)
87 SL_EXIT_MSG(
"Root node exists already with another ID among the entities");
#define SL_EXIT_MSG(message)
SLEntity is the Data Oriented Design version of a SLNode.
◆ selectedMeshes()
SLVMesh& SLScene::selectedMeshes |
( |
| ) |
|
|
inline |
◆ selectedNodes()
SLVNode& SLScene::selectedNodes |
( |
| ) |
|
|
inline |
◆ selectNodeMesh()
Handles the full mesh selection from double-clicks.
There are two different selection modes: Full or partial mesh selection.
The full selection is done by double-clicking a mesh. Multiple meshes can be selected with SHIFT-double-clicking. The full selection is handled in SLScene::selectNodeMesh. The selected nodes are stored in SLScene::_selectedNodes and the fully or partially selected meshes are stored in SLScene::_selectedMeshes. The SLNode::isSelected and SLMesh::isSelected show if a node or mesh is selected. A node can be selected with or without a mesh. If a mesh is selected, its node is always also selected. A node without mesh can only be selected in the scenegraph window. To avoid a node from selection you can set its drawing bit SL_DB_NOTSELECTABLE. You should transform a node or mesh and show the properties of a node or mesh if only a single node and single full mesh is selected. To get them call SLScene::singleNodeSelected() or SLScene::singleMeshFullSelected().
For partial mesh selection see SLMesh::handleRectangleSelection.
Definition at line 234 of file SLScene.cpp.
237 if (!nodeToSelect && !meshToSelect)
245 SL_LOG(
"Node is not selectable: %s", nodeToSelect->
name().c_str());
250 if (!nodeToSelect && meshToSelect)
251 SL_EXIT_MSG(
"SLScene::selectNodeMesh: No node or mesh to select.");
259 if (nodeToSelect && !meshToSelect)
296 if (foundNode ==
_selectedNodes.end() && *foundMesh == meshToSelect)
307 if (nodeToSelect && *foundNode == nodeToSelect && *foundMesh == meshToSelect)
310 bool otherMeshIsSelected =
false;
315 if (nm ==
sm && nm != meshToSelect)
317 otherMeshIsSelected =
true;
323 if (!otherMeshIsSelected)
334 SL_EXIT_MSG(
"SLScene::selectNodeMesh: We should not get here.");
#define SL_DB_NOTSELECTABLE
Flags an object as selected.
void deselectPartialSelection()
SLbool isSelected() const
SLbool drawBit(SLuint bit)
void isSelected(bool isSelected)
void name(const SLstring &Name)
void deselectAllNodesAndMeshes()
Deselects all nodes and its meshes.
◆ singleMeshFullSelected()
SLMesh* SLScene::singleMeshFullSelected |
( |
| ) |
|
|
inline |
Returns the node if only one is selected. See also SLMesh::selectNodeMesh.
Definition at line 119 of file SLScene.h.
◆ singleNodeSelected()
SLNode* SLScene::singleNodeSelected |
( |
| ) |
|
|
inline |
Returns the node if only one is selected. See also SLMesh::selectNodeMesh.
Definition at line 116 of file SLScene.h.
◆ skybox() [1/2]
◆ skybox() [2/2]
◆ stopAnimations() [1/2]
SLbool SLScene::stopAnimations |
( |
| ) |
const |
|
inline |
◆ stopAnimations() [2/2]
◆ unInit()
The scene uninitializing clears the scenegraph (_root3D) and all global global resources such as materials, textures & custom shaders loaded with the scene. The standard shaders, the fonts and the 2D-GUI elements remain. They are destructed at process end.
Definition at line 97 of file SLScene.cpp.
void clear()
Clears and deletes all node animations and skeletons.
◆ updateAABBTimesMS()
AvgFloat& SLScene::updateAABBTimesMS |
( |
| ) |
|
|
inline |
◆ updateAnimTimesMS()
AvgFloat& SLScene::updateAnimTimesMS |
( |
| ) |
|
|
inline |
◆ updateDODTimesMS()
◆ updateTimesMS()
◆ SLNode
◆ _animManager
Animation manager instance.
Definition at line 149 of file SLScene.h.
◆ _assetManager
Pointer to the external assetManager.
Definition at line 150 of file SLScene.h.
◆ _eventHandlers
Vector of all event handler.
Definition at line 148 of file SLScene.h.
◆ _fps
Averaged no. of frames per second.
Definition at line 162 of file SLScene.h.
◆ _frameTimeMS
Last frame time in ms.
Definition at line 160 of file SLScene.h.
◆ _frameTimesMS
Averaged total time per frame in ms.
Definition at line 165 of file SLScene.h.
◆ _info
◆ _lastUpdateTimeMS
Last time after update in ms.
Definition at line 161 of file SLScene.h.
◆ _lights
Vector of all lights.
Definition at line 147 of file SLScene.h.
◆ _loadTimeMS
time to load scene in ms
Definition at line 159 of file SLScene.h.
◆ _oculus
Oculus Rift interface.
Definition at line 173 of file SLScene.h.
◆ _root2D
Root node for 2D scene displayed in ortho projection.
Definition at line 153 of file SLScene.h.
◆ _root3D
Root node for 3D scene.
Definition at line 152 of file SLScene.h.
◆ _selectedMeshes
Vector of selected meshes. See SLMesh::selectNodeMesh.
Definition at line 157 of file SLScene.h.
◆ _selectedNodes
Vector of selected nodes. See SLMesh::selectNodeMesh.
Definition at line 156 of file SLScene.h.
◆ _skybox
◆ _stopAnimations
SLbool SLScene::_stopAnimations |
|
protected |
Global flag for stopping all animations.
Definition at line 171 of file SLScene.h.
◆ _updateAABBTimesMS
Averaged time for update the nodes AABB in ms.
Definition at line 167 of file SLScene.h.
◆ _updateAnimTimesMS
Averaged time for update the animations in ms.
Definition at line 168 of file SLScene.h.
◆ _updateDODTimesMS
◆ _updateTimesMS
Averaged time for update in ms.
Definition at line 166 of file SLScene.h.
The documentation for this class was generated from the following files: