fixed the composite material

metadata
Wenzel Jakob 2010-11-14 22:12:53 +01:00
parent 213f7d44d3
commit 2e07362fda
3 changed files with 25 additions and 3 deletions

View File

@ -45,7 +45,10 @@ class ParamSetItem(list):
def to_string_ref(self):
if self.type == "reference_texture" or self.type == "reference_material":
return '\t\t<ref name="%s" id="%s"/>\n' % (self.name, self.value)
if self.name == "":
return '\t\t<ref id="%s"/>\n' % self.value
else:
return '\t\t<ref name="%s" id="%s"/>\n' % (self.name, self.value)
else:
return ""

View File

@ -579,5 +579,10 @@ class mitsuba_mat_composite(declarative_property_group):
def get_params(self):
params = ParamSet()
weights = ""
for i in range(1,self.nElements+1):
weights += str(getattr(self, "mat%i_weight" % i)) + " "
params.add_reference('material', "mat%i" % i, getattr(self, "mat%i_name" % i))
params.add_string('weights', weights)
return params

View File

@ -28,14 +28,28 @@ class ui_material_composite(mitsuba_material_sub, bpy.types.Panel):
display_property_groups = [
( ('material', 'mitsuba_material'), 'mitsuba_mat_composite' )
]
def draw(self, context):
super().draw(context)
mat = context.material.mitsuba_material.mitsuba_mat_composite
weight = 0
missing = False
selfRef = False
for i in range(1,mat.nElements+1):
weight += getattr(mat, "mat%i_weight" % i)
name = getattr(mat, "mat%i_name" % i)
if name == '':
missing = True
elif name == context.material.name:
selfRef = True
if weight > 1:
row = self.layout.row()
row.label("Warning: material weights sum to >1")
row.label("Warning: material weights sum to >1!")
if selfRef:
row = self.layout.row()
row.label("Warning: self references not allowed!")
if missing:
row = self.layout.row()
row.label("Warning: missing material reference!")