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

Class for fire ring particle system scene. More...

#include <AppDemoSceneParticleComplexFire.h>

Inheritance diagram for AppDemoSceneParticleComplexFire:
[legend]

Public Member Functions

 AppDemoSceneParticleComplexFire (SLSceneID sceneID)
 
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...
 
SLNodecreateComplexFire (SLAssetManager *am, SLScene *s, SLbool withLight, SLGLTexture *texFireCld, SLGLTexture *texFireFlm, SLint flipbookCols, SLint flipbookRows, SLGLTexture *texCircle, SLGLTexture *texSmokeB, SLGLTexture *texSmokeW)
 Creates a complex fire group node. More...
 
SLNodecreateTorchFire (SLAssetManager *am, SLScene *s, SLbool withLight, SLGLTexture *texFireCld, SLGLTexture *texFireFlm, SLint flipbookCols, SLint flipbookRows)
 
- 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

SLSceneID _sceneID
 
SLGLTexture_texFireCld
 
SLGLTexture_texFireFlm
 
SLGLTexture_texCircle
 
SLGLTexture_texSmokeB
 
SLGLTexture_texSmokeW
 
SLGLTexture_texTorchFlm
 
SLGLTexture_texTorchSmk
 
SLGLTexture_texWallDIF
 
SLGLTexture_texWallNRM
 
SLNode_firewood
 
SLNode_torchL
 

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 fire ring particle system scene.

Definition at line 20 of file AppDemoSceneParticleComplexFire.h.

Constructor & Destructor Documentation

◆ AppDemoSceneParticleComplexFire()

AppDemoSceneParticleComplexFire::AppDemoSceneParticleComplexFire ( SLSceneID  sceneID)

Definition at line 22 of file AppDemoSceneParticleComplexFire.cpp.

23  : SLScene("Complex Fire Particle System"),
25 {
26  info("The fire particle systems contain each multiple sub particle systems.\n"
27  "See the scenegraph window for the sub particles systems. "
28  "See the properties window for the settings of the particles systems");
29 }
SLScene SLSceneView SLint sceneID
Definition: SLScene.h:33
SLScene(const SLstring &name)
Definition: SLScene.cpp:39
SLstring & info()
Definition: SLScene.h:102

Member Function Documentation

◆ assemble()

void AppDemoSceneParticleComplexFire::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 88 of file AppDemoSceneParticleComplexFire.cpp.

