[pyassimp] Rework material dict
- Normalize the names - Do not create numpy arrays for the propertiespull/10/head
parent
bfbcdfbae1
commit
76d2eb7057
|
@ -348,21 +348,24 @@ def _get_properties(properties, length):
|
||||||
for p in [properties[i] for i in range(length)]:
|
for p in [properties[i] for i in range(length)]:
|
||||||
#the name
|
#the name
|
||||||
p = p.contents
|
p = p.contents
|
||||||
key = str(p.mKey.data)
|
key = str(p.mKey.data).split('.')[1]
|
||||||
|
|
||||||
#the data
|
#the data
|
||||||
from ctypes import POINTER, cast, c_int, c_float, sizeof
|
from ctypes import POINTER, cast, c_int, c_float, sizeof
|
||||||
if p.mType == 1:
|
if p.mType == 1:
|
||||||
arr = cast(p.mData, POINTER(c_float * int(p.mDataLength/sizeof(c_float)) )).contents
|
arr = cast(p.mData, POINTER(c_float * int(p.mDataLength/sizeof(c_float)) )).contents
|
||||||
value = numpy.array([x for x in arr])
|
value = [x for x in arr]
|
||||||
elif p.mType == 3: #string can't be an array
|
elif p.mType == 3: #string can't be an array
|
||||||
value = cast(p.mData, POINTER(structs.String)).contents.data
|
value = cast(p.mData, POINTER(structs.String)).contents.data
|
||||||
elif p.mType == 4:
|
elif p.mType == 4:
|
||||||
arr = cast(p.mData, POINTER(c_int * int(p.mDataLength/sizeof(c_int)) )).contents
|
arr = cast(p.mData, POINTER(c_int * int(p.mDataLength/sizeof(c_int)) )).contents
|
||||||
value = numpy.array([x for x in arr])
|
value = [x for x in arr]
|
||||||
else:
|
else:
|
||||||
value = p.mData[:p.mDataLength]
|
value = p.mData[:p.mDataLength]
|
||||||
|
|
||||||
|
if len(value) == 1:
|
||||||
|
[value] = value
|
||||||
|
|
||||||
result[key] = value
|
result[key] = value
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -200,13 +200,13 @@ class GLRenderer():
|
||||||
|
|
||||||
if not hasattr(mat, "gl_mat"): # evaluate once the mat properties, and cache the values in a glDisplayList.
|
if not hasattr(mat, "gl_mat"): # evaluate once the mat properties, and cache the values in a glDisplayList.
|
||||||
|
|
||||||
diffuse = mat.properties.get("$clr.diffuse", numpy.array([0.8, 0.8, 0.8, 1.0]))
|
diffuse = numpy.array(mat.properties.get("diffuse", [0.8, 0.8, 0.8, 1.0]))
|
||||||
specular = mat.properties.get("$clr.specular", numpy.array([0., 0., 0., 1.0]))
|
specular = numpy.array(mat.properties.get("specular", [0., 0., 0., 1.0]))
|
||||||
ambient = mat.properties.get("$clr.ambient", numpy.array([0.2, 0.2, 0.2, 1.0]))
|
ambient = numpy.array(mat.properties.get("ambient", [0.2, 0.2, 0.2, 1.0]))
|
||||||
emissive = mat.properties.get("$clr.emissive", numpy.array([0., 0., 0., 1.0]))
|
emissive = numpy.array(mat.properties.get("emissive", [0., 0., 0., 1.0]))
|
||||||
shininess = min(mat.properties.get("$mat.shininess", 1.0), 128)
|
shininess = min(mat.properties.get("shininess", 1.0), 128)
|
||||||
wireframe = mat.properties.get("$mat.wireframe", 0)
|
wireframe = mat.properties.get("wireframe", 0)
|
||||||
twosided = mat.properties.get("$mat.twosided", 1)
|
twosided = mat.properties.get("twosided", 1)
|
||||||
|
|
||||||
from OpenGL.raw import GL
|
from OpenGL.raw import GL
|
||||||
setattr(mat, "gl_mat", GL.GLuint(0))
|
setattr(mat, "gl_mat", GL.GLuint(0))
|
||||||
|
|
Loading…
Reference in New Issue