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

SLParticleSystem creates a particle meshes from a point primitive buffer. More...

#include <SLParticleSystem.h>

Inheritance diagram for SLParticleSystem:
[legend]

Public Member Functions

 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. More...
 
void draw (SLSceneView *sv, SLNode *node, SLuint instances=1)
 
void buildAABB (SLAABBox &aabb, const SLMat4f &wmNode)
 
void generate ()
 Function which will generate the particles and attributes them to the VAO. More...
 
void generateBernsteinPAlpha ()
 
void generateBernsteinPSize ()
 
void changeTexture ()
 
void setNotVisibleInFrustum ()
 
void pauseOrResume ()
 
void calcNormals ()
 SLMesh::calcNormals recalculates vertex normals for triangle meshes. More...
 
SLVec3f acceleration ()
 
SLfloat accelerationConst ()
 
SLint amount ()
 
SLfloat angularVelocityConst ()
 
SLVec2f angularVelocityRange ()
 
float * bezierControlPointAlpha ()
 
float * bezierStartEndPointAlpha ()
 
float * bezierControlPointSize ()
 
float * bezierStartEndPointSize ()
 
SLBillboardType billboardType ()
 
SLCol4f color ()
 
SLbool doInstancedDrawing ()
 
SLbool doAcc ()
 
SLbool doAccDiffDir ()
 
SLbool doAlphaOverLT ()
 
SLbool doAlphaOverLTCurve ()
 
SLbool doBlendBrightness ()
 
SLbool doCounterGap ()
 
SLbool doColor ()
 
SLbool doColorOverLT ()
 
SLbool doDirectionSpeed ()
 
SLbool doGravity ()
 
SLbool doFlipBookTexture ()
 
SLbool doRotation ()
 
SLbool doRotRange ()
 
SLbool doSizeOverLT ()
 
SLbool doSizeOverLTCurve ()
 
SLbool doShape ()
 
SLbool doShapeSurface ()
 
SLbool doShapeOverride ()
 
SLbool doShapeSpawnBase ()
 
SLbool doSpeedRange ()
 
SLbool doWorldSpace ()
 
SLVec3f direction ()
 
AvgFloatdrawTime ()
 
SLVec3f emitterPos () const
 
SLVec3f gravity ()
 
SLint flipbookColumns ()
 
SLint flipbookRows ()
 
int frameRateFB ()
 
SLbool isGenerated ()
 
SLbool isPaused ()
 
SLfloat radiusW ()
 
SLfloat radiusH ()
 
SLfloat scale ()
 
SLShapeType shapeType ()
 
SLfloat shapeAngle ()
 
SLfloat shapeHeight ()
 
SLfloat shapeRadius ()
 
SLVec3f shapeScale ()
 
SLfloat shapeWidth ()
 
SLfloat speed ()
 
SLVec2f speedRange ()
 
SLGLTexturetexParticle ()
 
SLGLTexturetexFlipbook ()
 
SLTexColorLUTtexGradient ()
 
SLfloat timeToLive ()
 
AvgFloatupdateTime ()
 
SLint velocityType ()
 
SLVec3f velocityConst ()
 
SLVec3f velocityRndMin ()
 
SLVec3f velocityRndMax ()
 
void doInstancedDrawing (bool instanced)
 
void amount (SLint i)
 
void accConst (SLfloat f)
 
void acceleration (SLVec3f v)
 
void acceleration (SLfloat vX, SLfloat vY, SLfloat vZ)
 
void angularVelocityConst (SLfloat f)
 
void angularVelocityRange (SLVec2f v)
 
void angularVelocityRange (SLfloat vX, SLfloat vY)
 
void billboardType (SLBillboardType bt)
 
void bezierControlPointAlpha (float arrayPoint[4])
 
void bezierStartEndPointAlpha (float arrayPoint[4])
 
void bezierControlPointSize (float arrayPoint[4])
 
void bezierStartEndPointSize (float arrayPoint[4])
 
void color (SLCol4f c)
 
void direction (SLVec3f v)
 
void direction (SLfloat vX, SLfloat vY, SLfloat vZ)
 
void doAcceleration (SLbool b)
 
void doAlphaOverLT (SLbool b)
 
void doAlphaOverLTCurve (SLbool b)
 
void doAccDiffDir (SLbool b)
 
void doBlendBrightness (SLbool b)
 
void doColor (SLbool b)
 
void doColorOverLT (SLbool b)
 
void doCounterGap (SLbool b)
 
void doDirectionSpeed (SLbool b)
 
void doGravity (SLbool b)
 
void doFlipBookTexture (SLbool b)
 
void doRotation (SLbool b)
 
void doRotRange (SLbool b)
 
void doSpeedRange (SLbool b)
 
void doShape (SLbool b)
 
void doShapeSurface (SLbool b)
 
void doShapeOverride (SLbool b)
 
void doShapeSpawnBase (SLbool b)
 
void doSizeOverLT (SLbool b)
 
void doSizeOverLTCurve (SLbool b)
 
void doWorldSpace (SLbool b)
 
void emitterPos (SLVec3f p)
 
void gravity (SLVec3f v)
 
void gravity (SLfloat vX, SLfloat vY, SLfloat vZ)
 
void flipbookColumns (SLint i)
 
void flipbookRows (SLint i)
 
void frameRateFB (int i)
 
void isGenerated (SLbool b)
 
void radiusW (SLfloat f)
 
void radiusH (SLfloat f)
 
void scale (SLfloat f)
 
void speed (SLfloat f)
 
void speedRange (SLVec2f v)
 
void speedRange (SLfloat vX, SLfloat vY)
 
void shapeType (SLShapeType st)
 
void shapeAngle (SLfloat f)
 
void shapeRadius (SLfloat r)
 
void shapeScale (SLVec3f v)
 
void shapeScale (SLfloat vX, SLfloat vY, SLfloat vZ)
 
void shapeHeight (SLfloat f)
 
void shapeWidth (SLfloat f)
 
void timeToLive (SLfloat f)
 
void texParticle (SLGLTexture *tp)
 
void texFlipbook (SLGLTexture *tf)
 
void texGradient (SLTexColorLUT *tg)
 
void velocityType (SLint i)
 
void velocityConst (SLVec3f v)
 
void velocityConst (SLfloat vX, SLfloat vY, SLfloat vZ)
 
void velocityRndMin (SLVec3f v)
 
void velocityRndMin (SLfloat vX, SLfloat vY, SLfloat vZ)
 
void velocityRndMax (SLVec3f v)
 
void velocityRndMax (SLfloat vX, SLfloat vY, SLfloat vZ)
 
- Public Member Functions inherited from SLMesh
 SLMesh (SLAssetManager *assetMgr, const SLstring &name="Mesh")
 Construct a new SLMesh::SLMesh object. More...
 
 ~SLMesh () override
 The destructor deletes everything by calling deleteData. More...
 
virtual void init (SLNode *node)
 SLMesh::shapeInit sets the transparency flag of the AABB. More...
 
void drawIntoDepthBuffer (SLSceneView *sv, SLNode *node, SLMaterial *depthMat)
 Simplified drawing method for shadow map creation. More...
 
void addStats (SLNodeStats &stats)
 
void updateAccelStruct ()
 
SLbool hit (SLRay *ray, SLNode *node)
 
virtual void preShade (SLRay *ray)
 
virtual void deleteData ()
 SLMesh::deleteData deletes all mesh data and vbo's. More...
 
virtual void deleteDataGpu ()
 
void deleteSelected (SLNode *node)
 Deletes the rectangle selected vertices and the dependent triangles. More...
 
void deleteUnused ()
 Deletes unused vertices (= vertices that are not indexed in I16 or I32) More...
 
virtual void calcMinMax ()
 
void calcCenterRad (SLVec3f &center, SLfloat &radius)
 
SLbool hitTriangleOS (SLRay *ray, SLNode *node, SLuint iT)
 
virtual void generateVAO (SLGLVertexArray &vao)
 Generate the Vertex Array Object for a specific shader program. More...
 
void computeHardEdgesIndices (float angleRAD, float epsilon)
 computes the hard edges and stores the vertex indexes separately More...
 
