| 352 | } |
| 353 | |
| 354 | void DemoBase::render() |
| 355 | { |
| 356 | float gridColor[4] = { 0.2f, 0.2f, 0.2f, 1.0f }; |
| 357 | MiniGL::drawGrid_xz(gridColor); |
| 358 | |
| 359 | MiniGL::coordinateSystem(); |
| 360 | |
| 361 | // Draw sim model |
| 362 | SimulationModel *model = Simulation::getCurrent()->getModel(); |
| 363 | if (model == nullptr) |
| 364 | { |
| 365 | m_gui->update(); |
| 366 | return; |
| 367 | } |
| 368 | SimulationModel::RigidBodyVector &rb = model->getRigidBodies(); |
| 369 | SimulationModel::ConstraintVector &constraints = model->getConstraints(); |
| 370 | SimulationModel::RigidBodyContactConstraintVector &rigidBodyContacts = model->getRigidBodyContactConstraints(); |
| 371 | SimulationModel::ParticleRigidBodyContactConstraintVector &particleRigidBodyContacts = model->getParticleRigidBodyContactConstraints(); |
| 372 | |
| 373 | float selectionColor[4] = { 0.8f, 0.0f, 0.0f, 1 }; |
| 374 | float surfaceColor[4] = { 0.1f, 0.4f, 0.7f, 1 }; |
| 375 | float staticColor[4] = { 0.5f, 0.5f, 0.5f, 1 }; |
| 376 | |
| 377 | if (m_renderContacts) |
| 378 | { |
| 379 | for (unsigned int i = 0; i < rigidBodyContacts.size(); i++) |
| 380 | renderRigidBodyContact(rigidBodyContacts[i]); |
| 381 | for (unsigned int i = 0; i < particleRigidBodyContacts.size(); i++) |
| 382 | renderParticleRigidBodyContact(particleRigidBodyContacts[i]); |
| 383 | } |
| 384 | |
| 385 | |
| 386 | for (size_t i = 0; i < rb.size(); i++) |
| 387 | { |
| 388 | bool selected = false; |
| 389 | for (unsigned int j = 0; j < m_selectedBodies.size(); j++) |
| 390 | { |
| 391 | if (m_selectedBodies[j] == i) |
| 392 | selected = true; |
| 393 | } |
| 394 | |
| 395 | const VertexData &vd = rb[i]->getGeometry().getVertexData(); |
| 396 | const IndexedFaceMesh &mesh = rb[i]->getGeometry().getMesh(); |
| 397 | |
| 398 | if (mesh.getFlatShading()) |
| 399 | shaderFlatBegin(staticColor); |
| 400 | else |
| 401 | shaderBegin(staticColor); |
| 402 | |
| 403 | if (!selected) |
| 404 | { |
| 405 | if (rb[i]->getMass() == 0.0) |
| 406 | { |
| 407 | glUniform3fv(m_shader.getUniform("surface_color"), 1, staticColor); |
| 408 | Visualization::drawMesh(vd, mesh, 0, staticColor); |
| 409 | } |
| 410 | else |
| 411 | { |
no test coverage detected