90 {
92  {
93  // Create a scene group node
94  SLNode* scene = new SLNode("Root Scene Node");
95  root3D(scene);
96 
97  // Create and add camera
98  SLCamera* cam1 = new SLCamera("Camera 1");
99  cam1->translation(0, 1.2f, 4.0f);
100  cam1->lookAt(0, 1.2f, 0);
101  cam1->focalDist(4.5f);
102  cam1->setInitialState();
103  scene->addChild(cam1);
104  sv->camera(cam1);
105 
106  SLNode* complexFire = createComplexFire(am,
107  this,
108  true,
109  _texTorchSmk,
110  _texFireFlm,
111  8,
112  8,
113  _texCircle,
114  _texSmokeB,
115  _texSmokeW);
116  scene->addChild(complexFire);
117 
118  // Room parent node
119  SLNode* room = new SLNode("Room");
120  scene->addChild(room);
121 
122  // Back wall material
123  SLMaterial* matWall = new SLMaterial(am,
124  "mat3",
125  _texWallDIF,
126  _texWallNRM);
127  matWall->specular(SLCol4f::BLACK);
128  matWall->metalness(0);
129  matWall->roughness(1);
131 
132  // Room dimensions
133  SLfloat pL = -2.0f, pR = 2.0f; // left/right
134  SLfloat pB = -0.01f, pT = 4.0f; // bottom/top
135  SLfloat pN = 2.0f, pF = -2.0f; // near/far
136 
137  // bottom rectangle
138  SLNode* b = new SLNode(new SLRectangle(am,
139  SLVec2f(pL, -pN),
140  SLVec2f(pR, -pF),
141  10,
142  10,
143  "Floor",
144  matWall));
145  b->rotate(90, -1, 0, 0);
146  b->translate(0, 0, pB, TS_object);
147  room->addChild(b);
148 
149  // far rectangle
150  SLNode* f = new SLNode(new SLRectangle(am,
151  SLVec2f(pL, pB),
152  SLVec2f(pR, pT),
153  10,
154  10,
155  "Wall far",
156  matWall));
157  f->translate(0, 0, pF, TS_object);
158  room->addChild(f);
159 
160  // near rectangle
161  SLNode* n = new SLNode(new SLRectangle(am,
162  SLVec2f(pL, pB),
163  SLVec2f(pR, pT),
164  10,
165  10,
166  "Wall near",
167  matWall));
168  n->rotate(180, 0, 1, 0);
169  n->translate(0, 0, pF, TS_object);
170  room->addChild(n);
171 
172  // left rectangle
173  SLNode* l = new SLNode(new SLRectangle(am,
174  SLVec2f(-pN, pB),
175  SLVec2f(-pF, pT),
176  10,
177  10,
178  "Wall left",
179  matWall));
180  l->rotate(90, 0, 1, 0);
181  l->translate(0, 0, pL, TS_object);
182  room->addChild(l);
183 
184  // right rectangle
185  SLNode* r = new SLNode(new SLRectangle(am,
186  SLVec2f(pF, pB),
187  SLVec2f(pN, pT),
188  10,
189  10,
190  "Wall right",
191  matWall));
192  r->rotate(90, 0, -1, 0);
193  r->translate(0, 0, -pR, TS_object);
194  room->addChild(r);
195 
196  // Firewood
197  _firewood->scale(2);
198  scene->addChild(_firewood);
199 
200  // Torch
201  _torchL->name("Torch Left");
202  SLNode* torchR = _torchL->copyRec();
203  torchR->name("Torch Right");
204  _torchL->translate(-2, 1.5f, 0);
205  _torchL->rotate(90, 0, 1, 0);
206  _torchL->scale(2);
207  scene->addChild(_torchL);
208  torchR->translate(2, 1.5f, 0);
209  torchR->rotate(-90, 0, 1, 0);
210  torchR->scale(2);
211  scene->addChild(torchR);
212 
213  // Torch flame left
214  SLNode* torchFlameNodeL = createTorchFire(am,
215  this,
216  true,
217  _texTorchSmk,
218  _texTorchFlm,
219  16,
220  4);
221  torchFlameNodeL->translate(-1.6f, 2.25f, 0);
222  torchFlameNodeL->name("Torch Fire Left");
223  scene->addChild(torchFlameNodeL);
224 
225  // Torch flame right
226  SLNode* torchFlameNodeR = createTorchFire(am,
227  this,
228  true,
229  _texTorchSmk,
230  _texTorchFlm,
231  16,
232  4);
233  torchFlameNodeR->translate(1.6f, 2.25f, 0);
234  torchFlameNodeR->name("Torch Fire Right");
235  scene->addChild(torchFlameNodeR);
236 
237  // Set background color and the root scene node
238  sv->sceneViewCamera()->background().colors(SLCol4f(0.8f, 0.8f, 0.8f),
239  SLCol4f(0.2f, 0.2f, 0.2f));
240  // Save energy
241  sv->doWaitOnIdle(false);
242  }
244  {
245  SLCamera* cam1 = new SLCamera("Camera 1");
246  cam1->clipNear(0.1f);
247  cam1->clipFar(1000);
248  cam1->translation(0, 10, 40);
249  cam1->focalDist(100);
250  cam1->lookAt(0, 0, 0);
251  cam1->background().colors(SLCol4f(0.3f, 0.3f, 0.3f));
252  cam1->setInitialState();
253 
254  // Root scene node
255  SLNode* root = new SLNode("Root Scene Node");
256  root3D(root);
257  root->addChild(cam1);
258  const int NUM_NODES = 250;
259 
260  SLVNode nodes(NUM_NODES);
261  for (int i = 0; i < NUM_NODES; ++i)
262  {
263  SLNode* fireComplex = createComplexFire(am,
264  this,
265  false,
266  _texFireCld,
267  _texFireFlm,
268  8,
269  4,
270  _texCircle,
271  _texSmokeB,
272  _texSmokeW);
273  fireComplex->translate(-20.0f + (float)(i % 20) * 2,
274  0.0f,
275  -(float)((i - (float)(i % 20)) / 20) * 4,
276  TS_object);
277  root->addChild(fireComplex);
278  }
279 
280  sv->camera(cam1);
281  sv->doWaitOnIdle(false);
282  }
283  else
284  SL_EXIT_MSG("Assemble: Should not get here!");
285 }
@ SID_ParticleSystem_ComplexFire
@ SID_Benchmark_ParticleSystemComplexFire
float SLfloat
Definition: SL.h:173
#define SL_EXIT_MSG(message)
Definition: SL.h:240
@ TS_object
Definition: SLEnums.h:210
@ RM_CookTorrance
Definition: SLEnums.h:290
deque< SLNode * > SLVNode
SLVNode typedef for a vector of SLNodes.
Definition: SLNode.h:26
SLVec2< SLfloat > SLVec2f
Definition: SLVec2.h:141
SLVec4< SLfloat > SLCol4f
Definition: SLVec4.h:237
SLNode * createComplexFire(SLAssetManager *am, SLScene *s, SLbool withLight, SLGLTexture *texFireCld, SLGLTexture *texFireFlm, SLint flipbookCols, SLint flipbookRows, SLGLTexture *texCircle, SLGLTexture *texSmokeB, SLGLTexture *texSmokeW)
Creates a complex fire group node.
SLNode * createTorchFire(SLAssetManager *am, SLScene *s, SLbool withLight, SLGLTexture *texFireCld, SLGLTexture *texFireFlm, SLint flipbookCols, SLint flipbookRows)
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 clipNear(const SLfloat cNear)
Definition: SLCamera.h:108
void focalDist(const SLfloat f)
Definition: SLCamera.h:116
SLBackground & background()
Definition: SLCamera.h:165
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
void reflectionModel(SLReflectionModel rm)
Definition: SLMaterial.h:169
void specular(const SLCol4f &spec)
Definition: SLMaterial.h:173
void roughness(SLfloat r)
Definition: SLMaterial.h:182
void metalness(SLfloat m)
Definition: SLMaterial.h:183
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 scale(SLfloat s)
Definition: SLNode.h:640
virtual SLNode * copyRec()
Definition: SLNode.cpp:572
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
void name(const SLstring &Name)
Definition: SLObject.h:34
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
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
void doWaitOnIdle(SLbool doWI)
Definition: SLSceneView.h:149
SLCamera * sceneViewCamera()
Definition: SLSceneView.h:169
static SLVec4 BLACK
Definition: SLVec4.h:213

