SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoSceneAnimSkinned Class Reference

Class for skinned animation test scene. More...

#include <AppDemoSceneAnimSkinned.h>

Inheritance diagram for AppDemoSceneAnimSkinned:
[legend]

Public Member Functions

 AppDemoSceneAnimSkinned ()
 
void registerAssetsToLoad (SLAssetLoader &al) override
 All scene specific assets have to be registered for async loading in here. More...
 
void assemble (SLAssetManager *am, SLSceneView *sv) override
 After parallel loading of the assets the scene gets assembled in here. More...
 
- Public Member Functions inherited from SLScene
 SLScene (const SLstring &name)
 
 ~SLScene () override
 
void initOculus (SLstring shaderDir)
 
void root3D (SLNode *root3D)
 
void root2D (SLNode *root2D)
 
void skybox (SLSkybox *skybox)
 
void stopAnimations (SLbool stop)
 
void info (SLstring i)
 
void loadTimeMS (SLfloat loadTimeMS)
 
SLAnimManageranimManager ()
 
SLAssetManagerassetManager ()
 
SLNoderoot3D ()
 
SLNoderoot2D ()
 
SLSkyboxskybox ()
 
SLstringinfo ()
 
SLfloat elapsedTimeMS () const
 
SLfloat elapsedTimeSec () const
 
SLVEventHandlereventHandlers ()
 
SLfloat loadTimeMS () const
 
SLVLightlights ()
 
SLfloat fps () const
 
AvgFloatframeTimesMS ()
 
AvgFloatupdateTimesMS ()
 
AvgFloatupdateAnimTimesMS ()
 
AvgFloatupdateAABBTimesMS ()
 
AvgFloatupdateDODTimesMS ()
 
SLNodesingleNodeSelected ()
 Returns the node if only one is selected. See also SLMesh::selectNodeMesh. More...
 
SLMeshsingleMeshFullSelected ()
 Returns the node if only one is selected. See also SLMesh::selectNodeMesh. More...
 
SLVNodeselectedNodes ()
 
SLVMeshselectedMeshes ()
 
SLbool stopAnimations () const
 
SLint numSceneCameras ()
 Returns the number of camera nodes in the scene. More...
 
SLCameranextCameraInScene (SLCamera *activeSVCam)
 Returns the next camera in the scene if there is one. More...
 
bool onUpdate (bool renderTypeIsRT, bool voxelsAreShown, bool forceCPUSkinning)
 Updates animations and AABBs. More...
 
void init (SLAssetManager *am)
 
virtual void unInit ()
 
void selectNodeMesh (SLNode *nodeToSelect, SLMesh *meshToSelect)
 Handles the full mesh selection from double-clicks. More...
 
void deselectAllNodesAndMeshes ()
 Deselects all nodes and its meshes. More...
 
SLGLOculusoculus ()
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Private Attributes

SLNode_char1
 
SLNode_char2
 
SLNode_cube1
 
SLNode_cube2
 
SLNode_cube3
 

Additional Inherited Members

- Protected Attributes inherited from SLScene
SLVLight _lights
 Vector of all lights. More...
 
SLVEventHandler _eventHandlers
 Vector of all event handler. More...
 
SLAnimManager _animManager
 Animation manager instance. More...
 
SLAssetManager_assetManager
 Pointer to the external assetManager. More...
 
SLNode_root3D
 Root node for 3D scene. More...
 
SLNode_root2D
 Root node for 2D scene displayed in ortho projection. More...
 
SLSkybox_skybox
 pointer to skybox More...
 
SLstring _info
 scene info string More...
 
SLVNode _selectedNodes
 Vector of selected nodes. See SLMesh::selectNodeMesh. More...
 
SLVMesh _selectedMeshes
 Vector of selected meshes. See SLMesh::selectNodeMesh. More...
 
SLfloat _loadTimeMS
 time to load scene in ms More...
 
SLfloat _frameTimeMS
 Last frame time in ms. More...
 
SLfloat _lastUpdateTimeMS
 Last time after update in ms. More...
 
SLfloat _fps
 Averaged no. of frames per second. More...
 
AvgFloat _frameTimesMS
 Averaged total time per frame in ms. More...
 
AvgFloat _updateTimesMS
 Averaged time for update in ms. More...
 
AvgFloat _updateAABBTimesMS
 Averaged time for update the nodes AABB in ms. More...
 
AvgFloat _updateAnimTimesMS
 Averaged time for update the animations in ms. More...
 
AvgFloat _updateDODTimesMS
 Averaged time for update the SLEntities graph. More...
 
