/** 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
/** Sets a new particle type to be used. Note that the memory of this * kind must be managed by the caller. * \param type The emitter type for which to set the new particle type. * \param pk The particle kind to use. */ void KartGFX::setParticleKind(const KartGFXType type, const ParticleKind *pk) { ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN]; if(!pe) return; pe->setParticleType(pk); } // setParticleKind
/** Sets a new particle type to be used. Note that the memory of this * kind must be managed by the caller. * \param type The emitter type for which to set the new particle type. * \param pk The particle kind to use. */ void KartGFX::setParticleKind(const KartGFXType type, const ParticleKind *pk) { #ifndef SERVER_ONLY ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN]; if(!pe) return; pe->setParticleType(pk); #endif } // setParticleKind