◆ createComplexFire()

SLNode * AppDemoSceneParticleComplexFire::createComplexFire ( SLAssetManager am,
SLScene s,
SLbool  withLight,
SLGLTexture texFireCld,
SLGLTexture texFireFlm,
SLint  flipbookCols,
SLint  flipbookRows,
SLGLTexture texCircle,
SLGLTexture texSmokeB,
SLGLTexture texSmokeW 
)

Creates a complex fire group node.

Definition at line 288 of file AppDemoSceneParticleComplexFire.cpp.

298 {
299  SLNode* fireComplex = new SLNode("Fire complex node");
300 
301  // Fire light node
302  if (withLight)
303  {
304  SLLightSpot* light1 = new SLLightSpot(am,
305  s,
306  0.1f,
307  180.0f,
308  false);
309  light1->name("Fire light node");
310  light1->translate(0, 1.0f, 0);
311  light1->diffuseColor(SLCol4f(1, 0.7f, 0.2f));
312  light1->diffusePower(15);
313  light1->attenuation(0, 0, 1);
314  fireComplex->addChild(light1);
315  }
316 
317  // Fire glow mesh
318  {
319  SLParticleSystem* glow = new SLParticleSystem(am,
320  24,
321  SLVec3f(-0.1f, 0.0f, -0.1f),
322  SLVec3f(0.1f, 0.0f, 0.1f),
323  4.0f,
324  texFireCld,
325  "Fire glow PS");
326  glow->timeToLive(2.0f);
327  glow->billboardType(BT_Camera);
328  glow->radiusW(0.4f);
329  glow->radiusH(0.4f);
330  glow->doShape(false);
331  glow->doRotation(true);
332  glow->doRotRange(true);
333  glow->doSizeOverLT(false);
334  glow->doAlphaOverLT(false);
335  glow->doColorOverLT(false);
336  glow->doBlendBrightness(true);
337  glow->color(SLCol4f(0.925f, 0.5f, 0.097f, 0.199f));
338  glow->doAcceleration(false);
339  SLNode* flameGlowNode = new SLNode(glow, "Fire glow node");
340  flameGlowNode->translate(0, 0.15f, 0);
341  fireComplex->addChild(flameGlowNode);
342  }
343 
344  // Fire flame mesh
345  {
346  SLParticleSystem* flame = new SLParticleSystem(am,
347  1,
348  SLVec3f(0.0f, 0.0f, 0.0f),
349  SLVec3f(0.0f, 0.0f, 0.0f),
350 
351  1.0f,
352  texFireCld,
353  "Fire flame PS",
354  texFireFlm);
355  // Fire flame flipbook settings
356  flame->flipbookColumns(flipbookCols);
357  flame->flipbookRows(flipbookRows);
358  flame->doFlipBookTexture(true);
359  flame->doCounterGap(false); // We don't want to have flickering
360 
361  flame->doAlphaOverLT(false);
362  flame->doSizeOverLT(false);
363  flame->doRotation(false);
364 
365  flame->frameRateFB(64);
366  flame->radiusW(0.6f);
367  flame->radiusH(0.6f);
368  flame->scale(1.2f);
369  flame->billboardType(BT_Vertical);
370 
371  // Fire flame color
372  flame->doColor(true);
373  flame->color(SLCol4f(0.52f, 0.47f, 0.32f, 1.0f));
374  flame->doBlendBrightness(true);
375 
376  // Fire flame size
377  flame->doSizeOverLTCurve(true);
378  float sizeCPArrayFl[4] = {0.0f, 1.25f, 0.0f, 1.0f};
379  flame->bezierControlPointSize(sizeCPArrayFl);
380  float sizeSEArrayFl[4] = {0.0f, 1.0f, 1.0f, 1.0f};
381  flame->bezierStartEndPointSize(sizeSEArrayFl);
382  flame->generateBernsteinPSize();
383 
384  // Fire flame node
385  SLNode* fireFlameNode = new SLNode(flame, "Fire flame node");
386  fireFlameNode->translate(0.0f, 0.7f, 0.0f, TS_object);
387  fireComplex->addChild(fireFlameNode);
388  }
389 
390  // Fire smoke black mesh
391  {
392  SLParticleSystem* smokeB = new SLParticleSystem(am,
393  8,
394  SLVec3f(0.0f, 1.0f, 0.0f),
395  SLVec3f(0.0f, 0.7f, 0.0f),
396  2.0f,
397  texSmokeB,
398  "Fire smoke black PS");
399  smokeB->doColor(false);
400 
401  // Fire smoke black size
402  smokeB->doSizeOverLT(true);
403  smokeB->doSizeOverLTCurve(true);
404  float sizeCPArraySB[4] = {0.0f, 1.0f, 1.0f, 2.0f};
405  smokeB->bezierControlPointSize(sizeCPArraySB);
406  float sizeSEArraySB[4] = {0.0f, 1.0f, 1.0f, 2.0f};
407  smokeB->bezierStartEndPointSize(sizeSEArraySB);
408  smokeB->generateBernsteinPSize();
409 
410  // Fire smoke black alpha
411  smokeB->doAlphaOverLT(true);
412  smokeB->doAlphaOverLTCurve(true);
413  float alphaCPArraySB[4] = {0.0f, 0.4f, 1.0f, 0.4f};
414  smokeB->bezierControlPointAlpha(alphaCPArraySB);
415  float alphaSEArraySB[4] = {0.0f, 0.0f, 1.0f, 0.0f};
416  smokeB->bezierStartEndPointAlpha(alphaSEArraySB);
417  smokeB->generateBernsteinPAlpha();
418 
419  // Fire smoke black acceleration
420  smokeB->doAcceleration(true);
421  smokeB->doAccDiffDir(true);
422  smokeB->acceleration(0.0f, 0.25f, 0.3f);
423 
424  SLNode* fireSmokeBlackNode = new SLNode(smokeB, "Fire smoke black node");
425  fireSmokeBlackNode->translate(0.0f, 0.9f, 0.0f, TS_object);
426  fireComplex->addChild(fireSmokeBlackNode);
427  }
428 
429  // Fire smoke white mesh
430  {
431  SLParticleSystem* smokeW = new SLParticleSystem(am,
432  40,
433  SLVec3f(0.0f, 0.8f, 0.0f),
434  SLVec3f(0.0f, 0.6f, 0.0f),
435  4.0f,
436  texSmokeW,
437  "Fire smoke white PS");
438 
439  smokeW->doColor(false);
440 
441  // Size
442  smokeW->doSizeOverLT(true);
443  smokeW->doSizeOverLTCurve(true);
444  float sizeCPArraySW[4] = {0.0f, 0.5f, 1.0f, 2.0f};
445  smokeW->bezierControlPointSize(sizeCPArraySW);
446  float sizeSEArraySW[4] = {0.0f, 0.5f, 1.0f, 2.0f};
447  smokeW->bezierStartEndPointSize(sizeSEArraySW);
448  smokeW->generateBernsteinPSize();
449 
450  // Alpha
451  smokeW->doAlphaOverLT(true);
452  smokeW->doAlphaOverLTCurve(true);
453  float alphaCPArraySW[4] = {0.0f, 0.018f, 1.0f, 0.018f};
454  smokeW->bezierControlPointAlpha(alphaCPArraySW);
455  float alphaSEArraySW[4] = {0.0f, 0.0f, 1.0f, 0.0f};
456  smokeW->bezierStartEndPointAlpha(alphaSEArraySW);
457  smokeW->generateBernsteinPAlpha();
458 
459  // Acceleration
460  smokeW->doAcceleration(true);
461  smokeW->doAccDiffDir(true);
462  smokeW->acceleration(0.0f, 0.25f, 0.3f);
463 
464  SLNode* fireSmokeWNode = new SLNode(smokeW, "Fire smoke white node");
465  fireSmokeWNode->translate(0.0f, 0.9f, 0.0f, TS_object);
466  fireComplex->addChild(fireSmokeWNode);
467  }
468 
469  // Fire sparks rising mesh
470  {
471  SLParticleSystem* fireSparksRising = new SLParticleSystem(am,
472  30,
473  SLVec3f(-0.5f, 1, -0.5f),
474  SLVec3f(0.5f, 2, 0.5f),
475  1.2f,
476  texCircle,
477  "Fire sparks rising PS",
478  nullptr,
479  new SLTexColorLUT(am,
480  CLUT_WYR,
481  256));
482  fireSparksRising->scale(0.05f);
483  fireSparksRising->radiusH(0.8f);
484  fireSparksRising->radiusW(0.3f);
485  fireSparksRising->doShape(true);
486  fireSparksRising->doRotation(false);
487  fireSparksRising->shapeType(ST_Sphere);
488  fireSparksRising->shapeRadius(0.05f);
489  fireSparksRising->doAcceleration(true);
490  fireSparksRising->acceleration(0, 1.5f, 0);
491  fireSparksRising->doColor(true);
492  fireSparksRising->doColorOverLT(true);
493  fireSparksRising->doBlendBrightness(true);
494  fireSparksRising->doSizeOverLT(false);
495  fireSparksRising->doAlphaOverLT(false);
496  fireSparksRising->doGravity(false);
497  fireComplex->addChild(new SLNode(fireSparksRising,
498  "Fire sparks rising node"));
499  }
500 
501  return fireComplex;
502 }
@ ST_Sphere
Definition: SLEnums.h:280
@ BT_Camera
Definition: SLEnums.h:272
@ BT_Vertical
Definition: SLEnums.h:273
@ CLUT_WYR
white to black
Definition: SLTexColorLUT.h:28
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
void diffusePower(const SLfloat diffPow)
Definition: SLLight.h:108
void diffuseColor(const SLCol4f &diff)
Definition: SLLight.h:107
void attenuation(const SLfloat kConstant, const SLfloat kLinear, const SLfloat kQuadratic)
Definition: SLLight.h:116
SLLightSpot class for a spot light source.
Definition: SLLightSpot.h:36
SLParticleSystem creates a particle meshes from a point primitive buffer.
float * bezierControlPointSize()
float * bezierControlPointAlpha()
SLbool doFlipBookTexture()
SLShapeType shapeType()
float * bezierStartEndPointSize()
SLBillboardType billboardType()
float * bezierStartEndPointAlpha()
SLbool doAlphaOverLTCurve()
SLbool doBlendBrightness()
void doAcceleration(SLbool b)
SLbool doSizeOverLTCurve()
SLVec3f acceleration()
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SLTexColorLUT defines a lookup table as an 1D texture of (256) RGBA values.
Definition: SLTexColorLUT.h:70