void transformSkin (bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
 Transforms the vertex positions and normals with by joint weights. More...
 
void deselectPartialSelection ()
 
SLMaterialmat () const
 
SLMaterialmatOut () const
 
SLGLPrimitiveType primitive () const
 
const SLAnimSkeletonskeleton () const
 
SLuint numI () const
 
SLGLVertexArrayvao ()
 
SLbool isSelected () const
 
SLfloat edgeAngleDEG () const
 
SLfloat edgeWidth () const
 
SLCol4f edgeColor () const
 
SLVec3f finalP (SLuint i)
 
SLVec3f finalN (SLuint i)
 
SLbool accelStructIsOutOfDate ()
 
void mat (SLMaterial *m)
 
void matOut (SLMaterial *m)
 
void primitive (SLGLPrimitiveType pt)
 
void skeleton (SLAnimSkeleton *skel)
 
void isSelected (bool isSelected)
 
void edgeWidth (SLfloat ew)
 
void edgeAngleDEG (SLfloat ea)
 
void edgeColor (const SLCol4f &ec)
 
void vertexPosEpsilon (SLfloat eps)
 
- 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 Member Functions

SLVec3f getPointInSphere (float radius, SLVec3f randomX)
 Function which return a position in a sphere. More...
 
SLVec3f getPointOnSphere (float radius, SLVec3f randomX)
 Function which return a position on a sphere. More...
 
SLVec3f getDirectionSphere (SLVec3f position)
 Function which return the direction towards the exterior of a sphere. More...
 
SLVec3f getPointInBox (SLVec3f boxScale)
 Function which return a position in a box. More...
 
SLVec3f getPointOnBox (SLVec3f boxScale)
 Function which return a position on a box. More...
 
SLVec3f getDirectionBox (SLVec3f position)
 Function which return the direction towards the exterior of a box. More...
 
SLVec3f getPointInCone ()
 Function which return a position in the cone define in the particle system. More...
 
SLVec3f getPointOnCone ()
 Function which return a position on the cone define in the particle system. More...
 
SLVec3f getDirectionCone (SLVec3f position)
 Function which return a direction following the cone shape. More...
 
SLVec3f getPointInPyramid ()
 Function which returns a position in the pyramid that define the PS. More...
 
SLVec3f getPointOnPyramid ()
 Function which return a position on the pyramid that defines the PS. More...
 
SLVec3f getDirectionPyramid (SLVec3f position)
 Function which return a direction following the pyramid shape. More...
 

Private Attributes

SLAssetManager_assetManager
 pointer to the asset manager (the owner) if available More...
 
SLint _amount
 Amount of a particle. More...
 
SLVec3f _emitterPos
 Position of the particle emitter. More...
 
SLfloat _timeToLive
 Time to live of a particle. More...
 
SLfloat _radiusW = 0.4f
 width radius of a particle More...
 
SLfloat _radiusH = 0.4f
 height radius of a particle More...
 
SLfloat _scale = 1.0f
 Scale of a particle (Scale the radius) More...
 
SLVec4f _bernsteinPYAlpha = SLVec4f(2.0f, -3.0f, 0.0f, 1.0f)
 Vector for bezier curve (default linear function) More...
 
float _bezierControlPointAlpha [4] = {0.0f, 1.0f, 1.0f, 0.0f}
 Floats for bezier curve control points (P1: 01 ; P2: 23) More...
 
float _bezierStartEndPointAlpha [4] = {0.0f, 1.0f, 1.0f, 0.0f}
 Floats for bezier curve end start points (Start: 01 ; End: 23) More...
 
SLVec4f _bernsteinPYSize = SLVec4f(-1.4f, 1.8f, 0.6f, 0.0f)
 Vector for bezier curve (default linear function) More...
 
float _bezierControlPointSize [4] = {0.0f, 0.0f, 1.0f, 1.0f}
 Floats for bezier curve control points (P1: 01 ; P2: 23) More...
 
float _bezierStartEndPointSize [4] = {0.0f, 0.0f, 1.0f, 1.0f}
 Floats for bezier curve end start points (Start: 01 ; End: 23) More...
 
SLVec3f _acceleration = SLVec3f(1, 1, 1)
 Vector for acceleration (different direction as the velocity) More...
 
SLfloat _accelerationConst = 0.0f
 Acceleration constant (same direction as the velocity) More...
 
SLVec3f _gravity = SLVec3f(0.0f, -9.81f, 0.0f)
 Vector for gravity (2nd. acceleration vector) More...
 
SLVec3f _velocityConst = SLVec3f(0, 1, 0)
 Velocity constant (go in xyz direction) More...
 
SLVec3f _velocityRndMin = SLVec3f(-1, -1, -1)
 Min. random velocity. More...
 
SLVec3f _velocityRndMax = SLVec3f(1, 1, 1)
 Max. random velocity. More...
 
SLVec3f _direction = SLVec3f(0, 0, 0)
 Direction of particle. More...
 
SLfloat _speed = 1.0f
 Speed of particle. More...
 
SLVec2f _speedRange = SLVec2f(1, 2)
 Speed random between two value. More...
 
SLCol4f _color = SLCol4f(0.66f, 0.0f, 0.66f, 0.2f)
 Color for particle. More...
 
int _drawBuf = 0
 Boolean to switch buffer. More...
 
int _flipbookFPS = 16
 Number of update of flipbook by second. More...
 
float _flipboookLastUpdate = 0.0f
 Last time flipbook was updated. More...
 
SLint _flipbookColumns = 8
 Number of flipbook sub-textures by column. More...
 
SLint _flipbookRows = 8
 Number of flipbook sub-textures by row. More...
 
AvgFloat _updateTime
 Averaged time for updating in MS. More...
 
AvgFloat _drawTime
 Averaged time for drawing in MS. More...
 
SLfloat _startDrawTimeMS = 0.0f
 Time since start of draw in MS. More...
 
SLfloat _startUpdateTimeMS = 0.0f
 Time since start for updating in MS. More...
 
SLfloat _startUpdateTimeS = 0.0f
 Time since start for updating in S. More...
 
SLfloat _deltaTimeUpdateS = 0.0f
 Delta time in between two frames S. More...
 
SLfloat _notVisibleTimeS = 0.0f
 Time since start when node not visible in S. More...
 
SLfloat _lastTimeBeforePauseS = 0.0f
 Time since the particle system is paused. More...
 
SLfloat _shapeRadius = 1.0f
 Radius of sphere and cone shape. More...
 
SLVec3f _shapeScale = SLVec3f(1.0f)
 Scale of box shape. More...
 
SLfloat _shapeHeight = 3.0f
 Height of cone and pyramid shapes. More...
 
SLfloat _shapeAngle = 10.0f
 Angle of cone and pyramid shapes. More...
 
SLfloat _shapeWidth = 2.0f
 Width of pyramid shape. More...
 
SLfloat _angularVelocityConst = 30.0f
 Rotation rate const (change in angular rotation divide by change in time) More...
 
SLVec2f _angularVelocityRange = SLVec2f(-30.0f, 30.0f)
 Rotation rate range (change in angular rotation divide by change in time) More...
 
SLBillboardType _billboardType = BT_Camera
 Billboard type (BT_Camera, BT_Vertical, BT_Horizontal. More...
 
SLShapeType _shapeType = ST_Sphere
 Shape type (ST_) More...
 
SLint _velocityType = 0
 Velocity type. More...
 
SLGLTexture_texParticle
 Main texture of PS (non flipbook) More...
 
SLGLTexture_texFlipbook
 Flipbook texture with e.g. multiple flames at subsequent frames. More...
 
SLTexColorLUT_texGradient
 Color gradient texture. More...
 
SLGLVertexArray _vao1
 
SLGLVertexArray _vao2
 
SLGLVertexArray _instanceVao1
 
SLGLVertexArray _instanceVao2
 
SLbool _isVisibleInFrustum = true
 Boolean to set time since node not visible. More...
 
SLbool _isPaused = false
 Boolean to stop updating. More...
 
SLbool _isGenerated = false
 Boolean to generate particle system and load it on the GPU. More...
 
SLbool _doBlendBrightness = false
 Boolean for glow/brightness on pixel with many particle. More...
 
SLbool _doDirectionSpeed = false
 Boolean for direction and speed (override velocity) More...
 
SLbool _doSpeedRange = false
 Boolean for speed range. More...
 
SLbool _doCounterGap = true
 Boolean for counter lag/gap, can create flickering with few particle (explained in documentation) when enable. More...
 
SLbool _doAcceleration = false
 Boolean for acceleration. More...
 
SLbool _doAccDiffDir = false
 Boolean for acceleration (different direction) More...
 
SLbool _doRotation = true
 Boolean for rotation. More...
 
SLbool _doRotRange = false
 Boolean for rotation range (random value between range) More...
 
SLbool _doColor = true
 Boolean for color. More...
 
SLbool _doShape = false
 Boolean for shape feature. More...
 
SLbool _doShapeSurface = false
 Boolean for shape surface (particle will be spawned on surface) More...
 
SLbool _doShapeOverride = false
 Boolean for override direction for shape direction. More...
 
SLbool _doShapeSpawnBase = false
 Boolean for spawn at base of shape (for cone and pyramid) More...
 
SLbool _doWorldSpace = false
 Boolean for world space position. More...
 
SLbool _doGravity = false
 Boolean for gravity. More...
 
SLbool _doAlphaOverLT = true
 Boolean for alpha over life time. More...
 
SLbool _doColorOverLT = false
 Boolean for color over life time. More...
 
SLbool _doAlphaOverLTCurve = false
 Boolean for alpha over life time curve. More...
 
SLbool _doSizeOverLT = true
 Boolean for size over life time. More...
 
SLbool _doSizeOverLTCurve = false
 Boolean for size over life time curve. More...
 
SLbool _doFlipBookTexture = false
 Boolean for flipbook texture. More...
 
SLbool _doInstancedDrawing = false
 Boolean for instanced rendering. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SLMesh
static void calcTex3DMatrix (SLNode *node)
 
- Public Attributes inherited from SLMesh
SLVVec3f P
 Vector for vertex positions layout (location = 0) More...
 
SLVVec3f N
 Vector for vertex normals (opt.) layout (location = 1) More...
 
SLVVec2f UV [2]
 Array of 2 Vectors for tex. coords. (opt.) layout (location = 2) More...
 
SLVCol4f C
 Vector of vertex colors (opt.) layout (location = 4) More...
 
SLVVec4f T
 Vector of vertex tangents (opt.) layout (location = 5) More...
 
SLVVuchar Ji
 2D Vector of per vertex joint ids (opt.) layout (location = 6) More...
 
SLVVfloat Jw
 2D Vector of per vertex joint weights (opt.) layout (location = 7) More...
 
SLVVec3f skinnedP
 temp. vector for CPU skinned vertex positions More...
 
SLVVec3f skinnedN
 temp. vector for CPU skinned vertex normals More...
 
SLVushort I16
 Vector of vertex indices 16 bit. More...
 
SLVuint I32
 Vector of vertex indices 32 bit. More...
 
SLVuint IS32
 Vector of rectangle selected vertex indices 32 bit. More...
 
SLVushort IE16
 Vector of hard edges vertex indices 16 bit (see computeHardEdgesIndices) More...
 
SLVuint IE32
 Vector of hard edges vertex indices 32 bit (see computeHardEdgesIndices) More...
 
SLVec3f minP
 min. vertex in OS More...
 
SLVec3f maxP
 max. vertex in OS More...
 
- Protected Attributes inherited from SLMesh
SLGLPrimitiveType _primitive
 Primitive type (default triangles) More...
 
SLMaterial_mat
 Pointer to the inside material. More...
 
SLMaterial_matOut
 Pointer to the outside material. More...
 
SLGLVertexArray _vao
 Main OpenGL Vertex Array Object for drawing. More...
 
SLGLVertexArrayExt _vaoN
 OpenGL VAO for optional normal drawing. More...
 
SLGLVertexArrayExt _vaoT
 OpenGL VAO for optional tangent drawing. More...
 
SLGLVertexArrayExt _vaoS
 OpenGL VAO for optional selection drawing. More...
 
SLbool _isSelected
 Flag if mesh is partially of fully selected. More...
 
SLfloat _edgeAngleDEG
 Edge crease angle in degrees between face normals (30 deg. default) More...
 
SLfloat _edgeWidth
 Line width for hard edge drawing. More...
 
SLCol4f _edgeColor
 Color for hard edge drawing. More...
 
SLfloat _vertexPosEpsilon
 Vertex position epsilon used in computeHardEdgesIndices. More...
 
SLbool _isVolume
 Flag for RT if mesh is a closed volume. More...
 
SLAccelStruct_accelStruct
 KD-tree or uniform grid. More...
 
SLbool _accelStructIsOutOfDate
 Flag if accel. struct needs update. More...
 
SLAnimSkeleton_skeleton
 The skeleton this mesh is bound to. More...
 
SLVMat4f _jointMatrices
 Joint matrix vector for this mesh. More...
 
SLbool _isCPUSkinned
 Flag if mesh has been skinned on CPU during update. More...
 
SLVVec3f_finalP
 Pointer to final vertex position vector. More...
 
SLVVec3f_finalN
 pointer to final vertex normal vector More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

SLParticleSystem creates a particle meshes from a point primitive buffer.

The SLParticleSystem mesh object of which the vertices are drawn as points. An OpenGL transform feedback buffer is used to update the particle positions on the GPU and a geometry shader is used the create two triangles per particle vertex and orient them as a billboard to the viewer. Geometry shaders are only supported under OpenGL >= 4.0 and OpenGLES >= 3.2. This is the case on most desktop systems and on Android SDK > 24 but not on iOS which has only OpenGL ES 3.0
. For all systems that don't support geometry shaders we use an alternative with instanced drawing (mainly for iOS and Emscripten with WebGL)
. The particle system supports many options of which many can be turned on the do* methods. All options can also be modified in the UI when the mesh is selected. See the different demo scenes in the app_demo_slproject under the demo scene group Particle Systems.

Remarks
It is important that during instantiation NO OpenGL functions (gl*) get called because this constructor will be most probably called in a parallel thread from within an SLScene::registerAssetsToLoad or SLScene::assemble function. All objects that get rendered have to do their OpenGL initialization when they are used the first time during rendering in the main thread. For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP, _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.

Definition at line 43 of file SLParticleSystem.h.

Constructor & Destructor Documentation

◆ SLParticleSystem()

SLParticleSystem::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.

The particle emitter position, the start and end random value range The time to live of the particle (lifetime). A texture, a name and a flipbook texture.

Definition at line 25 of file SLParticleSystem.cpp.

34  : SLMesh(assetMgr, name)
35 {
36  assert(!name.empty());
37 
38  _assetManager = assetMgr;
41 
42  // Trick SL project because it wants the mesh to have vertex
43  P.push_back(SLVec3f(0, 0, 0));
44  I32.push_back(0);
45 
46  if (amount > UINT_MAX) // Need to change for number of floats
47  SL_EXIT_MSG("SLParticleSystem supports max. 2^32 vertices.");
48 
50  _amount = amount;
51  _velocityRndMin = velocityRandomStart;
52  _velocityRndMax = velocityRandomEnd;
53 
54  _texParticle = texC;
56  if (texGradient)
58  else
59  _texGradient = new SLTexColorLUT(assetMgr, CLUT_WYR, 256);
60 
61  _updateTime.init(60, 0.0f);
62  _drawTime.init(60, 0.0f);
63 }
#define SL_EXIT_MSG(message)
Definition: SL.h:240
@ PT_points
Definition: SLGLEnums.h:31
@ CLUT_WYR
white to black
Definition: SLTexColorLUT.h:28
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
static SLGLState * instance()
Public static instance getter for singleton pattern.
Definition: SLGLState.h:74
SLbool glHasGeometryShaders() const
Definition: SLGLState.h:139
SLMesh(SLAssetManager *assetMgr, const SLstring &name="Mesh")
Construct a new SLMesh::SLMesh object.
Definition: SLMesh.cpp:51
SLVuint I32
Vector of vertex indices 32 bit.
Definition: SLMesh.h:215
SLGLPrimitiveType _primitive
Primitive type (default triangles)
Definition: SLMesh.h:231
SLVVec3f P
Vector for vertex positions layout (location = 0)
Definition: SLMesh.h:203
const SLstring & name() const
Definition: SLObject.h:38
SLGLTexture * _texFlipbook
Flipbook texture with e.g. multiple flames at subsequent frames.
AvgFloat _drawTime
Averaged time for drawing in MS.
SLGLTexture * texFlipbook()
SLfloat _timeToLive
Time to live of a particle.
SLbool _doInstancedDrawing
Boolean for instanced rendering.
SLint _amount
Amount of a particle.
SLTexColorLUT * texGradient()
AvgFloat _updateTime
Averaged time for updating in MS.
SLGLTexture * _texParticle
Main texture of PS (non flipbook)
SLVec3f _velocityRndMax
Max. random velocity.
SLTexColorLUT * _texGradient
Color gradient texture.
SLbool doInstancedDrawing()
SLAssetManager * _assetManager
pointer to the asset manager (the owner) if available
SLVec3f _velocityRndMin
Min. random velocity.
SLTexColorLUT defines a lookup table as an 1D texture of (256) RGBA values.
Definition: SLTexColorLUT.h:70
void init(int numValues, T initValue)
Initializes the average value array to a given value.
Definition: Averaged.h:41

Member Function Documentation

◆ accConst()

void SLParticleSystem::accConst ( SLfloat  f)
inline

Definition at line 136 of file SLParticleSystem.h.

136 { _accelerationConst = f; }
SLfloat _accelerationConst
Acceleration constant (same direction as the velocity)

◆ acceleration() [1/3]

SLVec3f SLParticleSystem::acceleration ( )
inline

Definition at line 68 of file SLParticleSystem.h.

68 { return _acceleration; }
SLVec3f _acceleration
Vector for acceleration (different direction as the velocity)

◆ acceleration() [2/3]

void SLParticleSystem::acceleration ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 138 of file SLParticleSystem.h.

139  {
140  _acceleration.x = vX;
141  _acceleration.y = vY;
142  _acceleration.z = vZ;
143  }
T y
Definition: SLVec3.h:43
T x
Definition: SLVec3.h:43
T z
Definition: SLVec3.h:43

◆ acceleration() [3/3]

void SLParticleSystem::acceleration ( SLVec3f  v)
inline

Definition at line 137 of file SLParticleSystem.h.

137 { _acceleration = v; }

◆ accelerationConst()

SLfloat SLParticleSystem::accelerationConst ( )
inline

Definition at line 69 of file SLParticleSystem.h.

69 { return _accelerationConst; }

◆ amount() [1/2]

SLint SLParticleSystem::amount ( )
inline

Definition at line 70 of file SLParticleSystem.h.

70 { return _amount; }

◆ amount() [2/2]

void SLParticleSystem::amount ( SLint  i)
inline

Definition at line 135 of file SLParticleSystem.h.

135 { _amount = i; }

◆ angularVelocityConst() [1/2]

SLfloat SLParticleSystem::angularVelocityConst ( )
inline

Definition at line 71 of file SLParticleSystem.h.

71 { return _angularVelocityConst; }
SLfloat _angularVelocityConst
Rotation rate const (change in angular rotation divide by change in time)

◆ angularVelocityConst() [2/2]

void SLParticleSystem::angularVelocityConst ( SLfloat  f)
inline

Definition at line 144 of file SLParticleSystem.h.

144 { _angularVelocityConst = f; }

◆ angularVelocityRange() [1/3]

SLVec2f SLParticleSystem::angularVelocityRange ( )
inline

Definition at line 72 of file SLParticleSystem.h.

72 { return _angularVelocityRange; }
SLVec2f _angularVelocityRange
Rotation rate range (change in angular rotation divide by change in time)

◆ angularVelocityRange() [2/3]

void SLParticleSystem::angularVelocityRange ( SLfloat  vX,
SLfloat  vY 
)
inline

Definition at line 146 of file SLParticleSystem.h.

147  {
150  }
T y
Definition: SLVec2.h:30
T x
Definition: SLVec2.h:30

◆ angularVelocityRange() [3/3]

void SLParticleSystem::angularVelocityRange ( SLVec2f  v)
inline

Definition at line 145 of file SLParticleSystem.h.

145 { _angularVelocityRange = v; }

◆ bezierControlPointAlpha() [1/2]

float* SLParticleSystem::bezierControlPointAlpha ( )
inline

Definition at line 73 of file SLParticleSystem.h.

73 { return _bezierControlPointAlpha; }
float _bezierControlPointAlpha[4]
Floats for bezier curve control points (P1: 01 ; P2: 23)

◆ bezierControlPointAlpha() [2/2]

void SLParticleSystem::bezierControlPointAlpha ( float  arrayPoint[4])
inline

Definition at line 152 of file SLParticleSystem.h.

153  {
154  _bezierControlPointAlpha[0] = arrayPoint[0];
155  _bezierControlPointAlpha[1] = arrayPoint[1];
156  _bezierControlPointAlpha[2] = arrayPoint[2];
157  _bezierControlPointAlpha[3] = arrayPoint[3];
158  }

◆ bezierControlPointSize() [1/2]

float* SLParticleSystem::bezierControlPointSize ( )
inline

Definition at line 75 of file SLParticleSystem.h.

75 { return _bezierControlPointSize; }
float _bezierControlPointSize[4]
Floats for bezier curve control points (P1: 01 ; P2: 23)

◆ bezierControlPointSize() [2/2]

void SLParticleSystem::bezierControlPointSize ( float  arrayPoint[4])
inline

Definition at line 166 of file SLParticleSystem.h.

167  {
168  _bezierControlPointSize[0] = arrayPoint[0];
169  _bezierControlPointSize[1] = arrayPoint[1];
170  _bezierControlPointSize[2] = arrayPoint[2];
171  _bezierControlPointSize[3] = arrayPoint[3];
172  }

◆ bezierStartEndPointAlpha() [1/2]

float* SLParticleSystem::bezierStartEndPointAlpha ( )
inline

Definition at line 74 of file SLParticleSystem.h.

74 { return _bezierStartEndPointAlpha; }
float _bezierStartEndPointAlpha[4]
Floats for bezier curve end start points (Start: 01 ; End: 23)

◆ bezierStartEndPointAlpha() [2/2]

void SLParticleSystem::bezierStartEndPointAlpha ( float  arrayPoint[4])
inline

Definition at line 159 of file SLParticleSystem.h.

160  {
161  _bezierStartEndPointAlpha[0] = arrayPoint[0];
162  _bezierStartEndPointAlpha[1] = arrayPoint[1];
163  _bezierStartEndPointAlpha[2] = arrayPoint[2];
164  _bezierStartEndPointAlpha[3] = arrayPoint[3];
165  }

◆ bezierStartEndPointSize() [1/2]

float* SLParticleSystem::bezierStartEndPointSize ( )
inline

Definition at line 76 of file SLParticleSystem.h.

76 { return _bezierStartEndPointSize; }
float _bezierStartEndPointSize[4]
Floats for bezier curve end start points (Start: 01 ; End: 23)

◆ bezierStartEndPointSize() [2/2]

void SLParticleSystem::bezierStartEndPointSize ( float  arrayPoint[4])
inline

Definition at line 173 of file SLParticleSystem.h.

174  {
175  _bezierStartEndPointSize[0] = arrayPoint[0];
176  _bezierStartEndPointSize[1] = arrayPoint[1];
177  _bezierStartEndPointSize[2] = arrayPoint[2];
178  _bezierStartEndPointSize[3] = arrayPoint[3];
179  }

◆ billboardType() [1/2]

SLBillboardType SLParticleSystem::billboardType ( )
inline

Definition at line 77 of file SLParticleSystem.h.

77 { return _billboardType; }
SLBillboardType _billboardType
Billboard type (BT_Camera, BT_Vertical, BT_Horizontal.

◆ billboardType() [2/2]

void SLParticleSystem::billboardType ( SLBillboardType  bt)
inline

Definition at line 151 of file SLParticleSystem.h.

151 { _billboardType = bt; }

◆ buildAABB()

void SLParticleSystem::buildAABB ( SLAABBox aabb,
const SLMat4f wmNode 
)
virtual

SLParticleSystem::buildAABB builds the passed axis-aligned bounding box in OS and updates the min & max points in WS with the passed WM of the node. Take into account features like acceleration, gravity, shape, velocity. SLMesh::buildAABB builds the passed axis-aligned bounding box in OS and updates the min& max points in WS with the passed WM of the node. Todo: Can ben enhance furthermore the acceleration doesn't work well for the moment. The negative value for the acceleration are not take into account and also acceleration which goes against the velocity. To adapt the acceleration to exactly the same as the gravity not enough time to do it. Need to adapt more accurately when direction speed is negative (for shape override example with Cone)

Reimplemented from SLMesh.

Definition at line 997 of file SLParticleSystem.cpp.

998 {
999  // Radius of particle
1000  float rW = _radiusW * _scale;
1001  float rH = _radiusH * _scale;
1002 
1003  // Speed for direction if used
1004  float tempSpeed = _doSpeedRange ? max(_speedRange.x, _speedRange.y) : _speed;
1005 
1006  // Empty point
1007  minP = SLVec3f();
1008  maxP = SLVec3f();
1009 
1010  // Empty velocity
1011  SLVec3f minV = SLVec3f();
1012  SLVec3f maxV = SLVec3f();
1013 
1014  // Shape
1015  if (_doShape)
1016  {
1017  if (_shapeType == ST_Sphere)
1018  {
1019  float radius = cbrt(_shapeRadius);
1020  minP = SLVec3f(-radius, -radius, -radius);
1021  maxP = SLVec3f(radius, radius, radius);
1022  // Override direction
1024  {
1025  minV += SLVec3f(-radius, -radius, -radius) * tempSpeed;
1026  maxV += SLVec3f(radius, radius, radius) * tempSpeed;
1027  }
1028  }
1029  else if (_shapeType == ST_Box)
1030  {
1032  maxP = _shapeScale;
1034  {
1035  minV += SLVec3f(-_shapeScale.x, -_shapeScale.y, -_shapeScale.z) * tempSpeed;
1036  maxV += _shapeScale * tempSpeed;
1037  }
1038  }
1039  else if (_shapeType == ST_Cone)
1040  {
1041  float radius = _shapeRadius + tan(_shapeAngle * DEG2RAD) * _shapeHeight;
1042  minP = SLVec3f(-radius, -0.0, -radius);
1043  if (!_doShapeSpawnBase) // Spawn inside volume
1044  maxP = SLVec3f(radius, _shapeHeight, radius);
1045  else // Spawn base volume
1046  maxP = SLVec3f(radius, 0.0f, radius);
1048  {
1049  SLVec3f temp = getDirectionCone(SLVec3f(-radius, -0.0, -radius)) * tempSpeed;
1050  temp.y = 0.0;
1051  minV += temp;
1052  maxV += getDirectionCone(SLVec3f(radius, _shapeHeight, radius)) * tempSpeed;
1053  }
1054  }
1055  else if (_shapeType == ST_Pyramid)
1056  {
1057  float radius = _shapeWidth + tan(_shapeAngle * DEG2RAD) * _shapeHeight;
1058  minP = SLVec3f(-radius, -0.0, -radius);
1059  if (!_doShapeSpawnBase) // Spawn inside volume
1060  maxP = SLVec3f(radius, _shapeHeight, radius);
1061  else // Spawn base volume
1062  maxP = SLVec3f(radius, 0.0f, radius);
1063 
1065  {
1066  SLVec3f temp = getDirectionPyramid(SLVec3f(-radius, -0.0, -radius)) * tempSpeed;
1067  temp.y = 0.0;
1068  minV += temp;
1069  maxV += getDirectionPyramid(SLVec3f(radius, _shapeHeight, radius)) * tempSpeed;
1070  }
1071  }
1072  }
1073 
1074  if (_doAcceleration || _doGravity) // If acceleration or gravity is enabled
1075  {
1076  if (!_doDirectionSpeed) // If direction is not enable
1077  {
1078  if (_velocityType == 0)
1079  {
1080  SLVec3f minVTemp = SLVec3f(min(_velocityRndMax.x, _velocityRndMin.x),
1082  min(_velocityRndMax.z, _velocityRndMin.z)); // Apply velocity distance after time
1083  SLVec3f maxVTemp = SLVec3f(max(_velocityRndMax.x, _velocityRndMin.x),
1085  max(_velocityRndMax.z, _velocityRndMin.z)); // Apply velocity distance after time
1086 
1087  if (minVTemp.x > 0 && maxVTemp.x > 0) minVTemp.x = 0.0;
1088  if (minVTemp.y > 0 && maxVTemp.y > 0) minVTemp.y = 0.0;
1089  if (minVTemp.z > 0 && maxVTemp.z > 0) minVTemp.z = 0.0;
1090 
1091  if (minVTemp.x < 0 && maxVTemp.x < 0) maxVTemp.x = 0.0;
1092  if (minVTemp.y < 0 && maxVTemp.y < 0) maxVTemp.y = 0.0;
1093  if (minVTemp.z < 0 && maxVTemp.z < 0) maxVTemp.z = 0.0;
1094 
1095  minV += minVTemp;
1096  maxV += maxVTemp;
1097  }
1098  else // Constant acceleration
1099  {
1100  minV = SLVec3f(_velocityConst.x, 0.0, 0.0);
1101  maxV = SLVec3f(0.0, _velocityConst.y, _velocityConst.z);
1102  }
1103  }
1104  // Direction and speed, but no shape override, because I want a constant direction in one way I don't want the direction to be overridden
1105  else if (_doDirectionSpeed && !_doShapeOverride)
1106  {
1107  if (_doSpeedRange)
1108  tempSpeed = max(_speedRange.x, _speedRange.y);
1109  else
1110  tempSpeed = _speed;
1111 
1112  minV = SLVec3f(_direction.x, 0.0, 0.0) * tempSpeed;
1113  maxV = SLVec3f(0.0, _direction.y, _direction.z) * tempSpeed;
1114  if (_direction.x > 0.0)
1115  {
1116  maxV.x = minV.x;
1117  minV.x = 0.0;
1118  }
1119  if (_direction.y < 0.0)
1120  {
1121  minV.y = maxV.y;
1122  maxV.y = 0.0;
1123  }
1124  if (_direction.z < 0.0)
1125  {
1126  minV.z = maxV.z;
1127  maxV.z = 0.0;
1128  }
1129  }
1130 
1131  // Apply time to velocity
1132  minP += minV * _timeToLive;
1133  maxP += maxV * _timeToLive;
1134 
1135  // GRAVITY
1136  if (_doGravity)
1137  {
1138  float timeForXGrav = 0.0f;
1139  float timeForYGrav = 0.0f;
1140  float timeForZGrav = 0.0f;
1141  // Time to have a velocity of 0
1142  if (_gravity.x != 0.0f) timeForXGrav = maxV.x / _gravity.x;
1143  if (_gravity.y != 0.0f) timeForYGrav = maxV.y / _gravity.y;
1144  if (_gravity.z != 0.0f) timeForZGrav = maxV.z / _gravity.z;
1145 
1146  if (timeForXGrav < 0.0f) // If the gravity go against the velocity
1147  maxP.x -= maxV.x * (_timeToLive + timeForXGrav); // I remove the position with the velocity that it will not do because it go against the velocity (becareful! here timeForXGrav is negative)
1148  else if (timeForXGrav > 0.0f) // If the gravity go with the velocity
1149  maxP.x += 0.5f * _gravity.x * (_timeToLive * _timeToLive);
1150  if (timeForYGrav < 0.0f) // If the gravity go against the velocity
1151  maxP.y -= maxV.y * (_timeToLive + timeForYGrav);
1152  else if (timeForYGrav > 0.0f) // If the gravity go with the velocity
1153  maxP.y += 0.5f * _gravity.y * (_timeToLive * _timeToLive);
1154  if (timeForZGrav < 0.0f) // If the gravity go against the velocity
1155  maxP.z -= maxV.z * (_timeToLive + timeForZGrav);
1156  else if (timeForZGrav > 0.0f) // If the gravity go with the velocity
1157  maxP.z += 0.5f * _gravity.z * (_timeToLive * _timeToLive);
1158 
1159  // Time remaining after the gravity has nullified the velocity for the particle to die (for each axes)
1160  float xTimeRemaining = _timeToLive - abs(timeForXGrav);
1161  float yTimeRemaining = _timeToLive - abs(timeForYGrav);
1162  float zTimeRemaining = _timeToLive - abs(timeForZGrav);
1163 
1164  if (timeForXGrav < 0.0f) // If the gravity go against the velocity
1165  minP.x += 0.5f * _gravity.x * (xTimeRemaining * xTimeRemaining); // We move down pour min point (becareful! here gravity is negative)
1166  if (timeForYGrav < 0.0f)
1167  minP.y += 0.5f * _gravity.y * (yTimeRemaining * yTimeRemaining);
1168  if (timeForZGrav < 0.0f)
1169  minP.z += 0.5f * _gravity.z * (zTimeRemaining * zTimeRemaining);
1170  }
1171 
1172  // ACCELERATION (Need to rework to work like gravity)
1173  if (_doAcceleration && _doAccDiffDir) // Need to be rework ( for negative value)
1174  {
1175  maxP += 0.5f * _acceleration * (_timeToLive * _timeToLive); // Apply acceleration after time
1176  }
1177  else if (_doAcceleration && !_doAccDiffDir) // Need to be rework
1178  {
1179  // minP += 0.5f * _accelerationConst * (_timeToLive * _timeToLive); //Apply constant acceleration
1180  maxP += 0.5f * _accelerationConst * maxV * (_timeToLive * _timeToLive); // Apply constant acceleration //Not good
1181  }
1182  }
1183  else // If acceleration and gravity is not enable
1184  {
1185  if (!_doDirectionSpeed)
1186  {
1187  if (_velocityType == 0)
1188  {
1189  SLVec3f minVTemp = SLVec3f(min(_velocityRndMax.x, _velocityRndMin.x), min(_velocityRndMax.y, _velocityRndMin.y), min(_velocityRndMax.z, _velocityRndMin.z)); // Apply velocity distance after time
1190  SLVec3f maxVTemp = SLVec3f(max(_velocityRndMax.x, _velocityRndMin.x), max(_velocityRndMax.y, _velocityRndMin.y), max(_velocityRndMax.z, _velocityRndMin.z)); // Apply velocity distance after time
1191 
1192  if (minVTemp.x > 0 && maxVTemp.x > 0) minVTemp.x = 0.0;
1193  if (minVTemp.y > 0 && maxVTemp.y > 0) minVTemp.y = 0.0;
1194  if (minVTemp.z > 0 && maxVTemp.z > 0) minVTemp.z = 0.0;
1195 
1196  if (minVTemp.x < 0 && maxVTemp.x < 0) maxVTemp.x = 0.0;
1197  if (minVTemp.y < 0 && maxVTemp.y < 0) maxVTemp.y = 0.0;
1198  if (minVTemp.z < 0 && maxVTemp.z < 0) maxVTemp.z = 0.0;
1199 
1200  minV += minVTemp;
1201  maxV += maxVTemp;
1202  }
1203  else
1204  {
1205  minV += SLVec3f(_velocityConst.x, 0.0, _velocityConst.z); // Apply velocity distance after time
1206  maxV += SLVec3f(0.0, _velocityConst.y, 0.0); // Apply velocity distance after time
1207  }
1208  }
1209  else if (_doDirectionSpeed && !_doShapeOverride)
1210  {
1211  tempSpeed = 0.0f;
1212  if (_doSpeedRange)
1213  tempSpeed = Utils::random(_speedRange.x, _speedRange.y);
1214  else
1215  tempSpeed = _speed;
1216 
1217  minV += SLVec3f(_direction.x, 0.0, 0.0) * tempSpeed;
1218  maxV += SLVec3f(0.0, _direction.y, _direction.z) * tempSpeed;
1219 
1220  if (_direction.x > 0.0)
1221  {
1222  maxV.x = minV.x;
1223  minV.x = 0.0;
1224  }
1225  if (_direction.y < 0.0)
1226  {
1227  minV.y = maxV.y;
1228  maxV.y = 0.0;
1229  }
1230  if (_direction.z < 0.0)
1231  {
1232  minV.z = maxV.z;
1233  maxV.z = 0.0;
1234  }
1235  }
1236  // Apply time to velocity
1237  minP += minV * _timeToLive;
1238  maxP += maxV * _timeToLive;
1239  }
1240 
1241  // Add size particle
1242  minP.x += minP.x < maxP.x ? -rW : rW; // Add size of particle
1243  minP.y += minP.y < maxP.y ? -rH : rH; // Add size of particle if we don't have size over life
1244  minP.z += minP.z < maxP.z ? -rW : rW; // Add size of particle
1245 
1246  maxP.x += maxP.x > minP.x ? rW : -rW; // Add size of particle
1247  maxP.y += maxP.y > minP.y ? rH : -rH; // Add size of particle
1248  maxP.z += maxP.z > minP.z ? rW : -rW; // Add size of particle
1249 
1250  // Apply world matrix
1251  aabb.fromOStoWS(minP, maxP, wmNode);
1252 }
@ ST_Sphere
Definition: SLEnums.h:280
@ ST_Pyramid
Definition: SLEnums.h:283
@ ST_Box
Definition: SLEnums.h:281
@ ST_Cone
Definition: SLEnums.h:282
void fromOStoWS(const SLVec3f &minOS, const SLVec3f &maxOS, const SLMat4f &wm)
Recalculate min and max after transformation in world coords.
Definition: SLAABBox.cpp:46
SLVec3f maxP
max. vertex in OS
Definition: SLMesh.h:221
SLVec3f minP
min. vertex in OS
Definition: SLMesh.h:220
SLfloat _shapeAngle
Angle of cone and pyramid shapes.
SLint _velocityType
Velocity type.
SLbool _doAcceleration
Boolean for acceleration.
SLVec2f _speedRange
Speed random between two value.
SLVec3f getDirectionCone(SLVec3f position)
Function which return a direction following the cone shape.
SLbool _doSpeedRange
Boolean for speed range.
SLbool _doGravity
Boolean for gravity.
SLfloat _scale
Scale of a particle (Scale the radius)
SLfloat _radiusW
width radius of a particle
SLbool _doDirectionSpeed
Boolean for direction and speed (override velocity)
SLfloat _shapeRadius
Radius of sphere and cone shape.
SLfloat _shapeWidth
Width of pyramid shape.
SLVec3f _direction
Direction of particle.
SLbool _doShapeOverride
Boolean for override direction for shape direction.
SLVec3f _velocityConst
Velocity constant (go in xyz direction)
SLbool _doAccDiffDir
Boolean for acceleration (different direction)
SLbool _doShape
Boolean for shape feature.
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)
SLVec3f _shapeScale
Scale of box shape.
SLVec3f getDirectionPyramid(SLVec3f position)
Function which return a direction following the pyramid shape.
SLShapeType _shapeType
Shape type (ST_)
SLfloat _speed
Speed of particle.
static const float DEG2RAD
Definition: Utils.h:239
T abs(T a)
Definition: Utils.h:249
float random(float min, float max)
Returns a uniform distributed random float number between min and max.
Definition: Utils.h:265

◆ calcNormals()

void SLParticleSystem::calcNormals ( )
inlinevirtual

SLMesh::calcNormals recalculates vertex normals for triangle meshes.

SLMesh::calcNormals recalculates the normals only from the vertices. This algorithms doesn't know anything about smoothgroups. It just loops over the triangle of the material faces and sums up the normal for each of its vertices. Note that the face normals are not normalized. The cross product of 2 vectors is proportional to the area of the triangle. Like this the normal of big triangles are more weighted than small triangles and we get a better normal quality. At the end all vertex normals are normalized.

Reimplemented from SLMesh.

Definition at line 65 of file SLParticleSystem.h.

65 { N.push_back(SLVec3f(0, 1, 0)); };
SLVVec3f N
Vector for vertex normals (opt.) layout (location = 1)
Definition: SLMesh.h:204

◆ changeTexture()

void SLParticleSystem::changeTexture ( )

Change the current use texture, this will switch between the normal texture and the flipbook texture (and vice versa)

Definition at line 972 of file SLParticleSystem.cpp.

973 {
974  if (_doFlipBookTexture)
975  {
978  }
979  else
980  {
983  }
984 }
@ TT_diffuse
Definition: SLGLTexture.h:78
void removeTextureType(SLTextureType tt)
Definition: SLMaterial.h:159
void addTexture(SLGLTexture *texture)
Adds the passed texture to the equivalent texture type vector.
Definition: SLMaterial.cpp:348
SLMaterial * mat() const
Definition: SLMesh.h:177
SLbool _doFlipBookTexture
Boolean for flipbook texture.

◆ color() [1/2]

SLCol4f SLParticleSystem::color ( )
inline

Definition at line 78 of file SLParticleSystem.h.

78 { return _color; }
SLCol4f _color
Color for particle.

◆ color() [2/2]

void SLParticleSystem::color ( SLCol4f  c)
inline

Definition at line 180 of file SLParticleSystem.h.

180 { _color = c; }

◆ direction() [1/3]

SLVec3f SLParticleSystem::direction ( )
inline

Definition at line 103 of file SLParticleSystem.h.

103 { return _direction; }

◆ direction() [2/3]

void SLParticleSystem::direction ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 182 of file SLParticleSystem.h.

183  {
184  _direction.x = vX;
185  _direction.y = vY;
186  _direction.z = vZ;
187  }

◆ direction() [3/3]

void SLParticleSystem::direction ( SLVec3f  v)
inline

Definition at line 181 of file SLParticleSystem.h.

181 { _direction = v; }

◆ doAcc()

SLbool SLParticleSystem::doAcc ( )
inline

Definition at line 81 of file SLParticleSystem.h.

81 { return _doAcceleration; }

◆ doAccDiffDir() [1/2]

SLbool SLParticleSystem::doAccDiffDir ( )
inline

Definition at line 82 of file SLParticleSystem.h.

82 { return _doAccDiffDir; }

◆ doAccDiffDir() [2/2]

void SLParticleSystem::doAccDiffDir ( SLbool  b)
inline

Definition at line 191 of file SLParticleSystem.h.

191 { _doAccDiffDir = b; }

◆ doAcceleration()

void SLParticleSystem::doAcceleration ( SLbool  b)
inline

Definition at line 188 of file SLParticleSystem.h.

188 { _doAcceleration = b; }

◆ doAlphaOverLT() [1/2]

SLbool SLParticleSystem::doAlphaOverLT ( )
inline

Definition at line 83 of file SLParticleSystem.h.

83 { return _doAlphaOverLT; }
SLbool _doAlphaOverLT
Boolean for alpha over life time.

◆ doAlphaOverLT() [2/2]

void SLParticleSystem::doAlphaOverLT ( SLbool  b)
inline

Definition at line 189 of file SLParticleSystem.h.

189 { _doAlphaOverLT = b; }

◆ doAlphaOverLTCurve() [1/2]

SLbool SLParticleSystem::doAlphaOverLTCurve ( )
inline

Definition at line 84 of file SLParticleSystem.h.

84 { return _doAlphaOverLTCurve; }
SLbool _doAlphaOverLTCurve
Boolean for alpha over life time curve.

◆ doAlphaOverLTCurve() [2/2]

void SLParticleSystem::doAlphaOverLTCurve ( SLbool  b)
inline

Definition at line 190 of file SLParticleSystem.h.

190 { _doAlphaOverLTCurve = b; }

◆ doBlendBrightness() [1/2]

SLbool SLParticleSystem::doBlendBrightness ( )
inline

Definition at line 85 of file SLParticleSystem.h.

85 { return _doBlendBrightness; }
SLbool _doBlendBrightness
Boolean for glow/brightness on pixel with many particle.

◆ doBlendBrightness() [2/2]

void SLParticleSystem::doBlendBrightness ( SLbool  b)
inline

Definition at line 192 of file SLParticleSystem.h.

192 { _doBlendBrightness = b; }

◆ doColor() [1/2]

SLbool SLParticleSystem::doColor ( )
inline

Definition at line 87 of file SLParticleSystem.h.

87 { return _doColor; }
SLbool _doColor
Boolean for color.

◆ doColor() [2/2]

void SLParticleSystem::doColor ( SLbool  b)
inline

Definition at line 193 of file SLParticleSystem.h.

193 { _doColor = b; }

◆ doColorOverLT() [1/2]

SLbool SLParticleSystem::doColorOverLT ( )
inline

Definition at line 88 of file SLParticleSystem.h.

88 { return _doColorOverLT; }
SLbool _doColorOverLT
Boolean for color over life time.

◆ doColorOverLT() [2/2]

void SLParticleSystem::doColorOverLT ( SLbool  b)
inline

Definition at line 194 of file SLParticleSystem.h.

194 { _doColorOverLT = b; }

◆ doCounterGap() [1/2]

SLbool SLParticleSystem::doCounterGap ( )
inline

Definition at line 86 of file SLParticleSystem.h.

86 { return _doCounterGap; }
SLbool _doCounterGap
Boolean for counter lag/gap, can create flickering with few particle (explained in documentation) whe...

◆ doCounterGap() [2/2]

void SLParticleSystem::doCounterGap ( SLbool  b)
inline

Definition at line 195 of file SLParticleSystem.h.

195 { _doCounterGap = b; }

◆ doDirectionSpeed() [1/2]

SLbool SLParticleSystem::doDirectionSpeed ( )
inline

Definition at line 89 of file SLParticleSystem.h.

89 { return _doDirectionSpeed; }

◆ doDirectionSpeed() [2/2]

void SLParticleSystem::doDirectionSpeed ( SLbool  b)
inline

Definition at line 196 of file SLParticleSystem.h.

196 { _doDirectionSpeed = b; }

◆ doFlipBookTexture() [1/2]

SLbool SLParticleSystem::doFlipBookTexture ( )
inline

Definition at line 91 of file SLParticleSystem.h.

91 { return _doFlipBookTexture; }

◆ doFlipBookTexture() [2/2]

void SLParticleSystem::doFlipBookTexture ( SLbool  b)
inline

Definition at line 198 of file SLParticleSystem.h.

198 { _doFlipBookTexture = b; }

◆ doGravity() [1/2]

SLbool SLParticleSystem::doGravity ( )
inline

Definition at line 90 of file SLParticleSystem.h.

90 { return _doGravity; }

◆ doGravity() [2/2]

void SLParticleSystem::doGravity ( SLbool  b)
inline

Definition at line 197 of file SLParticleSystem.h.

197 { _doGravity = b; }

◆ doInstancedDrawing() [1/2]

SLbool SLParticleSystem::doInstancedDrawing ( )
inline

Definition at line 80 of file SLParticleSystem.h.

80 { return _doInstancedDrawing; }

◆ doInstancedDrawing() [2/2]

void SLParticleSystem::doInstancedDrawing ( bool  instanced)
inline

Definition at line 134 of file SLParticleSystem.h.

134 { _doInstancedDrawing = instanced; }

◆ doRotation() [1/2]

SLbool SLParticleSystem::doRotation ( )
inline

Definition at line 92 of file SLParticleSystem.h.

92 { return _doRotation; }
SLbool _doRotation
Boolean for rotation.

◆ doRotation() [2/2]

void SLParticleSystem::doRotation ( SLbool  b)
inline

Definition at line 199 of file SLParticleSystem.h.

199 { _doRotation = b; }

◆ doRotRange() [1/2]

SLbool SLParticleSystem::doRotRange ( )
inline

Definition at line 93 of file SLParticleSystem.h.

93 { return _doRotRange; }
SLbool _doRotRange
Boolean for rotation range (random value between range)

◆ doRotRange() [2/2]

void SLParticleSystem::doRotRange ( SLbool  b)
inline

Definition at line 200 of file SLParticleSystem.h.

200 { _doRotRange = b; }

◆ doShape() [1/2]

SLbool SLParticleSystem::doShape ( )
inline

Definition at line 96 of file SLParticleSystem.h.

96 { return _doShape; }

◆ doShape() [2/2]

void SLParticleSystem::doShape ( SLbool  b)
inline

Definition at line 202 of file SLParticleSystem.h.

202 { _doShape = b; }

◆ doShapeOverride() [1/2]

SLbool SLParticleSystem::doShapeOverride ( )
inline

Definition at line 98 of file SLParticleSystem.h.

98 { return _doShapeOverride; }

◆ doShapeOverride() [2/2]

void SLParticleSystem::doShapeOverride ( SLbool  b)
inline

Definition at line 204 of file SLParticleSystem.h.

204 { _doShapeOverride = b; }

◆ doShapeSpawnBase() [1/2]

SLbool SLParticleSystem::doShapeSpawnBase ( )
inline

Definition at line 99 of file SLParticleSystem.h.

99 { return _doShapeSpawnBase; }

◆ doShapeSpawnBase() [2/2]

void SLParticleSystem::doShapeSpawnBase ( SLbool  b)
inline

Definition at line 205 of file SLParticleSystem.h.

205 { _doShapeSpawnBase = b; }

◆ doShapeSurface() [1/2]

SLbool SLParticleSystem::doShapeSurface ( )
inline

Definition at line 97 of file SLParticleSystem.h.

97 { return _doShapeSurface; }
SLbool _doShapeSurface
Boolean for shape surface (particle will be spawned on surface)

◆ doShapeSurface() [2/2]

void SLParticleSystem::doShapeSurface ( SLbool  b)
inline

Definition at line 203 of file SLParticleSystem.h.

203 { _doShapeSurface = b; }

◆ doSizeOverLT() [1/2]

SLbool SLParticleSystem::doSizeOverLT ( )
inline

Definition at line 94 of file SLParticleSystem.h.

94 { return _doSizeOverLT; }
SLbool _doSizeOverLT
Boolean for size over life time.

◆ doSizeOverLT() [2/2]

void SLParticleSystem::doSizeOverLT ( SLbool  b)
inline

Definition at line 206 of file SLParticleSystem.h.

206 { _doSizeOverLT = b; }

◆ doSizeOverLTCurve() [1/2]

SLbool SLParticleSystem::doSizeOverLTCurve ( )
inline

Definition at line 95 of file SLParticleSystem.h.

95 { return _doSizeOverLTCurve; }
SLbool _doSizeOverLTCurve
Boolean for size over life time curve.

◆ doSizeOverLTCurve() [2/2]

void SLParticleSystem::doSizeOverLTCurve ( SLbool  b)
inline

Definition at line 207 of file SLParticleSystem.h.

207 { _doSizeOverLTCurve = b; }

◆ doSpeedRange() [1/2]

SLbool SLParticleSystem::doSpeedRange ( )
inline

Definition at line 100 of file SLParticleSystem.h.

100 { return _doSpeedRange; }

◆ doSpeedRange() [2/2]

void SLParticleSystem::doSpeedRange ( SLbool  b)
inline

Definition at line 201 of file SLParticleSystem.h.

201 { _doSpeedRange = b; }

◆ doWorldSpace() [1/2]

SLbool SLParticleSystem::doWorldSpace ( )
inline

Definition at line 101 of file SLParticleSystem.h.

101 { return _doWorldSpace; }
SLbool _doWorldSpace
Boolean for world space position.

◆ doWorldSpace() [2/2]

void SLParticleSystem::doWorldSpace ( SLbool  b)
inline

Definition at line 208 of file SLParticleSystem.h.

208 { _doWorldSpace = b; }

◆ draw()

void SLParticleSystem::draw ( SLSceneView sv,
SLNode node,
SLuint  instances = 1 
)
virtual

Draw function override from SLMesh. In this function I start by generate the particle and programs if they are not, then I check if the particle have been culled by the frustum culling or if they have been resumed by the user. After I update the particle in the update pass, then and finally I draw them.

Todo:
The assignment of TF buffer to a rendering buffer causes most probably a warning on Emscripten-WebGL

Reimplemented from SLMesh.

Definition at line 601 of file SLParticleSystem.cpp.

602 {
603  ////////////////////////////////////////
604  // Init particles vector and init VAO //
605  ////////////////////////////////////////
606 
607  if (!_isGenerated)
608  generate();
609 
610  ///////////////////////
611  // Generate programs //
612  ///////////////////////
613 
614  if (!_mat->program() || !_mat->programTF())
616 
617  ///////////////////////////////////////////////////
618  // Calculate time and paused and frustum culling //
619  ///////////////////////////////////////////////////
620 
621  float difTime = 0.0f;
622  float deltaTime = GlobalTimer::timeS() - _startUpdateTimeS; // Actual delta time
623 
624  // Calculate time difference for frustum culling and paused
625  // If particle system was not visible, and was resumed when it was not visible
627  {
628  _isVisibleInFrustum = true;
629 
630  // Paused was set before not visible (will take _lastTimeBeforePauseS),
631  // if set after (will take _notVisibleTimeS)
633 
634  // maybe add later average delta time
635  // (because maybe bug when fast not visible long time, visible, not visible, visible
636  // Last delta time, because when culled draw is not called therefore
637  // the actual delta time will be too big
638  deltaTime = _deltaTimeUpdateS;
639 
640  // No more culling, the difference time has been applied, no further need
641  _notVisibleTimeS = 0.0f;
642 
643  // No more paused, the difference time has been applied, no further need
644  _lastTimeBeforePauseS = 0.0f;
645  }
646 
647  // If particle system was not visible, this one is called just once when the
648  // particle is draw again (Do nothing if paused, because update call is not done)
649  else if (!_isVisibleInFrustum)
650  {
651  _isVisibleInFrustum = true;
652 
653  // Use time since the particle system was not visible
654  difTime = GlobalTimer::timeS() - _notVisibleTimeS;
655 
656  // maybe add later average delta time (because maybe bug when
657  // fast not visible long time, visible, not visible, visible
658  // Last delta time, because when culled draw is not called
659  // therefore the actual delta time will be too big
660  deltaTime = _deltaTimeUpdateS;
661 
662  // If was paused when not visible. Need to take _notVisibleTimeS because
663  // it's since this value that the particle system is not drew.
665  // Get the value of since the particle system is not drew
667 
668  // No more culling, the difference time has been applied, no further need
669  _notVisibleTimeS = 0.0f;
670  }
671 
672  // If particle system was resumed
673  else if (!_isPaused && _lastTimeBeforePauseS != 0.0f)
674  {
675  // Use time since the particle system was paused
677 
678  // No more paused, the difference time has been applied, no further need
679  _lastTimeBeforePauseS = 0.0f;
680 
681  // Take default delta time, because when just paused no need to
682  // take last delta time, the draw call continue to be called
683  }
684 
685  // Calculate the elapsed time for the updating, need to change to
686  // use a real profiler (can't measure time like this on the GPU)
688 
689  // MS above, S below
692 
693  if (!_isPaused) // The updating is paused, therefore no need to send uniforms
694  {
695  ///////////
696  // UPDATING
697  ///////////
698 
699  // Now use the updating program
700  SLGLProgram* spTF = _mat->programTF();
701  spTF->useProgram();
702 
703  //////////////////////////
704  // Apply Uniform Variables
705  //////////////////////////
706 
707  // Time difference, between when the particle system was culled or paused or both
708  spTF->uniform1f("u_difTime", difTime);
709 
710  // Time between each draw call, take delta time from last draw called after frustum culling
711  spTF->uniform1f("u_deltaTime", deltaTime);
712 
713  // Time since process start
714  spTF->uniform1f("u_time", _startUpdateTimeS);
715 
716  if (_doAcceleration)
717  {
718  if (_doAccDiffDir)
719  spTF->uniform3f("u_acceleration",
722  _acceleration.z);
723  else
724  spTF->uniform1f("u_accConst",
726  }
727 
728  if (_doGravity)
729  spTF->uniform3f("u_gravity",
730  _gravity.x,
731  _gravity.y,
732  _gravity.z);
733 
734  spTF->uniform1f("u_tTL", _timeToLive);
735 
736  emitterPos(node->translationWS());
737 
738  // Worldspace
739  if (_doWorldSpace)
740  spTF->uniform3f("u_pGPosition",
741  _emitterPos.x,
742  _emitterPos.y,
743  _emitterPos.z);
744  else
745  spTF->uniform3f("u_pGPosition",
746  0.0f,
747  0.0f,
748  0.0f);
749 
750  // Flipbook
751  if (_doFlipBookTexture)
752  {
753  spTF->uniform1i("u_col", _flipbookColumns);
754  spTF->uniform1i("u_row", _flipbookRows);
756 
757  if (_flipboookLastUpdate > (1.0f / (float)_flipbookFPS))
758  {
759  // Last time FB was updated is bigger than the time needed for each update
760  spTF->uniform1i("u_condFB", 1);
761  _flipboookLastUpdate = 0.0f;
762  }
763  else
764  spTF->uniform1i("u_condFB", 0);
765  }
766 
767  // Rotation
768  if (_doRotation && !_doRotRange)
769  spTF->uniform1f("u_angularVelo",
771 
772  /////////////////////////
773  // Draw call to update //
774  /////////////////////////
775 
776  if (_drawBuf == 0)
777  {
780  _vao1.endTF();
781 
782  // @todo The assignment of TF buffer to a rendering buffer causes most probably a warning on Emscripten-WebGL
784  }
785  else
786  {
789  _vao2.endTF();
790 
791  // @todo The assignment of TF buffer to a rendering buffer causes most probably a warning on Emscripten-WebGL
793  }
795  }
796 
797  /////////////
798  // DRAWING //
799  /////////////
800 
801  // Give uniform for drawing and find for linking vao vbo
802  SLGLProgram* spD = _mat->program();
803  spD->useProgram();
804 
805  SLGLState* stateGL = SLGLState::instance();
806 
807  // Start calculation of the elapsed time for the drawing, need to change
808  // to use a real profiler (can't measure time like this on the GPU)
810 
811  // Billboard type
812  // World space
813  if (_doWorldSpace)
814  {
816  {
817  // Just view matrix because world space is enabled
818  SLMat4f vMat = stateGL->viewMatrix;
819 
820  vMat.m(0, 1.0f);
821  vMat.m(1, 0.0f);
822  vMat.m(2, 0.0f);
823 
824  vMat.m(8, 0.0f);
825  vMat.m(9, 0.0f);
826  vMat.m(10, 1.0f);
827 
828  spD->uniformMatrix4fv("u_vYawPMatrix",
829  1,
830  (SLfloat*)&vMat);
831  }
832  else
833  {
834  // Just view matrix because world space is enabled
835  SLMat4f vMat = stateGL->viewMatrix;
836  std::cout << "vMat" << std::endl;
837  vMat.m(0, 1.0f);
838  vMat.m(1, 0.0f);
839  vMat.m(2, 0.0f);
840 
841  vMat.m(3, 1.0f);
842  vMat.m(4, 0.0f);
843  vMat.m(5, 0.0f);
844 
845  vMat.m(6, 0.0f);
846  vMat.m(7, 0.0f);
847  vMat.m(8, 1.0f);
848 
849  spD->uniformMatrix4fv("u_vOmvMatrix",
850  1,
851  (SLfloat*)&vMat);
852  }
853  }
854  else
855  {
856  // Build Model-View Matrix
857  SLMat4f mvMat = stateGL->viewMatrix * stateGL->modelMatrix;
858 
860  {
861  mvMat.m(0, 1.0f);
862  mvMat.m(1, 0.0f);
863  mvMat.m(2, 0.0f);
864 
865  mvMat.m(8, 0.0f);
866  mvMat.m(9, 0.0f);
867  mvMat.m(10, 1.0f);
868 
869  spD->uniformMatrix4fv("u_vYawPMatrix",
870  1,
871  (SLfloat*)&mvMat);
872  }
873  else
874  {
875  spD->uniformMatrix4fv("u_vOmvMatrix",
876  1,
877  (SLfloat*)&mvMat);
878  }
879  }
880 
881  // Alpha over life Bézier curve
883  {
884  spD->uniform4f("u_al_bernstein",
889  }
890 
891  // Size over life Bézier curve
892  if (_doSizeOverLTCurve)
893  {
894  spD->uniform4f("u_si_bernstein",
899  }
900 
901  // Color over life by gradient color editor
902  if (_doColorOverLT)
903  {
904  spD->uniform1fv("u_colorArr",
905  _texGradient->length() * 3,
906  (float*)&_texGradient->allColors()[0]);
907  /*
908  spD->uniform1fv("u_colorArr",
909  256 * 3,
910  _colorArr);
911  */
912  }
913  else
914  {
915  spD->uniform4f("u_color",
916  _color.x,
917  _color.y,
918  _color.z,
919  _color.w);
920  }
921 
922  // Flipbook
923  if (_doFlipBookTexture)
924  {
925  spD->uniform1i("u_col", _flipbookColumns);
926  spD->uniform1i("u_row", _flipbookRows);
927  }
928 
929  if (_isPaused) // Take time when pause was enable
930  spD->uniform1f("u_time", _lastTimeBeforePauseS);
931  else
932  spD->uniform1f("u_time", GlobalTimer::timeS());
933 
934  spD->uniform1f("u_tTL", _timeToLive);
935  spD->uniform1f("u_scale", _scale);
936  spD->uniform1f("u_radiusW", _radiusW);
937  spD->uniform1f("u_radiusH", _radiusH);
938  spD->uniform1f("u_oneOverGamma", 1.0f);
939 
940  // Check wireframe
941  if (sv->drawBits()->get(SL_DB_MESHWIRED) ||
942  node->drawBits()->get(SL_DB_MESHWIRED))
943  spD->uniform1i("u_doWireFrame", 1);
944  else
945  spD->uniform1i("u_doWireFrame", 0);
946 
948  stateGL->blendFunc(GL_SRC_ALPHA, GL_ONE);
949 
950  ///////////////////////////
952  SLMesh::draw(sv, node, 2 * _amount); // 2 triangles per particle
953  else
954  SLMesh::draw(sv, node);
955  ///////////////////////////
956 
958  stateGL->blendFunc(GL_SRC_ALPHA,
959  GL_ONE_MINUS_SRC_ALPHA);
960 
961  // End calculation of the elapsed time for the drawing
963 
964  // Swap buffer
965  _drawBuf = 1 - _drawBuf;
966 }
float SLfloat
Definition: SL.h:173
#define SL_DB_MESHWIRED
Draw polygons as wired mesh.
Definition: SLDrawBits.h:22
@ BT_Vertical
Definition: SLEnums.h:273
static float timeS()
Definition: GlobalTimer.cpp:20
static float timeMS()
Definition: GlobalTimer.cpp:25
SLbool get(SLuint bit)
Returns the specified bit.
Definition: SLDrawBits.h:69
Encapsulation of an OpenGL shader program object.
Definition: SLGLProgram.h:56
SLint uniformMatrix4fv(const SLchar *name, SLsizei count, const SLfloat *value, GLboolean transpose=false) const
Passes a 4x4 float matrix values py pointer to the uniform variable "name".
SLint uniform4f(const SLchar *name, SLfloat v0, SLfloat v1, SLfloat v2, SLfloat v3) const
Passes the float values v0,v1,v2 & v3 to the uniform variable "name".
SLint uniform1f(const SLchar *name, SLfloat v0) const
Passes the float value v0 to the uniform variable "name".
SLint uniform1fv(const SLchar *name, SLsizei count, const SLfloat *value) const
Passes 1 float value py pointer to the uniform variable "name".
SLint uniform3f(const SLchar *name, SLfloat v0, SLfloat v1, SLfloat v2) const
Passes the float values v0, v1 & v2 to the uniform variable "name".
void useProgram()
SLint uniform1i(const SLchar *name, SLint v0) const
Passes the int values v0 to the uniform variable "name".
Singleton class holding all OpenGL states.
Definition: SLGLState.h:71
SLMat4f modelMatrix
Init all states.
Definition: SLGLState.h:89
SLMat4f viewMatrix
matrix for the active cameras view transform
Definition: SLGLState.h:91
void blendFunc(SLenum blendFuncSFactor, SLenum blendFuncDFactor)
Sets new blend function source and destination factors.
Definition: SLGLState.cpp:250
void beginTF(SLuint tfoID)
Begin transform feedback.
void endTF()
End transform feedback.
SLuint tfoID() const
Returns the TFO id.
void drawArrayAs(SLGLPrimitiveType primitiveType, SLint firstVertex=0, SLsizei countVertices=0)
Draws the VAO as an array with a primitive type.
void m(int i, T val)
Definition: SLMat4.h:93
void programTF(SLGLProgram *sp)
Definition: SLMaterial.h:206
void generateProgramPS(bool drawInstanced=false)
Definition: SLMaterial.cpp:391
void program(SLGLProgram *sp)
Definition: SLMaterial.h:205
virtual void draw(SLSceneView *sv, SLNode *node, SLuint intances=0)
Definition: SLMesh.cpp:389
SLGLVertexArray _vao
Main OpenGL Vertex Array Object for drawing.
Definition: SLMesh.h:234
SLMaterial * _mat
Pointer to the inside material.
Definition: SLMesh.h:232
SLVec3f translationWS() const
Definition: SLNode.h:531
SLDrawBits * drawBits()
Definition: SLNode.h:299
SLbool _isPaused
Boolean to stop updating.
void generate()
Function which will generate the particles and attributes them to the VAO.
SLGLVertexArray _vao2
SLVec3f _emitterPos
Position of the particle emitter.
int _flipbookFPS
Number of update of flipbook by second.
SLbool _isGenerated
Boolean to generate particle system and load it on the GPU.
SLfloat _lastTimeBeforePauseS
Time since the particle system is paused.
SLfloat _notVisibleTimeS
Time since start when node not visible in S.
SLGLVertexArray _instanceVao2
SLfloat _deltaTimeUpdateS
Delta time in between two frames S.
SLVec3f emitterPos() const
SLVec4f _bernsteinPYAlpha
Vector for bezier curve (default linear function)
SLGLVertexArray _instanceVao1
SLbool _isVisibleInFrustum
Boolean to set time since node not visible.
int _drawBuf
Boolean to switch buffer.
SLfloat _startUpdateTimeS
Time since start for updating in S.
SLfloat _startUpdateTimeMS
Time since start for updating in MS.
SLVec4f _bernsteinPYSize
Vector for bezier curve (default linear function)
SLint _flipbookColumns
Number of flipbook sub-textures by column.
SLfloat _startDrawTimeMS
Time since start of draw in MS.
float _flipboookLastUpdate
Last time flipbook was updated.
SLint _flipbookRows
Number of flipbook sub-textures by row.
SLGLVertexArray _vao1
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
SLDrawBits * drawBits()
Definition: SLSceneView.h:198
SLVCol3f allColors()
Returns all alpha values of the transfer function as a float vector.
SLuint length()
Definition: SLTexColorLUT.h:93
T w
Definition: SLVec4.h:32
T z
Definition: SLVec4.h:32
T y
Definition: SLVec4.h:32
T x
Definition: SLVec4.h:32
void set(T value)
Sets the current value in the value array and builds the average.
Definition: Averaged.h:53

◆ drawTime()

AvgFloat& SLParticleSystem::drawTime ( )
inline

Definition at line 104 of file SLParticleSystem.h.

104 { return _drawTime; }

◆ emitterPos() [1/2]

SLVec3f SLParticleSystem::emitterPos ( ) const
inline

Definition at line 105 of file SLParticleSystem.h.

105 { return _emitterPos; }

◆ emitterPos() [2/2]

void SLParticleSystem::emitterPos ( SLVec3f  p)
inline

Definition at line 209 of file SLParticleSystem.h.

209 { _emitterPos = p; }

◆ flipbookColumns() [1/2]

SLint SLParticleSystem::flipbookColumns ( )
inline

Definition at line 107 of file SLParticleSystem.h.

107 { return _flipbookColumns; }

◆ flipbookColumns() [2/2]

void SLParticleSystem::flipbookColumns ( SLint  i)
inline

Definition at line 217 of file SLParticleSystem.h.

217 { _flipbookColumns = i; }

◆ flipbookRows() [1/2]

SLint SLParticleSystem::flipbookRows ( )
inline

Definition at line 108 of file SLParticleSystem.h.

108 { return _flipbookRows; }

◆ flipbookRows() [2/2]

void SLParticleSystem::flipbookRows ( SLint  i)
inline

Definition at line 218 of file SLParticleSystem.h.

218 { _flipbookRows = i; }

◆ frameRateFB() [1/2]

int SLParticleSystem::frameRateFB ( )
inline

Definition at line 109 of file SLParticleSystem.h.

109 { return _flipbookFPS; }

◆ frameRateFB() [2/2]

void SLParticleSystem::frameRateFB ( int  i)
inline

Definition at line 219 of file SLParticleSystem.h.

219 { _flipbookFPS = i; }

◆ generate()

void SLParticleSystem::generate ( )

Function which will generate the particles and attributes them to the VAO.

Definition at line 292 of file SLParticleSystem.cpp.

293 {
294  SLuint seed = (SLuint)chrono::system_clock::now().time_since_epoch().count();
295  default_random_engine generator(seed);
296  normal_distribution<float> distribution(0.0f, 1.0f);
297 
298  SLVVec3f tempP, tempV, tempInitV;
299  SLVfloat tempR, tempST, tempAngulareVelo;
300  SLVuint tempTexNum;
301  SLVVec3f tempInitP;
302 
305  else
307 
309 
310  // Initialize the drawing:
311  if (_doFlipBookTexture)
312  {
313  SLMaterial* mDraw = new SLMaterial(_assetManager,
314  "Drawing-Material",
315  this,
316  _texFlipbook);
317  mDraw->addTexture(_texGradient);
318  mat(mDraw);
319  }
320  else
321  {
322  SLMaterial* mDraw = new SLMaterial(_assetManager,
323  "Drawing-Material",
324  this,
325  _texParticle);
326  mDraw->addTexture(_texGradient);
327  mat(mDraw);
328  }
329 
330  tempP.resize(_amount);
331  tempV.resize(_amount);
332  tempST.resize(_amount);
333 
335  tempInitV.resize(_amount);
336  if (_doRotation)
337  tempR.resize(_amount);
338  if (_doRotation && _doRotRange)
339  tempAngulareVelo.resize(_amount);
340  if (_doFlipBookTexture)
341  tempTexNum.resize(_amount);
342  if (_doShape)
343  tempInitP.resize(_amount);
344 
345  // Normal generation
346  for (SLint i = 0; i < _amount; i++)
347  {
348  if (_doShape && _shapeType == ST_Sphere) // Position in or on sphere
349  {
350  if (!_doShapeSurface) // In volume
351  tempP[i] = getPointInSphere(_shapeRadius,
352  SLVec3f(distribution(generator),
353  distribution(generator),
354  distribution(generator)));
355  else // On surface
356  tempP[i] = getPointOnSphere(_shapeRadius,
357  SLVec3f(distribution(generator),
358  distribution(generator),
359  distribution(generator)));
360  }
361  else if (_doShape && _shapeType == ST_Box) // Position in or on box
362  if (!_doShapeSurface)
363  tempP[i] = getPointInBox(_shapeScale);
364  else
365  tempP[i] = getPointOnBox(_shapeScale);
366  else if (_doShape && _shapeType == ST_Cone) // Position in or on cone
367  if (!_doShapeSurface)
368  tempP[i] = getPointInCone();
369  else
370  tempP[i] = getPointOnCone();
371  else if (_doShape && _shapeType == ST_Pyramid) // Position in or on pyramid
372  if (!_doShapeSurface)
373  tempP[i] = getPointInPyramid();
374  else
375  tempP[i] = getPointOnPyramid();
376  else // Position is not a volume, spawn from start point (particle emitter position)
377  tempP[i] = SLVec3f(0, 0, 0);
378 
379  if (!_doDirectionSpeed) // Use normal velocity
380  {
381  if (_velocityType == 0) // Random value
382  {
383  tempV[i].x = Utils::random(_velocityRndMin.x, _velocityRndMax.x); // Random value for x velocity
384  tempV[i].y = Utils::random(_velocityRndMin.y, _velocityRndMax.y); // Random value for y velocity
385  tempV[i].z = Utils::random(_velocityRndMin.z, _velocityRndMax.z); // Random value for z velocity
386  }
387  else if (_velocityType == 1) // Constant
388  {
389  tempV[i].x = _velocityConst.x; // Constant value for x velocity
390  tempV[i].y = _velocityConst.y; // Constant value for y velocity
391  tempV[i].z = _velocityConst.z; // Constant value for z velocity
392  }
393  }
394  else // DO direction and speed
395  {
396  SLVec3f tempDirection;
397  if (_doShapeOverride) // Direction for shape
398  {
399  if (_doShape && _shapeType == ST_Sphere)
400  tempDirection = getDirectionSphere(tempP[i]);
401  else if (_doShape && _shapeType == ST_Box)
402  tempDirection = getDirectionBox(tempP[i]);
403  else if (_doShape && _shapeType == ST_Cone)
404  tempDirection = getDirectionCone(tempP[i]);
405  else if (_doShape && _shapeType == ST_Pyramid)
406  tempDirection = getDirectionPyramid(tempP[i]);
407  }
408  else // Normal direction
409  tempDirection = _direction;
410 
411  if (_doSpeedRange) // Apply speed
412  tempV[i] = tempDirection * Utils::random(_speedRange.x, _speedRange.y);
413  else
414  tempV[i] = tempDirection * _speed;
415  }
416 
417  // When the first particle dies the last one begin to live
418  tempST[i] = GlobalTimer::timeS() + ((float)i * (_timeToLive / (float)_amount)); // Time to start
419 
420  if (_doAcceleration || _doGravity) // Acceleration
421  tempInitV[i] = tempV[i];
422  if (_doRotation) // Rotation (constant angular velocity)
423  tempR[i] = Utils::random(0.0f * DEG2RAD, 360.0f * DEG2RAD); // Start rotation of the particle
424  if (_doRotation && _doRotRange) // Random angular velocity for each particle
425  tempAngulareVelo[i] = Utils::random(_angularVelocityRange.x * DEG2RAD,
426  _angularVelocityRange.y * DEG2RAD); // Start rotation of the particle
427  if (_doFlipBookTexture) // Flipbook texture
428  tempTexNum[i] = Utils::random(0,
430  if (_doShape) // Shape feature
431  tempInitP[i] = tempP[i];
432  }
433 
434  // Need to have two VAO for transform feedback swapping
435  // Configure first VAO
436  _vao1.deleteGL();
440 
444  &tempInitV);
445  if (_doRotation)
447  AT_rotation,
448  &tempR);
449  if (_doRotation && _doRotRange)
452  &tempAngulareVelo);
453  if (_doFlipBookTexture)
455  AT_texNum,
456  &tempTexNum);
457  if (_doShape)
460  &tempInitP);
461  _vao1.generateTF((SLuint)tempP.size());
462 
463  // Configure second VAO
464  _vao2.deleteGL();
468 
472  &tempInitV);
473  if (_doRotation)
475  AT_rotation,
476  &tempR);
477  if (_doRotation && _doRotRange)
480  &tempAngulareVelo);
481  if (_doFlipBookTexture)
483  AT_texNum,
484  &tempTexNum);
485  if (_doShape)
488  &tempInitP);
489  _vao2.generateTF((SLuint)tempP.size());
490 
492  {
493  P.clear();
494  I32.clear();
495 
496  // Generate for billboard (for drawing instanced without geometry shader)
497  P.push_back(SLVec3f(-1, -1, 0));
498  P.push_back(SLVec3f(1, -1, 0));
499  P.push_back(SLVec3f(1, 1, 0));
500  P.push_back(SLVec3f(-1, 1, 0));
501 
502  I32.push_back(0);
503  I32.push_back(1);
504  I32.push_back(2);
505  I32.push_back(2);
506  I32.push_back(3);
507  I32.push_back(0);
508 
513  _instanceVao1.generate((SLuint)P.size());
514 
519  _instanceVao2.generate((SLuint)P.size());
520  }
521 
522  _isGenerated = true;
523 }
unsigned int SLuint
Definition: SL.h:171
vector< SLfloat > SLVfloat
Definition: SL.h:200
vector< SLuint > SLVuint
Definition: SL.h:197
int SLint
Definition: SL.h:170
@ AT_instancePosition
Vertex instance position for instanced particle drawing.
Definition: SLGLEnums.h:85
@ AT_angularVelo
Vertex angular velocity for rotation float.
Definition: SLGLEnums.h:82
@ AT_texNum
Vertex texture number int.
Definition: SLGLEnums.h:83
@ AT_custom0
Custom vertex attribute 0.
Definition: SLGLEnums.h:67
@ AT_position
Vertex position as a 2, 3 or 4 component vectors.
Definition: SLGLEnums.h:58
@ AT_rotation
Vertex rotation float.
Definition: SLGLEnums.h:81
@ AT_startTime
Vertex start time float.
Definition: SLGLEnums.h:79
@ AT_initialPosition
Vertex initial position 3 component vectors.
Definition: SLGLEnums.h:84
@ AT_velocity
Vertex velocity 3 component vectors.
Definition: SLGLEnums.h:78
@ AT_initialVelocity
Vertex initial velocity 3 component vectors.
Definition: SLGLEnums.h:80
@ PT_triangles
Definition: SLGLEnums.h:35
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
void setInstanceVBO(SLGLVertexBuffer *vbo, SLuint divisor=0)
Attach a VBO that has been created outside of this VAO.
void setAttrib(SLGLAttributeType type, SLint elementSize, SLint location, void *dataPointer, SLGLBufferType dataType=BT_float)
Adds a vertex attribute with data pointer and an element size.
void generateTF(SLuint numVertices, SLGLBufferUsage usage=BU_static, SLbool outputInterleaved=true, SLuint divisor=0)
Generates the VA & VB & TF objects.
void setIndices(SLuint numIndicesElements, SLGLBufferType indexDataType, void *indexDataElements, SLuint numIndicesEdges=0, void *indexDataEdges=nullptr)
Adds the index array for indexed element drawing.
SLGLVertexBuffer * vbo()
void generate(SLuint numVertices, SLGLBufferUsage usage=BU_static, SLbool outputInterleaved=true, SLuint divisor=0)
Generates the VA & VB objects for a NO. of vertices.
void deleteGL()
Deletes all vertex array & vertex buffer objects.
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
virtual void deleteDataGpu()
Definition: SLMesh.cpp:128
SLVec3f getDirectionBox(SLVec3f position)
Function which return the direction towards the exterior of a box.
SLVec3f getPointInSphere(float radius, SLVec3f randomX)
Function which return a position in a sphere.
SLVec3f getPointOnCone()
Function which return a position on the cone define in the particle system.
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.
SLVec3f getPointInCone()
Function which return a position in the cone define in the particle system.
SLVec3f getPointInPyramid()
Function which returns a position in the pyramid that define the PS.
SLVec3f getPointOnBox(SLVec3f boxScale)
Function which return a position on a box.
SLVec3f getPointInBox(SLVec3f boxScale)
Function which return a position in a box.
SLVec3f getPointOnPyramid()
Function which return a position on the pyramid that defines the PS.

