main.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "tutorial_shared_path.h"
  2. #include <igl/opengl/glfw/Viewer.h>
  3. #include <string>
  4. #include <iostream>
  5. int main(int argc, char * argv[])
  6. {
  7. igl::opengl::glfw::Viewer viewer;
  8. const auto names =
  9. {"cube.obj","sphere.obj","xcylinder.obj","ycylinder.obj","zcylinder.obj"};
  10. for(const auto & name : names)
  11. {
  12. viewer.load_mesh_from_file(std::string(TUTORIAL_SHARED_PATH) + "/" + name);
  13. }
  14. // Set colors of each mesh by selecting its index first
  15. viewer.selected_data_index = 0;
  16. viewer.data().set_colors(Eigen::RowVector3d(0.8,0.47,0.22));
  17. viewer.selected_data_index = 1;
  18. viewer.data().set_colors(Eigen::RowVector3d(0.6,0.01,0.11));
  19. viewer.selected_data_index = 2;
  20. viewer.data().set_colors(Eigen::RowVector3d(0.37,0.06,0.25));
  21. viewer.selected_data_index = 3;
  22. viewer.data().set_colors(Eigen::RowVector3d(1,1,1));
  23. viewer.callback_key_down =
  24. [&](igl::opengl::glfw::Viewer &, unsigned int key, int mod)
  25. {
  26. // Delete
  27. if(key == '3')
  28. {
  29. viewer.erase_mesh(viewer.selected_data_index);
  30. return true;
  31. }
  32. return false;
  33. };
  34. viewer.launch();
  35. return EXIT_SUCCESS;
  36. }