mesh_alphas.py 535 B

12345678910111213141516171819
  1. """Create a set of transparencies
  2. which can be passed to method cmap()"""
  3. from vedo import Mesh, show, dataurl
  4. mesh = Mesh(dataurl+"beethoven.ply")
  5. # pick y coordinates of vertices and use them as scalars
  6. scalars = mesh.vertices[:, 1]
  7. # define opacities in the range of the scalar,
  8. # at min(scals) alpha is 0.1,
  9. # at max(scals) alpha is 0.9:
  10. alphas = [0.1, 0.1, 0.3, 0.4, 0.9]
  11. mesh.cmap("copper", scalars, alpha=alphas)
  12. # mesh.print()
  13. # print(mesh.pointdata['PointScalars']) # retrieve scalars
  14. show(mesh, __doc__, axes=9).close()