104_Colors.py 453 B

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