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

Class for node animation test scene. More...

#include <AppDemoSceneAnimNode.h>

Inheritance diagram for AppDemoSceneAnimNode:
[legend]

Public Member Functions

 AppDemoSceneAnimNode ()
 
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

SLGLTexture_tex1
 

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 node animation test scene.

Definition at line 20 of file AppDemoSceneAnimNode.h.

Constructor & Destructor Documentation

◆ AppDemoSceneAnimNode()

AppDemoSceneAnimNode::AppDemoSceneAnimNode ( )

Definition at line 23 of file AppDemoSceneAnimNode.cpp.

24  : SLScene("Node Animation Test Scene")
25 {
26  info("Node animations with different easing curves.");
27 }
SLScene(const SLstring &name)
Definition: SLScene.cpp:39
SLstring & info()
Definition: SLScene.h:102

Member Function Documentation

◆ assemble()

void AppDemoSceneAnimNode::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 37 of file AppDemoSceneAnimNode.cpp.

38 {
39  SLMaterial* m1 = new SLMaterial(am, "m1", _tex1);
40  m1->kr(0.5f);
41  SLMaterial* m2 = new SLMaterial(am, "m2", SLCol4f::WHITE * 0.5, SLCol4f::WHITE, 128, 0.5f, 0.0f, 1.0f);
42 
43  SLMesh* floorMesh = new SLRectangle(am, SLVec2f(-5, -5), SLVec2f(5, 5), 20, 20, "FloorMesh", m1);
44  SLNode* floorRect = new SLNode(floorMesh);
45  floorRect->rotate(90, -1, 0, 0);
46  floorRect->translate(0, 0, -5.5f);
47 
48  // Bouncing balls
49  SLNode* ball1 = new SLNode(new SLSphere(am, 0.3f, 16, 16, "Ball1", m2));
50  ball1->translate(0, 0, 4, TS_object);
51  SLAnimation* ball1Anim = animManager().createNodeAnimation("Ball1_anim", 1.0f, true, EC_linear, AL_pingPongLoop);
52  ball1Anim->createNodeAnimTrackForTranslation(ball1, SLVec3f(0.0f, -5.2f, 0.0f));
53 
54  SLNode* ball2 = new SLNode(new SLSphere(am, 0.3f, 16, 16, "Ball2", m2));
55  ball2->translate(-1.5f, 0, 4, TS_object);
56  SLAnimation* ball2Anim = animManager().createNodeAnimation("Ball2_anim", 1.0f, true, EC_inQuad, AL_pingPongLoop);
57  ball2Anim->createNodeAnimTrackForTranslation(ball2, SLVec3f(0.0f, -5.2f, 0.0f));
58 
59  SLNode* ball3 = new SLNode(new SLSphere(am, 0.3f, 16, 16, "Ball3", m2));
60  ball3->translate(-2.5f, 0, 4, TS_object);
61  SLAnimation* ball3Anim = animManager().createNodeAnimation("Ball3_anim", 1.0f, true, EC_outQuad, AL_pingPongLoop);
62  ball3Anim->createNodeAnimTrackForTranslation(ball3, SLVec3f(0.0f, -5.2f, 0.0f));
63 
64  SLNode* ball4 = new SLNode(new SLSphere(am, 0.3f, 16, 16, "Ball4", m2));
65  ball4->translate(1.5f, 0, 4, TS_object);
66  SLAnimation* ball4Anim = animManager().createNodeAnimation("Ball4_anim", 1.0f, true, EC_inOutQuad, AL_pingPongLoop);
67  ball4Anim->createNodeAnimTrackForTranslation(ball4, SLVec3f(0.0f, -5.2f, 0.0f));
68 
69  SLNode* ball5 = new SLNode(new SLSphere(am, 0.3f, 16, 16, "Ball5", m2));
70  ball5->translate(2.5f, 0, 4, TS_object);
71  SLAnimation* ball5Anim = animManager().createNodeAnimation("Ball5_anim", 1.0f, true, EC_outInQuad, AL_pingPongLoop);
72  ball5Anim->createNodeAnimTrackForTranslation(ball5, SLVec3f(0.0f, -5.2f, 0.0f));
73 
74  SLCamera* cam1 = new SLCamera("Camera 1");
75  cam1->translation(0, 0, 22);
76  cam1->lookAt(0, 0, 0);
77  cam1->focalDist(22);
78  cam1->setInitialState();
80 
81  SLCamera* cam2 = new SLCamera("Camera 2");
82  cam2->translation(5, 0, 0);
83  cam2->lookAt(0, 0, 0);
84  cam2->focalDist(5);
85  cam2->clipFar(10);
86  cam2->background().colors(SLCol4f(0, 0, 0.6f), SLCol4f(0, 0, 0.3f));
87  cam2->setInitialState();
89 
90  SLCamera* cam3 = new SLCamera("Camera 3");
91  cam3->translation(-5, -2, 0);
92  cam3->lookAt(0, 0, 0);
93  cam3->focalDist(5);
94  cam3->clipFar(10);
95  cam3->background().colors(SLCol4f(0.6f, 0, 0), SLCol4f(0.3f, 0, 0));
96  cam3->setInitialState();
98 
99  SLLightSpot* light1 = new SLLightSpot(am, this, 0, 2, 0, 0.5f);
100  light1->powers(0.2f, 1.0f, 1.0f);
101  light1->attenuation(1, 0, 0);
102  SLAnimation* light1Anim = this->animManager().createNodeAnimation("Light1_anim", 4.0f);
103  light1Anim->createNodeAnimTrackForEllipse(light1, 6, A_z, 6, A_x);
104 
105  SLLightSpot* light2 = new SLLightSpot(am, this, 0, 0, 0, 0.2f);
106  light2->powers(0.1f, 1.0f, 1.0f);
107  light2->attenuation(1, 0, 0);
108  light2->translate(-8, -4, 0, TS_world);
109  light2->setInitialState();
110  SLAnimation* light2Anim = animManager().createNodeAnimation("light2_anim", 2.0f, true, EC_linear, AL_pingPongLoop);
111  SLNodeAnimTrack* track = light2Anim->createNodeAnimTrack();
112  track->animatedNode(light2);
113  track->createNodeKeyframe(0.0f);
114  track->createNodeKeyframe(1.0f)->translation(SLVec3f(8, 8, 0));
115  track->createNodeKeyframe(2.0f)->translation(SLVec3f(16, 0, 0));
117 
118  SLNode* figure = AppDemoSceneFigure::BuildFigureGroup(am, this, m2, true);
119 
120  SLNode* scene = new SLNode("Scene");
121  root3D(scene);
122  scene->addChild(light1);
123  scene->addChild(light2);
124  scene->addChild(cam1);
125  scene->addChild(cam2);
126  scene->addChild(cam3);
127  scene->addChild(floorRect);
128  scene->addChild(ball1);
129  scene->addChild(ball2);
130  scene->addChild(ball3);
131  scene->addChild(ball4);
132  scene->addChild(ball5);
133  scene->addChild(figure);
134 
135  sv->camera(cam1);
136 }
@ A_z
Definition: SLEnums.h:82
@ A_x
Definition: SLEnums.h:80
@ AI_bezier
Definition: SLEnums.h:162
@ EC_outInQuad
quadratic easing out and then in
Definition: SLEnums.h:185
@ EC_inOutQuad
quadratic easing in and then out
Definition: SLEnums.h:184
@ EC_outQuad
quadratic easing out, decelerating to zero velocity
Definition: SLEnums.h:183
@ EC_linear
linear easing with constant velocity
Definition: SLEnums.h:181
@ EC_inQuad
quadratic easing in, acceleration from zero velocity
Definition: SLEnums.h:182
@ TS_world
Definition: SLEnums.h:208
@ TS_object
Definition: SLEnums.h:210
@ AL_pingPongLoop
loop forward and backwards
Definition: SLEnums.h:171
SLVec2< SLfloat > SLVec2f
Definition: SLVec2.h:141
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
static SLNode * BuildFigureGroup(SLAssetManager *am, SLScene *s, SLMaterial *mat, SLbool withAnimation)
Build a hierarchical figurine with arms and legs.
SLAnimation * createNodeAnimation(SLfloat duration)
SLAnimation is the base container for all animation data.
Definition: SLAnimation.h:33
SLNodeAnimTrack * createNodeAnimTrack()
Definition: SLAnimation.cpp:94
SLNodeAnimTrack * createNodeAnimTrackForTranslation(SLNode *target, const SLVec3f &endPos)
SLNodeAnimTrack * createNodeAnimTrackForEllipse(SLNode *target, SLfloat radiusA, SLAxis axisA, SLfloat radiusB, SLAxis axisB)
void colors(const SLCol4f &uniformColor)
Sets a uniform background color.
Active or visible camera node class.
Definition: SLCamera.h:54
void clipFar(const SLfloat cFar)
Definition: SLCamera.h:109
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
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
void kr(SLfloat kr)
Definition: SLMaterial.h:184
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
Specialized animation track for node animations.
Definition: SLAnimTrack.h:66
void animatedNode(SLNode *target)
Definition: SLAnimTrack.h:73
SLTransformKeyframe * createNodeKeyframe(SLfloat time)
void translationInterpolation(SLAnimInterpolation interp)
Definition: SLAnimTrack.h:82
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 rotate(const SLQuat4f &rot, SLTransformSpace relativeTo=TS_object)
Definition: SLNode.cpp:945
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
SLRectangle creates a rectangular mesh with a certain resolution.
Definition: SLRectangle.h:29
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
SLSphere creates a sphere mesh based on SLSpheric w. 180 deg polar angle.
Definition: SLSphere.h:33
void translation(const SLVec3f &t)
static SLVec4 WHITE
Definition: SLVec4.h:215

◆ registerAssetsToLoad()

void AppDemoSceneAnimNode::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 30 of file AppDemoSceneAnimNode.cpp.

31 {
33  AppCommon::texturePath + "Checkerboard0512_C.png");
34 }
static SLstring texturePath
Path to texture images.
Definition: AppCommon.h:86
void addTextureToLoad(SLGLTexture *&texture, const SLstring &path, SLint min_filter=GL_LINEAR_MIPMAP_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT)
Add 2D textures with internal image allocation.

Member Data Documentation

◆ _tex1

SLGLTexture* AppDemoSceneAnimNode::_tex1
private

Definition at line 45 of file AppDemoSceneAnimNode.h.


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