Guest User

Untitled

a guest
Oct 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import math
  2. import numpy as np
  3. import mayavi.mlab as mlab
  4. import pickle
  5.  
  6. # The following three lines will load the "pickled" arrays V and F from the
  7. # pickle file dino.pkl. V represents the vertices of the model as Nx3 matrix,
  8. # while N is the number of vertices the model consists of. F represent the
  9. # faces (here triangles of the model). F is also a Nx3 matrix, while here N
  10. # represents the number of the faces the model.
  11. fid = open('dino.pkl', 'rb')
  12. (V, F) = pickle.load(fid)
  13. fid.close()
  14.  
  15. # a small wrapper function around mlab's triangular_mesh
  16. # input are the face-vertex indices inside an (M x 3) array F
  17. # and the vertices in a (N x 3) array V
  18. def trimesh(F, V, new_figure=True):
  19. if new_figure:
  20. mlab.figure()
  21. mlab.triangular_mesh(V[:,0], V[:,1] , V[:,2] , F)
  22. mlab.show()
  23.  
  24.  
  25. # small helper function that is used to visualize the coordinate axes
  26. def draw_axes():
  27. mlab.points3d(1, 0, 0, 1, scale_factor=0.1, color=(1, 0, 0))
  28. mlab.points3d(0, 1, 0, 1, scale_factor=0.1, color=(0, 1, 0))
  29. mlab.points3d(0, 0, 1, 1, scale_factor=0.1, color=(0, 0, 1))
  30. mlab.plot3d([0, 1], [0, 0], [0, 0])
  31. mlab.plot3d([0, 0], [0, 1], [0, 0])
  32. mlab.plot3d([0, 0], [0, 0], [0, 1])
  33.  
  34.  
  35. # show dino triangle mesh
  36. draw_axes()
  37. trimesh(F, V)
Add Comment
Please, Sign In to add comment