From 213f7d44d3e05cb15c5f20e1bfb7e2ea7a1f3b1c Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 14 Nov 2010 18:52:39 +0100 Subject: [PATCH] more work on the composite material --- tools/blender/mitsuba/properties/material.py | 20 +++++++++++++++++-- .../blender/mitsuba/ui/materials/composite.py | 11 ++++++++++ tools/blender/mitsuba/ui/render_panels.py | 1 - 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tools/blender/mitsuba/properties/material.py b/tools/blender/mitsuba/properties/material.py index ecaed85b..51bbe4a6 100644 --- a/tools/blender/mitsuba/properties/material.py +++ b/tools/blender/mitsuba/properties/material.py @@ -5,6 +5,7 @@ import bpy from extensions_framework import declarative_property_group from extensions_framework import util as efutil +from extensions_framework.validate import Logic_Operator from mitsuba.properties.texture import TextureParameter from mitsuba.export import ParamSet @@ -513,7 +514,7 @@ class WeightedMaterialParameter: self.propertyGroup = propertyGroup def get_controls(self): - return [ ['%s_material' % self.name, .8, '%s_weight' % self.name ]] + return [ ['%s_material' % self.name, .7, '%s_weight' % self.name ]] def get_properties(self): return [ @@ -545,9 +546,17 @@ class WeightedMaterialParameter: param_mat = [] -for i in range(0, 6): +for i in range(1, 6): param_mat.append(WeightedMaterialParameter("mat%i" % i, "Material %i" % i, "mitsuba_mat_composite")); + +def mitsuba_mat_composite_visibility(): + result = {} + for i in range(2, 6): + result["mat%i_material" % i] = {'nElements' : Logic_Operator({'gte' : i})} + result["mat%i_weight" % i] = {'nElements' : Logic_Operator({'gte' : i})} + return result + class mitsuba_mat_composite(declarative_property_group): controls = [ 'nElements' @@ -565,3 +574,10 @@ class mitsuba_mat_composite(declarative_property_group): 'save_in_preset': True } ] + sum(map(lambda x: x.get_properties(), param_mat), []) + + visibility = mitsuba_mat_composite_visibility() + + def get_params(self): + params = ParamSet() + return params + diff --git a/tools/blender/mitsuba/ui/materials/composite.py b/tools/blender/mitsuba/ui/materials/composite.py index 56a819b0..91f690f4 100644 --- a/tools/blender/mitsuba/ui/materials/composite.py +++ b/tools/blender/mitsuba/ui/materials/composite.py @@ -28,3 +28,14 @@ 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 + for i in range(1,mat.nElements+1): + weight += getattr(mat, "mat%i_weight" % i) + if weight > 1: + row = self.layout.row() + row.label("Warning: material weights sum to >1") diff --git a/tools/blender/mitsuba/ui/render_panels.py b/tools/blender/mitsuba/ui/render_panels.py index 38e74363..9e07661c 100644 --- a/tools/blender/mitsuba/ui/render_panels.py +++ b/tools/blender/mitsuba/ui/render_panels.py @@ -44,7 +44,6 @@ class setup_preset(render_described_context, bpy.types.Panel): super().draw(context) - class engine(render_described_context, bpy.types.Panel): ''' Engine settings UI Panel