| 196 | } |
| 197 | |
| 198 | void render () |
| 199 | { |
| 200 | // Draw simulation model |
| 201 | |
| 202 | const ParticleData &pd = model.getParticles(); |
| 203 | const unsigned int nParticles = pd.size(); |
| 204 | |
| 205 | float surfaceColor[4] = { 0.2f, 0.6f, 0.8f, 1 }; |
| 206 | float speccolor[4] = { 1.0, 1.0, 1.0, 1.0 }; |
| 207 | glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, surfaceColor); |
| 208 | glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, surfaceColor); |
| 209 | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, speccolor); |
| 210 | glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 100.0); |
| 211 | glColor3fv(surfaceColor); |
| 212 | |
| 213 | glPointSize(4.0); |
| 214 | |
| 215 | const Real supportRadius = model.getSupportRadius(); |
| 216 | Real vmax = static_cast<Real>(0.4*2.0)*supportRadius / TimeManager::getCurrent()->getTimeStepSize(); |
| 217 | Real vmin = 0.0; |
| 218 | |
| 219 | if (context_major_version > 3) |
| 220 | { |
| 221 | for (unsigned int i = 0; i < nParticles; i++) |
| 222 | { |
| 223 | Real v = pd.getVelocity(i).norm(); |
| 224 | v = static_cast<Real>(0.5)*((v - vmin) / (vmax - vmin)); |
| 225 | v = min(static_cast<Real>(128.0)*v*v, static_cast<Real>(0.5)); |
| 226 | float fluidColor[4] = { 0.2f, 0.2f, 0.2f, 1.0 }; |
| 227 | MiniGL::hsvToRgb(0.55f, 1.0f, 0.5f + (float)v, fluidColor); |
| 228 | renderSphere(pd.getPosition(i), fluidColor); |
| 229 | } |
| 230 | |
| 231 | // for (unsigned int i = 0; i < model.numBoundaryParticles(); i++) |
| 232 | // renderSphere(model.getBoundaryX(i), surfaceColor); |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | glDisable(GL_LIGHTING); |
| 237 | glBegin(GL_POINTS); |
| 238 | for (unsigned int i = 0; i < nParticles; i++) |
| 239 | { |
| 240 | Real v = pd.getVelocity(i).norm(); |
| 241 | v = static_cast<Real>(0.5)*((v - vmin) / (vmax - vmin)); |
| 242 | v = min(static_cast<Real>(128.0)*v*v, static_cast<Real>(0.5)); |
| 243 | float fluidColor[4] = { 0.2f, 0.2f, 0.2f, 1.0 }; |
| 244 | MiniGL::hsvToRgb(0.55f, 1.0f, 0.5f + (float)v, fluidColor); |
| 245 | |
| 246 | glColor3fv(fluidColor); |
| 247 | glVertex3v(&pd.getPosition(i)[0]); |
| 248 | } |
| 249 | glEnd(); |
| 250 | |
| 251 | // glBegin(GL_POINTS); |
| 252 | // for (unsigned int i = 0; i < model.numBoundaryParticles(); i++) |
| 253 | // { |
| 254 | // glColor3fv(surfaceColor); |
| 255 | // glVertex3fv(&model.getBoundaryX(i)[0]); |
nothing calls this directly
no test coverage detected