本文整理汇总了C++中ParticleEmitter::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::setPosition方法的具体用法?C++ ParticleEmitter::setPosition怎么用?C++ ParticleEmitter::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter::setPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTerrain
/** If necessary defines a new particle type for the terrain emitter. Then
* adjusts the location of the terrain emitter to be in synch with the
* current wheel position, and defines the emission rate depending on speed,
* steering, and skidding.
* \param pk Particle type to use.
*/
void KartGFX::updateTerrain(const ParticleKind *pk)
{
ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
if(!pe) return;
pe->setParticleType(pk);
const btWheelInfo &wi = m_kart->getVehicle()
->getWheelInfo(2+m_wheel_toggle);
Vec3 xyz = wi.m_raycastInfo.m_contactPointWS;
// FIXME: the X and Z position is not always accurate.
xyz.setX(xyz.getX()+ 0.06f * (m_wheel_toggle ? +1 : -1));
xyz.setZ(xyz.getZ()+0.06f);
pe->setPosition(xyz);
// Now compute the particle creation rate:
float rate = 0;
const float speed = fabsf(m_kart->getSpeed());
const float skidding = m_kart->getSkidding()->getSkidFactor();
// Only create particles when the kart is actually on ground
bool on_ground = m_kart->isOnGround() &&
m_kart->getSkidding()->getGraphicalJumpOffset()==0;
if (skidding > 1.0f && on_ground)
rate = fabsf(m_kart->getControls().m_steer) > 0.8 ? skidding - 1 : 0;
else if (speed >= 0.5f && on_ground)
rate = speed/m_kart->getKartProperties()->getMaxSpeed();
else
{
pe->setCreationRateAbsolute(0);
return;
}
// m_skidding can be > 2, and speed > maxSpeed (if powerups are used).
if(rate>1.0f) rate = 1.0f;
pe->setCreationRateRelative(rate);
} // updateTerrain
示例2: setXYZ
/** Defines the new position of the specified emitter.
* \param type The emitter to set a new position for.
* \param xyz The new position of the emitter.
*/
void KartGFX::setXYZ(const KartGFXType type, const Vec3 &xyz)
{
#ifndef SERVER_ONLY
ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
if(!pe) return;
pe->setPosition(xyz);
#endif
} // setXYZ
示例3: 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);
}
}
示例4: _applyMotion
void ParticleSystem::_applyMotion(Real timeElapsed)
{
ActiveParticleList::iterator i, itEnd;
Particle* pParticle;
ParticleEmitter* pParticleEmitter;
itEnd = mActiveParticles.end();
for (i = mActiveParticles.begin(); i != itEnd; ++i)
{
pParticle = static_cast<Particle*>(*i);
pParticle->position += (pParticle->direction * timeElapsed);
if (pParticle->particleType == Particle::Emitter)
{
// If it is an emitter, the emitter position must also be updated
// Note, that position of the emitter becomes a position in worldspace if mLocalSpace is set
// to false (will this become a problem?)
pParticleEmitter = static_cast<ParticleEmitter*>(*i);
pParticleEmitter->setPosition(pParticle->position);
}
}
// Notify renderer
mRenderer->_notifyParticleMoved(mActiveParticles);
}
示例5: setXYZ
/** Defines the new position of the specified emitter.
* \param type The emitter to set a new position for.
* \param xyz The new position of the emitter.
*/
void KartGFX::setXYZ(const KartGFXType type, const Vec3 &xyz)
{
ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
if(!pe) return;
pe->setPosition(xyz);
} // setXYZ
示例6: create
//.........这里部分代码省略.........
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);
emitter->setColor(colorStart, colorStartVar, colorEnd, colorEndVar);
emitter->setPosition(position, positionVar);
emitter->setVelocity(velocity, velocityVar);
emitter->setAcceleration(acceleration, accelerationVar);
emitter->setRotationPerParticle(rotationPerParticleSpeedMin, rotationPerParticleSpeedMax);
emitter->setRotation(rotationSpeedMin, rotationSpeedMax, rotationAxis, rotationAxisVar);
emitter->setSpriteAnimated(spriteAnimated);
emitter->setSpriteLooped(spriteLooped);
emitter->setSpriteFrameRandomOffset(spriteFrameRandomOffset);
emitter->setSpriteFrameDuration(spriteFrameDuration);
emitter->setSpriteFrameCoords(spriteFrameCount, spriteWidth, spriteHeight);
emitter->setOrbit(orbitPosition, orbitVelocity, orbitAcceleration);
return emitter;
}
示例7: _executeTriggerEmitters
void ParticleSystem::_executeTriggerEmitters(ParticleEmitter* emitter, unsigned requested, Real timeElapsed)
{
ParticleAffectorList::iterator itAff, itAffEnd;
Real timePoint = 0.0f;
// avoid any divide by zero conditions
if (!requested)
{
return;
}
Real timeInc = timeElapsed / requested;
for (unsigned int j = 0; j < requested; ++j)
{
// Create a new particle & init using emitter
// The particle is a visual particle if the emit_emitter property of the emitter isn't set
Particle* p = 0;
String emitterName = emitter->getEmittedEmitter();
if (emitterName == "")
{
p = createParticle();
}
else
{
p = createEmitterParticle(emitterName);
}
// Only continue if the particle was really created (not null)
if (!p)
{
return;
}
emitter->_initParticle(p);
// apply partial frame motion to this particle
p->position += (p->direction * timePoint);
// apply particle initialization by the affectors
itAffEnd = mAffectors.end();
for (itAff = mAffectors.begin(); itAff != itAffEnd; ++itAff)
{
(*itAff)->_initParticle(p);
}
// Increment time fragment
timePoint += timeInc;
if (p->particleType == Particle::Emitter)
{
// If the particle is an emitter, the position on the emitter side must also be initialised
// Note, that position of the emitter becomes a position in worldspace if mLocalSpace is set
// to false (will this become a problem?)
ParticleEmitter* pParticleEmitter = static_cast<ParticleEmitter*>(p);
pParticleEmitter->setPosition(p->position);
}
// Notify renderer
mRenderer->_notifyParticleEmitted(p);
}
}
示例8: Update
//-------------------------------------------------------------------------------------------------------
// Update
//-------------------------------------------------------------------------------------------------------
void CarModel::Update(PosInfo& posInfo, PosInfo& posInfoCam, float time)
{
pReflect->camPosition = pMainNode->getPosition();
int w,i;
// upd chk mtr
if (bChkUpd && entNextChk)
{
MaterialPtr mtr = MaterialManager::getSingleton().getByName(sChkMtr);
if (!mtr.isNull())
entNextChk->setMaterial(mtr);
}
// stop/resume par sys
float fa = pGame->pause ? 0.f : 1.f;
for (w=0; w < numWheels; ++w)
{
for (i=0; i < PAR_ALL; ++i)
if (par[i][w]) par[i][w]->setSpeedFactor(fa);
if (w < PAR_BOOST && parBoost[w]) parBoost[w]->setSpeedFactor(fa);
if (parHit) parHit->setSpeedFactor(fa);
}
for (w=0; w < PAR_THRUST*2; ++w)
if (parThrust[w]) parThrust[w]->setSpeedFactor(fa);
if (!posInfo.bNew) return; // new only ?
posInfo.bNew = false;
/// dont get anything from pCar or car.dynamics here
/// all must be read from posInfo (it is filled from vdrift car or from replay)
if (!pMainNode) return;
// set car pos and rot
pMainNode->setPosition(posInfo.pos);
if (vtype == V_Sphere)
pMainNode->setOrientation(Quaternion(Quaternion(Degree(-posInfo.hov_roll),Vector3::UNIT_Y)));
else
if (vtype == V_Spaceship) // roll vis only
pMainNode->setOrientation(posInfo.rot * Quaternion(Degree(posInfo.hov_roll),Vector3::UNIT_X));
else
pMainNode->setOrientation(posInfo.rot);
///() grass sphere pos
Vector3 vx(1,0,0); // car x dir
vx = posInfo.rot * vx * 1.1; //par
posSph[0] = posInfo.pos + vx; posSph[0].y += 0.5f;
posSph[1] = posInfo.pos - vx; posSph[1].y += 0.5f;
if (ndSph) // sph test
{ ndSph->setPosition(posSph[0]);
ndSph->setScale(Vector3::UNIT_SCALE * 1.7 *2/0.6f); //par
}
// set camera view
if (fCam)
{ fCam->Apply(posInfoCam);
///~~ camera in fluid fog, detect and compute
iCamFluid = -1; fCamFl = 0.f; // none
const size_t sf = sc->fluids.size();
if (sf > 0 && pSet->game.local_players == 1)
{
const Vector3& p = posInfo.camPos;
const float r = 0.2f; //par, near cam?
// check if any fluid box overlaps camera pos sphere
bool srch = true; size_t f = 0;
while (srch && f < sf)
{
const FluidBox& fb = sc->fluids[f];
const Vector3& fp = fb.pos;
Vector3 fs = fb.size; fs.x *= 0.5f; fs.z *= 0.5f;
bool inFl = // p +r -fs fp +fs -r p
p.y +r > fp.y - fs.y && p.y -r < fp.y &&
p.x +r > fp.x - fs.x && p.x -r < fp.x + fs.x &&
p.z +r > fp.z - fs.z && p.z -r < fp.z + fs.z;
if (inFl) // 1st only
{ iCamFluid = f; fCamFl = std::min(1.f, std::max(0.f, fp.y - p.y)) * 3.f;
srch = false; }
++f;
}
} }
// upd rotY for minimap
if (vtype == V_Sphere)
angCarY = posInfo.hov_roll * 180.f / PI_d + 180.f;
else
{ Quaternion q = posInfo.rot * Quaternion(Degree(90),Vector3(0,1,0));
angCarY = q.getYaw().valueDegrees() + 90.f;
}
// brake state
#ifndef CAR_PRV
bool braking = posInfo.braking > 0;
if (bBraking != braking)
//.........这里部分代码省略.........
示例9: 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());
//.........这里部分代码省略.........