◆ generateBernsteinPAlpha()

void SLParticleSystem::generateBernsteinPAlpha ( )

Generate Bernstein Polynomial with 4 controls points for alpha over life. ContP contains 2 and 3 controls points StatEnd contains 1 and 4 controls points

Definition at line 530 of file SLParticleSystem.cpp.

531 {
532  float* ContP = _bezierControlPointAlpha;
533  float* StaEnd = _bezierStartEndPointAlpha;
534  // For Y bezier curve
535  // T^3
536  _bernsteinPYAlpha.x = -StaEnd[1] + ContP[1] * 3 - ContP[3] * 3 + StaEnd[3];
537  // T^2
538  _bernsteinPYAlpha.y = StaEnd[1] * 3 - ContP[1] * 6 + ContP[3] * 3;
539  // T
540  _bernsteinPYAlpha.z = -StaEnd[1] * 3 + ContP[1] * 3;
541  // 1
542  _bernsteinPYAlpha.w = StaEnd[1];
543 }

◆ generateBernsteinPSize()

void SLParticleSystem::generateBernsteinPSize ( )

Generate Bernstein Polynomial with 4 controls points for size over life. ContP contains 2 and 3 controls points StatEnd contains 1 and 4 controls points

Definition at line 550 of file SLParticleSystem.cpp.

