void GridModel::draw(const core::visual::VisualParams* vparams) { if (!isActive() || !((getNext()==NULL)?vparams->displayFlags().getShowCollisionModels():vparams->displayFlags().getShowBoundingCollisionModels())) return; glDisable(GL_LIGHTING); int level=0; CollisionModel* m = getPrevious(); float color = 1.0f; while (m!=NULL) { m = m->getPrevious(); ++level; color *= 0.5f; } if (isSimulated()) glColor4f(1.0f, 1.0f, 1.0f, color); else glColor4f(1.0f, 1.0f, 0.0f, color); if (color < 1.0f) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(0); } for (int i=0;i<size;i++) { draw(vparams,i); } if (color < 1.0f) { glDisable(GL_BLEND); glDepthMask(1); } if (getPrevious()!=NULL) getPrevious()->draw(vparams); }
void CubeModel::draw(const core::visual::VisualParams* vparams) { if (!isActive() || !((getNext()==NULL)?vparams->displayFlags().getShowCollisionModels():vparams->displayFlags().getShowBoundingCollisionModels())) return; int level=0; CollisionModel* m = getPrevious(); float color = 1.0f; while (m!=NULL) { m = m->getPrevious(); ++level; color *= 0.5f; } Vec<4,float> c; if (isSimulated()) c=Vec<4,float>(1.0f, 1.0f, 1.0f, color); else c=Vec<4,float>(1.0f, 1.0f, 1.0f, color); std::vector< Vector3 > points; for (int i=0; i<size; i++) { const Vector3& vmin = elems[i].minBBox; const Vector3& vmax = elems[i].maxBBox; points.push_back(Vector3(vmin[0], vmin[1], vmin[2])); points.push_back(Vector3(vmin[0], vmin[1], vmax[2])); points.push_back(Vector3(vmin[0], vmax[1], vmin[2])); points.push_back(Vector3(vmin[0], vmax[1], vmax[2])); points.push_back(Vector3(vmax[0], vmin[1], vmin[2])); points.push_back(Vector3(vmax[0], vmin[1], vmax[2])); points.push_back(Vector3(vmax[0], vmax[1], vmin[2])); points.push_back(Vector3(vmax[0], vmax[1], vmax[2])); points.push_back(Vector3(vmin[0], vmin[1], vmin[2])); points.push_back(Vector3(vmin[0], vmax[1], vmin[2])); points.push_back(Vector3(vmin[0], vmin[1], vmax[2])); points.push_back(Vector3(vmin[0], vmax[1], vmax[2])); points.push_back(Vector3(vmax[0], vmin[1], vmin[2])); points.push_back(Vector3(vmax[0], vmax[1], vmin[2])); points.push_back(Vector3(vmax[0], vmin[1], vmax[2])); points.push_back(Vector3(vmax[0], vmax[1], vmax[2])); points.push_back(Vector3(vmin[0], vmin[1], vmin[2])); points.push_back(Vector3(vmax[0], vmin[1], vmin[2])); points.push_back(Vector3(vmin[0], vmax[1], vmin[2])); points.push_back(Vector3(vmax[0], vmax[1], vmin[2])); points.push_back(Vector3(vmin[0], vmin[1], vmax[2])); points.push_back(Vector3(vmax[0], vmin[1], vmax[2])); points.push_back(Vector3(vmin[0], vmax[1], vmax[2])); points.push_back(Vector3(vmax[0], vmax[1], vmax[2])); } vparams->drawTool()->drawLines(points, 1, Vec<4,float>(c)); if (getPrevious()!=NULL) getPrevious()->draw(vparams); }