From 24927ff4cc0f15ca1555d09d69d29283d79bf9ca Mon Sep 17 00:00:00 2001 From: Rodrigo Benenson Date: Thu, 29 Nov 2012 19:06:26 +0100 Subject: [PATCH 1/3] fixed sample.py --- port/PyAssimp/sample.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/port/PyAssimp/sample.py b/port/PyAssimp/sample.py index 3788bd065..20cebcd36 100755 --- a/port/PyAssimp/sample.py +++ b/port/PyAssimp/sample.py @@ -5,8 +5,7 @@ This module demonstrates the functionality of PyAssimp. """ - -import pyassimp +import pyassimp.core as pyassimp import os, sys #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): filename = filename or DEFAULT_MODEL + + print "Reading model", filename scene = pyassimp.load(filename) #the model we load @@ -45,21 +46,23 @@ def main(filename=None): print " material id:", mesh.materialindex+1 print " vertices:", len(mesh.vertices) print " first 3 verts:", mesh.vertices[:3] - if mesh.normals: + if len(mesh.normals) > 0: print " first 3 normals:", mesh.normals[:3] else: print " no normals" print " colors:", len(mesh.colors) tc = mesh.texturecoords - if tc: + if len(tc) >= 4: 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 3:", len(tc[2]), "first3:", tc[2][:3] print " texture-coords 4:", len(tc[3]), "first3:", tc[3][:3] - else: + elif len(tc) == 0: 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 " 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 @@ -81,5 +84,7 @@ def main(filename=None): # Finally release the model pyassimp.release(scene) + print "Finished parsing the model." + if __name__ == "__main__": main(sys.argv[1] if len(sys.argv)>1 else None) From c883967735ccb8462dd4797465f9ed3bbdfcf249 Mon Sep 17 00:00:00 2001 From: Rodrigo Benenson Date: Thu, 29 Nov 2012 19:07:56 +0100 Subject: [PATCH 2/3] Fixed pyassimp core.py --- port/PyAssimp/pyassimp/core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 731dcd5a3..877272b1c 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -293,11 +293,9 @@ def release(scene): def _finalize_texture(tex, target): 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) - - def _finalize_mesh(mesh, target): """ Building of meshes is a bit specific. From 7b253016b73abc696e2cb6ac95b44b6bb8f3f59e Mon Sep 17 00:00:00 2001 From: Rodrigo Benenson Date: Fri, 7 Dec 2012 21:57:39 +0100 Subject: [PATCH 3/3] Fixing compilation on gcc 4.5.2 --- code/IFCUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/IFCUtil.cpp b/code/IFCUtil.cpp index 96877f934..17149906f 100644 --- a/code/IFCUtil.cpp +++ b/code/IFCUtil.cpp @@ -142,8 +142,8 @@ void TempMesh::RemoveDegenerates() bool drop = false; size_t inor = 0; - std::vector::const_iterator vit = verts.begin(); - for (std::vector::const_iterator it = vertcnt.begin(); it != vertcnt.end(); ++inor) { + std::vector::iterator vit = verts.begin(); + for (std::vector::iterator it = vertcnt.begin(); it != vertcnt.end(); ++inor) { const unsigned int pcount = *it; if (normals[inor].SquareLength() < 1e-5f) {