◆ createTorchFire()

SLNode * AppDemoSceneParticleComplexFire::createTorchFire ( SLAssetManager am,
SLScene s,
SLbool  withLight,
SLGLTexture texFireCld,
SLGLTexture texFireFlm,
SLint  flipbookCols,
SLint  flipbookRows 
)

Definition at line 504 of file AppDemoSceneParticleComplexFire.cpp.

511 {
512 
513  SLNode* torchFire = new SLNode("Fire torch node");
514 
515  // Fire light node
516  if (withLight)
517  {
518  SLLightSpot* light1 = new SLLightSpot(am,
519  s,
520  0.1f,
521  180.0f,
522  false);
523  light1->name("Fire light node");
524  light1->translate(0, 0, 0);
525  light1->diffuseColor(SLCol4f(1, 0.4f, 0.0f));
526  light1->diffusePower(2);
527  light1->attenuation(0, 0, 1);
528  torchFire->addChild(light1);
529  }
530 
531  // Fire glow mesh
532  {
533  SLParticleSystem* glow = new SLParticleSystem(am,
534  40,
535  SLVec3f(-0.1f, 0.0f, -0.1f),
536  SLVec3f(0.1f, 0.0f, 0.1f),
537  1.5f,
538  texFireCld,
539  "Torch Glow PS");
540  glow->color(SLCol4f(0.9f, 0.5f, 0, 0.63f));
541  glow->doBlendBrightness(true);
542  glow->radiusW(0.15f);
543  glow->radiusH(0.15f);
544  glow->doSizeOverLT(false);
545  SLNode* fireGlowNode = new SLNode(glow, "Torch Glow Node");
546  fireGlowNode->translate(0, -0.4f, 0);
547  torchFire->addChild(fireGlowNode);
548  }
549 
550  // Fire torches
551  {
552  SLParticleSystem* flame = new SLParticleSystem(am,
553  1,
554  SLVec3f(0.0f, 0.0f, 0.0f),
555  SLVec3f(0.0f, 0.0f, 0.0f),
556  4.0f,
557  texFireCld,
558  "Torch Flame PS",
559  texFireFlm);
560  flame->flipbookColumns(flipbookCols);
561  flame->flipbookRows(flipbookRows);
562  flame->doFlipBookTexture(true);
563  flame->doCounterGap(false); // We don't want to have flickering
564  flame->doAlphaOverLT(false);
565  flame->doSizeOverLT(false);
566  flame->doRotation(false);
567  flame->doColor(false);
568  flame->frameRateFB(64);
569  flame->radiusW(0.3f);
570  flame->radiusH(0.8f);
571  flame->billboardType(BT_Vertical);
572  SLNode* torchFlameNode = new SLNode(flame, "Torch Flame Node");
573  torchFlameNode->translate(0, 0.3f, 0);
574  torchFire->addChild(torchFlameNode);
575  }
576 
577  return torchFire;
578 }

