From 380737c4c444eac849af1fbef807f21ceb0bcc3c Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Wed, 11 Jan 2012 00:26:54 +0000 Subject: [PATCH] merge git://github.com/gellule/assimp.git the strings used in materials and elsewhere in assimp. Because of this, in PyAssimp3 strings in materials don't work properly on 64 bits platforms. This commit adds a StringUInt32 ctypes structure and use it in GetMaterialProperties as a workaround. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1105 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- port/PyAssimp3/pyassimp/pyassimp.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/port/PyAssimp3/pyassimp/pyassimp.py b/port/PyAssimp3/pyassimp/pyassimp.py index 0b4f221ae..decb290c6 100644 --- a/port/PyAssimp3/pyassimp/pyassimp.py +++ b/port/PyAssimp3/pyassimp/pyassimp.py @@ -119,7 +119,20 @@ class aiTuple: def __repr__(self): return str([x for x in self]) - + +class StringUInt32(ctypes.Structure): + """ + A ctypes structure used for material strings. + This is a workaround for a type mismatch for the length field between strings used for materials and elsewhere. + """ + + MAXLEN = 1024 + + _fields_ = [ + ("length", ctypes.c_uint32), + ("data", ctypes.c_char*MAXLEN), + ] + def _init(self): """ Custom initialize() for C structs, adds safely accessable member functionality. @@ -253,7 +266,7 @@ def GetMaterialProperties(material): value = [x for x in arr] elif p.mType == 3: #string can't be an array try: - value = cast(p.mData, POINTER(structs.String)).contents.data + value = cast(p.mData, POINTER(StringUInt32)).contents.data except UnicodeDecodeError: print('UnicodeDecodeError reading material property, ignoring.') continue