2008-09-17 17:08:36 +00:00
|
|
|
#-*- coding: UTF-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
This module demonstrates the functionality of PyAssimp.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2008-09-17 15:25:20 +00:00
|
|
|
from pyassimp import pyassimp
|
2008-09-17 17:08:36 +00:00
|
|
|
import os
|
2008-09-17 15:25:20 +00:00
|
|
|
|
2008-09-17 17:08:36 +00:00
|
|
|
#get a model out of assimp's test-data
|
|
|
|
MODEL = os.path.join(os.path.dirname(__file__),
|
|
|
|
"..", "..",
|
2009-04-25 21:12:53 +00:00
|
|
|
"test", "models", "MDL", "MDL3 (3DGS A4)", "minigun.MDL")
|
2008-09-17 15:25:20 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
scene = pyassimp.load(MODEL)
|
|
|
|
|
2008-09-17 17:08:36 +00:00
|
|
|
#the model we load
|
|
|
|
print "MODEL:", MODEL
|
|
|
|
print
|
|
|
|
|
2008-09-17 15:25:20 +00:00
|
|
|
#write some statistics
|
|
|
|
print "SCENE:"
|
|
|
|
print " meshes:", len(scene.meshes)
|
2008-09-23 12:38:39 +00:00
|
|
|
print " materials:", len(scene.materials)
|
2008-09-23 13:11:30 +00:00
|
|
|
print " textures:", len(scene.textures)
|
2008-09-23 12:38:39 +00:00
|
|
|
print
|
|
|
|
|
2008-09-17 15:25:20 +00:00
|
|
|
print "MESHES:"
|
|
|
|
for index, mesh in enumerate(scene.meshes):
|
|
|
|
print " MESH", index+1
|
2009-04-25 21:12:53 +00:00
|
|
|
print " material:", mesh.mMaterialIndex+1
|
2008-09-17 15:25:20 +00:00
|
|
|
print " vertices:", len(mesh.vertices)
|
|
|
|
print " first:", mesh.vertices[:3]
|
|
|
|
print " colors:", len(mesh.colors)
|
2008-09-18 12:45:03 +00:00
|
|
|
tc = mesh.texcoords
|
|
|
|
print " texture-coords 1:", len(tc[0]), "first:", tc[0][:3]
|
|
|
|
print " texture-coords 2:", len(tc[1]), "first:", tc[1][:3]
|
|
|
|
print " texture-coords 3:", len(tc[2]), "first:", tc[2][:3]
|
|
|
|
print " texture-coords 4:", len(tc[3]), "first:", tc[3][:3]
|
2009-04-25 21:12:53 +00:00
|
|
|
print " uv-component-count:", len(mesh.mNumUVComponents)
|
|
|
|
print " faces:", len(mesh.faces), "first:", [f.indices for f in mesh.faces[:3]]
|
|
|
|
print " bones:", len(mesh.bones), "first:", [b.mName for b in mesh.bones[:3]]
|
2008-09-17 17:08:36 +00:00
|
|
|
print
|
2009-04-25 21:12:53 +00:00
|
|
|
|
2008-09-23 13:11:30 +00:00
|
|
|
print "MATERIALS:"
|
|
|
|
for index, material in enumerate(scene.materials):
|
|
|
|
print " MATERIAL", index+1
|
2009-04-25 21:12:53 +00:00
|
|
|
properties = pyassimp.GetMaterialProperties(material)
|
|
|
|
for key in properties:
|
|
|
|
print " %s: %s" % (key, properties[key])
|
2008-09-23 13:11:30 +00:00
|
|
|
print
|
|
|
|
|
|
|
|
print "TEXTURES:"
|
|
|
|
for index, texture in enumerate(scene.textures):
|
|
|
|
print " TEXTURE", index+1
|
2009-04-25 21:12:53 +00:00
|
|
|
print " width:", texture.mWidth
|
|
|
|
print " height:", texture.mHeight
|
|
|
|
print " hint:", texture.achFormatHint
|
|
|
|
print " data (size):", texture.mWidth*texture.mHeight
|
|
|
|
|
|
|
|
# Finally release the model
|
|
|
|
pyassimp.release(scene)
|
2008-09-17 15:25:20 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|