![]() |
SLProject 4.0.000
|
SLParticleSystem creates a particle meshes from a point primitive buffer. More...
#include <SLParticleSystem.h>
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 return a position in the pyramid define in the particle system. More... | |
SLVec3f | getPointOnPyramid () |
Function which return a position on the pyramid define in the particle system. More... | |
SLVec3f | getDirectionPyramid (SLVec3f position) |
Function which return a direction following the pyramid shape. More... | |
Private Attributes | |
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... | |
SLfloat | _colorArr [256 *3] |
Color values of color gradient widget. More... | |
SLVColorLUTPoint | _colorPoints |
int | _drawBuf = 0 |
Color gradient points. 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 * | _textureFirst |
Main texture of PS (non flipbook) More... | |
SLGLTexture * | _textureFlipbook |
Flipbook texture with e.g. multiple flames at subsequent frames. More... | |
SLGLVertexArray | _vao1 |
First OpenGL Vertex Array Object for swapping between updating/drawing. More... | |
SLGLVertexArray | _vao2 |
Second OpenGL Vertex Array Object for swapping between updating/drawing. More... | |
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... | |
Additional Inherited Members | |
![]() | |
static void | calcTex3DMatrix (SLNode *node) |
![]() | |
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... | |
![]() | |
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 id accel.struct needs update. More... | |
SLAnimSkeleton * | _skeleton |
The skeleton this mesh is bound to. More... | |
SLVMat4f | _jointMatrices |
Joint matrix vector for this mesh. More... | |
SLVVec3f * | _finalP |
Pointer to final vertex position vector. More... | |
SLVVec3f * | _finalN |
pointer to final vertex normal vector More... | |
![]() | |
SLstring | _name |
name of an object More... | |
SLstring | _url |
uniform resource locator More... | |
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 OpenGL ES >= 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.
. 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.
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 |
||
) |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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 wll for the moments 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.
void SLParticleSystem::changeTexture | ( | ) |
Change the current use texture, this will switch between the normal texture and the flipbook texture (and vice versa)
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
deleteData deletes all mesh data and VAOs
Reimplemented from SLMesh.
|
virtual |
deleteData deletes all mesh data and VAOs
Reimplemented from SLMesh.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
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.
Reimplemented from SLMesh.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void SLParticleSystem::generate | ( | ) |
Function which will generate the particles and attributes them to the VAO.
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
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
Function which return the direction towards the exterior of a box.
Function which return a direction following the cone shape.
Function which return a direction following the pyramid shape.
Function which return the direction towards the exterior of a sphere.
Function which return a position in a box.
|
private |
Function which return a position in the cone define in the particle system.
|
private |
Function which return a position in the pyramid define in the particle system.
Function which return a position in a sphere.
Function which return a position on a box.
|
private |
Function which return a position on the cone define in the particle system.
|
private |
Function which return a position on the pyramid define in the particle system.
Function which return a position on a sphere.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Vector for acceleration (different direction as the velocity)
|
private |
Acceleration constant (same direction as the velocity)
|
private |
Amount of a particle.
|
private |
Rotation rate const (change in angular rotation divide by change in time)
Rotation rate range (change in angular rotation divide by change in time)
Vector for bezier curve (default linear function)
Vector for bezier curve (default linear function)
|
private |
Floats for bezier curve control points (P1: 01 ; P2: 23)
|
private |
Floats for bezier curve control points (P1: 01 ; P2: 23)
|
private |
Floats for bezier curve end start points (Start: 01 ; End: 23)
|
private |
Floats for bezier curve end start points (Start: 01 ; End: 23)
|
private |
Billboard type (BT_Camera, BT_Vertical, BT_Horizontal.
|
private |
Color values of color gradient widget.
|
private |
|
private |
Delta time in between two frames S.
|
private |
Boolean for acceleration (different direction)
|
private |
Boolean for acceleration.
|
private |
Boolean for alpha over life time.
|
private |
Boolean for alpha over life time curve.
|
private |
Boolean for glow/brightness on pixel with many particle.
|
private |
Boolean for color.
|
private |
Boolean for color over life time.
|
private |
Boolean for counter lag/gap, can create flickering with few particle (explained in documentation) when enable.
|
private |
Boolean for direction and speed (override velocity)
|
private |
Boolean for flipbook texture.
|
private |
Boolean for gravity.
|
private |
Boolean for rotation.
|
private |
Boolean for rotation range (random value between range)
|
private |
Boolean for shape feature.
|
private |
Boolean for override direction for shape direction.
|
private |
Boolean for spawn at base of shape (for cone and pyramid)
|
private |
Boolean for shape surface (particle will be spawned on surface)
|
private |
Boolean for size over life time.
|
private |
Boolean for size over life time curve.
|
private |
Boolean for speed range.
|
private |
Boolean for world space position.
|
private |
Color gradient points.
Boolean to switch buffer
|
private |
Averaged time for drawing in MS.
|
private |
Position of the particle emitter.
|
private |
Number of flipbook sub-textures by column.
|
private |
Number of update of flipbook by second.
|
private |
Number of flipbook sub-textures by row.
|
private |
Last time flipbook was updated.
Vector for gravity (2nd. acceleration vector)
|
private |
Boolean to generate particle system and load it on the GPU.
|
private |
Boolean to stop updating.
|
private |
Boolean to set time since node not visible.
|
private |
Time since the particle system is paused.
|
private |
Time since start when node not visible in S.
|
private |
height radius of a particle
|
private |
width radius of a particle
|
private |
Scale of a particle (Scale the radius)
|
private |
Angle of cone and pyramid shapes.
|
private |
Height of cone and pyramid shapes.
|
private |
Radius of sphere and cone shape.
|
private |
Shape type (ST_)
|
private |
Width of pyramid shape.
|
private |
Speed of particle.
|
private |
Time since start of draw in MS.
|
private |
Time since start for updating in MS.
|
private |
Time since start for updating in S.
|
private |
Main texture of PS (non flipbook)
|
private |
Flipbook texture with e.g. multiple flames at subsequent frames.
|
private |
Time to live of a particle.
|
private |
Averaged time for updating in MS.
|
private |
First OpenGL Vertex Array Object for swapping between updating/drawing.
|
private |
Second OpenGL Vertex Array Object for swapping between updating/drawing.
Velocity constant (go in xyz direction)
|
private |
Velocity type.