sample.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #-*- coding: UTF-8 -*-
  2. """
  3. This module demonstrates the functionality of PyAssimp.
  4. """
  5. from pyassimp import pyassimp
  6. import os
  7. #get a model out of assimp's test-data
  8. MODEL = os.path.join(os.path.dirname(__file__),
  9. "..", "..",
  10. "test", "3DSFiles", "test1.3ds")
  11. def main():
  12. scene = pyassimp.load(MODEL)
  13. #the model we load
  14. print "MODEL:", MODEL
  15. print
  16. #write some statistics
  17. print "SCENE:"
  18. print " flags:", ", ".join(scene.list_flags())
  19. print " meshes:", len(scene.meshes)
  20. print
  21. print "MESHES:"
  22. for index, mesh in enumerate(scene.meshes):
  23. print " MESH", index+1
  24. print " vertices:", len(mesh.vertices)
  25. print " first:", mesh.vertices[:3]
  26. print " colors:", len(mesh.colors)
  27. tc = mesh.texcoords
  28. print " texture-coords 1:", len(tc[0]), "first:", tc[0][:3]
  29. print " texture-coords 2:", len(tc[1]), "first:", tc[1][:3]
  30. print " texture-coords 3:", len(tc[2]), "first:", tc[2][:3]
  31. print " texture-coords 4:", len(tc[3]), "first:", tc[3][:3]
  32. print " uv-counts:", mesh.uvsize
  33. print
  34. if __name__ == "__main__":
  35. main()