SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLParticleSystem.h
Go to the documentation of this file.
1 /**
2  * \file SLParticleSystem.h
3  * \date February 2022
4  * \remarks Please use clangformat to format the code. See more code style on
5  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
6  * \authors Affolter Marc in his bachelor thesis in spring 2022
7  * \copyright http://opensource.org/licenses/GPL-3.0
8 */
9 
10 #ifndef SLParticleSystem_H
11 #define SLParticleSystem_H
12 
13 #include <SLMesh.h>
14 #include <SLGLTexture.h>
15 #include <Averaged.h>
16 #include <SLRnd3f.h>
17 #include <SLTexColorLUT.h>
18 
19 //-----------------------------------------------------------------------------
20 /**
21  * @brief SLParticleSystem creates a particle meshes from a point primitive buffer.
22  * @details The SLParticleSystem mesh object of which the vertices are drawn as points.
23  * An OpenGL transform feedback buffer is used to update the particle positions
24  * on the GPU and a geometry shader is used the create two triangles per
25  * particle vertex and orient them as a billboard to the viewer. Geometry
26  * shaders are only supported under OpenGL >= 4.0 and OpenGLES >= 3.2. This is
27  * the case on most desktop systems and on Android SDK > 24 but not on iOS which
28  * has only OpenGL ES 3.0\n.
29  * For all systems that don't support geometry shaders we use an alternative
30  * with instanced drawing (mainly for iOS and Emscripten with WebGL)\n.
31  * The particle system supports many options of which many can be turned on the
32  * do* methods. All options can also be modified in the UI when the mesh is
33  * selected. See the different demo scenes in the app_demo_slproject under the
34  * demo scene group Particle Systems.
35  * @remarks It is important that during instantiation NO OpenGL functions (gl*)
36  * get called because this constructor will be most probably called in a parallel
37  * thread from within an SLScene::registerAssetsToLoad or SLScene::assemble
38  * function. All objects that get rendered have to do their OpenGL initialization
39  * when they are used the first time during rendering in the main thread.
40  * For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP,
41  * _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.
42  */
43 class SLParticleSystem : public SLMesh
44 {
45 public:
47  const SLint amount,
48  const SLVec3f& velocityRandomStart,
49  const SLVec3f& velocityRandomEnd,
50  const SLfloat& timeToLive,
51  SLGLTexture* texC,
52  const SLstring& name = "Particle System",
53  SLGLTexture* texFlipbook = nullptr,
54  SLTexColorLUT* texGradient = nullptr,
55  const bool doInstancedDrawing = false);
56 
57  void draw(SLSceneView* sv, SLNode* node, SLuint instances = 1);
58  void buildAABB(SLAABBox& aabb, const SLMat4f& wmNode);
59  void generate();
62  void changeTexture();
64  void pauseOrResume();
65  void calcNormals() { N.push_back(SLVec3f(0, 1, 0)); };
66 
67  // Getters
70  SLint amount() { return _amount; }
78  SLCol4f color() { return _color; }
79 
87  SLbool doColor() { return _doColor; }
90  SLbool doGravity() { return _doGravity; }
96  SLbool doShape() { return _doShape; }
102 
104  AvgFloat& drawTime() { return _drawTime; }
105  SLVec3f emitterPos() const { return _emitterPos; }
106  SLVec3f gravity() { return _gravity; }
109  int frameRateFB() { return _flipbookFPS; }
111  SLbool isPaused() { return _isPaused; }
112  SLfloat radiusW() { return _radiusW; }
113  SLfloat radiusH() { return _radiusH; }
114  SLfloat scale() { return _scale; }
121  SLfloat speed() { return _speed; }
132 
133  // Setters
134  void doInstancedDrawing(bool instanced) { _doInstancedDrawing = instanced; }
135  void amount(SLint i) { _amount = i; }
139  {
140  _acceleration.x = vX;
141  _acceleration.y = vY;
142  _acceleration.z = vZ;
143  }
147  {
150  }
152  void bezierControlPointAlpha(float arrayPoint[4])
153  {
154  _bezierControlPointAlpha[0] = arrayPoint[0];
155  _bezierControlPointAlpha[1] = arrayPoint[1];
156  _bezierControlPointAlpha[2] = arrayPoint[2];
157  _bezierControlPointAlpha[3] = arrayPoint[3];
158  }
159  void bezierStartEndPointAlpha(float arrayPoint[4])
160  {
161  _bezierStartEndPointAlpha[0] = arrayPoint[0];
162  _bezierStartEndPointAlpha[1] = arrayPoint[1];
163  _bezierStartEndPointAlpha[2] = arrayPoint[2];
164  _bezierStartEndPointAlpha[3] = arrayPoint[3];
165  }
166  void bezierControlPointSize(float arrayPoint[4])
167  {
168  _bezierControlPointSize[0] = arrayPoint[0];
169  _bezierControlPointSize[1] = arrayPoint[1];
170  _bezierControlPointSize[2] = arrayPoint[2];
171  _bezierControlPointSize[3] = arrayPoint[3];
172  }
173  void bezierStartEndPointSize(float arrayPoint[4])
174  {
175  _bezierStartEndPointSize[0] = arrayPoint[0];
176  _bezierStartEndPointSize[1] = arrayPoint[1];
177  _bezierStartEndPointSize[2] = arrayPoint[2];
178  _bezierStartEndPointSize[3] = arrayPoint[3];
179  }
180  void color(SLCol4f c) { _color = c; }
181  void direction(SLVec3f v) { _direction = v; }
182  void direction(SLfloat vX, SLfloat vY, SLfloat vZ)
183  {
184  _direction.x = vX;
185  _direction.y = vY;
186  _direction.z = vZ;
187  }
193  void doColor(SLbool b) { _doColor = b; }
197  void doGravity(SLbool b) { _doGravity = b; }
199  void doRotation(SLbool b) { _doRotation = b; }
200  void doRotRange(SLbool b) { _doRotRange = b; }
202  void doShape(SLbool b) { _doShape = b; }
209  void emitterPos(SLVec3f p) { _emitterPos = p; }
210  void gravity(SLVec3f v) { _gravity = v; }
211  void gravity(SLfloat vX, SLfloat vY, SLfloat vZ)
212  {
213  _gravity.x = vX;
214  _gravity.y = vY;
215  _gravity.z = vZ;
216  }
219  void frameRateFB(int i) { _flipbookFPS = i; }
220  void isGenerated(SLbool b) { _isGenerated = b; }
221  void radiusW(SLfloat f) { _radiusW = f; }
222  void radiusH(SLfloat f) { _radiusH = f; }
223  void scale(SLfloat f) { _scale = f; }
224  void speed(SLfloat f) { _speed = f; }
225  void speedRange(SLVec2f v) { _speedRange = v; }
227  {
228  _speedRange.x = vX;
229  _speedRange.y = vY;
230  }
231  void shapeType(SLShapeType st) { _shapeType = st; }
232  void shapeAngle(SLfloat f) { _shapeAngle = f; }
234  void shapeScale(SLVec3f v) { _shapeScale = v; }
236  {
237  _shapeScale.x = vX;
238  _shapeScale.y = vY;
239  _shapeScale.z = vZ;
240  }
242  void shapeWidth(SLfloat f) { _shapeWidth = f; }
243  void timeToLive(SLfloat f) { _timeToLive = f; }
250  {
251  _velocityConst.x = vX;
252  _velocityConst.y = vY;
253  _velocityConst.z = vZ;
254  }
257  {
258  _velocityRndMin.x = vX;
259  _velocityRndMin.y = vY;
260  _velocityRndMin.z = vZ;
261  }
264  {
265  _velocityRndMax.x = vX;
266  _velocityRndMax.y = vY;
267  _velocityRndMax.z = vZ;
268  }
269 
270 private:
271  // Random point getter functions depending on the PS shape
272  SLVec3f getPointInSphere(float radius, SLVec3f randomX);
273  SLVec3f getPointOnSphere(float radius, SLVec3f randomX);
275  SLVec3f getPointInBox(SLVec3f boxScale);
276  SLVec3f getPointOnBox(SLVec3f boxScale);
277  SLVec3f getDirectionBox(SLVec3f position);
280  SLVec3f getDirectionCone(SLVec3f position);
284 
285  // Used to recreate material (the shader changes depending on if the PS is instanced or not)
286  SLAssetManager* _assetManager; //!< pointer to the asset manager (the owner) if available
287 
288  // Core values
289  SLint _amount; //!< Amount of a particle
290  SLVec3f _emitterPos; //!< Position of the particle emitter
291  SLfloat _timeToLive; //!< Time to live of a particle
292  SLfloat _radiusW = 0.4f; //!< width radius of a particle
293  SLfloat _radiusH = 0.4f; //!< height radius of a particle
294  SLfloat _scale = 1.0f; //!< Scale of a particle (Scale the radius)
295 
296  // Bezier
297  SLVec4f _bernsteinPYAlpha = SLVec4f(2.0f, -3.0f, 0.0f, 1.0f); //!< Vector for bezier curve (default linear function)
298  float _bezierControlPointAlpha[4] = {0.0f, 1.0f, 1.0f, 0.0f}; //!< Floats for bezier curve control points (P1: 01 ; P2: 23)
299  float _bezierStartEndPointAlpha[4] = {0.0f, 1.0f, 1.0f, 0.0f}; //!< Floats for bezier curve end start points (Start: 01 ; End: 23)
300  SLVec4f _bernsteinPYSize = SLVec4f(-1.4f, 1.8f, 0.6f, 0.0f); //!< Vector for bezier curve (default linear function)
301  float _bezierControlPointSize[4] = {0.0f, 0.0f, 1.0f, 1.0f}; //!< Floats for bezier curve control points (P1: 01 ; P2: 23)
302  float _bezierStartEndPointSize[4] = {0.0f, 0.0f, 1.0f, 1.0f}; //!< Floats for bezier curve end start points (Start: 01 ; End: 23)
303 
304  // Acceleration
305  SLVec3f _acceleration = SLVec3f(1, 1, 1); //!< Vector for acceleration (different direction as the velocity)
306  SLfloat _accelerationConst = 0.0f; //!< Acceleration constant (same direction as the velocity)
307  SLVec3f _gravity = SLVec3f(0.0f, -9.81f, 0.0f); //!< Vector for gravity (2nd. acceleration vector)
308 
309  // Velocity
310  SLVec3f _velocityConst = SLVec3f(0, 1, 0); //!< Velocity constant (go in xyz direction)
311  SLVec3f _velocityRndMin = SLVec3f(-1, -1, -1); //!< Min. random velocity
312  SLVec3f _velocityRndMax = SLVec3f(1, 1, 1); //!< Max. random velocity
313 
314  // Direction speed
315  SLVec3f _direction = SLVec3f(0, 0, 0); //!< Direction of particle
316  SLfloat _speed = 1.0f; //!< Speed of particle
317  SLVec2f _speedRange = SLVec2f(1, 2); //!< Speed random between two value
318 
319  // Color
320  SLCol4f _color = SLCol4f(0.66f, 0.0f, 0.66f, 0.2f); //!< Color for particle
321 
322  // Int (but boolean) to switch buffer
323  int _drawBuf = 0; //!< Boolean to switch buffer
324 
325  // Flipbook
326  int _flipbookFPS = 16; //!< Number of update of flipbook by second
327  float _flipboookLastUpdate = 0.0f; //!< Last time flipbook was updated
328  SLint _flipbookColumns = 8; //!< Number of flipbook sub-textures by column
329  SLint _flipbookRows = 8; //!< Number of flipbook sub-textures by row
330 
331  // Statistics
332  AvgFloat _updateTime; //!< Averaged time for updating in MS
333  AvgFloat _drawTime; //!< Averaged time for drawing in MS
334  SLfloat _startDrawTimeMS = 0.0f; //!< Time since start of draw in MS
335  SLfloat _startUpdateTimeMS = 0.0f; //!< Time since start for updating in MS
336  SLfloat _startUpdateTimeS = 0.0f; //!< Time since start for updating in S
337  SLfloat _deltaTimeUpdateS = 0.0f; //!< Delta time in between two frames S
338 
339  // For resume after frustumCulling
340  SLfloat _notVisibleTimeS = 0.0f; //!< Time since start when node not visible in S
341 
342  // For drawing while pause
343  SLfloat _lastTimeBeforePauseS = 0.0f; //!< Time since the particle system is paused
344 
345  // Shape parameters
346  SLfloat _shapeRadius = 1.0f; //!< Radius of sphere and cone shape
347  SLVec3f _shapeScale = SLVec3f(1.0f); //!< Scale of box shape
348  SLfloat _shapeHeight = 3.0f; //!< Height of cone and pyramid shapes
349  SLfloat _shapeAngle = 10.0f; //!< Angle of cone and pyramid shapes
350  SLfloat _shapeWidth = 2.0f; //!< Width of pyramid shape
351 
352  // Rotation
353  SLfloat _angularVelocityConst = 30.0f; //!< Rotation rate const (change in angular rotation divide by change in time)
354  SLVec2f _angularVelocityRange = SLVec2f(-30.0f, 30.0f); //!< Rotation rate range (change in angular rotation divide by change in time)
355 
356  // Type of selected feature
357  SLBillboardType _billboardType = BT_Camera; //!< Billboard type (BT_Camera, BT_Vertical, BT_Horizontal
358  SLShapeType _shapeType = ST_Sphere; //!< Shape type (ST_)
359  SLint _velocityType = 0; //!< Velocity type
360 
361  // Textures
362  SLGLTexture* _texParticle; //!< Main texture of PS (non flipbook)
363  SLGLTexture* _texFlipbook; //!< Flipbook texture with e.g. multiple flames at subsequent frames
364  SLTexColorLUT* _texGradient; //!< Color gradient texture
365 
366  // VAOs
367  SLGLVertexArray _vao1; //!< 1. VAO for swapping between updating/drawing
368  SLGLVertexArray _vao2; //!< 2. VAO for swapping between updating/drawing
369  SLGLVertexArray _instanceVao1; //!< 1. VAO for instanced rendering with vao1
370  SLGLVertexArray _instanceVao2; //!< 2. VAO for instanced rendering with vao2
371 
372  // Boolean for generation/resume
373  SLbool _isVisibleInFrustum = true; //!< Boolean to set time since node not visible
374  SLbool _isPaused = false; //!< Boolean to stop updating
375  SLbool _isGenerated = false; //!< Boolean to generate particle system and load it on the GPU
376 
377  // Boolean for features
378  SLbool _doBlendBrightness = false; //!< Boolean for glow/brightness on pixel with many particle
379  SLbool _doDirectionSpeed = false; //!< Boolean for direction and speed (override velocity)
380  SLbool _doSpeedRange = false; //!< Boolean for speed range
381  SLbool _doCounterGap = true; //!< Boolean for counter lag/gap, can create flickering with few particle (explained in documentation) when enable
382  SLbool _doAcceleration = false; //!< Boolean for acceleration
383  SLbool _doAccDiffDir = false; //!< Boolean for acceleration (different direction)
384  SLbool _doRotation = true; //!< Boolean for rotation
385  SLbool _doRotRange = false; //!< Boolean for rotation range (random value between range)
386  SLbool _doColor = true; //!< Boolean for color
387  SLbool _doShape = false; //!< Boolean for shape feature
388  SLbool _doShapeSurface = false; //!< Boolean for shape surface (particle will be spawned on surface)
389  SLbool _doShapeOverride = false; //!< Boolean for override direction for shape direction
390  SLbool _doShapeSpawnBase = false; //!< Boolean for spawn at base of shape (for cone and pyramid)
391  SLbool _doWorldSpace = false; //!< Boolean for world space position
392  SLbool _doGravity = false; //!< Boolean for gravity
393  SLbool _doAlphaOverLT = true; //!< Boolean for alpha over life time
394  SLbool _doColorOverLT = false; //!< Boolean for color over life time
395  SLbool _doAlphaOverLTCurve = false; //!< Boolean for alpha over life time curve
396  SLbool _doSizeOverLT = true; //!< Boolean for size over life time
397  SLbool _doSizeOverLTCurve = false; //!< Boolean for size over life time curve
398  SLbool _doFlipBookTexture = false; //!< Boolean for flipbook texture
399  SLbool _doInstancedDrawing = false; //!< Boolean for instanced rendering
400 };
401 //-----------------------------------------------------------------------------
402 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
SLShapeType
Particle system shape type.
Definition: SLEnums.h:279
@ ST_Sphere
Definition: SLEnums.h:280
SLBillboardType
Billboard type for its orientation used in SLParticleSystem.
Definition: SLEnums.h:271
@ BT_Camera
Definition: SLEnums.h:272
Declares a color look up table functionality.
SLVec2< SLfloat > SLVec2f
Definition: SLVec2.h:141
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
SLVec4< SLfloat > SLVec4f
Definition: SLVec4.h:235
SLVec4< SLfloat > SLCol4f
Definition: SLVec4.h:237
Defines an axis aligned bounding box.
Definition: SLAABBox.h:34
Toplevel holder of the assets meshes, materials, textures and shaders.
Texture object for OpenGL texturing.
Definition: SLGLTexture.h:110
SLGLVertexArray encapsulates the core OpenGL drawing.
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
SLVVec3f N
Vector for vertex normals (opt.) layout (location = 1)
Definition: SLMesh.h:204
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
const SLstring & name() const
Definition: SLObject.h:38
SLParticleSystem creates a particle meshes from a point primitive buffer.
void speed(SLfloat f)
void doAlphaOverLTCurve(SLbool b)
void bezierControlPointSize(float arrayPoint[4])
SLbool doShapeSpawnBase()
SLbool _isPaused
Boolean to stop updating.
void bezierStartEndPointAlpha(float arrayPoint[4])
SLbool doShapeOverride()
SLfloat _shapeAngle
Angle of cone and pyramid shapes.
SLbool _doWorldSpace
Boolean for world space position.
void speedRange(SLfloat vX, SLfloat vY)
AvgFloat & drawTime()
SLint _velocityType
Velocity type.
SLbool _doAcceleration
Boolean for acceleration.
SLVec2f _speedRange
Speed random between two value.
void generate()
Function which will generate the particles and attributes them to the VAO.
void emitterPos(SLVec3f p)
void calcNormals()
SLMesh::calcNormals recalculates vertex normals for triangle meshes.
SLGLVertexArray _vao2
SLVec3f getDirectionCone(SLVec3f position)
Function which return a direction following the cone shape.
void buildAABB(SLAABBox &aabb, const SLMat4f &wmNode)
SLVec3f _emitterPos
Position of the particle emitter.
SLGLTexture * _texFlipbook
Flipbook texture with e.g. multiple flames at subsequent frames.
int _flipbookFPS
Number of update of flipbook by second.
SLbool _isGenerated
Boolean to generate particle system and load it on the GPU.
void timeToLive(SLfloat f)
void acceleration(SLfloat vX, SLfloat vY, SLfloat vZ)
AvgFloat _drawTime
Averaged time for drawing in MS.
SLfloat _lastTimeBeforePauseS
Time since the particle system is paused.
SLGLTexture * texFlipbook()
float * bezierControlPointSize()
SLfloat _notVisibleTimeS
Time since start when node not visible in S.
SLbool _doShapeSurface
Boolean for shape surface (particle will be spawned on surface)
void shapeScale(SLVec3f v)
void frameRateFB(int i)
SLVec2f _angularVelocityRange
Rotation rate range (change in angular rotation divide by change in time)
SLfloat _timeToLive
Time to live of a particle.
SLbool _doSpeedRange
Boolean for speed range.
void radiusW(SLfloat f)
SLbool _doInstancedDrawing
Boolean for instanced rendering.
void doAccDiffDir(SLbool b)
SLVec3f getDirectionBox(SLVec3f position)
Function which return the direction towards the exterior of a box.
void doRotation(SLbool b)
void scale(SLfloat f)
void doSpeedRange(SLbool b)
void doSizeOverLTCurve(SLbool b)
SLbool _doGravity
Boolean for gravity.
SLfloat _scale
Scale of a particle (Scale the radius)
SLVec3f getPointInSphere(float radius, SLVec3f randomX)
Function which return a position in a sphere.
void velocityRndMax(SLfloat vX, SLfloat vY, SLfloat vZ)
SLint _amount
Amount of a particle.
SLGLVertexArray _instanceVao2
void direction(SLVec3f v)
float _bezierStartEndPointSize[4]
Floats for bezier curve end start points (Start: 01 ; End: 23)
void doRotRange(SLbool b)
SLfloat _deltaTimeUpdateS
Delta time in between two frames S.
void doShapeSpawnBase(SLbool b)
void doSizeOverLT(SLbool b)
float * bezierControlPointAlpha()
SLVec3f getPointOnCone()
Function which return a position on the cone define in the particle system.
void doInstancedDrawing(bool instanced)
void isGenerated(SLbool b)
SLTexColorLUT * texGradient()
SLbool doFlipBookTexture()
SLbool doDirectionSpeed()
SLVec3f velocityRndMax()
SLVec3f emitterPos() const
SLfloat _radiusW
width radius of a particle
void doColor(SLbool b)
SLVec4f _bernsteinPYAlpha
Vector for bezier curve (default linear function)
SLbool _doRotation
Boolean for rotation.
void bezierControlPointAlpha(float arrayPoint[4])
SLShapeType shapeType()
SLBillboardType _billboardType
Billboard type (BT_Camera, BT_Vertical, BT_Horizontal.
void billboardType(SLBillboardType bt)
SLfloat angularVelocityConst()
void doShapeSurface(SLbool b)
void gravity(SLVec3f v)
void radiusH(SLfloat f)
void shapeHeight(SLfloat f)
SLbool _doDirectionSpeed
Boolean for direction and speed (override velocity)
SLbool _doSizeOverLT
Boolean for size over life time.
SLfloat _angularVelocityConst
Rotation rate const (change in angular rotation divide by change in time)
void bezierStartEndPointSize(float arrayPoint[4])
void acceleration(SLVec3f v)
SLGLVertexArray _instanceVao1
void gravity(SLfloat vX, SLfloat vY, SLfloat vZ)
void shapeRadius(SLfloat r)
SLbool _doRotRange
Boolean for rotation range (random value between range)
SLbool _isVisibleInFrustum
Boolean to set time since node not visible.
SLfloat _shapeRadius
Radius of sphere and cone shape.
void amount(SLint i)
void texParticle(SLGLTexture *tp)
float * bezierStartEndPointSize()
int _drawBuf
Boolean to switch buffer.
void doShape(SLbool b)
SLfloat _accelerationConst
Acceleration constant (same direction as the velocity)
SLBillboardType billboardType()
void velocityRndMin(SLfloat vX, SLfloat vY, SLfloat vZ)
float _bezierStartEndPointAlpha[4]
Floats for bezier curve end start points (Start: 01 ; End: 23)
void doFlipBookTexture(SLbool b)
void doBlendBrightness(SLbool b)
void angularVelocityRange(SLVec2f v)
void doColorOverLT(SLbool b)
SLVec3f getDirectionSphere(SLVec3f position)
Function which return the direction towards the exterior of a sphere.
SLVec3f getPointOnSphere(float radius, SLVec3f randomX)
Function which return a position on a sphere.
SLbool _doColorOverLT
Boolean for color over life time.
SLfloat _shapeWidth
Width of pyramid shape.
void doShapeOverride(SLbool b)
SLVec3f getPointInCone()
Function which return a position in the cone define in the particle system.
void velocityConst(SLfloat vX, SLfloat vY, SLfloat vZ)
float _bezierControlPointSize[4]
Floats for bezier curve control points (P1: 01 ; P2: 23)
AvgFloat & updateTime()
float * bezierStartEndPointAlpha()
SLfloat _startUpdateTimeS
Time since start for updating in S.
SLbool doAlphaOverLTCurve()
void velocityType(SLint i)
void velocityRndMin(SLVec3f v)
SLbool _doAlphaOverLT
Boolean for alpha over life time.
SLfloat _startUpdateTimeMS
Time since start for updating in MS.
SLbool _doFlipBookTexture
Boolean for flipbook texture.
void doWorldSpace(SLbool b)
SLVec4f _bernsteinPYSize
Vector for bezier curve (default linear function)
void angularVelocityConst(SLfloat f)
void flipbookColumns(SLint i)
SLVec3f _direction
Direction of particle.
void color(SLCol4f c)
SLbool _doCounterGap
Boolean for counter lag/gap, can create flickering with few particle (explained in documentation) whe...
SLCol4f _color
Color for particle.
SLbool _doShapeOverride
Boolean for override direction for shape direction.
SLVec3f _velocityConst
Velocity constant (go in xyz direction)
SLGLTexture * texParticle()
AvgFloat _updateTime
Averaged time for updating in MS.
SLParticleSystem(SLAssetManager *assetMgr, const SLint amount, const SLVec3f &velocityRandomStart, const SLVec3f &velocityRandomEnd, const SLfloat &timeToLive, SLGLTexture *texC, const SLstring &name="Particle System", SLGLTexture *texFlipbook=nullptr, SLTexColorLUT *texGradient=nullptr, const bool doInstancedDrawing=false)
SLParticleSystem ctor with some initial values. The number of particles.
SLGLTexture * _texParticle
Main texture of PS (non flipbook)
SLbool _doAccDiffDir
Boolean for acceleration (different direction)
void shapeScale(SLfloat vX, SLfloat vY, SLfloat vZ)
SLVec3f getPointInPyramid()
Function which returns a position in the pyramid that define the PS.
SLint _flipbookColumns
Number of flipbook sub-textures by column.
SLbool _doAlphaOverLTCurve
Boolean for alpha over life time curve.
SLfloat _startDrawTimeMS
Time since start of draw in MS.
void texGradient(SLTexColorLUT *tg)
void direction(SLfloat vX, SLfloat vY, SLfloat vZ)
float _flipboookLastUpdate
Last time flipbook was updated.
void doDirectionSpeed(SLbool b)
SLbool doBlendBrightness()
void doCounterGap(SLbool b)
SLint _flipbookRows
Number of flipbook sub-textures by row.
SLbool _doShape
Boolean for shape feature.
void doAcceleration(SLbool b)
SLbool doSizeOverLTCurve()
SLbool _doBlendBrightness
Boolean for glow/brightness on pixel with many particle.
float _bezierControlPointAlpha[4]
Floats for bezier curve control points (P1: 01 ; P2: 23)
SLfloat _shapeHeight
Height of cone and pyramid shapes.
SLVec3f _gravity
Vector for gravity (2nd. acceleration vector)
SLfloat _radiusH
height radius of a particle
SLbool _doShapeSpawnBase
Boolean for spawn at base of shape (for cone and pyramid)
SLVec2f angularVelocityRange()
SLVec3f _shapeScale
Scale of box shape.
SLVec3f velocityRndMin()
SLfloat accelerationConst()
SLVec3f acceleration()
SLVec3f getDirectionPyramid(SLVec3f position)
Function which return a direction following the pyramid shape.
void angularVelocityRange(SLfloat vX, SLfloat vY)
void velocityConst(SLVec3f v)
void accConst(SLfloat f)
void flipbookRows(SLint i)
SLVec3f getPointOnBox(SLVec3f boxScale)
Function which return a position on a box.
SLGLVertexArray _vao1
SLVec3f _velocityRndMax
Max. random velocity.
void shapeType(SLShapeType st)
SLTexColorLUT * _texGradient
Color gradient texture.
void draw(SLSceneView *sv, SLNode *node, SLuint instances=1)
SLbool _doSizeOverLTCurve
Boolean for size over life time curve.
void velocityRndMax(SLVec3f v)
void speedRange(SLVec2f v)
SLVec3f _acceleration
Vector for acceleration (different direction as the velocity)
void shapeAngle(SLfloat f)
void shapeWidth(SLfloat f)
SLbool doInstancedDrawing()
SLVec3f getPointInBox(SLVec3f boxScale)
Function which return a position in a box.
void doAlphaOverLT(SLbool b)
void texFlipbook(SLGLTexture *tf)
void doGravity(SLbool b)
SLShapeType _shapeType
Shape type (ST_)
SLAssetManager * _assetManager
pointer to the asset manager (the owner) if available
SLbool _doColor
Boolean for color.
SLVec3f getPointOnPyramid()
Function which return a position on the pyramid that defines the PS.
SLfloat _speed
Speed of particle.
SLVec3f _velocityRndMin
Min. random velocity.
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
SLTexColorLUT defines a lookup table as an 1D texture of (256) RGBA values.
Definition: SLTexColorLUT.h:70
T y
Definition: SLVec2.h:30
T x
Definition: SLVec2.h:30
T y
Definition: SLVec3.h:43
T x
Definition: SLVec3.h:43
T z
Definition: SLVec3.h:43