104_Colors.py 562 B

12345678910111213141516171819202122232425262728
  1. # Add the igl library to the modules search path
  2. import sys, os
  3. sys.path.insert(0, os.getcwd() + "/../")
  4. import igl
  5. V = igl.eigen.MatrixXd()
  6. F = igl.eigen.MatrixXi()
  7. C = igl.eigen.MatrixXd()
  8. # Load a mesh in OFF format
  9. igl.readOFF("../../tutorial/shared/screwdriver.off", V, F)
  10. # Plot the mesh
  11. viewer = igl.viewer.Viewer()
  12. viewer.data.set_mesh(V, F)
  13. # Use the z coordinate as a scalar field over the surface
  14. Z = V.col(2);
  15. # Compute per-vertex colors
  16. igl.jet(Z,True,C)
  17. # Add per-vertex colors
  18. viewer.data.set_colors(C)
  19. # Launch the viewer
  20. viewer.launch()