551 {
552  // For Y bezier curve
553  // T^3
554  float* ContP = _bezierControlPointSize;
555  float* StaEnd = _bezierStartEndPointSize;
556  _bernsteinPYSize.x = -StaEnd[1] + ContP[1] * 3 - ContP[3] * 3 + StaEnd[3];
557  // T^2
558  _bernsteinPYSize.y = StaEnd[1] * 3 - ContP[1] * 6 + ContP[3] * 3;
559  // T
560  _bernsteinPYSize.z = -StaEnd[1] * 3 + ContP[1] * 3;
561  // 1
562  _bernsteinPYSize.w = StaEnd[1];
563 }

◆ getDirectionBox()

SLVec3f SLParticleSystem::getDirectionBox ( SLVec3f  position)
private

Function which return the direction towards the exterior of a box.

Definition at line 165 of file SLParticleSystem.cpp.

166 {
167  // return a unit vector from center to position
168  return (position - SLVec3f(0.0f, 0.0f, 0.0f)).normalized();
169 }

◆ getDirectionCone()

SLVec3f SLParticleSystem::getDirectionCone ( SLVec3f  position)
private

Function which return a direction following the cone shape.

Definition at line 210 of file SLParticleSystem.cpp.

211 {
212  float maxRadius = _shapeRadius + tan(_shapeAngle * DEG2RAD) * _shapeHeight;
213 
214  // Calculate at which percent our x is, to know how much we need to adapt our angle
215  float percentX = position.x / maxRadius;
216  // Calculate at which percent our z is, to know how much we need to adapt our angle
217  float percentZ = position.z / maxRadius;
218  float newX = position.x + tan(_shapeAngle * percentX * DEG2RAD) * _shapeHeight;
219  float newZ = position.z + tan(_shapeAngle * percentZ * DEG2RAD) * _shapeHeight;
220  return SLVec3f(newX, _shapeHeight, newZ).normalize();
221 }
SLVec3 & normalize()
Definition: SLVec3.h:124