SLbool _stopAnimations
 Global flag for stopping all animations. More...
 
std::unique_ptr< SLGLOculus_oculus
 Oculus Rift interface. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

Class for skinned animation test scene.

Definition at line 20 of file AppDemoSceneAnimSkinned.h.

Constructor & Destructor Documentation

◆ AppDemoSceneAnimSkinned()

AppDemoSceneAnimSkinned::AppDemoSceneAnimSkinned ( )

Definition at line 20 of file AppDemoSceneAnimSkinned.cpp.

21  : SLScene("Skeletal Animation Test Scene")
22 {
23  info("Skeletal Animation Test Scene");
24 }
SLScene(const SLstring &name)
Definition: SLScene.cpp:39
SLstring & info()
Definition: SLScene.h:102

Member Function Documentation

◆ assemble()

void AppDemoSceneAnimSkinned::assemble ( SLAssetManager am,
SLSceneView sv 
)
overridevirtual

After parallel loading of the assets the scene gets assembled in here.

Remarks
All scene-specific assets have to be loaded async by overriding SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and assembling means that it happens in a parallel thread and that in there are no OpenGL calls allowed. OpenGL calls are only allowed in the main thread. It is important that all object instantiations within SLScene::assemble do NOT call any OpenGL functions (gl*) because they happen in a parallel thread. All objects that get rendered have to do their initialization when they are used the first time during rendering in the main thread.

Reimplemented from SLScene.

Definition at line 47 of file AppDemoSceneAnimSkinned.cpp.

