本文整理汇总了C++中ParticleEmitter::setEmissionRate方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::setEmissionRate方法的具体用法?C++ ParticleEmitter::setEmissionRate怎么用?C++ ParticleEmitter::setEmissionRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter::setEmissionRate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateWeather
void CScene::UpdateWeather(Camera* cam, float mul)
{
const Vector3& pos = cam->getPosition(), dir = cam->getDirection();
static Vector3 oldPos = Vector3::ZERO;
Vector3 vel = (pos-oldPos) * app->mWindow->getLastFPS(); oldPos = pos;
Vector3 par = pos + dir * 12.f + vel * 0.6f;
if (pr && sc->rainEmit > 0)
{
ParticleEmitter* pe = pr->getEmitter(0);
pe->setPosition(par);
pe->setEmissionRate(mul * sc->rainEmit);
}
if (pr2 && sc->rain2Emit > 0)
{
ParticleEmitter* pe = pr2->getEmitter(0);
pe->setPosition(par);
pe->setEmissionRate(mul * sc->rain2Emit);
}
}
示例2: clone
Drawable* ParticleEmitter::clone(NodeCloneContext& context)
{
// Create a clone of this emitter
ParticleEmitter* clone = ParticleEmitter::create(_spriteBatch->getSampler()->getTexture(),
_spriteBlendMode, _particleCountMax);
// Clone properties
clone->setEmissionRate(_emissionRate);
clone->_ellipsoid = _ellipsoid;
clone->_sizeStartMin = _sizeStartMin;
clone->_sizeStartMax = _sizeStartMax;
clone->_sizeEndMin = _sizeEndMin;
clone->_sizeEndMax = _sizeEndMax;
clone->_energyMin = _energyMin;
clone->_energyMax = _energyMax;
clone->_colorStart = _colorStart;
clone->_colorStartVar = _colorStartVar;
clone->_colorEnd = _colorEnd;
clone->_colorEndVar = _colorEndVar;
clone->_position = _position;
clone->_positionVar = _positionVar;
clone->_velocity = _velocity;
clone->_velocityVar = _velocityVar;
clone->_acceleration = _acceleration;
clone->_accelerationVar = _accelerationVar;
clone->_rotationPerParticleSpeedMin = _rotationPerParticleSpeedMin;
clone->_rotationPerParticleSpeedMax = _rotationPerParticleSpeedMax;
clone->_rotationSpeedMin = _rotationSpeedMin;
clone->_rotationSpeedMax = _rotationSpeedMax;
clone->_rotationAxis = _rotationAxis;
clone->_rotationAxisVar = _rotationAxisVar;
clone->setSpriteTexCoords(_spriteFrameCount, _spriteTextureCoords);
clone->_spriteAnimated = _spriteAnimated;
clone->_spriteLooped = _spriteLooped;
clone->_spriteFrameRandomOffset = _spriteFrameRandomOffset;
clone->setSpriteFrameDuration(_spriteFrameDuration);
clone->_orbitPosition = _orbitPosition;
clone->_orbitVelocity = _orbitVelocity;
clone->_orbitAcceleration = _orbitAcceleration;
return clone;
}
示例3: onHit
void GunTurret::onHit()
{
if (m_active)
{
ParticleSystemManager& psm = getWriteableGameResource().getParticleSystemManager();
ParticleEmitter* pe = psm.createEmitter(m_center, Vector3::yAxis());
pe->setMaxParticles(250.0f);
pe->setEmissionRate(75.0f);
pe->setParticleStartColor(Color(1.0f, 1.0f, 1.0f, 1.0f));//Color(0.75f, 0.5f, 0.01f, 0.75f));
pe->setParticleKey1Color(Color(1.0f, 1.0f, 0.0f, 0.8f));
pe->setParticleKey1Pos(0.001f);
pe->setParticleKey2Color(Color(1.0f, 0.5f, 0.0f, 0.6f));
pe->setParticleKey2Pos(0.25f);
pe->setParticelEndColor(Color(0.0f, 0.0f, 0.0f, 0.0f));//Color(0.99f, 0.2f, 0.1f, 0.0f));
pe->setParticleLifetime(1.0f);
pe->setLifeTime(5.0f);
pe->setParticleSize(7.5f);
pe->setStartVelocity(10.0f);
pe->setSpreadAngle(180.0f);
pe->setAlive(true);
m_active = false;
}
}
示例4: create
ParticleEmitter* ParticleEmitter::create(Properties* properties)
{
if (!properties || strcmp(properties->getNamespace(), "particle") != 0)
{
GP_ERROR("Properties object must be non-null and have namespace equal to 'particle'.");
return NULL;
}
Properties* sprite = properties->getNextNamespace();
if (!sprite || strcmp(sprite->getNamespace(), "sprite") != 0)
{
GP_ERROR("Failed to load particle emitter: required namespace 'sprite' is missing.");
return NULL;
}
// Load sprite properties.
// Path to image file is required.
const char* texturePath = sprite->getString("path");
if (!texturePath || strlen(texturePath) == 0)
{
GP_ERROR("Failed to load particle emitter: required image file path ('path') is missing.");
return NULL;
}
const char* blendingString = sprite->getString("blending");
TextureBlending textureBlending = getTextureBlendingFromString(blendingString);
int spriteWidth = sprite->getInt("width");
int spriteHeight = sprite->getInt("height");
bool spriteAnimated = sprite->getBool("animated");
bool spriteLooped = sprite->getBool("looped");
int spriteFrameCount = sprite->getInt("frameCount");
int spriteFrameRandomOffset = sprite->getInt("frameRandomOffset");
float spriteFrameDuration = sprite->getFloat("frameDuration");
// Emitter properties.
unsigned int particleCountMax = (unsigned int)properties->getInt("particleCountMax");
if (particleCountMax == 0)
{
// Set sensible default.
particleCountMax = PARTICLE_COUNT_MAX;
}
unsigned int emissionRate = (unsigned int)properties->getInt("emissionRate");
if (emissionRate == 0)
{
emissionRate = PARTICLE_EMISSION_RATE;
}
bool ellipsoid = properties->getBool("ellipsoid");
float sizeStartMin = properties->getFloat("sizeStartMin");
float sizeStartMax = properties->getFloat("sizeStartMax");
float sizeEndMin = properties->getFloat("sizeEndMin");
float sizeEndMax = properties->getFloat("sizeEndMax");
long energyMin = properties->getLong("energyMin");
long energyMax = properties->getLong("energyMax");
Vector4 colorStart;
Vector4 colorStartVar;
Vector4 colorEnd;
Vector4 colorEndVar;
properties->getVector4("colorStart", &colorStart);
properties->getVector4("colorStartVar", &colorStartVar);
properties->getVector4("colorEnd", &colorEnd);
properties->getVector4("colorEndVar", &colorEndVar);
Vector3 position;
Vector3 positionVar;
Vector3 velocity;
Vector3 velocityVar;
Vector3 acceleration;
Vector3 accelerationVar;
Vector3 rotationAxis;
Vector3 rotationAxisVar;
properties->getVector3("position", &position);
properties->getVector3("positionVar", &positionVar);
properties->getVector3("velocity", &velocity);
properties->getVector3("velocityVar", &velocityVar);
properties->getVector3("acceleration", &acceleration);
properties->getVector3("accelerationVar", &accelerationVar);
float rotationPerParticleSpeedMin = properties->getFloat("rotationPerParticleSpeedMin");
float rotationPerParticleSpeedMax = properties->getFloat("rotationPerParticleSpeedMax");
float rotationSpeedMin = properties->getFloat("rotationSpeedMin");
float rotationSpeedMax = properties->getFloat("rotationSpeedMax");
properties->getVector3("rotationAxis", &rotationAxis);
properties->getVector3("rotationAxisVar", &rotationAxisVar);
bool orbitPosition = properties->getBool("orbitPosition");
bool orbitVelocity = properties->getBool("orbitVelocity");
bool orbitAcceleration = properties->getBool("orbitAcceleration");
// Apply all properties to a newly created ParticleEmitter.
ParticleEmitter* emitter = ParticleEmitter::create(texturePath, textureBlending, particleCountMax);
if (!emitter)
{
GP_ERROR("Failed to create particle emitter.");
return NULL;
}
emitter->setEmissionRate(emissionRate);
emitter->setEllipsoid(ellipsoid);
emitter->setSize(sizeStartMin, sizeStartMax, sizeEndMin, sizeEndMax);
emitter->setEnergy(energyMin, energyMax);
//.........这里部分代码省略.........
示例5: Update
//.........这里部分代码省略.........
#define MAX_TERRAIN_DIST 2.0 // meters
bool changed = false;
if (terrain)
{
Vector3 carPos = pMainNode->getPosition();
float terrainHeight = terrain->getHeightAtWorldPosition(carPos);
float diff = std::abs(carPos.y - terrainHeight);
if (diff > MAX_TERRAIN_DIST)
{
if (bLightMapEnabled)
{ changed = true; bLightMapEnabled = false; }
}
else if (!bLightMapEnabled)
{ changed = true; bLightMapEnabled = true; }
}
// if no terrain, disable
else if (bLightMapEnabled)
{ changed = true; bLightMapEnabled = false; }
if (changed)
UpdateLightMap();
// update particle emitters
if (pSet->particles && pCar)
{
// boost
for (i=0; i < PAR_BOOST; ++i) if (parBoost[i])
{
/// <><> damage reduce
float dmg = pCar->dynamics.fDamage >= 80.f ? 0.f : std::max(0.f, 1.4f - pCar->dynamics.fDamage*0.01f);
float emitB = posInfo.fboost * 40.f * dmg; // par
ParticleEmitter* pe = parBoost[i]->getEmitter(0);
pe->setEmissionRate(emitB);
}
// spaceship thrusters
for (i=0; i < PAR_THRUST*2; ++i) if (parThrust[i])
{
float dmg = 1.f - 0.5f * pCar->dynamics.fDamage*0.01f;
float emitT = posInfo.hov_throttle * 60.f * dmg; // par
ParticleEmitter* pe = parThrust[i]->getEmitter(0);
pe->setEmissionRate(emitT);
}
}
// world hit
if (parHit)
{ ParticleEmitter* pe = parHit->getEmitter(0);
if (posInfo.fHitTime > 0.f && pSet->particles)
{
pe->setPosition(posInfo.vHitPos);
pe->setDirection(posInfo.vHitNorm);
pe->setEmissionRate(pSet->particles_len * std::min(160.f, posInfo.fParIntens) * posInfo.fHitTime);
pe->setParticleVelocity(posInfo.fParVel);
}else
pe->setEmissionRate(0.f);
}
// wheels ------------------------------------------------------------------------
const float trlH = sc->ter ? 0.90f : 0.76f; // vdr needs up (ter bumps), no ter ..get from wheel contact ?rpl
for (w=0; w < numWheels; ++w)
{
float wR = whRadius[w];
#ifdef CAM_TILT_DBG // cam debug test only
示例6: controlEvent
void ParticlesGame::controlEvent(Control* control, EventType evt)
{
std::string id = control->getId();
// Handle UI events.
ParticleEmitter* emitter = _particleEmitterNode->getParticleEmitter();
switch(evt)
{
case Listener::VALUE_CHANGED:
if (control == _startRed)
{
Vector4 startColor = emitter->getColorStart();
startColor.x = _startRed->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _startGreen)
{
Vector4 startColor = emitter->getColorStart();
startColor.y = _startGreen->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _startBlue)
{
Vector4 startColor = emitter->getColorStart();
startColor.z = _startBlue->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _startAlpha)
{
Vector4 startColor = emitter->getColorStart();
startColor.w = _startAlpha->getValue();
emitter->setColor(startColor, emitter->getColorStartVariance(), emitter->getColorEnd(), emitter->getColorEndVariance());
}
else if (control == _endRed)
{
Vector4 endColor = emitter->getColorEnd();
endColor.x = _endRed->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _endGreen)
{
Vector4 endColor = emitter->getColorEnd();
endColor.y = _endGreen->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _endBlue)
{
Vector4 endColor = emitter->getColorEnd();
endColor.z = _endBlue->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _endAlpha)
{
Vector4 endColor = emitter->getColorEnd();
endColor.w = _endAlpha->getValue();
emitter->setColor(emitter->getColorStart(), emitter->getColorStartVariance(), endColor, emitter->getColorEndVariance());
}
else if (control == _startMin)
{
emitter->setSize(_startMin->getValue(), emitter->getSizeStartMax(), emitter->getSizeEndMin(), emitter->getSizeEndMax());
}
else if (control == _startMax)
{
emitter->setSize(emitter->getSizeStartMin(), _startMax->getValue(), emitter->getSizeEndMin(), emitter->getSizeEndMax());
}
else if (control == _endMin)
{
emitter->setSize(emitter->getSizeStartMin(), emitter->getSizeStartMax(), _endMin->getValue(), emitter->getSizeEndMax());
}
else if (control == _endMax)
{
emitter->setSize(emitter->getSizeStartMin(), emitter->getSizeStartMax(), emitter->getSizeEndMin(), _endMax->getValue());
}
else if (control == _energyMin)
{
emitter->setEnergy(_energyMin->getValue(), emitter->getEnergyMax());
}
else if (control == _energyMax)
{
emitter->setEnergy(emitter->getEnergyMin(), _energyMax->getValue());
}
else if (control == _emissionRate)
{
emitter->setEmissionRate(_emissionRate->getValue());
}
else if (id == "posX")
{
Vector3 pos(emitter->getPosition());
pos.x = ((Slider*)control)->getValue();
emitter->setPosition(pos, emitter->getPositionVariance());
}
else if (id == "posY")
{
Vector3 pos(emitter->getPosition());
pos.y = ((Slider*)control)->getValue();
emitter->setPosition(pos, emitter->getPositionVariance());
}
else if (id == "posZ")
{
Vector3 pos(emitter->getPosition());
//.........这里部分代码省略.........
示例7: update
void DustPool::update(float gspeed)
{
gspeed=fabs(gspeed);
for (int i=0; i<allocated; i++)
{
ParticleEmitter *emit = pss[i]->getEmitter(0);
Vector3 ndir = velocities[i];
Real vel = ndir.length();
ColourValue col = colours[i];
if (vel == 0)
vel += 0.0001;
ndir = ndir / vel;
emit->setEnabled(true);
if (types[i] != DUST_RIPPLE)
{
emit->setDirection(ndir);
emit->setParticleVelocity(vel);
sns[i]->setPosition(positions[i]);
}
if (types[i]==DUST_NORMAL)
{
ndir.y=0;
ndir=ndir/2.0;
col.a=(vel+(gspeed/10.0))*0.05;
emit->setTimeToLive((vel+(gspeed/10.0))*0.05/0.1);
}
else if (types[i]==DUST_CLUMP)
{
ndir=ndir/2.0;
if (ndir.y<0) ndir.y=-ndir.y;
col.a=1.0;
}
else if (types[i]==DUST_RUBBER)
{
ndir.y=0;
ndir=ndir/4.0;
col.a = vel*0.05;
col.b = 0.9;
col.g = 0.9;
col.r = 0.9;
emit->setTimeToLive(vel*0.05/0.1);
}
else if (types[i]==DUST_SPARKS)
{
//ugh
}
else if (types[i]==DUST_VAPOUR)
{
emit->setParticleVelocity(vel/2.0);
col.a = rates[i] * 0.03;
col.b = 0.9;
col.g = 0.9;
col.r = 0.9;
emit->setTimeToLive(rates[i]*0.03/0.1);
}
else if (types[i]==DUST_DRIP)
{
emit->setEmissionRate(rates[i]);
}
else if (types[i]==DUST_SPLASH)
{
if (ndir.y<0)
ndir.y=-ndir.y/2.0;
emit->setDirection(ndir);
col.a = vel*0.05;
col.b = 0.9;
col.g = 0.9;
col.r = 0.9;
emit->setTimeToLive(vel*0.05/0.1);
}
else if (types[i]==DUST_RIPPLE)
{
positions[i].y = gEnv->terrainManager->getWater()->getHeight() - 0.02;
sns[i]->setPosition(positions[i]);
col.a = vel*0.04;
col.b = 0.9;
col.g = 0.9;
col.r = 0.9;
emit->setTimeToLive(vel*0.04/0.1);
}
emit->setColour(col);
}
for (int i=allocated; i<size; i++)
//.........这里部分代码省略.........