◆ registerAssetsToLoad()

void AppDemoSceneParticleComplexFire::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 32 of file AppDemoSceneParticleComplexFire.cpp.

33 {
36  "ParticleFirecloudTransparent_C.png");
39  "ParticleFlames_06_8x8_C.png");
42  "ParticleCircle_05_C.png");
45  "ParticleCloudBlack_C.png");
48  "ParticleCloudWhite_C.png");
51  "ParticleFlames_04_16x4_C.png");
54  "ParticleSmoke_08_C.png");
55 
58  "BrickLimestoneGray_1K_DIF.jpg",
60  GL_LINEAR);
63  "BrickLimestoneGray_1K_NRM.jpg",
65  GL_LINEAR);
66 
69  "GLTF/Firewood/Firewood1.gltf",
70  nullptr,
71  false,
72  true,
73  nullptr,
74  0.3f,
75  true);
78  "GLTF/Torch/Torch.gltf",
79  nullptr,
80  false,
81  true,
82  nullptr,
83  0.3f,
84  true);
85 }
#define SL_ANISOTROPY_MAX
Definition: SLGLTexture.h:34
static SLstring modelPath
Path to 3D models.
Definition: AppCommon.h:85
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.
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

◆ _firewood

SLNode* AppDemoSceneParticleComplexFire::_firewood
private

