fixed the composite material
parent
213f7d44d3
commit
2e07362fda
|
@ -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 ""
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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!")
|
||||
|
|
Loading…
Reference in New Issue