예제 #1
0
파일: example.cpp 프로젝트: nixz/libigl
int main(int argc, char * argv[])
{
  using namespace Eigen;
  using namespace igl;
  using namespace std;

  // init mesh
  string filename = "/usr/local/igl/libigl/examples/shared/decimated-knight.obj" ;
  if(argc > 1)
  {
    filename = argv[1];
  }
  if(!read_triangle_mesh(filename,V,F))
  {
    return 1;
  }

  // Compute normals, centroid, colors, bounding box diagonal
  per_face_normals(V,F,N);
  normalize_row_lengths(N,N);
  mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff());
  bbd =
    (V.colwise().maxCoeff() -
    V.colwise().minCoeff()).maxCoeff();

  // Init glut
  glutInit(&argc,argv);

  if( !TwInit(TW_OPENGL, NULL) )
  {
    // A fatal error occured
    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
    return 1;
  }
  // Create a tweak bar
  rebar.TwNewBar("TweakBar");
  rebar.TwAddVarRW("scene_rot", TW_TYPE_QUAT4F, &scene_rot, "");
  rebar.load(REBAR_NAME);

  glutInitDisplayString( "rgba depth double samples>=8 ");
  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
  glutCreateWindow("sorted primitives transparency");
  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(key);
  glutMouseFunc(mouse);
  glutMotionFunc(mouse_drag);

  glutMainLoop();

  return 0;
}
예제 #2
0
void FourView::update_anttweakbar_visibility(igl::anttweakbar::ReTwBar & rebar) const
{
  using namespace igl;
  for(int vp = 0;vp<NUM_VIEWPORTS;vp++)
  {
    if(vp == m_down_vp)
    {
      rebar.TwSetParam(C_STR("Viewport["<<vp<<"]"), "visible", TW_PARAM_INT32, 1, &INT_ONE);
    }else 
    {
      rebar.TwSetParam(C_STR("Viewport["<<vp<<"]"), "visible", TW_PARAM_INT32, 1, &INT_ZERO);
    }
  }
}
예제 #3
0
void FourView::add_to_reanttweakbar(igl::anttweakbar::ReTwBar & rebar)
{
  using namespace igl;
  using namespace igl::anttweakbar;
  // loop over viewports
  for(int vp = 0;vp<NUM_VIEWPORTS;vp++)
  {
    //rebar.TwAddVarRW(C_STR("viewport_"<<vp<<"_zoom"),TW_TYPE_DOUBLE,&m_viewports[vp].camera.zoom,C_STR(
    //  "group='Viewport["<<vp<<"]' "
    //  "label='zoom' "
    //  "step=0.01 min="<<min_zoom<<" max="<<max_zoom<<" "
    //  "help='Zoom viewing camera in and out' "
    //  ));
    rebar.TwAddVarRW(C_STR("viewport_"<<vp<<"_rotation"),TW_TYPE_QUAT4D,
      m_viewports[vp].camera.m_rotation_conj.coeffs().data(),
      C_STR("group='Viewport["<<vp<<"]' "
      "label='rotation' "
      "open "
      "help='Rotate viewing camera (0 0 0 1 = identity)' "
      ));
    //rebar.TwAddVarRW(
    //  C_STR("viewport_"<<vp<<"_translation"),TW_TYPE_DIR3D,
    //  m_viewports[vp].camera.m_translation.data(), "visible=false");
    //rebar.TwAddVarRW(C_STR("viewport_"<<vp<<"_angle"),TW_TYPE_DOUBLE,&m_viewports[vp].camera.angle,
    //  C_STR("group='Viewport["<<vp<<"]' "
    //  "label='angle' "
    //  "help='Perspective viewing angle (45-natural, 0-ortho)' "
    //  "max=90 min=0")
    //  );
    rebar.TwSetParam(C_STR("Viewport["<<vp<<"]"), "opened", TW_PARAM_INT32, 1, &INT_ZERO);
    rebar.TwSetParam(C_STR("Viewport["<<vp<<"]"), "visible", TW_PARAM_INT32, 1, &INT_ZERO);
  }
  // so these are remembered
  rebar.TwAddVarRW("horiz",TW_TYPE_DOUBLE,&m_horiz,"visible=false");
  rebar.TwAddVarRW("vert",TW_TYPE_DOUBLE,&m_vert,"visible=false");
}
예제 #4
0
파일: example.cpp 프로젝트: nixz/libigl
void key(unsigned char key, int mouse_x, int mouse_y)
{
  using namespace Eigen;
  using namespace igl;
  using namespace std;
  switch(key)
  {
    // Ctrl-c and esc exit
    case char(3):
    case char(27):
      rebar.save(REBAR_NAME);
      exit(0);
    default:
      cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
  }

}
예제 #5
0
파일: example.cpp 프로젝트: nixz/libigl
void key(unsigned char key, int mouse_x, int mouse_y)
{
  using namespace std;
  switch(key)
  {
    // ESC
    case char(27):
      rebar.save(REBAR_NAME);
    // ^C
    case char(3):
      exit(0);
    default:
      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
      {
        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
      }
  }

}
예제 #6
0
int main(int argc, char * argv[])
{
  using namespace Eigen;
  using namespace igl;
  using namespace std;

  // init mesh
  string filename = "../shared/truck.obj";
  string filename_other = "";
  switch(argc)
  {
    case 3:
      // Read and prepare mesh
      filename_other = argv[2];
      has_other=true;
      // fall through
    case 2:
      // Read and prepare mesh
      filename = argv[1];
      break;
    default:
    cerr<<"Usage:"<<endl<<"    ./example input.obj [other.obj]"<<endl;
    cout<<endl<<"Opening default mesh..."<<endl;
  }

  const auto read = []
    (const string & filename, MatrixXd & V, MatrixXi & F, MatrixXd & N) -> bool
  {
    // dirname, basename, extension and filename
    string d,b,ext,f;
    pathinfo(filename,d,b,ext,f);
    // Convert extension to lower case
    transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
    vector<vector<double > > vV,vN,vTC;
    vector<vector<int > > vF,vFTC,vFN;
    if(ext == "obj")
    {
      // Convert extension to lower case
      if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
      {
        return false;
      }
    }else if(ext == "off")
    {
      // Convert extension to lower case
      if(!igl::readOFF(filename,vV,vF,vN))
      {
        return false;
      }
    }else if(ext == "wrl")
    {
      // Convert extension to lower case
      if(!igl::readWRL(filename,vV,vF))
      {
        return false;
      }
    //}else
    //{
    //  // Convert extension to lower case
    //  MatrixXi T;
    //  if(!igl::readMESH(filename,V,T,F))
    //  {
    //    return false;
    //  }
    //  //if(F.size() > T.size() || F.size() == 0)
    //  {
    //    boundary_facets(T,F);
    //  }
    }
    if(vV.size() > 0)
    {
      if(!list_to_matrix(vV,V))
      {
        return false;
      }
      polygon_mesh_to_triangle_mesh(vF,F);
    }
    // Compute normals, centroid, colors, bounding box diagonal
    per_face_normals(V,F,N);
    return true;
  };

  if(!read(filename,V,F,N))
  {
    return 1;
  }
  if(has_other)
  {
    if(!read(argv[2],U,G,W))
    {
      return 1;
    }
    cat(1,V,U,VU);
    color_intersections(V,F,U,G,C,D);
  }else
  {
    VU = V;
    color_selfintersections(V,F,C);
  }
  mid = 0.5*(VU.colwise().maxCoeff() + VU.colwise().minCoeff());
  bbd = (VU.colwise().maxCoeff() - VU.colwise().minCoeff()).maxCoeff();

  // Init glut
  glutInit(&argc,argv);

  if( !TwInit(TW_OPENGL, NULL) )
  {
    // A fatal error occured
    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
    return 1;
  }
  // Create a tweak bar
  rebar.TwNewBar("TweakBar");
  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
  s.camera.push_away(3);
  s.camera.dolly_zoom(25-s.camera.m_angle);
  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
    "igl_trackball,two-a...-fixed-up");
  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
  if(has_other)
  {
    rebar.TwAddVarRW("show_A",TW_TYPE_BOOLCPP,&show_A, "key=a",false);
    rebar.TwAddVarRW("show_B",TW_TYPE_BOOLCPP,&show_B, "key=b",false);
  }
  rebar.load(REBAR_NAME);

  glutInitDisplayString("rgba depth double samples>=8 ");
  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
  glutCreateWindow("mesh-intersections");
  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(key);
  glutMouseFunc(mouse);
  glutMotionFunc(mouse_drag);
  glutPassiveMotionFunc(
    [](int x, int y)
    {
      TwEventMouseMotionGLUT(x,y);
      glutPostRedisplay();
    });
  static std::function<void(int)> timer_bounce;
  auto timer = [] (int ms) {
    timer_bounce(ms);
  };
  timer_bounce = [&] (int ms) {
    glutTimerFunc(ms, timer, ms);
    glutPostRedisplay();
  };
  glutTimerFunc(500, timer, 500);

  glutMainLoop();
  return 0;
}
예제 #7
0
int main(int argc, char * argv[])
{
  using namespace std;
  using namespace Eigen;
  using namespace igl;
  string filename = "../shared/truck.obj";
  switch(argc)
  {
    case 3:
      out_filename = argv[2];
    case 2:
      // Read and prepare mesh
      filename = argv[1];
      break;
    default:
      cerr<<"Usage:"<<endl<<"    ./example input.obj (output.obj)"<<endl;
      cout<<endl<<"Opening default mesh..."<<endl;
      break;
  }

  // print key commands
  cout<<"[Click] and [drag]  Rotate model using trackball."<<endl;
  cout<<"[Z,z]               Snap rotation to canonical view."<<endl;
  cout<<"[Command+Z]         Undo."<<endl;
  cout<<"[Shift+Command+Z]   Redo."<<endl;
  cout<<"[^C,ESC]            Exit."<<endl;

  // dirname, basename, extension and filename
  string d,b,ext,f;
  pathinfo(filename,d,b,ext,f);
  // Convert extension to lower case
  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
  vector<vector<double > > vV,vN,vTC;
  vector<vector<int > > vF,vFTC,vFN;
  if(ext == "obj")
  {
    // Convert extension to lower case
    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
    {
      return 1;
    }
  }else if(ext == "off")
  {
    // Convert extension to lower case
    if(!igl::readOFF(filename,vV,vF,vN))
    {
      return 1;
    }
  }else if(ext == "ply")
  {
    // Convert extension to lower case
    if(!igl::readPLY(filename,vV,vF,vN,vTC))
    {
      return 1;
    }
  }else if(ext == "wrl")
  {
    // Convert extension to lower case
    if(!igl::readWRL(filename,vV,vF))
    {
      return 1;
    }
  //}else
  //{
  //  // Convert extension to lower case
  //  MatrixXi T;
  //  if(!igl::readMESH(filename,V,T,F))
  //  {
  //    return 1;
  //  }
  //  //if(F.size() > T.size() || F.size() == 0)
  //  {
  //    boundary_facets(T,F);
  //  }
  }
  if(vV.size() > 0)
  {
    if(!list_to_matrix(vV,V))
    {
      return 1;
    }
    polygon_mesh_to_triangle_mesh(vF,F);
  }
  MatrixXi F_unique;
  unique_simplices(F, F_unique);
  F = F_unique;

  init_patches();
  init_relative();
  randomly_color(CC,s.C);

  // Init glut
  glutInit(&argc,argv);
  if( !TwInit(TW_OPENGL, NULL) )
  {
    // A fatal error occured
    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
    return 1;
  }
  // Create a tweak bar
  rebar.TwNewBar("bar");
  TwDefine("bar label='Patches' size='200 550' text=light alpha='200' color='68 68 68'");
  rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
    s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
    "igl_trackball,two-axis-valuator-fixed-up");
  rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
    set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("CenterType","orbit,fps");
  rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
    "keyIncr={ keyDecr=}");
  TwType OrientMethodTW = igl::anttweakbar::ReTwDefineEnumFromString("OrientMethod",
    "outward,ambient-occlusion");
  rebar.TwAddVarCB( "orient_method", OrientMethodTW,
    set_orient_method,get_orient_method,NULL,"keyIncr=< keyDecr=>");

  rebar.TwAddVarRW("wireframe_visible",TW_TYPE_BOOLCPP,&wireframe_visible,"key=l");
  rebar.TwAddVarRW("fill_visible",TW_TYPE_BOOLCPP,&fill_visible,"key=f");
  rebar.TwAddButton("randomize_colors",randomize_colors,NULL,"key=c");
  if(out_filename != "")
  {
    rebar.TwAddButton("save",
      saveCB,NULL,
      C_STR("label='Save to `"<<out_filename<<"`' "<<
      "key=s"));
  }
  rebar.load(REBAR_NAME);


  animation_from_quat = Quaterniond(1,0,0,0);
  s.camera.m_rotation_conj = animation_from_quat;
  animation_start_time = get_seconds();

  // Init antweakbar