Definition at line 73 of file AppDemoSceneParticleComplexFire.h.

◆ _sceneID

SLSceneID AppDemoSceneParticleComplexFire::_sceneID
private

Definition at line 63 of file AppDemoSceneParticleComplexFire.h.

◆ _texCircle

SLGLTexture* AppDemoSceneParticleComplexFire::_texCircle
private

Definition at line 66 of file AppDemoSceneParticleComplexFire.h.

◆ _texFireCld

SLGLTexture* AppDemoSceneParticleComplexFire::_texFireCld
private

Definition at line 64 of file AppDemoSceneParticleComplexFire.h.

◆ _texFireFlm

SLGLTexture* AppDemoSceneParticleComplexFire::_texFireFlm
private

Definition at line 65 of file AppDemoSceneParticleComplexFire.h.

◆ _texSmokeB

SLGLTexture* AppDemoSceneParticleComplexFire::_texSmokeB
private

Definition at line 67 of file AppDemoSceneParticleComplexFire.h.

◆ _texSmokeW

SLGLTexture* AppDemoSceneParticleComplexFire::_texSmokeW
private

Definition at line 68 of file AppDemoSceneParticleComplexFire.h.

◆ _texTorchFlm

SLGLTexture* AppDemoSceneParticleComplexFire::_texTorchFlm
private

Definition at line 69 of file AppDemoSceneParticleComplexFire.h.

◆ _texTorchSmk

SLGLTexture* AppDemoSceneParticleComplexFire::_texTorchSmk
private

Definition at line 70 of file AppDemoSceneParticleComplexFire.h.

◆ _texWallDIF

SLGLTexture* AppDemoSceneParticleComplexFire::_texWallDIF
private

Definition at line 71 of file AppDemoSceneParticleComplexFire.h.

◆ _texWallNRM

SLGLTexture* AppDemoSceneParticleComplexFire::_texWallNRM
private

Definition at line 72 of file AppDemoSceneParticleComplexFire.h.

◆ _torchL

SLNode* AppDemoSceneParticleComplexFire::_torchL
private

Definition at line 74 of file AppDemoSceneParticleComplexFire.h.


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