Merge pull request #13 from rodrigob/master

Fixes to pyassimp
pull/12/merge
Kim Kulling 2013-01-15 00:53:48 -08:00
commit e7aeb8e08b
2 changed files with 12 additions and 9 deletions

View File

@ -293,11 +293,9 @@ def release(scene):
def _finalize_texture(tex, target): def _finalize_texture(tex, target):
setattr(target, "achformathint", tex.achFormatHint) setattr(target, "achformathint", tex.achFormatHint)
data = numpy.array([make_tuple(getattr(tex, pcData)[i]) for i in range(tex.mWidth * tex.mHeight)]) data = numpy.array([make_tuple(getattr(tex, "pcData")[i]) for i in range(tex.mWidth * tex.mHeight)])
setattr(target, "data", data) setattr(target, "data", data)
def _finalize_mesh(mesh, target): def _finalize_mesh(mesh, target):
""" Building of meshes is a bit specific. """ Building of meshes is a bit specific.

View File

@ -5,8 +5,7 @@
This module demonstrates the functionality of PyAssimp. This module demonstrates the functionality of PyAssimp.
""" """
import pyassimp.core as pyassimp
import pyassimp
import os, sys import os, sys
#get a model out of assimp's test-data if none is provided on the command line #get a model out of assimp's test-data if none is provided on the command line
@ -22,6 +21,8 @@ def recur_node(node,level = 0):
def main(filename=None): def main(filename=None):
filename = filename or DEFAULT_MODEL filename = filename or DEFAULT_MODEL
print "Reading model", filename
scene = pyassimp.load(filename) scene = pyassimp.load(filename)
#the model we load #the model we load
@ -45,21 +46,23 @@ def main(filename=None):
print " material id:", mesh.materialindex+1 print " material id:", mesh.materialindex+1
print " vertices:", len(mesh.vertices) print " vertices:", len(mesh.vertices)
print " first 3 verts:", mesh.vertices[:3] print " first 3 verts:", mesh.vertices[:3]
if mesh.normals: if len(mesh.normals) > 0:
print " first 3 normals:", mesh.normals[:3] print " first 3 normals:", mesh.normals[:3]
else: else:
print " no normals" print " no normals"
print " colors:", len(mesh.colors) print " colors:", len(mesh.colors)
tc = mesh.texturecoords tc = mesh.texturecoords
if tc: if len(tc) >= 4:
print " texture-coords 1:", len(tc[0]), "first3:", tc[0][:3] print " texture-coords 1:", len(tc[0]), "first3:", tc[0][:3]
print " texture-coords 2:", len(tc[1]), "first3:", tc[1][:3] print " texture-coords 2:", len(tc[1]), "first3:", tc[1][:3]
print " texture-coords 3:", len(tc[2]), "first3:", tc[2][:3] print " texture-coords 3:", len(tc[2]), "first3:", tc[2][:3]
print " texture-coords 4:", len(tc[3]), "first3:", tc[3][:3] print " texture-coords 4:", len(tc[3]), "first3:", tc[3][:3]
else: elif len(tc) == 0:
print " no texture coordinates" print " no texture coordinates"
else:
print " tc is an unexpected number of elements (expect 4, got", len(tc), ")"
print " uv-component-count:", len(mesh.numuvcomponents) print " uv-component-count:", len(mesh.numuvcomponents)
print " faces:", len(mesh.faces), "first:", [f.indices for f in mesh.faces[:3]] print " faces:", len(mesh.faces), "first:", [f for f in mesh.faces[:3]]
print " bones:", len(mesh.bones), "first:", [str(b) for b in mesh.bones[:3]] print " bones:", len(mesh.bones), "first:", [str(b) for b in mesh.bones[:3]]
print print
@ -81,5 +84,7 @@ def main(filename=None):
# Finally release the model # Finally release the model
pyassimp.release(scene) pyassimp.release(scene)
print "Finished parsing the model."
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1] if len(sys.argv)>1 else None) main(sys.argv[1] if len(sys.argv)>1 else None)