◆ getDirectionPyramid()

SLVec3f SLParticleSystem::getDirectionPyramid ( SLVec3f  position)
private

Function which return a direction following the pyramid shape.

Definition at line 278 of file SLParticleSystem.cpp.

279 {
280  float maxRadius = _shapeWidth +
282 
283  // Calculate at which percent our x & z is to know how much we need to adapt our angle
284  float percentX = position.x / maxRadius;
285  float percentZ = position.z / maxRadius;
286  float newX = position.x + tan(_shapeAngle * percentX * DEG2RAD) * _shapeHeight;
287  float newZ = position.z + tan(_shapeAngle * percentZ * DEG2RAD) * _shapeHeight;
288  return SLVec3f(newX, _shapeHeight, newZ).normalize();
289 }

◆ getDirectionSphere()

SLVec3f SLParticleSystem::getDirectionSphere ( SLVec3f  position)
private

Function which return the direction towards the exterior of a sphere.

Definition at line 101 of file SLParticleSystem.cpp.

102 {
103  // return a unit vector from center to position
104  return (position - SLVec3f(0.0f, 0.0f, 0.0f)).normalized();
105 }

◆ getPointInBox()

SLVec3f SLParticleSystem::getPointInBox ( SLVec3f  boxScale)
private

Function which return a position in a box.