48 {
49  // Root scene node
50  SLNode* scene = new SLNode("scene group");
51  root3D(scene);
52 
53  // camera
54  SLCamera* cam1 = new SLCamera("Camera 1");
55  cam1->translation(0, 2, 10);
56  cam1->lookAt(0, 2, 0);
57  cam1->focalDist(10);
58  cam1->setInitialState();
59  cam1->background().colors(SLCol4f(0.1f, 0.4f, 0.8f));
60  cam1->setInitialState();
62  scene->addChild(cam1);
63 
64  // light
65  SLLightSpot* light1 = new SLLightSpot(am,
66  this,
67  10,
68  10,
69  5,
70  0.5f);
71  light1->powers(0.2f, 1.0f, 1.0f);
72  light1->attenuation(1, 0, 0);
73  scene->addChild(light1);
74 
75  // Floor grid
76  SLMaterial* m2 = new SLMaterial(am, "m2", SLCol4f::WHITE);
77  SLGrid* grid = new SLGrid(am,
78  SLVec3f(-5, 0, -5),
79  SLVec3f(5, 0, 5),
80  20,
81  20,
82  "Grid",
83  m2);
84  scene->addChild(new SLNode(grid, "grid"));
85 
86  // Astro boy character
87  _char1->translate(-1, 0, 0);
88  SLAnimPlayback* char1Anim = animManager().animPlaybackByName("unnamed_anim_0");
89  char1Anim->playForward();
90  scene->addChild(_char1);
91 
92  // Sintel character
93  _char2->translate(1, 0, 0);
94  SLAnimPlayback* char2Anim = animManager().animPlaybackByName("Wave");
95  char2Anim->playForward();
96  char2Anim->playbackRate(30);
97  scene->addChild(_char2);
98 
99  // Skinned cube 1
100  _cube1->translate(3, 0, 0);
101  SLAnimPlayback* cube1Anim = animManager().animPlaybackByName("unnamed_anim_2");
102  cube1Anim->easing(EC_inOutSine);
103  cube1Anim->playForward();
104  scene->addChild(_cube1);
105 
106  // Skinned cube 2
107  _cube2->translate(-3, 0, 0);
108  SLAnimPlayback* cube2Anim = animManager().animPlaybackByName("unnamed_anim_3");
109  cube2Anim->easing(EC_inOutSine);
110  cube2Anim->playForward();
111  scene->addChild(_cube2);
112 
113  // Skinned cube 3
114  _cube3->translate(0, 3, 0);
115  SLAnimPlayback* cube3Anim = animManager().animPlaybackByName("unnamed_anim_4");
116  cube3Anim->loop(AL_pingPongLoop);
117  cube3Anim->easing(EC_inOutCubic);
118  cube3Anim->playForward();
119  scene->addChild(_cube3);
120 
121  sv->camera(cam1);
122 }
@ EC_inOutCubic
cubic easing in and then out
Definition: SLEnums.h:188
@ EC_inOutSine
sine easing in and then out
Definition: SLEnums.h:200
@ AL_pingPongLoop
loop forward and backwards
Definition: SLEnums.h:171
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
SLVec4< SLfloat > SLCol4f
Definition: SLVec4.h:237
static SLDeviceRotation devRot
Mobile device rotation from IMU.
Definition: AppCommon.h:64
static SLDeviceLocation devLoc
Mobile device location from GPS.
Definition: AppCommon.h:65
SLAnimPlayback * animPlaybackByName(const SLstring &name)
Returns the playback of a node animation or skeleton by name if it exists.
Manages the playback of an SLAnimation.
SLAnimLooping loop() const
SLEasingCurve easing() const
SLfloat playbackRate() const
void colors(const SLCol4f &uniformColor)
Sets a uniform background color.
Active or visible camera node class.
Definition: SLCamera.h:54
void devRotLoc(SLDeviceRotation *devRot, SLDeviceLocation *devLoc)
Definition: SLCamera.h:120
void focalDist(const SLfloat f)
Definition: SLCamera.h:116
SLBackground & background()
Definition: SLCamera.h:165
SLGrid creates a rectangular grid with lines with a certain resolution.
Definition: SLGrid.h:29
void attenuation(const SLfloat kConstant, const SLfloat kLinear, const SLfloat kQuadratic)
Definition: SLLight.h:116
void powers(SLfloat ambiPow, SLfloat diffPow, SLfloat specPow, const SLCol4f &ambiDiffSpecCol=SLCol4f::WHITE)
Sets the ambient, diffuse and specular powers all with the same color.
Definition: SLLight.h:74
SLLightSpot class for a spot light source.
Definition: SLLightSpot.h:36
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
void addChild(SLNode *child)
Definition: SLNode.cpp:207
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
Definition: SLNode.cpp:828
void setInitialState()
Definition: SLNode.cpp:1084
void lookAt(SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
Definition: SLNode.h:652
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
Definition: SLNode.cpp:906
SLNode * root3D()
Definition: SLScene.h:99
friend class SLNode
Definition: SLScene.h:48
SLAnimManager & animManager()
Definition: SLScene.h:97
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
static SLVec4 WHITE
Definition: SLVec4.h:215

◆ registerAssetsToLoad()

void AppDemoSceneAnimSkinned::registerAssetsToLoad ( SLAssetLoader al)
overridevirtual

All scene specific assets have to be registered for async loading in here.

All assets the should be loaded in parallel must be registered in here.

Remarks
All scene sspecific assets have to be loaded async by overriding SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and assembling means that it happens in a parallel thread and that in there are no OpenGL calls allowed. OpenGL calls are only allowed in the main thread.

Reimplemented from SLScene.

Definition at line 27 of file AppDemoSceneAnimSkinned.cpp.

28 {
31  "DAE/AstroBoy/AstroBoy.dae");
34  "GLTF/Sintel/Sintel_LowRes-Rigged.gltf");
37  "DAE/SkinnedCube/skinnedcube2.dae");
40  "DAE/SkinnedCube/skinnedcube4.dae");
43  "DAE/SkinnedCube/skinnedcube5.dae");
44 }
static SLstring modelPath
Path to 3D models.
Definition: AppCommon.h:85
void addNodeToLoad(SLNode *&node, const SLstring &modelPath, SLSkybox *skybox=nullptr, SLbool deleteTexImgAfterBuild=false, SLbool loadMeshesOnly=true, SLMaterial *overrideMat=nullptr, float ambientFactor=0.5f, SLbool forceCookTorranceRM=false, SLuint flags=SLProcess_Triangulate|SLProcess_JoinIdenticalVertices|SLProcess_RemoveRedundantMaterials|SLProcess_FindDegenerates|SLProcess_FindInvalidData|SLProcess_SplitLargeMeshes)
Add mesh from file to load via assimp loader.

Member Data Documentation

◆ _char1

SLNode* AppDemoSceneAnimSkinned::_char1
private

Definition at line 45 of file AppDemoSceneAnimSkinned.h.

◆ _char2

SLNode* AppDemoSceneAnimSkinned::_char2
private

Definition at line 46 of file AppDemoSceneAnimSkinned.h.

◆ _cube1

SLNode* AppDemoSceneAnimSkinned::_cube1
private

Definition at line 47 of file AppDemoSceneAnimSkinned.h.

◆ _cube2

SLNode* AppDemoSceneAnimSkinned::_cube2
private

Definition at line 48 of file AppDemoSceneAnimSkinned.h.

◆ _cube3

SLNode* AppDemoSceneAnimSkinned::_cube3
private

Definition at line 49 of file AppDemoSceneAnimSkinned.h.


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