merge git://github.com/gellule/assimp.git

Before, neither the texture index nor its semantic were kept in the
returned output. Now GetMaterialProperties returns a (name, color,
material, texture) tuple. Name is the name of the material. Color is a
dictionary of color properties. Material is a dictionary of material
properties. Textures is a triply nested dictionary addressed by the
following: textures[index][semantic][key]. See assimp documentation for
the meaning of index, semantic, and keys in general.



git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1106 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/5/head
aramis_acg 2012-01-11 00:27:49 +00:00
parent 380737c4c4
commit f7c232cfe8
1 changed files with 25 additions and 5 deletions

View File

@ -250,10 +250,18 @@ def aiGetMaterialString(material, key):
def GetMaterialProperties(material): def GetMaterialProperties(material):
""" """
Convenience Function to get the material properties as a dict Convenience Function to get the material properties.
and values in a python format. This function returns the following tuple: (name, clr, mat, tex) where:
name: is the name of the material
clr: is a dictionary of color parameters
mat: is a dictionary of material parameters
tex: is a triply nested dictionary than can be indexed by index, semantic, and then key:
tex[index][semantic][key]
""" """
result = {} name = ""
clr = {}
mat = {}
tex = {}
#read all properties #read all properties
for p in material.properties: for p in material.properties:
#the name #the name
@ -276,9 +284,21 @@ def GetMaterialProperties(material):
else: else:
value = p.mData[:p.mDataLength] value = p.mData[:p.mDataLength]
result[key] = value #store in the appropriate dict
if key == b'?mat.name':
name = value
elif key[:5] == b'$mat.':
mat[key[5:]] = value
elif key[:5] == b'$clr.':
clr[key[5:]] = value
elif key[:5] == b'$tex.':
if p.mIndex not in tex:
tex[p.mIndex] = {}
if p.mSemantic not in tex[p.mIndex]:
tex[p.mIndex][p.mSemantic] = {}
tex[p.mIndex][p.mSemantic][key[5:]] = value
return result return (name, clr, mat, tex)
def aiDecomposeMatrix(matrix): def aiDecomposeMatrix(matrix):