Definition at line 108 of file SLParticleSystem.cpp.

109 {
110  float x = Utils::random(-boxScale.x, boxScale.x);
111  float y = Utils::random(-boxScale.y, boxScale.y);
112  float z = Utils::random(-boxScale.z, boxScale.z);
113 
114  return SLVec3f(x, y, z);
115 }

◆ getPointInCone()

SLVec3f SLParticleSystem::getPointInCone ( )
private

Function which return a position in the cone define in the particle system.

Definition at line 172 of file SLParticleSystem.cpp.

173 {
174  float y = 0.0f;
175  float radius = _shapeRadius;
176  if (!_doShapeSpawnBase) // Spawn inside volume
177  {
178  // NEED TO HAVE MORE value near 1 when we have smaller base that top
179  y = Utils::random(0.0f, _shapeHeight);
180  radius = _shapeRadius + tan(_shapeAngle * DEG2RAD) * y;
181  }
182  float r = radius * sqrt(random(0.0f, 1.0f));
183  float theta = Utils::random(0.0f, 1.0f) * 2 * PI;
184  float x = r * cos(theta);
185  float z = r * sin(theta);
186 
187  return SLVec3f(x, y, z);
188 }
static const float PI
Definition: Utils.h:237

◆ getPointInPyramid()

SLVec3f SLParticleSystem::getPointInPyramid ( )
private

Function which returns a position in the pyramid that define the PS.

Definition at line 224 of file SLParticleSystem.cpp.

225 {
226  float y = 0.0f;
227  float radius = _shapeWidth;
228  if (!_doShapeSpawnBase) // Spawn inside volume
229  {
230  y = Utils::random(0.0f, _shapeHeight);
231  radius = _shapeWidth + tan(_shapeAngle * DEG2RAD) * y;
232  }
233  float x = Utils::random(-radius, radius);
234  float z = Utils::random(-radius, radius);
235 
236  return SLVec3f(x, y, z);
237 }

