void display() { using namespace Eigen; using namespace igl; using namespace std; if(!trackball_on && tot_num_samples < 10000) { if(S.size() == 0) { S.resize(V.rows()); S.setZero(); } VectorXd Si; const int num_samples = 20; igl::embree::ambient_occlusion(ei,V,N,num_samples,Si); S *= (double)tot_num_samples; S += Si*(double)num_samples; tot_num_samples += num_samples; S /= (double)tot_num_samples; } // Convert to 1-intensity C.conservativeResize(S.rows(),3); if(ao_on) { C<<S,S,S; C.array() = (1.0-ao_factor*C.array()); }else { C.setConstant(1.0); } if(ao_normalize) { C.col(0) *= ((double)C.rows())/C.col(0).sum(); C.col(1) *= ((double)C.rows())/C.col(1).sum(); C.col(2) *= ((double)C.rows())/C.col(2).sum(); } C.col(0) *= color(0); C.col(1) *= color(1); C.col(2) *= color(2); glClearColor(back[0],back[1],back[2],0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // All smooth points glEnable( GL_POINT_SMOOTH ); glDisable(GL_LIGHTING); if(lights_on) { lights(); } push_scene(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); push_object(); // Draw the model // Set material properties glEnable(GL_COLOR_MATERIAL); igl::opengl2::draw_mesh(V,F,N,C); pop_object(); // Draw a nice floor glPushMatrix(); const double floor_offset = -2./bbd*(V.col(1).maxCoeff()-mid(1)); glTranslated(0,floor_offset,0); const float GREY[4] = {0.5,0.5,0.6,1.0}; const float DARK_GREY[4] = {0.2,0.2,0.3,1.0}; igl::opengl2::draw_floor(GREY,DARK_GREY); glPopMatrix(); pop_scene(); igl::opengl::report_gl_error(); TwDraw(); glutSwapBuffers(); glutPostRedisplay(); }