main.cpp 700 B

12345678910111213141516171819202122232425262728
  1. #include <igl/readOFF.h>
  2. #include <igl/opengl/glfw/Viewer.h>
  3. #include "tutorial_shared_path.h"
  4. Eigen::MatrixXd V;
  5. Eigen::MatrixXi F;
  6. Eigen::MatrixXd C;
  7. int main(int argc, char *argv[])
  8. {
  9. // Load a mesh in OFF format
  10. igl::readOFF(TUTORIAL_SHARED_PATH "/screwdriver.off", V, F);
  11. // Plot the mesh
  12. igl::opengl::glfw::Viewer viewer;
  13. viewer.data().set_mesh(V, F);
  14. // Use the (normalized) vertex positions as colors
  15. C =
  16. (V.rowwise() - V.colwise().minCoeff()).array().rowwise()/
  17. (V.colwise().maxCoeff() - V.colwise().minCoeff()).array();
  18. // Add per-vertex colors
  19. viewer.data().set_colors(C);
  20. // Launch the viewer
  21. viewer.launch();
  22. }