float LifeCycleParticleLayer::getIntensity(ParticleStorage::Particle *p) { float t = time - getBirthDate(p); if (t < fadeInDelay) { return t / fadeInDelay; } else { t -= fadeInDelay; if (t < activeDelay) { return 1.0f; } else { t -= activeDelay; return max(0.0f, 1.0f - t / fadeOutDelay); } } }
void LifeCycleParticleLayer::removeOldParticles() { // all particles with a birth date less than minBirthDate must be deleted float minBirthDate = time - (fadeInDelay + activeDelay + fadeOutDelay); ptr<ParticleStorage> s = getOwner()->getStorage(); vector<ParticleStorage::Particle*>::iterator i = s->getParticles(); vector<ParticleStorage::Particle*>::iterator end = s->end(); while (i != end) { ParticleStorage::Particle *p = *i; if (getBirthDate(p) <= minBirthDate) { s->deleteParticle(p); } ++i; } }
bool LifeCycleParticleLayer::isFadingOut(ParticleStorage::Particle *p) { float age = time - getBirthDate(p); return age >= fadeInDelay + activeDelay; }
bool LifeCycleParticleLayer::isFadingIn(ParticleStorage::Particle *p) { float age = time - getBirthDate(p); return age < fadeInDelay; }
// print Employee's information (virtual, but not pure virtual) void Employee::print() const { cout << getFirstName() << " " << getLastName() << "\nsocial security number: " << getSocialSecurityNumber() << "\nbirthday: " << getBirthDate(); }