2
0

main.cpp 637 B

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