void setColoursByAcceleration() { int i; particle_t *p, *plast; particleDetail_t *pd; float d; float accMax = 0; float accCurrent; float velSpeed1; float velSpeed2; VectorNew(zero); VectorZero(zero); if (state.currentFrame == 0) return; for (i = 0; i < state.particleCount; i++) { p = getParticleCurrentFrame(i); plast = state.particleHistory + state.particleCount * (state.currentFrame-1) + i; distance(zero, p->vel, velSpeed1); distance(p->vel, plast->vel, velSpeed2); accCurrent = abs(velSpeed2 - velSpeed1); if (i == 0) { accMax = accCurrent; } else { if (accCurrent > accMax) accMax = accCurrent; } } for (i = 0; i < state.particleCount; i++) { p = getParticleCurrentFrame(i); plast = state.particleHistory + state.particleCount * (state.currentFrame-1) + i; distance(zero, p->vel, velSpeed1); distance(p->vel, plast->vel, velSpeed2); accCurrent = velSpeed2 - velSpeed1; pd = getParticleDetail(i); d = accCurrent / accMax; colourFromNormal(pd->col, (float)fabs((double)d)); pd->particleSprite = colourSprite(pd->col, pd->mass); } }
void setColoursByKinetic() { int i; particle_t *p; particleDetail_t *pd; float d; float kinMax = 0; float kinValue; float velocity; VectorNew(zero); VectorZero(zero); for (i = 0; i < state.particleCount; i++) { p = getParticleCurrentFrame(i); pd = getParticleDetail(i); distance(zero, p->vel, velocity); velocity = fabs(velocity); kinValue = velocity * velocity * pd->mass * 0.5; if (i == 0) { kinMax = kinValue; } else { if (kinValue > kinMax) kinMax = kinValue; } } for (i = 0; i < state.particleCount; i++) { p = getParticleFirstFrame(i); pd = getParticleDetail(i); distance(zero, p->vel, velocity); kinValue = velocity * velocity * pd->mass * 0.5; d = kinValue / kinMax; colourFromNormal(pd->col, (float)fabs((double)d)); pd->particleSprite = colourSprite(pd->col, pd->mass); } }
void setColoursByMass() { int i; particle_t *p; particleDetail_t *pd; float d; for (i = 0; i < state.particleCount; i++) { p = getParticleCurrentFrame(i); pd = getParticleDetail(i); if (i == 0) { state.massRange[0] = pd->mass; state.massRange[1] = pd->mass; } else { if (pd->mass < state.massRange[0]) state.massRange[0] = pd->mass; if (pd->mass > state.massRange[1]) state.massRange[1] = pd->mass; } } for (i = 0; i < state.particleCount; i++) { p = getParticleCurrentFrame(i); pd = getParticleDetail(i); d = pd->mass / state.massRange[1]; colourFromNormal(pd->col, (float)fabs(d)); if (d < 0) { pd->col[0] = 1 - pd->col[0]; pd->col[1] = 1 - pd->col[1]; pd->col[2] = 1 - pd->col[2]; } pd->particleSprite = colourSprite(pd->col, pd->mass); } }
void setColoursByVel() { int i; particle_t *p; particleDetail_t *pd; float d; float velMax = 0; float velSpeed; VectorNew(zero); VectorZero(zero); // works out the highest velocity for (i = 0; i < state.particleCount; i++) { p = getParticleCurrentFrame(i); distance(zero, p->vel, velSpeed); velSpeed = fabs(velSpeed); if (i == 0) { velMax = velSpeed; } else { if (velSpeed > velMax) velMax = velSpeed; } } // applies velocity based on the highest for (i = 0; i < state.particleCount; i++) { p = getParticleFirstFrame(i); pd = getParticleDetail(i); distance(zero, p->vel, velSpeed); d = velSpeed / velMax; colourFromNormal(pd->col, (float)fabs((double)d)); pd->particleSprite = colourSprite(pd->col, pd->mass); } }
void drawRGB() { float width = 5; float margin = 5; float i; float sx = (float)video.screenW - width - margin; #ifndef WITHOUT_AGAR float sy = 70 + margin; #else float sy = margin; #endif float wx = width; float wy = 200; float c[4]; float step = .01f; if (view.screenSaver) sy = margin; drawFrameSet2D(); glEnable(GL_BLEND); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBindTexture(GL_TEXTURE_2D, 0); // positive for (i = 0; i < 1; i += step) { colourFromNormal(c, i); glBegin(GL_QUADS); glColor4fv(c); glVertex2f(sx, sy + wy * i); glVertex2f(sx + wx, sy + wy * i); glVertex2f(sx + wx, sy + wy * (i + step)); glVertex2f(sx, sy + wy * (i + step)); glEnd(); } glColor3f(0.5f,0.5f,0.5f); glLineWidth(1.0f); glDisable(GL_LINE_SMOOTH); glBegin(GL_LINE_STRIP); glVertex2f(sx-1, sy-1); glVertex2f(sx+1 + wx, sy-1); glVertex2f(sx+1 + wx, sy+2 + wy); glVertex2f(sx-1, sy+2 + wy); glVertex2f(sx-1, sy-1); glEnd(); glEnable(GL_LINE_SMOOTH); // negative if (1) { sx -= margin * 1.5; for (i = 0; i < 1; i+=step) { colourFromNormal(c, i); c[0] = 1 - c[0]; c[1] = 1 - c[1]; c[2] = 1 - c[2]; glBegin(GL_QUADS); glColor4fv(c); glVertex2f(sx, sy + wy * i); glVertex2f(sx + wx, sy + wy * i); glVertex2f(sx + wx, sy + wy * (i + step)); glVertex2f(sx, sy + wy * (i + step)); glEnd(); } glColor3f(0.5f,0.5f,0.5f); glLineWidth(1.0f); glDisable(GL_LINE_SMOOTH); glBegin(GL_LINE_STRIP); glVertex2f(sx-1, sy-1); glVertex2f(sx+1 + wx, sy-1); glVertex2f(sx+1 + wx, sy+2 + wy); glVertex2f(sx-1, sy+2 + wy); glVertex2f(sx-1, sy-1); glEnd(); glEnable(GL_LINE_SMOOTH); } }