glyphs1.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """Glyphs:
  2. at each vertex of a mesh, another mesh
  3. is shown with various orientation options"""
  4. from vedo import Sphere, Ellipsoid, Mesh, dataurl, Glyph, show
  5. import numpy as np
  6. # Create a sphere with resolution 12, set its color and show as wireframe
  7. sph = Sphere(res=12).c("white", 0.1).wireframe()
  8. randvs = np.random.rand(sph.npoints, 3) # random orientation vectors
  9. #######################################
  10. # Create an ellipsoid glyph and scale it down
  11. gly1 = Ellipsoid().scale(0.04)
  12. # create a Glyph object that will show an ellipsoid at each vertex
  13. gsphere1 = Glyph(
  14. sph,
  15. gly1,
  16. orientation_array=randvs,
  17. scale_by_vector_size=True,
  18. color_by_vector_size=True,
  19. c="jet",
  20. )
  21. #######################################
  22. # Create a mesh glyph and scale it down
  23. gly2 = Mesh(dataurl + "shuttle.obj").rotate_y(180).scale(0.02)
  24. # Create a Glyph object that will show a shuttle at each vertex
  25. gsphere2 = Glyph(
  26. sph,
  27. gly2,
  28. orientation_array="normals",
  29. c="lightblue",
  30. )
  31. # Show two groups of objects on N=2 renderers:
  32. show([
  33. (sph, gsphere1, __doc__),
  34. (sph, gsphere2)
  35. ],
  36. N=2,
  37. bg="bb",
  38. zoom=1.4,
  39. ).close()