2011-03-19 10:07:16 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2011-07-04 19:20:16 +08:00
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-07-15 12:23:50 +08:00
|
|
|
Copyright (c) 2021 Bytedance Inc.
|
2011-03-19 10:07:16 +08:00
|
|
|
|
2022-01-04 12:36:20 +08:00
|
|
|
https://adxeproject.github.io/
|
2011-03-19 10:07:16 +08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __CCPARTICLE_SYSTEM_H__
|
|
|
|
#define __CCPARTICLE_SYSTEM_H__
|
2010-08-23 14:57:37 +08:00
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "base/CCProtocols.h"
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCNode.h"
|
2014-04-27 01:35:57 +08:00
|
|
|
#include "base/CCValue.h"
|
2022-05-21 22:47:44 +08:00
|
|
|
#include "2d/CCSpriteFrame.h"
|
2022-05-21 22:57:21 +08:00
|
|
|
#include "2d/CCSpriteFrameCache.h"
|
2010-08-25 14:37:40 +08:00
|
|
|
|
2012-03-20 15:04:53 +08:00
|
|
|
NS_CC_BEGIN
|
2010-08-23 14:57:37 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
2015-03-24 10:34:41 +08:00
|
|
|
* @addtogroup _2d
|
2012-06-20 18:09:11 +08:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class ParticleBatchNode;
|
2010-08-23 14:57:37 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** @struct sParticle
|
|
|
|
Structure that contains the values of each particle.
|
2010-12-27 17:39:15 +08:00
|
|
|
*/
|
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
struct particle_point
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
};
|
2012-03-14 14:55:17 +08:00
|
|
|
|
2022-06-03 00:26:02 +08:00
|
|
|
/**
|
|
|
|
* Particle emission shapes.
|
|
|
|
* Current supported shapes are Point, Rectangle, RectangularTorus, Circle, Torus
|
|
|
|
* @since adxe-1.0.0b7
|
|
|
|
*/
|
|
|
|
enum class EmissionShapeType
|
|
|
|
{
|
|
|
|
POINT,
|
|
|
|
RECT,
|
|
|
|
RECTTORUS,
|
|
|
|
CIRCLE,
|
2022-06-12 05:58:01 +08:00
|
|
|
TORUS,
|
|
|
|
ALPHA_MASK
|
|
|
|
};
|
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/**
|
|
|
|
* Particle emission mask descriptor.
|
|
|
|
* @since adxe-1.0.0b7
|
|
|
|
*/
|
2022-06-12 05:58:01 +08:00
|
|
|
struct ParticleEmissionMaskDescriptor
|
|
|
|
{
|
|
|
|
Vec2 size;
|
|
|
|
std::vector<cocos2d::Vec2> points;
|
2022-06-03 00:26:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Particle emission shapes.
|
2022-06-11 23:06:43 +08:00
|
|
|
* Current supported shapes are Point, Rectangle, RectangularTorus, Circle, Torus, Cone, Cone Torus
|
2022-06-03 00:26:02 +08:00
|
|
|
* @since adxe-1.0.0b7
|
|
|
|
*/
|
|
|
|
struct EmissionShape
|
|
|
|
{
|
|
|
|
EmissionShapeType type;
|
|
|
|
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
|
|
|
float innerWidth;
|
|
|
|
float innerHeight;
|
|
|
|
float outerWidth;
|
|
|
|
float outerHeight;
|
|
|
|
|
|
|
|
float innerRadius;
|
|
|
|
float outerRadius;
|
2022-06-11 23:06:43 +08:00
|
|
|
float coneOffset;
|
|
|
|
float coneAngle;
|
2022-06-03 00:26:02 +08:00
|
|
|
float edgeElasticity;
|
2022-06-12 05:58:01 +08:00
|
|
|
|
2022-06-12 07:44:27 +08:00
|
|
|
std::string_view maskName;
|
2022-06-03 00:26:02 +08:00
|
|
|
};
|
|
|
|
|
2022-05-21 22:47:44 +08:00
|
|
|
/** @struct ParticleAnimationDescriptor
|
|
|
|
Structure that contains animation description
|
|
|
|
*/
|
2022-05-21 21:48:46 +08:00
|
|
|
struct ParticleAnimationDescriptor
|
|
|
|
{
|
2022-06-07 00:23:11 +08:00
|
|
|
float animationSpeed;
|
|
|
|
float animationSpeedVariance;
|
2022-05-21 21:48:46 +08:00
|
|
|
std::vector<unsigned short> animationIndices;
|
2022-06-07 00:23:11 +08:00
|
|
|
bool reverseIndices;
|
2022-05-21 21:48:46 +08:00
|
|
|
};
|
|
|
|
|
2022-05-21 22:47:44 +08:00
|
|
|
/** @struct ParticleFrameDescriptor
|
|
|
|
Structure that contains frame description
|
|
|
|
*/
|
2022-05-21 21:48:46 +08:00
|
|
|
struct ParticleFrameDescriptor
|
|
|
|
{
|
|
|
|
cocos2d::Rect rect;
|
2022-06-07 00:23:11 +08:00
|
|
|
bool isRotated;
|
2022-05-21 21:48:46 +08:00
|
|
|
};
|
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
class CC_DLL ParticleData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
float* posx;
|
|
|
|
float* posy;
|
|
|
|
float* startPosX;
|
|
|
|
float* startPosY;
|
|
|
|
|
|
|
|
float* colorR;
|
|
|
|
float* colorG;
|
|
|
|
float* colorB;
|
|
|
|
float* colorA;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
float* deltaColorR;
|
|
|
|
float* deltaColorG;
|
|
|
|
float* deltaColorB;
|
|
|
|
float* deltaColorA;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-26 19:00:33 +08:00
|
|
|
float* hue;
|
|
|
|
float* sat;
|
|
|
|
float* val;
|
|
|
|
|
2022-05-27 00:59:48 +08:00
|
|
|
float* opacityFadeInDelta;
|
|
|
|
float* opacityFadeInLength;
|
|
|
|
|
2022-05-27 03:53:19 +08:00
|
|
|
float* scaleInDelta;
|
|
|
|
float* scaleInLength;
|
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
float* size;
|
|
|
|
float* deltaSize;
|
|
|
|
float* rotation;
|
2022-05-21 21:48:46 +08:00
|
|
|
float* staticRotation;
|
2015-08-31 17:25:34 +08:00
|
|
|
float* deltaRotation;
|
2022-05-20 06:15:39 +08:00
|
|
|
float* totalTimeToLive;
|
2015-08-31 17:25:34 +08:00
|
|
|
float* timeToLive;
|
2022-05-21 21:48:46 +08:00
|
|
|
float* animTimeDelta;
|
|
|
|
float* animTimeLength;
|
|
|
|
unsigned short* animIndex;
|
|
|
|
unsigned short* animCellIndex;
|
2015-08-31 17:25:34 +08:00
|
|
|
unsigned int* atlasIndex;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
//! Mode A: gravity, direction, radial accel, tangential accel
|
2021-12-25 10:04:45 +08:00
|
|
|
struct
|
|
|
|
{
|
2015-08-31 17:25:34 +08:00
|
|
|
float* dirX;
|
|
|
|
float* dirY;
|
|
|
|
float* radialAccel;
|
|
|
|
float* tangentialAccel;
|
2012-04-19 14:35:52 +08:00
|
|
|
} modeA;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
//! Mode B: radius mode
|
2021-12-25 10:04:45 +08:00
|
|
|
struct
|
|
|
|
{
|
2015-08-31 17:25:34 +08:00
|
|
|
float* angle;
|
|
|
|
float* degreesPerSecond;
|
|
|
|
float* radius;
|
|
|
|
float* deltaRadius;
|
2012-04-19 14:35:52 +08:00
|
|
|
} modeB;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
unsigned int maxCount;
|
|
|
|
ParticleData();
|
|
|
|
bool init(int count);
|
|
|
|
void release();
|
2016-09-12 09:44:21 +08:00
|
|
|
unsigned int getMaxCount() { return maxCount; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2016-09-12 09:44:21 +08:00
|
|
|
void copyParticle(int p1, int p2)
|
2015-08-31 17:25:34 +08:00
|
|
|
{
|
2022-05-25 15:46:54 +08:00
|
|
|
posx[p1] = posx[p2];
|
|
|
|
posy[p1] = posy[p2];
|
|
|
|
startPosX[p1] = startPosX[p2];
|
|
|
|
startPosY[p1] = startPosY[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
colorR[p1] = colorR[p2];
|
|
|
|
colorG[p1] = colorG[p2];
|
|
|
|
colorB[p1] = colorB[p2];
|
|
|
|
colorA[p1] = colorA[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-08-31 17:25:34 +08:00
|
|
|
deltaColorR[p1] = deltaColorR[p2];
|
|
|
|
deltaColorG[p1] = deltaColorG[p2];
|
|
|
|
deltaColorB[p1] = deltaColorB[p2];
|
|
|
|
deltaColorA[p1] = deltaColorA[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-26 20:56:56 +08:00
|
|
|
if (hue && sat && val)
|
|
|
|
{
|
|
|
|
hue[p1] = hue[p2];
|
|
|
|
sat[p1] = sat[p2];
|
|
|
|
val[p1] = val[p2];
|
|
|
|
}
|
2022-05-25 15:46:54 +08:00
|
|
|
|
2022-05-27 00:59:48 +08:00
|
|
|
if (opacityFadeInDelta && opacityFadeInLength)
|
|
|
|
{
|
|
|
|
opacityFadeInDelta[p1] = opacityFadeInDelta[p2];
|
|
|
|
opacityFadeInLength[p1] = opacityFadeInLength[p2];
|
|
|
|
}
|
|
|
|
|
2022-05-27 03:53:19 +08:00
|
|
|
if (scaleInDelta && scaleInLength)
|
|
|
|
{
|
|
|
|
scaleInDelta[p1] = scaleInDelta[p2];
|
|
|
|
scaleInLength[p1] = scaleInLength[p2];
|
|
|
|
}
|
|
|
|
|
2022-05-26 19:00:33 +08:00
|
|
|
size[p1] = size[p2];
|
|
|
|
deltaSize[p1] = deltaSize[p2];
|
|
|
|
rotation[p1] = rotation[p2];
|
|
|
|
staticRotation[p1] = staticRotation[p2];
|
|
|
|
deltaRotation[p1] = deltaRotation[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-20 06:15:39 +08:00
|
|
|
totalTimeToLive[p1] = totalTimeToLive[p2];
|
2022-05-26 19:00:33 +08:00
|
|
|
timeToLive[p1] = timeToLive[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-26 20:56:56 +08:00
|
|
|
if (animTimeDelta && animTimeLength && animIndex && animCellIndex)
|
|
|
|
{
|
|
|
|
animTimeDelta[p1] = animTimeDelta[p2];
|
|
|
|
animTimeLength[p1] = animTimeLength[p2];
|
|
|
|
animIndex[p1] = animIndex[p2];
|
|
|
|
animCellIndex[p1] = animCellIndex[p2];
|
|
|
|
}
|
|
|
|
|
2022-06-07 00:23:11 +08:00
|
|
|
atlasIndex[p1] = atlasIndex[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
modeA.dirX[p1] = modeA.dirX[p2];
|
|
|
|
modeA.dirY[p1] = modeA.dirY[p2];
|
|
|
|
modeA.radialAccel[p1] = modeA.radialAccel[p2];
|
2015-08-31 17:25:34 +08:00
|
|
|
modeA.tangentialAccel[p1] = modeA.tangentialAccel[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
modeB.angle[p1] = modeB.angle[p2];
|
2015-08-31 17:25:34 +08:00
|
|
|
modeB.degreesPerSecond[p1] = modeB.degreesPerSecond[p2];
|
2021-12-25 10:04:45 +08:00
|
|
|
modeB.radius[p1] = modeB.radius[p2];
|
|
|
|
modeB.deltaRadius[p1] = modeB.deltaRadius[p2];
|
2015-08-31 17:25:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/**
|
|
|
|
* Particle emission mask cache.
|
|
|
|
* @since adxe-1.0.0b7
|
|
|
|
*/
|
2022-06-12 05:58:01 +08:00
|
|
|
class CC_DLL ParticleEmissionMaskCache : public cocos2d::Ref
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static ParticleEmissionMaskCache* getInstance();
|
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/** Bakes a particle emission mask from texture data on cpu and stores it in memory by it's name.
|
|
|
|
* If the mask already exists then it will be overwritten.
|
|
|
|
*
|
|
|
|
* @param maskName The name that identifies the mask.
|
|
|
|
* @param texturePath Path of the texture that holds alpha data.
|
|
|
|
* @param alphaThreshold The threshold at which pixels are picked, If a pixel's alpha channel is greater than
|
|
|
|
* alphaThreshold then it will be picked.
|
|
|
|
* @param inverted Inverts the pick condition so that If a pixel's alpha channel is lower than alphaThreshold then
|
|
|
|
* it will be picked.
|
|
|
|
*/
|
2022-06-12 05:58:01 +08:00
|
|
|
void bakeEmissionMask(std::string_view maskName,
|
|
|
|
std::string_view texturePath,
|
|
|
|
float alphaThreshold = 0.5F,
|
|
|
|
bool inverted = false);
|
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/** Bakes a particle emission mask from texture data on cpu and stores it in memory by it's name.
|
|
|
|
* If the mask already exists then it will be overwritten.
|
|
|
|
*
|
|
|
|
* @param maskName The name that identifies the mask.
|
|
|
|
* @param imageTexture Image object containing texture data with alpha channel.
|
|
|
|
* @param alphaThreshold The threshold at which pixels are picked, If a pixel's alpha channel is greater than
|
|
|
|
* alphaThreshold then it will be picked.
|
|
|
|
* @param inverted Inverts the pick condition so that If a pixel's alpha channel is lower than alphaThreshold then
|
|
|
|
* it will be picked.
|
|
|
|
*/
|
2022-06-12 05:58:01 +08:00
|
|
|
void bakeEmissionMask(std::string_view maskName,
|
|
|
|
Image* imageTexture,
|
|
|
|
float alphaThreshold = 0.5F,
|
|
|
|
bool inverted = false);
|
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/** Returns a baked mask with the specified name if it exists. otherwise, it will return a dummy mask.
|
|
|
|
*
|
|
|
|
* @param maskName The name that identifies the mask.
|
|
|
|
*/
|
2022-06-12 05:58:01 +08:00
|
|
|
const ParticleEmissionMaskDescriptor& getEmissionMask(std::string_view maskName);
|
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/** Deletes a baked mask and releases the data from memory with the specified name if it exists.
|
|
|
|
*
|
|
|
|
* @param maskName The name that identifies the mask.
|
|
|
|
*/
|
|
|
|
void deleteMask(std::string_view maskName);
|
2022-06-12 05:58:01 +08:00
|
|
|
|
2022-06-12 20:36:25 +08:00
|
|
|
/** Deletes all baked masks and releases their data from memory. */
|
|
|
|
void deleteAllMasks();
|
|
|
|
|
|
|
|
private:
|
2022-06-12 05:58:01 +08:00
|
|
|
hlookup::string_map<ParticleEmissionMaskDescriptor> masks;
|
2022-06-12 20:36:25 +08:00
|
|
|
|
2022-06-12 05:58:01 +08:00
|
|
|
};
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vec2);
|
2010-12-27 17:39:15 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class Texture2D;
|
2010-12-27 17:39:15 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** @class ParticleSystem
|
|
|
|
* @brief Particle System base class.
|
2010-12-27 17:39:15 +08:00
|
|
|
Attributes of a Particle System:
|
2012-09-17 15:02:24 +08:00
|
|
|
- emission rate of the particles
|
2010-12-27 17:39:15 +08:00
|
|
|
- Gravity Mode (Mode A):
|
|
|
|
- gravity
|
|
|
|
- direction
|
|
|
|
- speed +- variance
|
|
|
|
- tangential acceleration +- variance
|
|
|
|
- radial acceleration +- variance
|
|
|
|
- Radius Mode (Mode B):
|
|
|
|
- startRadius +- variance
|
|
|
|
- endRadius +- variance
|
|
|
|
- rotate +- variance
|
|
|
|
- Properties common to all modes:
|
|
|
|
- life +- life variance
|
|
|
|
- start spin +- variance
|
|
|
|
- end spin +- variance
|
|
|
|
- start size +- variance
|
|
|
|
- end size +- variance
|
|
|
|
- start color +- variance
|
|
|
|
- end color +- variance
|
|
|
|
- life +- variance
|
|
|
|
- blending function
|
|
|
|
- texture
|
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
Cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
|
2012-09-17 15:02:24 +08:00
|
|
|
'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d,
|
2021-12-25 10:04:45 +08:00
|
|
|
cocos2d uses a another approach, but the results are almost identical.
|
2010-12-27 17:39:15 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
Cocos2d supports all the variables used by Particle Designer plus a bit more:
|
2013-06-20 14:13:12 +08:00
|
|
|
- spinning particles (supported when using ParticleSystemQuad)
|
2010-12-27 17:39:15 +08:00
|
|
|
- tangential acceleration (Gravity mode)
|
|
|
|
- radial acceleration (Gravity mode)
|
|
|
|
- radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
|
|
|
|
|
|
|
|
It is possible to customize any of the above mentioned properties in runtime. Example:
|
|
|
|
|
|
|
|
@code
|
|
|
|
emitter.radialAccel = 15;
|
|
|
|
emitter.startSpin = 0;
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
*/
|
2016-01-12 17:21:01 +08:00
|
|
|
class CC_DLL ParticleSystem : public Node, public TextureProtocol, public PlayableProtocol
|
2013-07-18 07:56:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Mode
|
2015-03-23 20:27:13 +08:00
|
|
|
* @js cc.ParticleSystem.MODE_GRAVITY;
|
2015-03-21 18:02:56 +08:00
|
|
|
*/
|
2013-07-26 13:48:32 +08:00
|
|
|
enum class Mode
|
2013-07-25 13:54:32 +08:00
|
|
|
{
|
2013-07-26 13:48:32 +08:00
|
|
|
GRAVITY,
|
|
|
|
RADIUS,
|
2013-07-25 13:54:32 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** PositionType
|
2022-05-20 06:15:39 +08:00
|
|
|
Types of particle positioning.
|
2015-03-23 20:27:13 +08:00
|
|
|
* @js cc.ParticleSystem.TYPE_FREE
|
2013-07-25 14:27:46 +08:00
|
|
|
*/
|
2013-07-26 13:48:32 +08:00
|
|
|
enum class PositionType
|
2013-07-25 14:27:46 +08:00
|
|
|
{
|
2015-03-21 18:02:56 +08:00
|
|
|
FREE, /** Living particles are attached to the world and are unaffected by emitter repositioning. */
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
RELATIVE, /** Living particles are attached to the world but will follow the emitter repositioning.
|
|
|
|
Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
GROUPED, /** Living particles are attached to the emitter and are translated along with it. */
|
|
|
|
|
2013-07-25 14:27:46 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-06-07 00:23:11 +08:00
|
|
|
/** TexAnimDir
|
|
|
|
Texture animation direction for the particles.
|
|
|
|
*/
|
2022-05-20 06:15:39 +08:00
|
|
|
enum class TexAnimDir
|
|
|
|
{
|
|
|
|
VERTICAL, /** texture coordinates are read top to bottom within the texture */
|
|
|
|
|
|
|
|
HORIZONTAL, /** texture coordinates are read left to right within the texture */
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-07-25 14:27:46 +08:00
|
|
|
//* @enum
|
2021-12-25 10:04:45 +08:00
|
|
|
enum
|
|
|
|
{
|
2015-03-21 18:02:56 +08:00
|
|
|
/** The Particle emitter lives forever. */
|
2013-07-25 14:27:46 +08:00
|
|
|
DURATION_INFINITY = -1,
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** The starting size of the particle is equal to the ending size. */
|
2013-07-25 14:27:46 +08:00
|
|
|
START_SIZE_EQUAL_TO_END_SIZE = -1,
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** The starting radius of the particle is equal to the ending radius. */
|
2013-07-25 14:27:46 +08:00
|
|
|
START_RADIUS_EQUAL_TO_END_RADIUS = -1,
|
2022-05-24 05:46:38 +08:00
|
|
|
|
|
|
|
/** The simulation's seconds are set to the particles' lifetime specified inclusive of variant. */
|
|
|
|
SIMULATION_USE_PARTICLE_LIFETIME = -1,
|
2022-05-24 14:42:27 +08:00
|
|
|
|
|
|
|
/** The simulation's framerate is set to the animation interval specified in director. */
|
|
|
|
SIMULATION_USE_GAME_ANIMATION_INTERVAL = -1,
|
2013-07-25 14:27:46 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Creates an initializes a ParticleSystem from a plist file.
|
2013-07-18 07:56:19 +08:00
|
|
|
This plist files can be created manually or with Particle Designer:
|
|
|
|
http://particledesigner.71squared.com/
|
2015-03-21 18:02:56 +08:00
|
|
|
@since v2.0
|
|
|
|
*
|
2015-03-27 12:07:19 +08:00
|
|
|
* @param plistFile Particle plist file name.
|
2015-03-21 18:02:56 +08:00
|
|
|
* @return An autoreleased ParticleSystem object.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static ParticleSystem* create(std::string_view plistFile);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Create a system with a fixed number of particles.
|
|
|
|
*
|
|
|
|
* @param numberOfParticles A given number of particles.
|
|
|
|
* @return An autoreleased ParticleSystemQuad object.
|
2015-03-23 20:27:13 +08:00
|
|
|
* @js NA
|
2015-03-21 18:02:56 +08:00
|
|
|
*/
|
2013-11-15 08:21:49 +08:00
|
|
|
static ParticleSystem* createWithTotalParticles(int numberOfParticles);
|
2017-06-05 13:37:50 +08:00
|
|
|
|
|
|
|
/** Gets all ParticleSystem references
|
|
|
|
*/
|
|
|
|
static Vector<ParticleSystem*>& getAllParticleSystems();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-26 20:56:56 +08:00
|
|
|
protected:
|
|
|
|
bool allocAnimationMem();
|
|
|
|
void deallocAnimationMem();
|
|
|
|
bool _isAnimAllocated;
|
|
|
|
|
|
|
|
bool allocHSVMem();
|
|
|
|
void deallocHSVMem();
|
|
|
|
bool _isHSVAllocated;
|
|
|
|
|
2022-05-27 00:59:48 +08:00
|
|
|
bool allocOpacityFadeInMem();
|
|
|
|
void deallocOpacityFadeInMem();
|
|
|
|
bool _isOpacityFadeInAllocated;
|
|
|
|
|
2022-05-27 03:53:19 +08:00
|
|
|
bool allocScaleInMem();
|
|
|
|
void deallocScaleInMem();
|
|
|
|
bool _isScaleInAllocated;
|
|
|
|
|
2017-06-05 13:37:50 +08:00
|
|
|
public:
|
2022-05-26 20:56:56 +08:00
|
|
|
void addParticles(int count, int animationIndex = -1, int animationCellIndex = -1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
void stopSystem();
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Kill all living particles.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
void resetSystem();
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Whether or not the system is full.
|
|
|
|
*
|
|
|
|
* @return True if the system is full.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
bool isFull();
|
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Update the verts position data of particle,
|
2021-12-25 10:04:45 +08:00
|
|
|
should be overridden by subclasses.
|
2015-03-21 18:02:56 +08:00
|
|
|
*/
|
2015-08-31 17:25:34 +08:00
|
|
|
virtual void updateParticleQuads();
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Update the VBO verts buffer which does not use batch node,
|
|
|
|
should be overridden by subclasses. */
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void postStep();
|
|
|
|
|
2015-09-22 16:08:23 +08:00
|
|
|
/** Call the update method with no time..
|
2015-03-21 18:02:56 +08:00
|
|
|
*/
|
2015-03-27 12:07:19 +08:00
|
|
|
virtual void updateWithNoTime();
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Whether or not the particle system removed self on finish.
|
|
|
|
*
|
|
|
|
* @return True if the particle system removed self on finish.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual bool isAutoRemoveOnFinish() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Set the particle system auto removed it self on finish.
|
|
|
|
*
|
|
|
|
* @param var True if the particle system removed self on finish.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setAutoRemoveOnFinish(bool var);
|
|
|
|
|
|
|
|
// mode A
|
2015-09-22 16:08:23 +08:00
|
|
|
/** Gets the gravity.
|
2015-03-21 18:02:56 +08:00
|
|
|
*
|
|
|
|
* @return The gravity.
|
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
virtual const Vec2& getGravity();
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the gravity.
|
|
|
|
*
|
|
|
|
* @param g The gravity.
|
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
virtual void setGravity(const Vec2& g);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the speed.
|
|
|
|
*
|
|
|
|
* @return The speed.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getSpeed() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the speed.
|
|
|
|
*
|
|
|
|
* @param speed The speed.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setSpeed(float speed);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the speed variance.
|
|
|
|
*
|
|
|
|
* @return The speed variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getSpeedVar() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the speed variance.
|
|
|
|
*
|
|
|
|
* @param speed The speed variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setSpeedVar(float speed);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the tangential acceleration.
|
|
|
|
*
|
|
|
|
* @return The tangential acceleration.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getTangentialAccel() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the tangential acceleration.
|
|
|
|
*
|
|
|
|
* @param t The tangential acceleration.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setTangentialAccel(float t);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the tangential acceleration variance.
|
|
|
|
*
|
|
|
|
* @return The tangential acceleration variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getTangentialAccelVar() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the tangential acceleration variance.
|
|
|
|
*
|
|
|
|
* @param t The tangential acceleration variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setTangentialAccelVar(float t);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the radial acceleration.
|
|
|
|
*
|
|
|
|
* @return The radial acceleration.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getRadialAccel() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the radial acceleration.
|
|
|
|
*
|
|
|
|
* @param t The radial acceleration.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setRadialAccel(float t);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the radial acceleration variance.
|
|
|
|
*
|
|
|
|
* @return The radial acceleration variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getRadialAccelVar() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the radial acceleration variance.
|
|
|
|
*
|
|
|
|
* @param t The radial acceleration variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setRadialAccelVar(float t);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Whether or not the rotation of each particle to its direction.
|
|
|
|
*
|
|
|
|
* @return True if the rotation is the direction.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual bool getRotationIsDir() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the rotation of each particle to its direction.
|
|
|
|
*
|
|
|
|
* @param t True if the rotation is the direction.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setRotationIsDir(bool t);
|
|
|
|
// mode B
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start radius.
|
|
|
|
*
|
|
|
|
* @return The start radius.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getStartRadius() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start radius.
|
|
|
|
*
|
|
|
|
* @param startRadius The start radius.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setStartRadius(float startRadius);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start radius variance.
|
|
|
|
*
|
|
|
|
* @return The start radius variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getStartRadiusVar() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start radius variance.
|
|
|
|
*
|
|
|
|
* @param startRadiusVar The start radius variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setStartRadiusVar(float startRadiusVar);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end radius.
|
|
|
|
*
|
|
|
|
* @return The end radius.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getEndRadius() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end radius.
|
|
|
|
*
|
|
|
|
* @param endRadius The end radius.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setEndRadius(float endRadius);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end radius variance.
|
|
|
|
*
|
|
|
|
* @return The end radius variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getEndRadiusVar() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end radius variance.
|
|
|
|
*
|
|
|
|
* @param endRadiusVar The end radius variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setEndRadiusVar(float endRadiusVar);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the number of degrees to rotate a particle around the source pos per second.
|
|
|
|
*
|
|
|
|
* @return The number of degrees to rotate a particle around the source pos per second.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getRotatePerSecond() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the number of degrees to rotate a particle around the source pos per second.
|
|
|
|
*
|
|
|
|
* @param degrees The number of degrees to rotate a particle around the source pos per second.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setRotatePerSecond(float degrees);
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the rotate per second variance.
|
|
|
|
*
|
|
|
|
* @return The rotate per second variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual float getRotatePerSecondVar() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the rotate per second variance.
|
|
|
|
*
|
|
|
|
* @param degrees The rotate per second variance.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setRotatePerSecondVar(float degrees);
|
|
|
|
|
2015-03-15 02:33:15 +08:00
|
|
|
virtual void setScale(float s) override;
|
|
|
|
virtual void setRotation(float newRotation) override;
|
|
|
|
virtual void setScaleX(float newScaleX) override;
|
|
|
|
virtual void setScaleY(float newScaleY) override;
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Whether or not the particle system is active.
|
|
|
|
*
|
|
|
|
* @return True if the particle system is active.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual bool isActive() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Whether or not the particle system is blend additive.
|
|
|
|
*
|
|
|
|
* @return True if the particle system is blend additive.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual bool isBlendAdditive() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the particle system blend additive.
|
|
|
|
*
|
|
|
|
* @param value True if the particle system is blend additive.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setBlendAdditive(bool value);
|
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the batch node.
|
|
|
|
*
|
|
|
|
* @return The batch node.
|
|
|
|
*/
|
2013-07-23 18:26:26 +08:00
|
|
|
virtual ParticleBatchNode* getBatchNode() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the batch node.
|
|
|
|
*
|
|
|
|
* @param batchNode The batch node.
|
|
|
|
*/
|
2013-07-23 18:26:26 +08:00
|
|
|
virtual void setBatchNode(ParticleBatchNode* batchNode);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the index of system in batch node array.
|
|
|
|
*
|
|
|
|
* @return The index of system in batch node array.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
int getAtlasIndex() const { return _atlasIndex; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the index of system in batch node array.
|
|
|
|
*
|
|
|
|
* @param index The index of system in batch node array.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setAtlasIndex(int index) { _atlasIndex = index; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the Quantity of particles that are being simulated at the moment.
|
|
|
|
*
|
|
|
|
* @return The Quantity of particles that are being simulated at the moment.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
unsigned int getParticleCount() const { return _particleCount; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets how many seconds the emitter will run. -1 means 'forever'.
|
|
|
|
*
|
|
|
|
* @return The seconds that the emitter will run. -1 means 'forever'.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getDuration() const { return _duration; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets how many seconds the emitter will run. -1 means 'forever'.
|
|
|
|
*
|
|
|
|
* @param duration The seconds that the emitter will run. -1 means 'forever'.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setDuration(float duration) { _duration = duration; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the source position of the emitter.
|
|
|
|
*
|
|
|
|
* @return The source position of the emitter.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Vec2& getSourcePosition() const { return _sourcePosition; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the source position of the emitter.
|
|
|
|
*
|
2015-03-27 12:07:19 +08:00
|
|
|
* @param pos The source position of the emitter.
|
2015-03-21 18:02:56 +08:00
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setSourcePosition(const Vec2& pos) { _sourcePosition = pos; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the position variance of the emitter.
|
|
|
|
*
|
|
|
|
* @return The position variance of the emitter.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Vec2& getPosVar() const { return _posVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the position variance of the emitter.
|
|
|
|
*
|
|
|
|
* @param pos The position variance of the emitter.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setPosVar(const Vec2& pos) { _posVar = pos; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the life of each particle.
|
|
|
|
*
|
|
|
|
* @return The life of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getLife() const { return _life; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the life of each particle.
|
|
|
|
*
|
|
|
|
* @param life The life of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setLife(float life) { _life = life; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the life variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The life variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getLifeVar() const { return _lifeVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the life variance of each particle.
|
|
|
|
*
|
|
|
|
* @param lifeVar The life variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setLifeVar(float lifeVar) { _lifeVar = lifeVar; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Gets the angle of each particle.
|
2015-03-21 18:02:56 +08:00
|
|
|
*
|
|
|
|
* @return The angle of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getAngle() const { return _angle; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the angle of each particle.
|
|
|
|
*
|
|
|
|
* @param angle The angle of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setAngle(float angle) { _angle = angle; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the angle variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The angle variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getAngleVar() const { return _angleVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the angle variance of each particle.
|
|
|
|
*
|
|
|
|
* @param angleVar The angle variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setAngleVar(float angleVar) { _angleVar = angleVar; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-07-23 18:26:26 +08:00
|
|
|
/** Switch between different kind of emitter modes:
|
2015-03-21 18:02:56 +08:00
|
|
|
- kParticleModeGravity: uses gravity, speed, radial and tangential acceleration.
|
|
|
|
- kParticleModeRadius: uses radius movement + rotation.
|
|
|
|
*
|
|
|
|
* @return The mode of the emitter.
|
2013-07-23 18:26:26 +08:00
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
Mode getEmitterMode() const { return _emitterMode; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the mode of the emitter.
|
|
|
|
*
|
|
|
|
* @param mode The mode of the emitter.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEmitterMode(Mode mode) { _emitterMode = mode; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start size in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @return The start size in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getStartSize() const { return _startSize; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start size in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @param startSize The start size in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setStartSize(float startSize) { _startSize = startSize; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start size variance in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @return The start size variance in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getStartSizeVar() const { return _startSizeVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start size variance in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @param sizeVar The start size variance in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setStartSizeVar(float sizeVar) { _startSizeVar = sizeVar; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end size in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @return The end size in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getEndSize() const { return _endSize; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end size in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @param endSize The end size in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEndSize(float endSize) { _endSize = endSize; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end size variance in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @return The end size variance in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getEndSizeVar() const { return _endSizeVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end size variance in pixels of each particle.
|
|
|
|
*
|
|
|
|
* @param sizeVar The end size variance in pixels of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEndSizeVar(float sizeVar) { _endSizeVar = sizeVar; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start color of each particle.
|
|
|
|
*
|
|
|
|
* @return The start color of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Color4F& getStartColor() const { return _startColor; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start color of each particle.
|
|
|
|
*
|
|
|
|
* @param color The start color of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setStartColor(const Color4F& color) { _startColor = color; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start color variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The start color variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Color4F& getStartColorVar() const { return _startColorVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start color variance of each particle.
|
|
|
|
*
|
|
|
|
* @param color The start color variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setStartColorVar(const Color4F& color) { _startColorVar = color; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end color and end color variation of each particle.
|
|
|
|
*
|
|
|
|
* @return The end color and end color variation of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Color4F& getEndColor() const { return _endColor; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end color and end color variation of each particle.
|
|
|
|
*
|
|
|
|
* @param color The end color and end color variation of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEndColor(const Color4F& color) { _endColor = color; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end color variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The end color variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
const Color4F& getEndColorVar() const { return _endColorVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end color variance of each particle.
|
|
|
|
*
|
|
|
|
* @param color The end color variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEndColorVar(const Color4F& color) { _endColorVar = color; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2022-05-26 19:00:33 +08:00
|
|
|
/** Sets wether to use HSV color system.
|
|
|
|
* WARNING: becareful when using HSV with too many particles because it's expensive.
|
|
|
|
*
|
|
|
|
* @param hsv Use HSV color system.
|
|
|
|
*/
|
2022-05-26 20:56:56 +08:00
|
|
|
void useHSV(bool hsv);
|
2022-05-27 19:08:25 +08:00
|
|
|
bool isHSV() { return _isHSVAllocated; };
|
2022-05-26 19:00:33 +08:00
|
|
|
|
|
|
|
/** Gets the hue of each particle.
|
|
|
|
*
|
|
|
|
* @return The hue of each particle.
|
|
|
|
*/
|
|
|
|
float getHue() const { return _hsv.h; }
|
|
|
|
/** Sets the hue of each particle.
|
|
|
|
*
|
|
|
|
* @param hsv The hue color of each particle.
|
|
|
|
*/
|
|
|
|
void setHue(float hue) { _hsv.h = hue; }
|
|
|
|
|
|
|
|
/** Gets the hue variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The hue variance of each particle.
|
|
|
|
*/
|
|
|
|
float getHueVar() const { return _hsvVar.h; }
|
|
|
|
/** Sets the hue variance of each particle.
|
|
|
|
*
|
|
|
|
* @param hsv The hue variance color of each particle.
|
|
|
|
*/
|
|
|
|
void setHueVar(float hue) { _hsvVar.h = hue; }
|
|
|
|
|
|
|
|
/** Gets the HSV color of each particle.
|
|
|
|
*
|
|
|
|
* @return The HSV color of each particle.
|
|
|
|
*/
|
|
|
|
const HSV& getHSV() const { return _hsv; }
|
|
|
|
/** Sets the HSV color of each particle.
|
|
|
|
*
|
|
|
|
* @param hsv The HSV color of each particle.
|
|
|
|
*/
|
|
|
|
void setHSV(const HSV& hsv) { _hsv = hsv; }
|
|
|
|
|
|
|
|
/** Gets the HSV color variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The HSV color variance of each particle.
|
|
|
|
*/
|
|
|
|
const HSV& getHSVVar() const { return _hsvVar; }
|
|
|
|
/** Sets the HSV color variance of each particle.
|
|
|
|
*
|
|
|
|
* @param hsv The HSV color variance of each particle.
|
|
|
|
*/
|
|
|
|
void setHSVVar(const HSV& hsv) { _hsvVar = hsv; }
|
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start spin of each particle.
|
|
|
|
*
|
|
|
|
* @return The start spin of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getStartSpin() const { return _startSpin; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start spin of each particle.
|
|
|
|
*
|
|
|
|
* @param spin The start spin of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setStartSpin(float spin) { _startSpin = spin; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the start spin variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The start spin variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getStartSpinVar() const { return _startSpinVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the start spin variance of each particle.
|
|
|
|
*
|
|
|
|
* @param pinVar The start spin variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setStartSpinVar(float pinVar) { _startSpinVar = pinVar; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end spin of each particle.
|
|
|
|
*
|
|
|
|
* @return The end spin of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getEndSpin() const { return _endSpin; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end spin of each particle.
|
|
|
|
*
|
|
|
|
* @param endSpin The end spin of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEndSpin(float endSpin) { _endSpin = endSpin; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the end spin variance of each particle.
|
|
|
|
*
|
|
|
|
* @return The end spin variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getEndSpinVar() const { return _endSpinVar; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the end spin variance of each particle.
|
|
|
|
*
|
|
|
|
* @param endSpinVar The end spin variance of each particle.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEndSpinVar(float endSpinVar) { _endSpinVar = endSpinVar; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2022-05-24 05:46:38 +08:00
|
|
|
/** Gets the spawn angle of each particle
|
2022-05-21 21:48:46 +08:00
|
|
|
*
|
2022-05-23 01:51:56 +08:00
|
|
|
* @return The angle in degrees of each particle.
|
2022-05-21 21:48:46 +08:00
|
|
|
*/
|
2022-05-24 05:46:38 +08:00
|
|
|
float getSpawnAngle() { return _spawnAngle; }
|
|
|
|
/** Sets the spawn angle of each particle
|
2022-05-21 21:48:46 +08:00
|
|
|
*
|
2022-05-23 01:51:56 +08:00
|
|
|
* @param angle The angle in degrees of each particle.
|
2022-05-21 21:48:46 +08:00
|
|
|
*/
|
2022-05-24 05:46:38 +08:00
|
|
|
void setSpawnAngle(float angle) { _spawnAngle = angle; }
|
2022-05-23 01:51:56 +08:00
|
|
|
|
2022-05-24 05:46:38 +08:00
|
|
|
/** Sets the spawn angle variance of each particle.
|
2022-05-23 01:51:56 +08:00
|
|
|
*
|
|
|
|
* @return The angle variance in degrees of each particle.
|
|
|
|
*/
|
2022-05-24 05:46:38 +08:00
|
|
|
float getSpawnAngleVar() { return _spawnAngleVar; }
|
|
|
|
/** Sets the spawn angle variance of each particle.
|
2022-05-23 01:51:56 +08:00
|
|
|
*
|
|
|
|
* @param angle The angle variance in degrees of each particle.
|
|
|
|
*/
|
2022-05-24 05:46:38 +08:00
|
|
|
void setSpawnAngleVar(float angle) { _spawnAngleVar = angle; }
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-05-27 00:59:48 +08:00
|
|
|
/** Gets the spawn opacity fade in time of each particle.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
|
|
|
specified time.
|
2022-05-27 03:53:19 +08:00
|
|
|
|
2022-05-27 00:59:48 +08:00
|
|
|
* @return The spawn opacity fade in time in seconds.
|
|
|
|
*/
|
|
|
|
float getSpawnFadeIn() { return _spawnFadeIn; }
|
|
|
|
/** Sets the spawn opacity fade in time of each particle when it's created.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
|
|
|
* specified time.
|
|
|
|
*
|
2022-05-27 00:59:48 +08:00
|
|
|
* @param time The spawn opacity fade in time in seconds.
|
|
|
|
*/
|
|
|
|
void setSpawnFadeIn(float time);
|
|
|
|
|
|
|
|
/** Gets the spawn opacity fade in time variance of each particle.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
|
|
|
* specified time.
|
|
|
|
*
|
2022-05-27 00:59:48 +08:00
|
|
|
* @return The spawn opacity fade in time variance in seconds.
|
|
|
|
*/
|
|
|
|
float getSpawnFadeInVar() { return _spawnFadeInVar; }
|
|
|
|
/** Sets the spawn opacity fade in time variance of each particle when it's created.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
|
|
|
* specified time.
|
|
|
|
*
|
2022-05-27 00:59:48 +08:00
|
|
|
* @param time The spawn opacity fade in time variance in seconds.
|
|
|
|
*/
|
|
|
|
void setSpawnFadeInVar(float time);
|
|
|
|
|
2022-05-27 03:53:19 +08:00
|
|
|
/** Gets the spawn opacity fade in time of each particle.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
|
|
|
* time.
|
|
|
|
*
|
2022-05-27 03:53:19 +08:00
|
|
|
* @return The spawn opacity fade in time in seconds.
|
|
|
|
*/
|
|
|
|
float getSpawnScaleIn() { return _spawnScaleIn; }
|
|
|
|
/** Sets the spawn opacity fade in time of each particle when it's created.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
|
|
|
* time.
|
|
|
|
*
|
2022-05-27 03:53:19 +08:00
|
|
|
* @param time The spawn opacity fade in time in seconds.
|
|
|
|
*/
|
|
|
|
void setSpawnScaleIn(float time);
|
|
|
|
|
|
|
|
/** Gets the spawn opacity fade in time variance of each particle.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
|
|
|
* time.
|
|
|
|
*
|
2022-05-27 03:53:19 +08:00
|
|
|
* @return The spawn opacity fade in time variance in seconds.
|
|
|
|
*/
|
|
|
|
float getSpawnScaleInVar() { return _spawnScaleInVar; }
|
|
|
|
/** Sets the spawn opacity fade in time variance of each particle when it's created.
|
2022-06-07 00:23:11 +08:00
|
|
|
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
|
|
|
* time.
|
|
|
|
*
|
2022-05-27 03:53:19 +08:00
|
|
|
* @param time The spawn opacity fade in time variance in seconds.
|
|
|
|
*/
|
|
|
|
void setSpawnScaleInVar(float time);
|
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the emission rate of the particles.
|
|
|
|
*
|
|
|
|
* @return The emission rate of the particles.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getEmissionRate() const { return _emissionRate; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the emission rate of the particles.
|
|
|
|
*
|
|
|
|
* @param rate The emission rate of the particles.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setEmissionRate(float rate) { _emissionRate = rate; }
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the maximum particles of the system.
|
|
|
|
*
|
|
|
|
* @return The maximum particles of the system.
|
|
|
|
*/
|
2013-09-08 11:26:38 +08:00
|
|
|
virtual int getTotalParticles() const;
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the maximum particles of the system.
|
|
|
|
*
|
|
|
|
* @param totalParticles The maximum particles of the system.
|
|
|
|
*/
|
2013-09-08 11:26:38 +08:00
|
|
|
virtual void setTotalParticles(int totalParticles);
|
2013-07-23 18:26:26 +08:00
|
|
|
|
|
|
|
/** does the alpha value modify color */
|
2016-09-12 09:44:21 +08:00
|
|
|
void setOpacityModifyRGB(bool opacityModifyRGB) override { _opacityModifyRGB = opacityModifyRGB; }
|
|
|
|
bool isOpacityModifyRGB() const override { return _opacityModifyRGB; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-20 06:15:39 +08:00
|
|
|
/** Enables or disables tex coord animations that are set based on particle life. */
|
2022-05-26 20:56:56 +08:00
|
|
|
void setLifeAnimation(bool enabled);
|
2022-05-20 06:15:39 +08:00
|
|
|
|
2022-05-23 01:51:56 +08:00
|
|
|
/** Enables or disables tex coord animations that are set by the emitter randomly when a particle is emitted. */
|
2022-05-26 20:56:56 +08:00
|
|
|
void setEmitterAnimation(bool enabled);
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-06-07 00:23:11 +08:00
|
|
|
/** Enables or disables tex coord animations that are used to make particles play a sequence forever until they die
|
|
|
|
*/
|
2022-05-26 20:56:56 +08:00
|
|
|
void setLoopAnimation(bool enabled);
|
2022-05-20 06:15:39 +08:00
|
|
|
|
|
|
|
bool isLifeAnimated() { return _isLifeAnimated; }
|
|
|
|
bool isEmitterAnimated() { return _isEmitterAnimated; }
|
2022-05-22 20:58:36 +08:00
|
|
|
bool isLoopAnimated() { return _isLoopAnimated; }
|
2022-05-20 06:15:39 +08:00
|
|
|
|
2022-06-07 00:23:11 +08:00
|
|
|
/** Gets the total number of indices.
|
|
|
|
*
|
|
|
|
* @return The size of the list holding animation indices.
|
|
|
|
*/
|
2022-05-22 20:58:36 +08:00
|
|
|
int getTotalAnimationIndices() { return _animIndexCount; }
|
2022-05-20 06:15:39 +08:00
|
|
|
|
2022-05-23 01:51:56 +08:00
|
|
|
/** Sets wether to start from first cell and go forwards (normal) or last cell and go backwards (reversed) */
|
2022-05-22 20:58:36 +08:00
|
|
|
void setAnimationReverse(bool reverse) { _isAnimationReversed = reverse; }
|
|
|
|
bool isAnimationReversed() { return _isAnimationReversed; }
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-05-23 01:51:56 +08:00
|
|
|
/** Resets the count of indices to 0 and empties the animation index array */
|
2022-05-21 21:48:46 +08:00
|
|
|
void resetAnimationIndices();
|
|
|
|
|
2022-05-23 01:51:56 +08:00
|
|
|
/** Empties the container of animation descriptors */
|
2022-05-21 21:48:46 +08:00
|
|
|
void resetAnimationDescriptors();
|
|
|
|
|
2022-05-23 01:51:56 +08:00
|
|
|
/** Choose what animation descriptors are to be selected at random for particles.
|
2022-06-07 00:23:11 +08:00
|
|
|
* This function should be called after you've inserted/overwritten any animation descriptors.
|
|
|
|
*
|
|
|
|
* @param animations Array of specific indices of animations to play at random
|
|
|
|
*/
|
|
|
|
void setMultiAnimationRandomSpecific(const std::vector<unsigned short>& animations)
|
|
|
|
{
|
|
|
|
_randomAnimations = animations;
|
|
|
|
};
|
2022-05-21 21:48:46 +08:00
|
|
|
|
|
|
|
/** Choose ALL animation descriptors to be selected at random for particles.
|
2022-06-07 00:23:11 +08:00
|
|
|
* This function should be called after you've inserted/overwritten any animation descriptors.
|
|
|
|
*/
|
2022-05-21 21:48:46 +08:00
|
|
|
void setMultiAnimationRandom();
|
|
|
|
|
2022-05-22 20:58:36 +08:00
|
|
|
/** Add all particle animation indices based on cells size and direction spicified using a texture atlas.
|
2022-06-07 00:23:11 +08:00
|
|
|
* will erase the array and add new indices from the atlas.
|
|
|
|
* This function will automatically figure out your atlas cell size and direction for you! thank her later :) */
|
2022-05-22 20:58:36 +08:00
|
|
|
void setAnimationIndicesAtlas();
|
|
|
|
|
2022-06-07 00:23:11 +08:00
|
|
|
/** Add all particle animation indices based on cell size and direction spicified if the method of rendering
|
|
|
|
* preferred is texture atlas. will erase the array and add new indices from the atlas.
|
|
|
|
*
|
|
|
|
* @param unifiedCellSize The size of cell unified.
|
|
|
|
* @param direction What direction is the atlas
|
|
|
|
*/
|
2022-05-22 20:58:36 +08:00
|
|
|
void setAnimationIndicesAtlas(unsigned int unifiedCellSize, TexAnimDir direction = TexAnimDir::HORIZONTAL);
|
|
|
|
|
|
|
|
/** Add a particle animation index based on tex coords spicified using a sprite frame.
|
2022-06-07 00:23:11 +08:00
|
|
|
* The index is automatically incremented on each addition.
|
|
|
|
*
|
|
|
|
* @param frameName SpriteFrame name to search for
|
|
|
|
*
|
|
|
|
* @return Returns true of the index was successfully found and added. Otherwise, false
|
|
|
|
*/
|
2022-05-23 01:51:56 +08:00
|
|
|
bool addAnimationIndex(std::string_view frameName);
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-05-22 20:58:36 +08:00
|
|
|
/** Add a particle animation index based on tex coords spicified using a sprite frame.
|
2022-06-07 00:23:11 +08:00
|
|
|
*
|
|
|
|
* @param index Index id to add the frame to or override it with the new frame
|
|
|
|
* @param frameName SpriteFrame name to search for
|
|
|
|
*
|
|
|
|
* @return Returns true of the index was successfully found and added. Otherwise, false
|
|
|
|
*/
|
2022-05-23 01:51:56 +08:00
|
|
|
bool addAnimationIndex(unsigned short index, std::string_view frameName);
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-05-22 20:58:36 +08:00
|
|
|
/** Add a particle animation index based on tex coords spicified using a sprite frame.
|
2022-06-07 00:23:11 +08:00
|
|
|
* The index is automatically incremented on each addition.
|
|
|
|
*
|
|
|
|
* @param frame SpriteFrame containting data about tex coords
|
|
|
|
*
|
|
|
|
* @return Returns true of the index was successfully found and added. Otherwise, false
|
|
|
|
*/
|
2022-05-23 01:51:56 +08:00
|
|
|
bool addAnimationIndex(cocos2d::SpriteFrame* frame);
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-05-22 20:58:36 +08:00
|
|
|
/** Add a particle animation index based on tex coords spicified using a sprite frame.
|
2022-06-07 00:23:11 +08:00
|
|
|
* you can specify which index you want to override in this function
|
|
|
|
*
|
|
|
|
* @param index Index id to add the frame to or override it with the new frame
|
|
|
|
* @param frame SpriteFrame containting data about tex coords
|
|
|
|
*
|
|
|
|
* @return Returns true of the index was successfully found and added. Otherwise, false
|
|
|
|
*/
|
2022-05-23 01:51:56 +08:00
|
|
|
bool addAnimationIndex(unsigned short index, cocos2d::SpriteFrame* frame);
|
2022-05-21 21:48:46 +08:00
|
|
|
|
2022-05-22 20:58:36 +08:00
|
|
|
/** Add a particle animation index based on tex coords spicified.
|
2022-06-07 00:23:11 +08:00
|
|
|
* you can specify which index you want to override in this function
|
|
|
|
*
|
|
|
|
* @param index Index id to add the frame to or override it with the new rect
|
|
|
|
* @param rect Rect containting data about tex coords in pixels
|
|
|
|
* @param rotated Not implemented.
|
|
|
|
*
|
|
|
|
* @return Returns true of the index was successfully found and added. Otherwise, false
|
|
|
|
*/
|
2022-05-23 01:51:56 +08:00
|
|
|
bool addAnimationIndex(unsigned short index, cocos2d::Rect rect, bool rotated = false);
|
2022-05-22 20:58:36 +08:00
|
|
|
|
2022-05-24 16:26:53 +08:00
|
|
|
/** You can specify what rect is used if an index in an animation descriptor wasn't found.
|
2022-06-07 00:23:11 +08:00
|
|
|
*
|
|
|
|
* @param rect Rect containting data about tex coords in pixels
|
|
|
|
*/
|
2022-05-24 16:26:53 +08:00
|
|
|
void setRectForUndefinedIndices(cocos2d::Rect rect) { _undefinedIndexRect = rect; };
|
|
|
|
|
2022-05-21 21:48:46 +08:00
|
|
|
/** Add a particle animation descriptor with an index.
|
2022-06-07 00:23:11 +08:00
|
|
|
*
|
|
|
|
* @param indexOfDescriptor Index of the animation to be added, adding to the same index will just override the
|
|
|
|
* pervious animation descriptor
|
|
|
|
* @param time length of the animation in seconds
|
|
|
|
* @param timeVariance Time randomly selected for each different particle added on the animation length
|
|
|
|
* @param indices An array of the indicies
|
|
|
|
* @param reverse Should the animation indicies be played backwards? (default: false)
|
|
|
|
*/
|
2022-05-21 21:48:46 +08:00
|
|
|
void setAnimationDescriptor(unsigned short indexOfDescriptor,
|
|
|
|
float time,
|
|
|
|
float timeVariance,
|
2022-06-07 00:23:11 +08:00
|
|
|
const std::vector<unsigned short>& indices,
|
2022-05-21 21:48:46 +08:00
|
|
|
bool reverse = false);
|
|
|
|
|
2022-05-22 01:23:19 +08:00
|
|
|
/** Add a particle animation descriptor with the index 0.
|
|
|
|
*
|
|
|
|
* @param indices An array of the indicies
|
|
|
|
* @param reverse Should the animation indicies be played backwards? (default: false)
|
|
|
|
*/
|
2022-06-07 00:23:11 +08:00
|
|
|
void setAnimationDescriptor(const std::vector<unsigned short>& indices, bool reverse = false)
|
2022-05-22 01:23:19 +08:00
|
|
|
{
|
|
|
|
setAnimationDescriptor(0, 0, 0, indices, reverse);
|
|
|
|
};
|
|
|
|
|
2022-05-24 16:26:53 +08:00
|
|
|
/** Sets wether the animation descriptors should follow the time scale of the system or not.
|
|
|
|
*
|
|
|
|
* @param independent Should the animation descriptor speeds be played independently? (default: false)
|
|
|
|
*/
|
|
|
|
void setAnimationSpeedTimescaleIndependent(bool independent) { _animationTimescaleInd = independent; };
|
|
|
|
bool isAnimationSpeedTimescaleIndependent() { return _animationTimescaleInd; };
|
|
|
|
|
2022-06-03 00:26:02 +08:00
|
|
|
/** Sets wether to use emission shapes for this particle system or not */
|
|
|
|
void setEmissionShapes(bool enabled) { _isEmissionShapes = enabled; }
|
|
|
|
bool isEmissionShapes() { return _isEmissionShapes; }
|
|
|
|
|
2022-06-03 00:29:19 +08:00
|
|
|
/** Resets the count of emission shapes to 0 and empties the emission shapes array */
|
|
|
|
void resetEmissionShapes();
|
|
|
|
|
2022-06-11 23:06:43 +08:00
|
|
|
/** Adds an emission shape to the system.
|
|
|
|
* The index is automatically incremented on each addition.
|
|
|
|
*
|
|
|
|
* @param shape Shape descriptor object.
|
|
|
|
*/
|
|
|
|
void addEmissionShape(EmissionShape shape);
|
2022-06-03 00:26:02 +08:00
|
|
|
|
2022-06-11 23:06:43 +08:00
|
|
|
/** Updates an existing emission shape or adds it.
|
|
|
|
* @param index index of the shape descriptor.
|
|
|
|
* @param shape Shape descriptor object.
|
|
|
|
*/
|
|
|
|
void setEmissionShape(unsigned short index, EmissionShape shape);
|
2022-06-03 00:26:02 +08:00
|
|
|
|
2022-06-12 05:58:01 +08:00
|
|
|
/** Adds an emission shape of type mask to the system.
|
|
|
|
* The mask should be added using the ParticleEmissionMaskCache class.
|
|
|
|
*
|
|
|
|
* @param maskName Name of the emission mask.
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param overrideSize Size of the emission mask in pixels, leave ZERO to use texture size.
|
|
|
|
* @param scale Scale of the emission mask, the size will be multiplied by the specified scale.
|
|
|
|
* @param angle Angle of the sampled points to be rotated in degrees.
|
|
|
|
*/
|
|
|
|
static EmissionShape createMaskShape(std::string_view maskName, Vec2 pos = Vec2::ZERO, Vec2 overrideSize = Vec2::ZERO, Vec2 scale = Vec2::ONE, float angle = 0.0F);
|
|
|
|
|
2022-06-11 23:06:43 +08:00
|
|
|
/** Adds an emission shape of type point to the system.
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
*/
|
|
|
|
static EmissionShape createPointShape(Vec2 pos);
|
|
|
|
|
|
|
|
/** Adds an emission shape of type Rectangle to the system.
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param size Size of the rectangle.
|
|
|
|
*/
|
|
|
|
static EmissionShape createRectShape(Vec2 pos, Size size);
|
|
|
|
|
|
|
|
/** Adds an emission shape of type Rectangular Torus to the system.
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param innerSize Inner size offset of the rectangle.
|
|
|
|
* @param outerSize Outer size of the rectangle.
|
|
|
|
*/
|
|
|
|
static EmissionShape createRectTorusShape(Vec2 pos, Size innerSize, Size outerSize);
|
2022-06-03 00:26:02 +08:00
|
|
|
|
|
|
|
/** Adds an emission shape of type Circle to the system.
|
2022-06-11 23:06:43 +08:00
|
|
|
*
|
|
|
|
* The default angle offset of the circle is 0 and the default angle of the circle is 360
|
|
|
|
*
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param radius Radius of the circle.
|
|
|
|
* @param edgeBias circle edge center bias value, If the value is greater than 1.0 then particles will bias
|
|
|
|
* towards the edge of the circle more often the greater the value is; If the value is lower than 1.0 then particles
|
|
|
|
* will bias towards the center of the circle more often the closer the value is to 0.0; If the value is exactly 1.0
|
|
|
|
* then there will be no bias behaviour.
|
2022-06-07 00:23:11 +08:00
|
|
|
*/
|
2022-06-11 23:06:43 +08:00
|
|
|
static EmissionShape createCircleShape(Vec2 pos, float radius, float edgeBias = 1.0F);
|
|
|
|
|
|
|
|
/** Adds an emission shape of type Cone to the system.
|
|
|
|
*
|
|
|
|
* The default angle offset of the circle is 0 and the default angle of the circle is 360
|
|
|
|
*
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param radius Radius of the circle.
|
|
|
|
* @param offset Cone offset angle in degrees.
|
|
|
|
* @param angle Cone angle in degrees.
|
|
|
|
* @param edgeBias circle edge center bias value, If the value is greater than 1.0 then particles will bias
|
|
|
|
* towards the edge of the circle more often the greater the value is; If the value is lower than 1.0 then particles
|
|
|
|
* will bias towards the center of the circle more often the closer the value is to 0.0; If the value is exactly 1.0
|
|
|
|
* then there will be no bias behaviour.
|
|
|
|
*/
|
|
|
|
static EmissionShape createConeShape(Vec2 pos,
|
|
|
|
float radius,
|
|
|
|
float offset,
|
|
|
|
float angle,
|
|
|
|
float edgeBias = 1.0F);
|
2022-06-03 00:26:02 +08:00
|
|
|
|
|
|
|
/** Adds an emission shape of type Torus to the system.
|
2022-06-11 23:06:43 +08:00
|
|
|
*
|
|
|
|
* The default angle offset of the torus is 0 and the default angle of the torus is 360
|
|
|
|
*
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param innerRadius Inner radius offset of the torus.
|
|
|
|
* @param outerRadius Outer radius of the torus.
|
|
|
|
* @param edgeBias torus edge center bias value, If the value is greater than 1.0 then particles will bias
|
|
|
|
* towards the edge of the torus more often the greater the value is; If the value is lower than 1.0 then particles
|
|
|
|
* will bias towards the center of the torus more often the closer the value is to 0.0; If the value is exactly 1.0
|
|
|
|
* then there will be no bias behaviour.
|
2022-06-07 00:23:11 +08:00
|
|
|
*/
|
2022-06-11 23:06:43 +08:00
|
|
|
static EmissionShape createTorusShape(Vec2 pos, float innerRadius, float outerRadius, float edgeBias = 1.0F);
|
|
|
|
|
|
|
|
/** Adds an emission shape of type Torus to the system.
|
|
|
|
*
|
|
|
|
* The default angle offset of the torus is 0 and the default angle of the torus is 360
|
|
|
|
*
|
|
|
|
* @param pos Position of the emission shape in local space.
|
|
|
|
* @param innerRadius Inner radius offset of the torus.
|
|
|
|
* @param outerRadius Outer radius of the torus.
|
|
|
|
* @param offset Cone offset angle in degrees.
|
|
|
|
* @param angle Cone angle in degrees.
|
|
|
|
* @param edgeBias torus edge center bias value, If the value is greater than 1.0 then particles will bias
|
|
|
|
* towards the edge of the torus more often the greater the value is; If the value is lower than 1.0 then particles
|
|
|
|
* will bias towards the center of the torus more often the closer the value is to 0.0; If the value is exactly 1.0
|
|
|
|
* then there will be no bias behaviour.
|
|
|
|
*/
|
|
|
|
static EmissionShape createConeTorusShape(Vec2 pos,
|
|
|
|
float innerRadius,
|
|
|
|
float outerRadius,
|
|
|
|
float offset,
|
|
|
|
float angle,
|
|
|
|
float edgeBias = 1.0F);
|
2022-06-03 00:26:02 +08:00
|
|
|
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Gets the particles movement type: Free or Grouped.
|
2013-07-23 18:26:26 +08:00
|
|
|
@since v0.8
|
2015-03-21 18:02:56 +08:00
|
|
|
*
|
|
|
|
* @return The particles movement type.
|
2013-07-23 18:26:26 +08:00
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
PositionType getPositionType() const { return _positionType; }
|
2015-03-21 18:02:56 +08:00
|
|
|
/** Sets the particles movement type: Free or Grouped.
|
|
|
|
@since v0.8
|
|
|
|
*
|
|
|
|
* @param type The particles movement type.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setPositionType(PositionType type) { _positionType = type; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-24 05:46:38 +08:00
|
|
|
/** Advance the particle system and make it seem like it ran for this many seconds.
|
|
|
|
*
|
|
|
|
* @param seconds Seconds to advance. value of -1 means (SIMULATION_USE_PARTICLE_LIFETIME)
|
2022-06-07 00:23:11 +08:00
|
|
|
* @param frameRate Frame rate to run the simulation with (preferred: 30.0) The higher this value is the more
|
|
|
|
* accurate the simulation will be at the cost of performance. value of -1 means
|
|
|
|
* (SIMULATION_USE_GAME_ANIMATION_INTERVAL)
|
2022-05-24 05:46:38 +08:00
|
|
|
*/
|
2022-06-07 00:23:11 +08:00
|
|
|
void simulate(float seconds = SIMULATION_USE_PARTICLE_LIFETIME,
|
|
|
|
float frameRate = SIMULATION_USE_GAME_ANIMATION_INTERVAL);
|
2022-05-24 05:46:38 +08:00
|
|
|
|
|
|
|
/** Resets the particle system and then advances the particle system and make it seem like it ran for this many
|
2022-06-11 23:06:43 +08:00
|
|
|
* seconds. The frame rate used for simulation accuracy is the director's animation interval.
|
2022-05-24 05:46:38 +08:00
|
|
|
*
|
|
|
|
* @param seconds Seconds to advance. value of -1 means (SIMULATION_USE_PARTICLE_LIFETIME)
|
2022-06-07 00:23:11 +08:00
|
|
|
* @param frameRate Frame rate to run the simulation with (preferred: 30.0) The higher this value is the more
|
|
|
|
* accurate the simulation will be at the cost of performance. value of -1 means
|
|
|
|
* (SIMULATION_USE_GAME_ANIMATION_INTERVAL)
|
2022-05-24 05:46:38 +08:00
|
|
|
*/
|
2022-05-24 14:42:27 +08:00
|
|
|
void resimulate(float seconds = SIMULATION_USE_PARTICLE_LIFETIME,
|
|
|
|
float frameRate = SIMULATION_USE_GAME_ANIMATION_INTERVAL);
|
2022-05-24 05:46:38 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
2014-03-28 14:05:38 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void update(float dt) override;
|
2013-07-23 18:26:26 +08:00
|
|
|
virtual Texture2D* getTexture() const override;
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void setTexture(Texture2D* texture) override;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
*@code
|
|
|
|
*When this function bound into js or lua,the parameter will be changed
|
|
|
|
*In js: var setBlendFunc(var src, var dst)
|
|
|
|
*In lua: local setBlendFunc(local src, local dst)
|
|
|
|
*@endcode
|
|
|
|
*/
|
|
|
|
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual const BlendFunc& getBlendFunc() const override;
|
2015-11-12 09:49:49 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view getResourceFile() const { return _plistFile; }
|
2015-11-12 09:49:49 +08:00
|
|
|
|
2016-01-12 17:21:01 +08:00
|
|
|
/// @{
|
|
|
|
/// @name implement Playable Protocol
|
|
|
|
virtual void start() override;
|
|
|
|
virtual void stop() override;
|
2017-01-11 09:31:45 +08:00
|
|
|
/// @} end of PlayableProtocol
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
void setSourcePositionCompatible(bool sourcePositionCompatible)
|
|
|
|
{
|
|
|
|
_sourcePositionCompatible = sourcePositionCompatible;
|
|
|
|
}
|
2017-09-07 17:16:46 +08:00
|
|
|
bool isSourcePositionCompatible() const { return _sourcePositionCompatible; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-03-18 21:46:07 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
ParticleSystem();
|
2013-11-15 08:21:49 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~ParticleSystem();
|
|
|
|
|
|
|
|
/** initializes a ParticleSystem*/
|
2015-03-15 02:33:15 +08:00
|
|
|
bool init() override;
|
2013-11-15 08:21:49 +08:00
|
|
|
/** initializes a ParticleSystem from a plist file.
|
|
|
|
This plist files can be created manually or with Particle Designer:
|
|
|
|
http://particledesigner.71squared.com/
|
|
|
|
@since v0.99.3
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool initWithFile(std::string_view plistFile);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-11-15 08:21:49 +08:00
|
|
|
/** initializes a QuadParticleSystem from a Dictionary.
|
|
|
|
@since v0.99.3
|
|
|
|
*/
|
2021-07-15 12:23:50 +08:00
|
|
|
bool initWithDictionary(const ValueMap& dictionary);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-11-15 08:21:49 +08:00
|
|
|
/** initializes a particle system from a NSDictionary and the path from where to load the png
|
|
|
|
@since v2.1
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool initWithDictionary(const ValueMap& dictionary, std::string_view dirname);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-11-15 08:21:49 +08:00
|
|
|
//! Initializes a system with a fixed number of particles
|
|
|
|
virtual bool initWithTotalParticles(int numberOfParticles);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2016-06-15 18:31:10 +08:00
|
|
|
/** Are the emissions paused
|
|
|
|
@return True if the emissions are paused, else false
|
|
|
|
*/
|
|
|
|
virtual bool isPaused() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-23 21:04:09 +08:00
|
|
|
/* Pause the emissions */
|
2016-06-15 18:31:10 +08:00
|
|
|
virtual void pauseEmissions();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-23 21:04:09 +08:00
|
|
|
/* Unpause the emissions */
|
2016-06-15 18:31:10 +08:00
|
|
|
virtual void resumeEmissions();
|
2013-11-15 08:21:49 +08:00
|
|
|
|
2022-05-23 21:04:09 +08:00
|
|
|
/** Is system update paused
|
2022-06-11 23:06:43 +08:00
|
|
|
@return True if system update is paused, else false
|
2022-05-23 21:04:09 +08:00
|
|
|
*/
|
|
|
|
virtual bool isUpdatePaused() const;
|
|
|
|
|
|
|
|
/* Pause the particles from being updated */
|
|
|
|
virtual void pauseUpdate();
|
|
|
|
|
|
|
|
/* Unpause the particles from being updated */
|
|
|
|
virtual void resumeUpdate();
|
|
|
|
|
2022-05-24 05:46:38 +08:00
|
|
|
/** Gets the fixed frame rate count of the particle system.
|
|
|
|
@return Fixed frame rate count of the particle system.
|
|
|
|
*/
|
|
|
|
virtual float getFixedFPS();
|
|
|
|
|
|
|
|
/** Sets the fixed frame rate count of the particle system.
|
2022-06-07 00:23:11 +08:00
|
|
|
* i.e. if the framerate is set to 30.0 while the refresh rate is greater than 30.0 then the particle system will
|
|
|
|
wait until it hits the 30.0 FPS mark.
|
|
|
|
* This is usefull for increasing performance or for creating old-school effects with it.
|
2022-05-24 05:46:38 +08:00
|
|
|
@param Fixed frame rate count of the particle system. (default: 0.0)
|
|
|
|
*/
|
|
|
|
virtual void setFixedFPS(float frameRate = 0.0F);
|
|
|
|
|
2022-05-24 05:49:17 +08:00
|
|
|
/** Gets the time scale of the particle system.
|
|
|
|
@return Time scale of the particle system.
|
|
|
|
*/
|
|
|
|
virtual float getTimeScale();
|
|
|
|
|
2022-05-29 13:21:08 +08:00
|
|
|
/** Sets the time scale of the particle system.
|
2022-05-24 05:49:17 +08:00
|
|
|
@param Time scale of the particle system. (default: 1.0)
|
|
|
|
*/
|
|
|
|
virtual void setTimeScale(float scale = 1.0F);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void updateBlendFunc();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2017-06-05 13:37:50 +08:00
|
|
|
private:
|
|
|
|
friend class EngineDataManager;
|
|
|
|
/** Internal use only, it's used by EngineDataManager class for Android platform */
|
|
|
|
static void setTotalParticleCountFactor(float factor);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
protected:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** whether or not the particles are using blend additive.
|
|
|
|
If enabled, the following blending function will be used.
|
|
|
|
@code
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
source blend function = BlendFactor::SRC_ALPHA;
|
|
|
|
dest blend function = BlendFactor::ONE;
|
2013-07-18 07:56:19 +08:00
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
bool _isBlendAdditive;
|
|
|
|
|
|
|
|
/** whether or not the node will be auto-removed when it has no particles left.
|
|
|
|
By default it is false.
|
|
|
|
@since v0.8
|
|
|
|
*/
|
|
|
|
bool _isAutoRemoveOnFinish;
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
std::string _plistFile;
|
2012-04-19 14:35:52 +08:00
|
|
|
//! time elapsed since the start of the system (in seconds)
|
2013-06-15 14:03:30 +08:00
|
|
|
float _elapsed;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Different modes
|
|
|
|
//! Mode A:Gravity + Tangential Accel + Radial Accel
|
2021-12-25 10:04:45 +08:00
|
|
|
struct
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Gravity value. Only available in 'Gravity' mode. */
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 gravity;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** speed of each particle. Only available in 'Gravity' mode. */
|
|
|
|
float speed;
|
|
|
|
/** speed variance of each particle. Only available in 'Gravity' mode. */
|
|
|
|
float speedVar;
|
|
|
|
/** tangential acceleration of each particle. Only available in 'Gravity' mode. */
|
|
|
|
float tangentialAccel;
|
|
|
|
/** tangential acceleration variance of each particle. Only available in 'Gravity' mode. */
|
|
|
|
float tangentialAccelVar;
|
|
|
|
/** radial acceleration of each particle. Only available in 'Gravity' mode. */
|
|
|
|
float radialAccel;
|
|
|
|
/** radial acceleration variance of each particle. Only available in 'Gravity' mode. */
|
|
|
|
float radialAccelVar;
|
2013-01-21 17:39:48 +08:00
|
|
|
/** set the rotation of each particle to its direction Only available in 'Gravity' mode. */
|
2013-01-22 10:30:22 +08:00
|
|
|
bool rotationIsDir;
|
2012-04-19 14:35:52 +08:00
|
|
|
} modeA;
|
|
|
|
|
|
|
|
//! Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode)
|
2021-12-25 10:04:45 +08:00
|
|
|
struct
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
/** The starting radius of the particles. Only available in 'Radius' mode. */
|
|
|
|
float startRadius;
|
|
|
|
/** The starting radius variance of the particles. Only available in 'Radius' mode. */
|
|
|
|
float startRadiusVar;
|
|
|
|
/** The ending radius of the particles. Only available in 'Radius' mode. */
|
|
|
|
float endRadius;
|
|
|
|
/** The ending radius variance of the particles. Only available in 'Radius' mode. */
|
2013-07-18 07:56:19 +08:00
|
|
|
float endRadiusVar;
|
2012-09-17 15:02:24 +08:00
|
|
|
/** Number of degrees to rotate a particle around the source pos per second. Only available in 'Radius' mode. */
|
2012-04-19 14:35:52 +08:00
|
|
|
float rotatePerSecond;
|
|
|
|
/** Variance in degrees for rotatePerSecond. Only available in 'Radius' mode. */
|
|
|
|
float rotatePerSecondVar;
|
|
|
|
} modeB;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
// particle data
|
2015-08-31 17:25:34 +08:00
|
|
|
ParticleData _particleData;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// Emitter name
|
2013-09-24 16:18:51 +08:00
|
|
|
std::string _configName;
|
2013-09-18 16:21:48 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// color modulate
|
|
|
|
// BOOL colorModulate;
|
|
|
|
|
|
|
|
//! How many particles can be emitted per second
|
2013-06-15 14:03:30 +08:00
|
|
|
float _emitCounter;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Optimization
|
2021-12-25 10:04:45 +08:00
|
|
|
// CC_UPDATE_PARTICLE_IMP updateParticleImp;
|
|
|
|
// SEL updateParticleSel;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** weak reference to the SpriteBatchNode that renders the Sprite */
|
2013-07-23 18:26:26 +08:00
|
|
|
ParticleBatchNode* _batchNode;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// index of system in batch node array
|
2013-07-23 18:26:26 +08:00
|
|
|
int _atlasIndex;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// true if scaled or rotated
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _transformSystemDirty;
|
2012-04-19 14:35:52 +08:00
|
|
|
// Number of allocated particles
|
2013-09-08 11:26:38 +08:00
|
|
|
int _allocatedParticles;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Is the emitter active */
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _isActive;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Quantity of particles that are being simulated at the moment */
|
2013-09-08 11:26:38 +08:00
|
|
|
int _particleCount;
|
2017-06-05 13:37:50 +08:00
|
|
|
/** The factor affects the total particle count, its value should be 0.0f ~ 1.0f, default 1.0f*/
|
|
|
|
static float __totalParticleCountFactor;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
/** How many seconds the emitter will run. -1 means 'forever' */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _duration;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** sourcePosition of the emitter */
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _sourcePosition;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Position variance of the emitter */
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _posVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** life, and life variation of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _life;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** life variance of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _lifeVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** angle and angle variation of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _angle;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** angle variance of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _angleVar;
|
2010-12-27 17:39:15 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
/** Switch between different kind of emitter modes:
|
|
|
|
- kParticleModeGravity: uses gravity, speed, radial and tangential acceleration
|
|
|
|
- kParticleModeRadius: uses radius movement + rotation
|
|
|
|
*/
|
2013-07-26 08:47:42 +08:00
|
|
|
Mode _emitterMode;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** start size in pixels of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _startSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** size variance in pixels of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _startSizeVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** end size in pixels of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _endSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** end size variance in pixels of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _endSizeVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** start color of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
Color4F _startColor;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** start color variance of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
Color4F _startColorVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** end color and end color variation of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
Color4F _endColor;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** end color variance of each particle */
|
2013-07-23 18:26:26 +08:00
|
|
|
Color4F _endColorVar;
|
2022-05-26 19:00:33 +08:00
|
|
|
/** hsv color of each particle */
|
|
|
|
HSV _hsv;
|
|
|
|
/** hsv color variance of each particle */
|
|
|
|
HSV _hsvVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
//* initial angle of each particle
|
2013-07-23 18:26:26 +08:00
|
|
|
float _startSpin;
|
2012-04-19 14:35:52 +08:00
|
|
|
//* initial angle of each particle
|
2013-07-23 18:26:26 +08:00
|
|
|
float _startSpinVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
//* initial angle of each particle
|
2013-07-23 18:26:26 +08:00
|
|
|
float _endSpin;
|
2012-04-19 14:35:52 +08:00
|
|
|
//* initial angle of each particle
|
2013-07-23 18:26:26 +08:00
|
|
|
float _endSpinVar;
|
2022-05-21 21:48:46 +08:00
|
|
|
//* initial rotation of each particle
|
2022-05-24 05:46:38 +08:00
|
|
|
float _spawnAngle;
|
2022-05-21 21:48:46 +08:00
|
|
|
//* initial rotation of each particle
|
2022-05-24 05:46:38 +08:00
|
|
|
float _spawnAngleVar;
|
2022-05-27 00:59:48 +08:00
|
|
|
//* initial fade in time of each particle
|
|
|
|
float _spawnFadeIn;
|
|
|
|
//* initial fade in time variance of each particle
|
|
|
|
float _spawnFadeInVar;
|
2022-05-27 03:53:19 +08:00
|
|
|
//* initial scale in time of each particle
|
|
|
|
float _spawnScaleIn;
|
|
|
|
//* initial scale in time variance of each particle
|
|
|
|
float _spawnScaleInVar;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** emission rate of the particles */
|
2013-07-23 18:26:26 +08:00
|
|
|
float _emissionRate;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** maximum particles of the system */
|
2013-09-08 11:26:38 +08:00
|
|
|
int _totalParticles;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** conforms to CocosNodeTexture protocol */
|
2013-07-23 18:26:26 +08:00
|
|
|
Texture2D* _texture;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** conforms to CocosNodeTexture protocol */
|
2013-07-23 18:26:26 +08:00
|
|
|
BlendFunc _blendFunc;
|
2012-06-14 05:26:28 +08:00
|
|
|
/** does the alpha value modify color */
|
2013-07-23 18:26:26 +08:00
|
|
|
bool _opacityModifyRGB;
|
2022-05-20 06:15:39 +08:00
|
|
|
/** is the particle system animated */
|
|
|
|
bool _isLifeAnimated;
|
|
|
|
/** is the emitter particle system animated */
|
|
|
|
bool _isEmitterAnimated;
|
2022-05-21 21:48:46 +08:00
|
|
|
/** is the emitter particle system animated */
|
|
|
|
bool _isLoopAnimated;
|
2022-05-22 20:58:36 +08:00
|
|
|
/** variable keeping count of sprite frames or atlas indices added */
|
2022-05-21 21:48:46 +08:00
|
|
|
int _animIndexCount;
|
|
|
|
/** wether to start from first or last when using life animation */
|
2022-05-22 20:58:36 +08:00
|
|
|
bool _isAnimationReversed;
|
2022-05-21 21:48:46 +08:00
|
|
|
/** A map that stores particle animation index coords */
|
|
|
|
std::unordered_map<unsigned short, ParticleFrameDescriptor> _animationIndices;
|
|
|
|
/** A map that stores particle animation descriptors */
|
|
|
|
std::unordered_map<unsigned short, ParticleAnimationDescriptor> _animations;
|
|
|
|
/** A vector that stores ids of animation descriptors that are choosen at random */
|
|
|
|
std::vector<unsigned short> _randomAnimations;
|
2022-05-24 16:26:53 +08:00
|
|
|
/** Wether the animation goes with the time scale of the system or is independent. */
|
|
|
|
bool _animationTimescaleInd;
|
|
|
|
/** A rect that is used instead when an index is not found */
|
|
|
|
cocos2d::Rect _undefinedIndexRect;
|
2013-09-24 16:18:51 +08:00
|
|
|
/** does FlippedY variance of each particle */
|
2013-09-23 10:12:54 +08:00
|
|
|
int _yCoordFlipped;
|
2013-09-18 16:21:48 +08:00
|
|
|
|
2022-06-03 00:26:02 +08:00
|
|
|
/** Wether to use emission shapes for this particle system or not */
|
|
|
|
bool _isEmissionShapes;
|
|
|
|
|
2022-06-11 23:06:43 +08:00
|
|
|
/** variable keeping count of emission shapes added */
|
|
|
|
int _emissionShapeIndex;
|
|
|
|
/** A map that stores emission shapes that are choosen at random */
|
|
|
|
std::unordered_map<unsigned short, EmissionShape> _emissionShapes;
|
2022-06-03 00:26:02 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** particles movement type: Free or Grouped
|
2013-07-18 07:56:19 +08:00
|
|
|
@since v0.8
|
2012-11-15 17:16:51 +08:00
|
|
|
*/
|
2013-07-25 14:27:46 +08:00
|
|
|
PositionType _positionType;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2016-06-15 18:31:10 +08:00
|
|
|
/** is the emitter paused */
|
|
|
|
bool _paused;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-05-24 05:46:38 +08:00
|
|
|
/** is particle system update paused */
|
2022-05-23 21:04:09 +08:00
|
|
|
bool _updatePaused;
|
|
|
|
|
|
|
|
/** time scale of the particle system */
|
|
|
|
float _timeScale;
|
|
|
|
|
2022-05-24 05:46:38 +08:00
|
|
|
/** Fixed frame rate of the particle system */
|
|
|
|
float _fixedFPS;
|
|
|
|
|
|
|
|
/** Fixed frame rate delta (internal) */
|
|
|
|
float _fixedFPSDelta;
|
|
|
|
|
2017-09-07 17:16:46 +08:00
|
|
|
/** is sourcePosition compatible */
|
|
|
|
bool _sourcePositionCompatible;
|
2013-11-15 08:21:49 +08:00
|
|
|
|
2017-06-05 13:37:50 +08:00
|
|
|
static Vector<ParticleSystem*> __allInstances;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-11-15 08:21:49 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ParticleSystem);
|
2010-08-23 14:57:37 +08:00
|
|
|
};
|
2011-03-19 10:07:16 +08:00
|
|
|
|
2015-03-24 10:34:41 +08:00
|
|
|
// end of _2d group
|
2012-06-20 18:09:11 +08:00
|
|
|
/// @}
|
|
|
|
|
2012-03-20 15:04:53 +08:00
|
|
|
NS_CC_END
|
2011-03-19 10:07:16 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#endif //__CCPARTICLE_SYSTEM_H__
|