◆ getPointInSphere()

SLVec3f SLParticleSystem::getPointInSphere ( float  radius,
SLVec3f  randomX 
)
private

Function which return a position in a sphere.

Definition at line 66 of file SLParticleSystem.cpp.

67 {
68  float u = Utils::random(0.0f, radius);
69  float x1 = randomXs.x;
70  float x2 = randomXs.y;
71  float x3 = randomXs.z;
72 
73  float mag = sqrt(x1 * x1 + x2 * x2 + x3 * x3);
74  x1 /= mag;
75  x2 /= mag;
76  x3 /= mag;
77 
78  float c = cbrt(u);
79 
80  return SLVec3f(x1 * c, x2 * c, x3 * c);
81 }

◆ getPointOnBox()

SLVec3f SLParticleSystem::getPointOnBox ( SLVec3f  boxScale)
private

Function which return a position on a box.

Definition at line 118 of file SLParticleSystem.cpp.

119 {
120  int temp = Utils::random(0, 5);
121  float x = 0.0f;
122  float y = 0.0f;
123  float z = 0.0f;
124  if (temp == 0)
125  { // LEFT side
126  x = -boxScale.x;
127  y = Utils::random(-boxScale.y, boxScale.y);
128  z = Utils::random(-boxScale.z, boxScale.z);
129  }
130  else if (temp == 1) // RIGHT side
131  {
132  x = boxScale.x;
133  y = Utils::random(-boxScale.y, boxScale.y);
134  z = Utils::random(-boxScale.z, boxScale.z);
135  }
136  else if (temp == 2) // FRONT side
137  {
138  x = Utils::random(-boxScale.x, boxScale.x);
139  y = Utils::random(-boxScale.y, boxScale.y);
140  z = boxScale.z;
141  }
142  else if (temp == 3) // BACK side
143  {
144  x = Utils::random(-boxScale.x, boxScale.x);
145  y = Utils::random(-boxScale.y, boxScale.y);
146  z = -boxScale.z;
147  }
148  else if (temp == 4) // TOP side
149  {
150  x = Utils::random(-boxScale.x, boxScale.x);
151  y = boxScale.y;
152  z = Utils::random(-boxScale.z, boxScale.z);
153  }
154  else if (temp == 5) // BOTTOM side
155  {
156  x = Utils::random(-boxScale.x, boxScale.x);
157  y = -boxScale.y;
158  z = Utils::random(-boxScale.z, boxScale.z);
159  }
160 
161  return SLVec3f(x, y, z);
162 }

◆ getPointOnCone()

SLVec3f SLParticleSystem::getPointOnCone ( )
private

Function which return a position on the cone define in the particle system.

Definition at line 191 of file SLParticleSystem.cpp.

192 {
193  float y = 0.0f;
194  float radius = _shapeRadius;
195  if (!_doShapeSpawnBase) // Spawn inside volume
196  {
197  // NEED TO HAVE MORE value near 1 when we have smaller base that top
198  y = Utils::random(0.0f, _shapeHeight);
199  radius = _shapeRadius + tan(_shapeAngle * DEG2RAD) * y;
200  }
201  float r = radius;
202  float theta = Utils::random(0.0f, 1.0f) * 2 * PI;
203  float x = r * cos(theta);
204  float z = r * sin(theta);
205 
206  return SLVec3f(x, y, z);
207 }

◆ getPointOnPyramid()

SLVec3f SLParticleSystem::getPointOnPyramid ( )
private

Function which return a position on the pyramid that defines the PS.

Definition at line 240 of file SLParticleSystem.cpp.

241 {
242  float y = 0.0f;
243  float radius = _shapeWidth;
244  if (!_doShapeSpawnBase) // Spawn inside volume
245  {
246  y = Utils::random(0.0f, _shapeHeight);
247  radius = _shapeWidth + tan(_shapeAngle * DEG2RAD) * y;
248  }
249 
250  int temp = Utils::random(0, 3);
251  float x = 0.0f, z = 0.0f;
252 
253  if (temp == 0) // LEFT
254  {
255  x = -radius;
256  z = Utils::random(-radius, radius);
257  }
258  else if (temp == 1) // RIGHT
259  {
260  x = radius;
261  z = Utils::random(-radius, radius);
262  }
263  else if (temp == 2) // FRONT
264  {
265  x = Utils::random(-radius, radius);
266  z = radius;
267  }
268  else if (temp == 3) // BACK
269  {
270  x = Utils::random(-radius, radius);
271  z = -radius;
272  }
273 
274  return SLVec3f(x, y, z);
275 }

◆ getPointOnSphere()

SLVec3f SLParticleSystem::getPointOnSphere ( float  radius,
SLVec3f  randomX 
)
private

Function which return a position on a sphere.

Definition at line 84 of file SLParticleSystem.cpp.

85 {
86  float x1 = randomXs.x;
87  float x2 = randomXs.y;
88  float x3 = randomXs.z;
89 
90  float mag = sqrt(x1 * x1 + x2 * x2 + x3 * x3);
91  x1 /= mag;
92  x2 /= mag;
93  x3 /= mag;
94 
95  float c = cbrt(radius);
96 
97  return SLVec3f(x1 * c, x2 * c, x3 * c);
98 }

◆ gravity() [1/3]

SLVec3f SLParticleSystem::gravity ( )
inline

Definition at line 106 of file SLParticleSystem.h.

106 { return _gravity; }

◆ gravity() [2/3]

void SLParticleSystem::gravity ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 211 of file SLParticleSystem.h.

212  {
213  _gravity.x = vX;
214  _gravity.y = vY;
215  _gravity.z = vZ;
216  }

◆ gravity() [3/3]

void SLParticleSystem::gravity ( SLVec3f  v)
inline

Definition at line 210 of file SLParticleSystem.h.

210 { _gravity = v; }

◆ isGenerated() [1/2]

SLbool SLParticleSystem::isGenerated ( )
inline

Definition at line 110 of file SLParticleSystem.h.

110 { return _isGenerated; }

◆ isGenerated() [2/2]

void SLParticleSystem::isGenerated ( SLbool  b)
inline

Definition at line 220 of file SLParticleSystem.h.

220 { _isGenerated = b; }

◆ isPaused()

SLbool SLParticleSystem::isPaused ( )
inline

Definition at line 111 of file SLParticleSystem.h.

111 { return _isPaused; }

◆ pauseOrResume()

void SLParticleSystem::pauseOrResume ( )

Function called by the user to pause or resume the particle system. This will freeze the particle system there won't be any updating, only the drawing

Definition at line 582 of file SLParticleSystem.cpp.

583 {
584  if (!_isPaused)
585  {
586  _isPaused = true;
588  }
589  else
590  _isPaused = false;
591 }

◆ radiusH() [1/2]

SLfloat SLParticleSystem::radiusH ( )
inline

Definition at line 113 of file SLParticleSystem.h.

113 { return _radiusH; }

◆ radiusH() [2/2]

void SLParticleSystem::radiusH ( SLfloat  f)
inline

Definition at line 222 of file SLParticleSystem.h.

222 { _radiusH = f; }

◆ radiusW() [1/2]

SLfloat SLParticleSystem::radiusW ( )
inline

Definition at line 112 of file SLParticleSystem.h.

112 { return _radiusW; }

◆ radiusW() [2/2]

void SLParticleSystem::radiusW ( SLfloat  f)
inline

Definition at line 221 of file SLParticleSystem.h.

221 { _radiusW = f; }

◆ scale() [1/2]

SLfloat SLParticleSystem::scale ( )
inline

Definition at line 114 of file SLParticleSystem.h.

114 { return _scale; }

◆ scale() [2/2]

void SLParticleSystem::scale ( SLfloat  f)
inline

Definition at line 223 of file SLParticleSystem.h.

223 { _scale = f; }

◆ setNotVisibleInFrustum()

void SLParticleSystem::setNotVisibleInFrustum ( )

Function called inside SLNode cull3DRec(..) which flags the particle system to be not visible in the view frustum. This is needed to correct later the start time of the PS when it reappears again.

Definition at line 569 of file SLParticleSystem.cpp.

570 {
572  {
573  _isVisibleInFrustum = false;
575  }
576 }

◆ shapeAngle() [1/2]

SLfloat SLParticleSystem::shapeAngle ( )
inline

Definition at line 116 of file SLParticleSystem.h.

116 { return _shapeAngle; }

◆ shapeAngle() [2/2]

void SLParticleSystem::shapeAngle ( SLfloat  f)
inline

Definition at line 232 of file SLParticleSystem.h.

232 { _shapeAngle = f; }

◆ shapeHeight() [1/2]

SLfloat SLParticleSystem::shapeHeight ( )
inline

Definition at line 117 of file SLParticleSystem.h.

117 { return _shapeHeight; }

◆ shapeHeight() [2/2]

void SLParticleSystem::shapeHeight ( SLfloat  f)
inline

Definition at line 241 of file SLParticleSystem.h.

241 { _shapeHeight = f; }

◆ shapeRadius() [1/2]

SLfloat SLParticleSystem::shapeRadius ( )
inline

Definition at line 118 of file SLParticleSystem.h.

118 { return _shapeRadius; }

◆ shapeRadius() [2/2]

void SLParticleSystem::shapeRadius ( SLfloat  r)
inline

Definition at line 233 of file SLParticleSystem.h.

233 { _shapeRadius = r; }

◆ shapeScale() [1/3]

SLVec3f SLParticleSystem::shapeScale ( )
inline

Definition at line 119 of file SLParticleSystem.h.

119 { return _shapeScale; }

◆ shapeScale() [2/3]

void SLParticleSystem::shapeScale ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 235 of file SLParticleSystem.h.

236  {
237  _shapeScale.x = vX;
238  _shapeScale.y = vY;
239  _shapeScale.z = vZ;
240  }

◆ shapeScale() [3/3]

void SLParticleSystem::shapeScale ( SLVec3f  v)
inline

Definition at line 234 of file SLParticleSystem.h.

234 { _shapeScale = v; }

◆ shapeType() [1/2]

SLShapeType SLParticleSystem::shapeType ( )
inline

Definition at line 115 of file SLParticleSystem.h.

115 { return _shapeType; }

◆ shapeType() [2/2]

void SLParticleSystem::shapeType ( SLShapeType  st)
inline

Definition at line 231 of file SLParticleSystem.h.

231 { _shapeType = st; }

◆ shapeWidth() [1/2]

SLfloat SLParticleSystem::shapeWidth ( )
inline

Definition at line 120 of file SLParticleSystem.h.

120 { return _shapeWidth; }

◆ shapeWidth() [2/2]

void SLParticleSystem::shapeWidth ( SLfloat  f)
inline

Definition at line 242 of file SLParticleSystem.h.

242 { _shapeWidth = f; }

◆ speed() [1/2]

SLfloat SLParticleSystem::speed ( )
inline

Definition at line 121 of file SLParticleSystem.h.

121 { return _speed; }

◆ speed() [2/2]

void SLParticleSystem::speed ( SLfloat  f)
inline

Definition at line 224 of file SLParticleSystem.h.

224 { _speed = f; }

◆ speedRange() [1/3]

SLVec2f SLParticleSystem::speedRange ( )
inline

Definition at line 122 of file SLParticleSystem.h.

122 { return _speedRange; }

◆ speedRange() [2/3]

void SLParticleSystem::speedRange ( SLfloat  vX,
SLfloat  vY 
)
inline

Definition at line 226 of file SLParticleSystem.h.

227  {
228  _speedRange.x = vX;
229  _speedRange.y = vY;
230  }

◆ speedRange() [3/3]

void SLParticleSystem::speedRange ( SLVec2f  v)
inline

Definition at line 225 of file SLParticleSystem.h.

225 { _speedRange = v; }

◆ texFlipbook() [1/2]

SLGLTexture* SLParticleSystem::texFlipbook ( )
inline

Definition at line 124 of file SLParticleSystem.h.

124 { return _texFlipbook; }

◆ texFlipbook() [2/2]

void SLParticleSystem::texFlipbook ( SLGLTexture tf)
inline

Definition at line 245 of file SLParticleSystem.h.

245 { _texFlipbook = tf; }

◆ texGradient() [1/2]

SLTexColorLUT* SLParticleSystem::texGradient ( )
inline

Definition at line 125 of file SLParticleSystem.h.

125 { return _texGradient; }

◆ texGradient() [2/2]

void SLParticleSystem::texGradient ( SLTexColorLUT tg)
inline

Definition at line 246 of file SLParticleSystem.h.

246 { _texGradient = tg; }

◆ texParticle() [1/2]

SLGLTexture* SLParticleSystem::texParticle ( )
inline

Definition at line 123 of file SLParticleSystem.h.

123 { return _texParticle; }

◆ texParticle() [2/2]

void SLParticleSystem::texParticle ( SLGLTexture tp)
inline

Definition at line 244 of file SLParticleSystem.h.

244 { _texParticle = tp; }

◆ timeToLive() [1/2]

SLfloat SLParticleSystem::timeToLive ( )
inline

Definition at line 126 of file SLParticleSystem.h.

126 { return _timeToLive; }

◆ timeToLive() [2/2]

void SLParticleSystem::timeToLive ( SLfloat  f)
inline

Definition at line 243 of file SLParticleSystem.h.

243 { _timeToLive = f; }

◆ updateTime()

AvgFloat& SLParticleSystem::updateTime ( )
inline

Definition at line 127 of file SLParticleSystem.h.

127 { return _updateTime; }

◆ velocityConst() [1/3]

SLVec3f SLParticleSystem::velocityConst ( )
inline

Definition at line 129 of file SLParticleSystem.h.

129 { return _velocityConst; }

◆ velocityConst() [2/3]

void SLParticleSystem::velocityConst ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 249 of file SLParticleSystem.h.

250  {
251  _velocityConst.x = vX;
252  _velocityConst.y = vY;
253  _velocityConst.z = vZ;
254  }

◆ velocityConst() [3/3]

void SLParticleSystem::velocityConst ( SLVec3f  v)
inline

Definition at line 248 of file SLParticleSystem.h.

248 { _velocityConst = v; }

◆ velocityRndMax() [1/3]

SLVec3f SLParticleSystem::velocityRndMax ( )
inline

Definition at line 131 of file SLParticleSystem.h.

131 { return _velocityRndMax; }

◆ velocityRndMax() [2/3]

void SLParticleSystem::velocityRndMax ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 263 of file SLParticleSystem.h.

264  {
265  _velocityRndMax.x = vX;
266  _velocityRndMax.y = vY;
267  _velocityRndMax.z = vZ;
268  }

◆ velocityRndMax() [3/3]

void SLParticleSystem::velocityRndMax ( SLVec3f  v)
inline

Definition at line 262 of file SLParticleSystem.h.

262 { _velocityRndMax = v; }

◆ velocityRndMin() [1/3]

SLVec3f SLParticleSystem::velocityRndMin ( )
inline

Definition at line 130 of file SLParticleSystem.h.

130 { return _velocityRndMin; }

◆ velocityRndMin() [2/3]

void SLParticleSystem::velocityRndMin ( SLfloat  vX,
SLfloat  vY,
SLfloat  vZ 
)
inline

Definition at line 256 of file SLParticleSystem.h.

257  {
258  _velocityRndMin.x = vX;
259  _velocityRndMin.y = vY;
260  _velocityRndMin.z = vZ;
261  }

◆ velocityRndMin() [3/3]

void SLParticleSystem::velocityRndMin ( SLVec3f  v)
inline