#ifdef __APPLE__
  glutInitDisplayString( "rgba depth double samples>=8");
#else
  glutInitDisplayString( "rgba depth double ");   // samples>=8 somehow not supported on Kenshi's machines...?
#endif
  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
  glutCreateWindow("patches");
  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(key);
  glutMouseFunc(mouse);
  glutMotionFunc(mouse_drag);
  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  glutMainLoop();

  return 0;
}
예제 #8
0
void key(unsigned char key, int mouse_x, int mouse_y)
{
  using namespace std;
  using namespace Eigen;
  using namespace igl;
  int mod = glutGetModifiers();
  switch(key)
  {
    // ESC
    case char(27):
      rebar.save(REBAR_NAME);
    // ^C
    case char(3):
      exit(0);
    case 'I':
    case 'i':
      {
        push_undo();
        s.N *= -1.0;
        F = F.rowwise().reverse().eval();
        break;
      }
    case 'z':
    case 'Z':
      if(mod & GLUT_ACTIVE_COMMAND)
      {
        if(mod & GLUT_ACTIVE_SHIFT)
        {
          redo();
        }else
        {
          undo();
        }
      }else
      {
        push_undo();
        Quaterniond q;
        snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
        switch(center_type)
        {
          default:
          case CENTER_TYPE_ORBIT:
            s.camera.orbit(q.conjugate());
            break;
          case CENTER_TYPE_FPS:
            s.camera.turn_eye(q.conjugate());
            break;
        }
      }
      break;
    case 'u':
        mouse_wheel(0, 1,mouse_x,mouse_y);
        break;
    case 'j':
        mouse_wheel(0,-1,mouse_x,mouse_y);
        break;
    case 'n':
      cc_selected = (cc_selected + 1) % (CC.maxCoeff() + 2);
      cout << "selected cc: " << cc_selected << endl;
      glutPostRedisplay();
      break;
    default:
      if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
      {
        cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
      }
  }

}
예제 #9
0
파일: example.cpp 프로젝트: nixz/libigl
int main(int argc, char * argv[])
{
    using namespace Eigen;
    using namespace igl;
    using namespace std;

    // init mesh
    string filename = "../shared/animal.obj";
    string tfilename = "../shared/animal.png";
    if(argc < 3)
    {
        cerr<<"Usage:"<<endl<<"    ./example input.obj texture.png"<<endl;
        cout<<endl<<"Opening default mesh..."<<endl;
    } else
    {
        // Read and prepare mesh
        filename = argv[1];
        tfilename = argv[2];
    }

    vector<vector<double > > vV,vN,vTC;
    vector<vector<int > > vF,vTF,vFN;
    // Convert extension to lower case
    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vTF,vFN))
    {
        return 1;
    }
    if(vV.size() > 0)
    {
        if(!list_to_matrix(vV,V))
        {
            cerr<<"Bad V"<<endl;
            return 1;
        }
        polygon_mesh_to_triangle_mesh(vF,F);
    }
    if(vTC.size() > 0)
    {
        if(!list_to_matrix(vTC,TC))
        {
            cerr<<"Bad TC"<<endl;
            return 1;
        }
    }
    if(vTF.size() > 0)
    {
        if(!list_to_matrix(vTF,TF))
        {
            cerr<<"Bad TF"<<endl;
            return 1;
        }
    }

    //if(vN.size() > 0)
    //{
    //  if(!list_to_matrix(vN,N))
    //  {
    //    return 1;
    //  }
    //}else
    //{
    per_vertex_normals(V,F,N);
    //}

    // Compute normals, centroid, colors, bounding box diagonal
    mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff());
    bbd = (V.colwise().maxCoeff() - V.colwise().minCoeff()).maxCoeff();

    // Init glut
    glutInit(&argc,argv);

    if( !TwInit(TW_OPENGL, NULL) )
    {
        // A fatal error occured
        fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
        return 1;
    }
    // Create a tweak bar
    rebar.TwNewBar("TweakBar");
    rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
                     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
    s.camera.push_away(3);
    s.camera.dolly_zoom(25-s.camera.m_angle);
    TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
                            "igl_trackball,two-a...-fixed-up");
    rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
                      set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
    rebar.TwAddVarRW("flip_y", TW_TYPE_BOOLCPP, &flip_y,"key=f");
    rebar.TwAddVarRW("rotate_xy", TW_TYPE_BOOLCPP, &rotate_xy,"key=r");
    rebar.load(REBAR_NAME);

    glutInitDisplayString( "rgba depth double samples>=8 ");
    glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
    glutCreateWindow("colored-mesh");
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutKeyboardFunc(key);
    glutMouseFunc(mouse);
    glutMotionFunc(mouse_drag);
    glutPassiveMotionFunc(
        [](int x, int y)
    {
        TwEventMouseMotionGLUT(x,y);
        glutPostRedisplay();
    });
    static std::function<void(int)> timer_bounce;
    auto timer = [] (int ms) {
        timer_bounce(ms);
    };
    timer_bounce = [&] (int ms) {
        glutTimerFunc(ms, timer, ms);
        glutPostRedisplay();
    };
    glutTimerFunc(500, timer, 500);


    // Must be called after opengl context is initialized
    if(!igl::png::texture_from_file(tfilename,tex_id))
    {
        return 1;
    }

    glutMainLoop();
    return 0;
}
예제 #10
0
파일: example.cpp 프로젝트: nixz/libigl
int main(int argc, char * argv[])
{
  using namespace Eigen;
  using namespace igl;
  using namespace std;

  // init mesh
  string filename = "../shared/beast.obj";
  if(argc < 2)
  {
    cerr<<"Usage:"<<endl<<"    ./example input.obj"<<endl;
    cout<<endl<<"Opening default mesh..."<<endl;
  }else
  {
    // Read and prepare mesh
    filename = argv[1];
  }

  // dirname, basename, extension and filename
  string d,b,ext,f;
  pathinfo(filename,d,b,ext,f);
  // Convert extension to lower case
  transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
  vector<vector<double > > vV,vN,vTC;
  vector<vector<int > > vF,vFTC,vFN;
  if(ext == "obj")
  {
    // Convert extension to lower case
    if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
    {
      return 1;
    }
  }else if(ext == "off")
  {
    // Convert extension to lower case
    if(!igl::readOFF(filename,vV,vF,vN))
    {
      return 1;
    }
  }else if(ext == "wrl")
  {
    // Convert extension to lower case
    if(!igl::readWRL(filename,vV,vF))
    {
      return 1;
    }
  //}else
  //{
  //  // Convert extension to lower case
  //  MatrixXi T;
  //  if(!igl::readMESH(filename,V,T,F))
  //  {
  //    return 1;
  //  }
  //  //if(F.size() > T.size() || F.size() == 0)
  //  {
  //    boundary_facets(T,F);
  //  }
  }
  if(vV.size() > 0)
  {
    if(!list_to_matrix(vV,V))
    {
      return 1;
    }
    polygon_mesh_to_triangle_mesh(vF,F);
  }

  // Compute normals, centroid, colors, bounding box diagonal
  per_vertex_normals(V,F,N);
  mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff());
  bbd = (V.colwise().maxCoeff() - V.colwise().minCoeff()).maxCoeff();

  // Init embree
  ei.init(V.cast<float>(),F.cast<int>());

  // Init glut
  glutInit(&argc,argv);

  if( !TwInit(TW_OPENGL, NULL) )
  {
    // A fatal error occured
    fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
    return 1;
  }
  // Create a tweak bar
  rebar.TwNewBar("TweakBar");
  rebar.TwAddVarRW("scene_rot", TW_TYPE_QUAT4F, &scene_rot, "");
  rebar.TwAddVarRW("lights_on", TW_TYPE_BOOLCPP, &lights_on, "key=l");
  rebar.TwAddVarRW("color", TW_TYPE_COLOR4F, color.data(), "colormode=hls");
  rebar.TwAddVarRW("ao_factor", TW_TYPE_DOUBLE, &ao_factor, "min=0 max=1 step=0.2 keyIncr=] keyDecr=[ ");
  rebar.TwAddVarRW("ao_normalize", TW_TYPE_BOOLCPP, &ao_normalize, "key=n");
  rebar.TwAddVarRW("ao_on", TW_TYPE_BOOLCPP, &ao_on, "key=a");
  rebar.TwAddVarRW("light_intensity", TW_TYPE_DOUBLE, &light_intensity, "min=0 max=0.4 step=0.1 keyIncr=} keyDecr={ ");
  rebar.load(REBAR_NAME);

  glutInitDisplayString( "rgba depth double samples>=8 ");
  glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
  glutCreateWindow("ambient-occlusion");
  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(key);
  glutMouseFunc(mouse);
  glutMotionFunc(mouse_drag);
  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  glutMainLoop();
  return 0;
}