Color ParticleSystem::getColorProgression(Color a, Color b, float progression) { Color color; color.r = getProgression(a.r, b.r, progression); color.g = getProgression(a.g, b.g, progression); color.b = getProgression(a.b, b.b, progression); color.a = getProgression(a.a, b.a, progression); return color; }
void ParticleSystem::updateParticles(UpdateInfo info) { // Update particles for (std::list<Particle>::iterator it = particles.begin(); it != particles.end();) { Particle &particle = (*it); Vertex * vertices = &(*vertexSource)[particle.vertexOffset]; float radius; float a, b, c, d; // Update particle age particle.age += info.updateInterval; // Update color and size progression if (particle.age < particle.grow) { float progression = particle.age / particle.grow; particle.color = getColorProgression(color[0], color[1], progression); particle.size = getProgression(particle.templateSize[0], particle.templateSize[1], progression); } else if (particle.age > particle.duration - shrink) { float progression = (particle.age - (particle.duration - particle.shrink)) / particle.shrink; particle.color = getColorProgression(color[1], color[2], progression); particle.size = getProgression(particle.templateSize[1], particle.templateSize[2], progression); } vertices[0].color = particle.color; vertices[1].color = particle.color; vertices[2].color = particle.color; vertices[3].color = particle.color; // Update particle position particle.position += (systemSpeed * 0.25f + particle.speed) * (info.updateInterval / 1000.0f); // Update particle visual radius = particle.size / 2; a = particle.position.x + radius; b = particle.position.x - radius; c = particle.position.y + radius; d = particle.position.y - radius; vertices[0].position = Vector2f(a, c); vertices[1].position = Vector2f(b, c); vertices[2].position = Vector2f(b, d); vertices[3].position = Vector2f(a, d); // Increment iterator it++; } }
MThreadRetVal tProgressBar(void *data) { MStatus status=MS::kSuccess; if(!MProgressWindow::reserve()) { MGlobal::displayError("Progress window already in use"); stopSim(); return (MThreadRetVal)-1; } // Set up and print progress window state MProgressWindow::setProgressRange(PROGRESSBARMINVALUE, PROGRESSBARMAXVALUE); MProgressWindow::setTitle("Boids Progress"); MProgressWindow::setInterruptable(true); MProgressWindow::setProgressStatus("Simulation Progress"); MProgressWindow::setProgress(PROGRESSBARMINVALUE); MProgressWindow::startProgress(); while((MProgressWindow::progress()<PROGRESSBARMAXVALUE)&&(!MProgressWindow::isCancelled())) { int prog=getProgression(); int progV=MProgressWindow::progress(); while(prog>=progV+PROGRESSBARADVANCEVALUE) { MProgressWindow::advanceProgress(PROGRESSBARADVANCEVALUE); progV+=PROGRESSBARADVANCEVALUE; } if(progV>=PROGRESSBARMAXVALUE) MProgressWindow::setProgress(PROGRESSBARMAXVALUE); Sleep(PROGRESSBARSLEEPTIME); } if (MProgressWindow::isCancelled()) { MGlobal::displayInfo("Progress interrupted!"); stopSim(); } return (MThreadRetVal)0; }
int Direction::getPosition() { return getProgression(); }
void ScoreDigit::show() { m_texture->show(m_position, engine::Vector3d(), engine::graphics::ColorRGBA(255, 255, 255, 255 - (float) 255 * getProgression())); }