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__),
|
|
|
|
"..", "..",
|
2008-09-23 13:11:30 +00:00
|
|
|
"test", "MDLFiles", "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 " flags:", ", ".join(scene.list_flags())
|
|
|
|
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
|
|
|
|
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]
|
|
|
|
print " uv-counts:", mesh.uvsize
|
2008-09-18 13:17:44 +00:00
|
|
|
print " faces:", len(mesh.faces), "first:", mesh.faces[:3]
|
2008-09-19 17:53:25 +00:00
|
|
|
print " bones:", len(mesh.bones), "first:", mesh.bones[:3]
|
2008-09-17 17:08:36 +00:00
|
|
|
print
|
2008-09-17 15:25:20 +00:00
|
|
|
|
2008-09-23 13:11:30 +00:00
|
|
|
print "MATERIALS:"
|
|
|
|
for index, material in enumerate(scene.materials):
|
|
|
|
print " MATERIAL", index+1
|
|
|
|
for key, value in material.properties.iteritems():
|
|
|
|
print " %s: %s" % (key, value)
|
|
|
|
print
|
|
|
|
|
|
|
|
print "TEXTURES:"
|
|
|
|
for index, texture in enumerate(scene.textures):
|
|
|
|
print " TEXTURE", index+1
|
|
|
|
print " width:", texture.width
|
|
|
|
print " height:", texture.height
|
|
|
|
print " hint:", texture.hint
|
|
|
|
print " data (size):", len(texture.data)
|
|
|
|
|
2008-09-17 15:25:20 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|