Definition at line 255 of file SLParticleSystem.h.

255 { _velocityRndMin = v; }

◆ velocityType() [1/2]

SLint SLParticleSystem::velocityType ( )
inline

Definition at line 128 of file SLParticleSystem.h.

128 { return _velocityType; }

◆ velocityType() [2/2]

void SLParticleSystem::velocityType ( SLint  i)
inline

Definition at line 247 of file SLParticleSystem.h.

247 { _velocityType = i; }

Member Data Documentation

◆ _acceleration

SLVec3f SLParticleSystem::_acceleration = SLVec3f(1, 1, 1)
private

Vector for acceleration (different direction as the velocity)

Definition at line 305 of file SLParticleSystem.h.

◆ _accelerationConst

SLfloat SLParticleSystem::_accelerationConst = 0.0f
private

Acceleration constant (same direction as the velocity)

Definition at line 306 of file SLParticleSystem.h.

◆ _amount

SLint SLParticleSystem::_amount
private

Amount of a particle.

Definition at line 289 of file SLParticleSystem.h.

◆ _angularVelocityConst

SLfloat SLParticleSystem::_angularVelocityConst = 30.0f
private

Rotation rate const (change in angular rotation divide by change in time)

Definition at line 353 of file SLParticleSystem.h.

◆ _angularVelocityRange

SLVec2f SLParticleSystem::_angularVelocityRange = SLVec2f(-30.0f, 30.0f)
private

Rotation rate range (change in angular rotation divide by change in time)

Definition at line 354 of file SLParticleSystem.h.

◆ _assetManager

SLAssetManager* SLParticleSystem::_assetManager
private

pointer to the asset manager (the owner) if available

Definition at line 286 of file SLParticleSystem.h.

◆ _bernsteinPYAlpha

SLVec4f SLParticleSystem::_bernsteinPYAlpha = SLVec4f(2.0f, -3.0f, 0.0f, 1.0f)
private

Vector for bezier curve (default linear function)

Definition at line 297 of file SLParticleSystem.h.

◆ _bernsteinPYSize

SLVec4f SLParticleSystem::_bernsteinPYSize = SLVec4f(-1.4f, 1.8f, 0.6f, 0.0f)
private

Vector for bezier curve (default linear function)

Definition at line 300 of file SLParticleSystem.h.

◆ _bezierControlPointAlpha

float SLParticleSystem::_bezierControlPointAlpha[4] = {0.0f, 1.0f, 1.0f, 0.0f}
private

Floats for bezier curve control points (P1: 01 ; P2: 23)

Definition at line 298 of file SLParticleSystem.h.

◆ _bezierControlPointSize

float SLParticleSystem::_bezierControlPointSize[4] = {0.0f, 0.0f, 1.0f, 1.0f}
private

Floats for bezier curve control points (P1: 01 ; P2: 23)

Definition at line 301 of file SLParticleSystem.h.

◆ _bezierStartEndPointAlpha

float SLParticleSystem::_bezierStartEndPointAlpha[4] = {0.0f, 1.0f, 1.0f, 0.0f}
private

Floats for bezier curve end start points (Start: 01 ; End: 23)

Definition at line 299 of file SLParticleSystem.h.

◆ _bezierStartEndPointSize

float SLParticleSystem::_bezierStartEndPointSize[4] = {0.0f, 0.0f, 1.0f, 1.0f}
private

Floats for bezier curve end start points (Start: 01 ; End: 23)

Definition at line 302 of file SLParticleSystem.h.

◆ _billboardType

SLBillboardType SLParticleSystem::_billboardType = BT_Camera
private

Billboard type (BT_Camera, BT_Vertical, BT_Horizontal.

Definition at line 357 of file SLParticleSystem.h.

◆ _color

SLCol4f SLParticleSystem::_color = SLCol4f(0.66f, 0.0f, 0.66f, 0.2f)
private

Color for particle.

Definition at line 320 of file SLParticleSystem.h.

◆ _deltaTimeUpdateS

SLfloat SLParticleSystem::_deltaTimeUpdateS = 0.0f
private

Delta time in between two frames S.

Definition at line 337 of file SLParticleSystem.h.

◆ _direction

SLVec3f SLParticleSystem::_direction = SLVec3f(0, 0, 0)
private

Direction of particle.

Definition at line 315 of file SLParticleSystem.h.

◆ _doAccDiffDir

SLbool SLParticleSystem::_doAccDiffDir = false
private

Boolean for acceleration (different direction)

Definition at line 383 of file SLParticleSystem.h.

◆ _doAcceleration

SLbool SLParticleSystem::_doAcceleration = false
private

Boolean for acceleration.

Definition at line 382 of file SLParticleSystem.h.

◆ _doAlphaOverLT

SLbool SLParticleSystem::_doAlphaOverLT = true
private

Boolean for alpha over life time.

Definition at line 393 of file SLParticleSystem.h.

◆ _doAlphaOverLTCurve

SLbool SLParticleSystem::_doAlphaOverLTCurve = false
private

Boolean for alpha over life time curve.

Definition at line 395 of file SLParticleSystem.h.

◆ _doBlendBrightness

SLbool SLParticleSystem::_doBlendBrightness = false
private

Boolean for glow/brightness on pixel with many particle.

Definition at line 378 of file SLParticleSystem.h.

◆ _doColor

SLbool SLParticleSystem::_doColor = true
private

Boolean for color.

Definition at line 386 of file SLParticleSystem.h.

◆ _doColorOverLT

SLbool SLParticleSystem::_doColorOverLT = false
private

Boolean for color over life time.

Definition at line 394 of file SLParticleSystem.h.

◆ _doCounterGap

SLbool SLParticleSystem::_doCounterGap = true
private

Boolean for counter lag/gap, can create flickering with few particle (explained in documentation) when enable.

Definition at line 381 of file SLParticleSystem.h.

◆ _doDirectionSpeed

SLbool SLParticleSystem::_doDirectionSpeed = false
private

Boolean for direction and speed (override velocity)

Definition at line 379 of file SLParticleSystem.h.

◆ _doFlipBookTexture

SLbool SLParticleSystem::_doFlipBookTexture = false
private

Boolean for flipbook texture.

Definition at line 398 of file SLParticleSystem.h.

◆ _doGravity

SLbool SLParticleSystem::_doGravity = false
private

Boolean for gravity.

Definition at line 392 of file SLParticleSystem.h.

◆ _doInstancedDrawing

SLbool SLParticleSystem::_doInstancedDrawing = false
private

Boolean for instanced rendering.

Definition at line 399 of file SLParticleSystem.h.

◆ _doRotation

SLbool SLParticleSystem::_doRotation = true
private

Boolean for rotation.

Definition at line 384 of file SLParticleSystem.h.

◆ _doRotRange

SLbool SLParticleSystem::_doRotRange = false
private

Boolean for rotation range (random value between range)

Definition at line 385 of file SLParticleSystem.h.

◆ _doShape

SLbool SLParticleSystem::_doShape = false
private

Boolean for shape feature.

Definition at line 387 of file SLParticleSystem.h.

◆ _doShapeOverride

SLbool SLParticleSystem::_doShapeOverride = false
private

Boolean for override direction for shape direction.

Definition at line 389 of file SLParticleSystem.h.

◆ _doShapeSpawnBase

SLbool SLParticleSystem::_doShapeSpawnBase = false
private

Boolean for spawn at base of shape (for cone and pyramid)

Definition at line 390 of file SLParticleSystem.h.

◆ _doShapeSurface

SLbool SLParticleSystem::_doShapeSurface = false
private

Boolean for shape surface (particle will be spawned on surface)

Definition at line 388 of file SLParticleSystem.h.

◆ _doSizeOverLT

SLbool SLParticleSystem::_doSizeOverLT = true
private

Boolean for size over life time.

Definition at line 396 of file SLParticleSystem.h.

◆ _doSizeOverLTCurve

SLbool SLParticleSystem::_doSizeOverLTCurve = false
private

Boolean for size over life time curve.

Definition at line 397 of file SLParticleSystem.h.

◆ _doSpeedRange

SLbool SLParticleSystem::_doSpeedRange = false
private

Boolean for speed range.

Definition at line 380 of file SLParticleSystem.h.

◆ _doWorldSpace

SLbool SLParticleSystem::_doWorldSpace = false
private

Boolean for world space position.

Definition at line 391 of file SLParticleSystem.h.

◆ _drawBuf

int SLParticleSystem::_drawBuf = 0
private

Boolean to switch buffer.

Definition at line 323 of file SLParticleSystem.h.

◆ _drawTime

AvgFloat SLParticleSystem::_drawTime
private

Averaged time for drawing in MS.

Definition at line 333 of file SLParticleSystem.h.

◆ _emitterPos

SLVec3f SLParticleSystem::_emitterPos
private

Position of the particle emitter.

Definition at line 290 of file SLParticleSystem.h.

◆ _flipbookColumns

SLint SLParticleSystem::_flipbookColumns = 8
private

Number of flipbook sub-textures by column.

Definition at line 328 of file SLParticleSystem.h.

◆ _flipbookFPS

int SLParticleSystem::_flipbookFPS = 16
private

Number of update of flipbook by second.

Definition at line 326 of file SLParticleSystem.h.

◆ _flipbookRows

SLint SLParticleSystem::_flipbookRows = 8
private

Number of flipbook sub-textures by row.

Definition at line 329 of file SLParticleSystem.h.

◆ _flipboookLastUpdate

float SLParticleSystem::_flipboookLastUpdate = 0.0f
private

Last time flipbook was updated.

Definition at line 327 of file SLParticleSystem.h.

◆ _gravity

SLVec3f SLParticleSystem::_gravity = SLVec3f(0.0f, -9.81f, 0.0f)
private

Vector for gravity (2nd. acceleration vector)

Definition at line 307 of file SLParticleSystem.h.

◆ _instanceVao1

SLGLVertexArray SLParticleSystem::_instanceVao1
private
  1. VAO for instanced rendering with vao1

Definition at line 369 of file SLParticleSystem.h.

◆ _instanceVao2

SLGLVertexArray SLParticleSystem::_instanceVao2
private
  1. VAO for instanced rendering with vao2

Definition at line 370 of file SLParticleSystem.h.

◆ _isGenerated

SLbool SLParticleSystem::_isGenerated = false
private

Boolean to generate particle system and load it on the GPU.

Definition at line 375 of file SLParticleSystem.h.

◆ _isPaused

SLbool SLParticleSystem::_isPaused = false
private

Boolean to stop updating.

Definition at line 374 of file SLParticleSystem.h.

◆ _isVisibleInFrustum

SLbool SLParticleSystem::_isVisibleInFrustum = true
private

Boolean to set time since node not visible.

Definition at line 373 of file SLParticleSystem.h.

◆ _lastTimeBeforePauseS

SLfloat SLParticleSystem::_lastTimeBeforePauseS = 0.0f
private

Time since the particle system is paused.

Definition at line 343 of file SLParticleSystem.h.

◆ _notVisibleTimeS

SLfloat SLParticleSystem::_notVisibleTimeS = 0.0f
private

Time since start when node not visible in S.

Definition at line 340 of file SLParticleSystem.h.

◆ _radiusH

SLfloat SLParticleSystem::_radiusH = 0.4f
private

height radius of a particle

Definition at line 293 of file SLParticleSystem.h.

◆ _radiusW

SLfloat SLParticleSystem::_radiusW = 0.4f
private

width radius of a particle

Definition at line 292 of file SLParticleSystem.h.

◆ _scale

SLfloat SLParticleSystem::_scale = 1.0f
private

Scale of a particle (Scale the radius)

Definition at line 294 of file SLParticleSystem.h.

◆ _shapeAngle

SLfloat SLParticleSystem::_shapeAngle = 10.0f
private

Angle of cone and pyramid shapes.

Definition at line 349 of file SLParticleSystem.h.

◆ _shapeHeight

SLfloat SLParticleSystem::_shapeHeight = 3.0f
private

Height of cone and pyramid shapes.

Definition at line 348 of file SLParticleSystem.h.

◆ _shapeRadius

SLfloat SLParticleSystem::_shapeRadius = 1.0f
private

Radius of sphere and cone shape.

Definition at line 346 of file SLParticleSystem.h.

◆ _shapeScale

SLVec3f SLParticleSystem::_shapeScale = SLVec3f(1.0f)
private

Scale of box shape.

Definition at line 347 of file SLParticleSystem.h.

◆ _shapeType

SLShapeType SLParticleSystem::_shapeType = ST_Sphere
private

Shape type (ST_)

Definition at line 358 of file SLParticleSystem.h.

◆ _shapeWidth

SLfloat SLParticleSystem::_shapeWidth = 2.0f
private

Width of pyramid shape.

Definition at line 350 of file SLParticleSystem.h.

◆ _speed

SLfloat SLParticleSystem::_speed = 1.0f
private

Speed of particle.

Definition at line 316 of file SLParticleSystem.h.

◆ _speedRange

SLVec2f SLParticleSystem::_speedRange = SLVec2f(1, 2)
private

Speed random between two value.

Definition at line 317 of file SLParticleSystem.h.

◆ _startDrawTimeMS

SLfloat SLParticleSystem::_startDrawTimeMS = 0.0f
private

Time since start of draw in MS.

Definition at line 334 of file SLParticleSystem.h.

◆ _startUpdateTimeMS

SLfloat SLParticleSystem::_startUpdateTimeMS = 0.0f
private

Time since start for updating in MS.

Definition at line 335 of file SLParticleSystem.h.

◆ _startUpdateTimeS

SLfloat SLParticleSystem::_startUpdateTimeS = 0.0f
private

Time since start for updating in S.

Definition at line 336 of file SLParticleSystem.h.

◆ _texFlipbook

SLGLTexture* SLParticleSystem::_texFlipbook
private

Flipbook texture with e.g. multiple flames at subsequent frames.

Definition at line 363 of file SLParticleSystem.h.

◆ _texGradient

SLTexColorLUT* SLParticleSystem::_texGradient
private

Color gradient texture.

Definition at line 364 of file SLParticleSystem.h.

◆ _texParticle

SLGLTexture* SLParticleSystem::_texParticle
private

Main texture of PS (non flipbook)

Definition at line 362 of file SLParticleSystem.h.

◆ _timeToLive

SLfloat SLParticleSystem::_timeToLive
private

Time to live of a particle.

Definition at line 291 of file SLParticleSystem.h.

◆ _updateTime

AvgFloat SLParticleSystem::_updateTime
private

Averaged time for updating in MS.

Definition at line 332 of file SLParticleSystem.h.

◆ _vao1

SLGLVertexArray SLParticleSystem::_vao1
private
  1. VAO for swapping between updating/drawing

Definition at line 367 of file SLParticleSystem.h.

◆ _vao2

SLGLVertexArray SLParticleSystem::_vao2
private
  1. VAO for swapping between updating/drawing

Definition at line 368 of file SLParticleSystem.h.

◆ _velocityConst

SLVec3f SLParticleSystem::_velocityConst = SLVec3f(0, 1, 0)
private

Velocity constant (go in xyz direction)

Definition at line 310 of file SLParticleSystem.h.

◆ _velocityRndMax

SLVec3f SLParticleSystem::_velocityRndMax = SLVec3f(1, 1, 1)
private

Max. random velocity.

Definition at line 312 of file SLParticleSystem.h.

◆ _velocityRndMin

SLVec3f SLParticleSystem::_velocityRndMin = SLVec3f(-1, -1, -1)
private

Min. random velocity.

Definition at line 311 of file SLParticleSystem.h.

◆ _velocityType

SLint SLParticleSystem::_velocityType = 0
private

Velocity type.

Definition at line 359 of file SLParticleSystem.h.


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