本文整理汇总了C++中ParticleEmitter::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::setEnabled方法的具体用法?C++ ParticleEmitter::setEnabled怎么用?C++ ParticleEmitter::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter::setEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateVisuals
void Turboprop::updateVisuals(RoR::GfxActor* gfx_actor)
{
RoR::GfxActor::NodeData* node_buf = gfx_actor->GetSimNodeBuffer();
//smoke
if (smokeNode)
{
smokeNode->setPosition(node_buf[nodeback].AbsPosition);
ParticleEmitter* emit = smokePS->getEmitter(0);
Vector3 dir = node_buf[nodeback].AbsPosition - node_buf[noderef].AbsPosition;
emit->setDirection(dir);
emit->setParticleVelocity(propwash - propwash / 10, propwash + propwash / 10);
if (!failed)
{
if (ignition)
{
emit->setEnabled(true);
emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.03 + throtle * 0.05));
emit->setTimeToLive((0.03 + throtle * 0.05) / 0.1);
}
else
{
emit->setEnabled(false);
}
}
else
{
emit->setDirection(Vector3(0, 1, 0));
emit->setParticleVelocity(5, 9);
emit->setEnabled(true);
emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.1));
emit->setTimeToLive(0.1 / 0.1);
}
}
#ifdef USE_ANGELSCRIPT
if (failed != failedold)
{
TRIGGER_EVENT(SE_TRUCK_ENGINE_FIRE, trucknum);
failedold = failed;
}
#endif
}
示例2: increaseEmittedEmitterPool
void ParticleSystem::increaseEmittedEmitterPool(size_t size)
{
// Don't proceed if the pool doesn't contain any keys of emitted emitters
if (mEmittedEmitterPool.empty())
{
return;
}
EmittedEmitterPool::iterator emittedEmitterPoolIterator;
ParticleEmitterList::iterator emitterIterator;
ParticleEmitter* emitter = 0;
ParticleEmitter* clonedEmitter = 0;
String name = BLANK;
EmittedEmitterList* e = 0;
size_t maxNumberOfEmitters = size / mEmittedEmitterPool.size(); // equally distribute the number for each emitted emitter list
size_t oldSize = 0;
// Run through mEmittedEmitterPool and search for every key (=name) its corresponding emitter in mEmitters
for (emittedEmitterPoolIterator = mEmittedEmitterPool.begin(); emittedEmitterPoolIterator != mEmittedEmitterPool.end();
++emittedEmitterPoolIterator)
{
name = emittedEmitterPoolIterator->first;
e = &emittedEmitterPoolIterator->second;
// Search the correct emitter in the mEmitters vector
emitter = 0;
for (emitterIterator = mEmitters.begin(); emitterIterator != mEmitters.end(); ++emitterIterator)
{
emitter = *emitterIterator;
if (emitter && name != "" && name == emitter->getName())
{
// Found the right emitter, clone each emitter a number of times
oldSize = e->size();
for (size_t t = oldSize; t < maxNumberOfEmitters; ++t)
{
clonedEmitter = ParticleSystemManager::getSingleton()._createEmitter(emitter->getType(), this);
emitter->copyParametersTo(clonedEmitter);
clonedEmitter->setEmitted(emitter->isEmitted()); // is always 'true' by the way, but just in case
// Initially deactivate the emitted emitter if duration/repeat_delay are set
if (clonedEmitter->getDuration() > 0.0f && (clonedEmitter->getRepeatDelay() > 0.0f
|| clonedEmitter->getMinRepeatDelay() > 0.0f || clonedEmitter->getMinRepeatDelay() > 0.0f))
{
clonedEmitter->setEnabled(false);
}
// Add cloned emitters to the pool
e->push_back(clonedEmitter);
}
}
}
}
}
示例3: stopFade
//-----------------------------------------------------------------------
void ParticleSystem::stopFade(void)
{
size_t i;
size_t j;
size_t numTechniques = getNumTechniques();
size_t numEmitters;
ParticleTechnique* technique;
ParticleEmitter* emitter;
for (i = 0; i < numTechniques; ++i)
{
technique = getTechnique(i);
numEmitters = getTechnique(i)->getNumEmitters();
for (j = 0; j < numEmitters; ++j)
{
emitter = technique->getEmitter(j);
emitter->setEnabled(false);
}
}
mStopFadeSet = true;
}
示例4: update
void WeaponTower::update( Crawler *closestEnemy, float dist , float dt, TowerGameApp *game )
{
if (m_type == Type_NODULE)
{
// nodules dont do anything
return;
}
// don't update if out of range or no bug
ParticleEmitter *emitter = m_psys->getEmitter( 0 );
if ((dist > m_sensorRange) || (!closestEnemy))
{
emitter->setEnabled( false );
return;
}
// turn on the juice
emitter->setEnabled( true );
// aim at the bug
Vector3 myPos = m_platform->getPosition();
Vector3 crawlerPos = closestEnemy->getNode()->getPosition();
Vector3 dir = crawlerPos - myPos;
dir.y = 0.0;
dir.normalise();
//Radian targetHeading = Ogre::Math::ATan2( dir.x, dir.z );
//m_bracket->yaw( targetHeading );
m_bracket->setDirection( dir, Ogre::Node::TS_WORLD );
dir = crawlerPos - (myPos + Vector3( 0.0, 7.0, 0.0));
//float adj = sqrt((dir.x * dir.x) + ( dir.z * dir.z));
//Radian angle = Ogre::Math::ATan2( dir.y, adj );
//m_gun->pitch( angle, Ogre::Node::TS_LOCAL);
m_gun->setDirection( dir, Ogre::Node::TS_WORLD );
//game->mFrameListener->mDebugText = " blarg blarg";
// Ok.. now actually apply damage
if (m_timeout < 0.001)
{
#if 0
Ray shooty( m_gun->getWorldPosition(),
m_gun->getWorldOrientation().zAxis() );
RaySceneQuery *rayQuery = m_sceneMgr ->createRayQuery( shooty );
rayQuery->setQueryMask( MASK_CRAWLER );
RaySceneQueryResult &result = rayQuery->execute();
RaySceneQueryResult::iterator itr = result.begin();
/// did we hit a crawler
game->mFrameListener->mDebugText = String("Hit Test: ");
if (itr != result.end() && ( itr->movable))
{
game->mFrameListener->mDebugText += String(" movable: ") + itr->movable->getName();
SceneNode *node = itr->movable->getParentSceneNode();
if (node)
{
game->mFrameListener->mDebugText += node->getName();
// did we hit a crawler??
for (std::vector<Crawler*>::iterator ci = game->m_crawlers.begin();
ci != game->m_crawlers.end(); ++ci )
{
if ( (*ci)->getNode() == node )
{
// hit!
(*ci)->m_health -= m_damage;
}
}
}
}
m_sceneMgr->destroyQuery(rayQuery);
#endif
// forget all of that nonsense... just hit the
// closest crawler
if (m_type == Type_FLAMETHROWER)
{
// TODO: should be all enemies within range
closestEnemy->m_health -= m_damage * dt;
}
else
{
closestEnemy->m_health -= m_damage;
}
// reset timeout
m_timeout = m_reloadTime;
}
else
{
// wait to 'recharge'
m_timeout -= dt;
}
//.........这里部分代码省略.........
示例5: updateVisuals
void Turbojet::updateVisuals()
{
//nozzle
nzsnode->setPosition(nodes[nodeback].AbsPosition);
//build a local system
Vector3 laxis = nodes[nodefront].RelPosition - nodes[nodeback].RelPosition;
laxis.normalise();
Vector3 paxis = Plane(laxis, 0).projectVector(nodes[noderef].RelPosition - nodes[nodeback].RelPosition);
paxis.normalise();
Vector3 taxis = laxis.crossProduct(paxis);
Quaternion dir = Quaternion(laxis, paxis, taxis);
nzsnode->setOrientation(dir);
//afterburner
if (afterburner)
{
absnode->setVisible(true);
float flamelength = (afterburnthrust / 15.0) * (rpm / 100.0);
flamelength = flamelength * (1.0 + (((Real)rand() / (Real)RAND_MAX) - 0.5) / 10.0);
absnode->setScale(flamelength, radius * 2.0, radius * 2.0);
absnode->setPosition(nodes[nodeback].AbsPosition + dir * Vector3(-0.2, 0.0, 0.0));
absnode->setOrientation(dir);
}
else
absnode->setVisible(false);
//smoke
if (smokeNode)
{
smokeNode->setPosition(nodes[nodeback].AbsPosition);
ParticleEmitter* emit = smokePS->getEmitter(0);
ParticleEmitter* hemit = 0;
if (heathazePS)
hemit = heathazePS->getEmitter(0);
emit->setDirection(-axis);
emit->setParticleVelocity(exhaust_velocity);
if (hemit)
{
hemit->setDirection(-axis);
hemit->setParticleVelocity(exhaust_velocity);
}
if (!failed)
{
if (ignition)
{
emit->setEnabled(true);
emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.02 + throtle * 0.03));
emit->setTimeToLive((0.02 + throtle * 0.03) / 0.1);
if (hemit)
{
hemit->setEnabled(true);
hemit->setTimeToLive((0.02 + throtle * 0.03) / 0.1);
}
}
else
{
emit->setEnabled(false);
if (hemit)
hemit->setEnabled(false);
}
}
else
{
emit->setDirection(Vector3(0, 1, 0));
emit->setParticleVelocity(7.0);
emit->setEnabled(true);
emit->setColour(ColourValue(0.0, 0.0, 0.0, 0.1));
emit->setTimeToLive(0.1 / 0.1);
if (hemit)
{
hemit->setDirection(Vector3(0, 1, 0));
hemit->setParticleVelocity(7.0);
hemit->setEnabled(true);
hemit->setTimeToLive(0.1 / 0.1);
}
}
}
}
示例6: 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++)
//.........这里部分代码省略.........
示例7: _handle
//-----------------------------------------------------------------------
void DoEnableComponentEventHandler::_handle (ParticleTechnique* particleTechnique, Particle* particle, Real timeElapsed)
{
/** Search for the component.
*/
ParticleTechnique* technique = 0;
switch (mComponentType)
{
case CT_EMITTER:
{
ParticleEmitter* emitter = particleTechnique->getEmitter(mComponentName);
if (!emitter)
{
// Search all techniques in this ParticleSystem for an emitter with the correct name
ParticleSystem* system = particleTechnique->getParentSystem();
size_t size = system->getNumTechniques();
for(size_t i = 0; i < size; ++i)
{
technique = system->getTechnique(i);
emitter = technique->getEmitter(mComponentName);
if (emitter)
{
break;
}
}
}
if (emitter)
{
emitter->setEnabled(mComponentEnabled);
}
}
break;
case CT_AFFECTOR:
{
ParticleAffector* affector = particleTechnique->getAffector(mComponentName);
if (!affector)
{
// Search all techniques in this ParticleSystem for an affector with the correct name
ParticleSystem* system = particleTechnique->getParentSystem();
size_t size = system->getNumTechniques();
for(size_t i = 0; i < size; ++i)
{
technique = system->getTechnique(i);
affector = technique->getAffector(mComponentName);
if (affector)
{
break;
}
}
}
if (affector)
{
affector->setEnabled(mComponentEnabled);
}
}
break;
case CT_OBSERVER:
{
ParticleObserver* observer = particleTechnique->getObserver(mComponentName);
if (!observer)
{
// Search all techniques in this ParticleSystem for an observer with the correct name
ParticleSystem* system = particleTechnique->getParentSystem();
size_t size = system->getNumTechniques();
for(size_t i = 0; i < size; ++i)
{
technique = system->getTechnique(i);
observer = technique->getObserver(mComponentName);
if (observer)
{
break;
}
}
}
if (observer)
{
observer->setEnabled(mComponentEnabled);
}
}
break;
case CT_TECHNIQUE:
{
// Search in this ParticleSystem for a technique with the correct name
ParticleSystem* system = particleTechnique->getParentSystem();
technique = system->getTechnique(mComponentName);
if (technique)
{
technique->setEnabled(mComponentEnabled);
}
}
break;
}
}