From 4c5b2a69423b04e7e54c405cc5ea0d599a08f95a Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 12 Nov 2010 02:05:24 +0100 Subject: [PATCH] MtsBlend: missing files (lamp control panel + properties) --- tools/blender/mitsuba/properties/lamp.py | 95 +++++++++++++++++++++++ tools/blender/mitsuba/ui/lamps.py | 99 ++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 tools/blender/mitsuba/properties/lamp.py create mode 100644 tools/blender/mitsuba/ui/lamps.py diff --git a/tools/blender/mitsuba/properties/lamp.py b/tools/blender/mitsuba/properties/lamp.py new file mode 100644 index 00000000..acede349 --- /dev/null +++ b/tools/blender/mitsuba/properties/lamp.py @@ -0,0 +1,95 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +from extensions_framework import declarative_property_group + +class mitsuba_lamp(declarative_property_group): + controls = [ + 'sampling_weight', + 'envmap_type', + 'envmap_file' + ] + + visibility = { + 'envmap_type': { 'type': 'ENV' }, + 'envmap_file': { 'type': 'ENV', 'envmap_type' : 'envmap' } + } + + properties = [ + { + 'type': 'enum', + 'attr': 'type', + 'name': 'Light source type', + 'description': 'Specifies the behavior of the light source', + 'default': 'POINT', + 'items': [ + ('POINT', 'Point', 'Omnidirectional spot light source'), + ('SUN', 'Dir', 'Constant direction parallel light source'), + ('SPOT', 'Spot', 'Directional cone light source'), + ('ENV', 'Env', 'Environment map light source'), + ('AREA', 'Area', 'Diffuse area light source') + ], + 'save_in_preset': True + }, + { + 'type': 'float', + 'attr': 'sampling_weight', + 'name': 'Sampling weight', + 'description': 'Determines the relative amount of samples for this light source', + 'default': 1.0, + 'min': 1e-3, + 'soft_min': 1e-3, + 'max': 1e3, + 'soft_max': 1e3, + 'save_in_preset': True + }, + { + 'type': 'float', + 'attr': 'intensity', + 'name': 'Intensity', + 'description': 'Specifies the intensity of the light source', + 'default': 1.0, + 'min': 1e-3, + 'soft_min': 1e-3, + 'max': 1e3, + 'soft_max': 1e3, + 'save_in_preset': True + }, + { + 'type': 'enum', + 'attr': 'envmap_type', + 'name': 'Environment map type', + 'description': 'Environment map type', + 'default': 'constant', + 'items': [ + ('constant', 'Constant background source', 'constant'), + ('envmap', 'HDRI environment map', 'envmap') + ], + 'save_in_preset': True + }, + { + 'type': 'string', + 'subtype': 'FILE_PATH', + 'attr': 'envmap_file', + 'name': 'HDRI Map', + 'description': 'EXR image to use for lighting (in latitude-longitude format)', + 'default': '', + 'save_in_preset': True + } + ] + diff --git a/tools/blender/mitsuba/ui/lamps.py b/tools/blender/mitsuba/ui/lamps.py new file mode 100644 index 00000000..e4e594c0 --- /dev/null +++ b/tools/blender/mitsuba/ui/lamps.py @@ -0,0 +1,99 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +import bpy +from properties_data_lamp import DataButtonsPanel + +from extensions_framework.ui import property_group_renderer + +narrowui = 180 + +class lamps(DataButtonsPanel, property_group_renderer, bpy.types.Panel): + bl_label = 'Mitsuba Lamps' + COMPAT_ENGINES = {'mitsuba'} + + display_property_groups = [ + ( ('lamp',), 'mitsuba_lamp' ) + ] + + # Overridden to draw some of blender's lamp controls + def draw(self, context): + lamp = context.lamp + if lamp is not None: + layout = self.layout + wide_ui = context.region.width > narrowui + + if wide_ui: + layout.prop(lamp.mitsuba_lamp, "type", expand=True) + else: + layout.prop(lamp.mitsuba_lamp, "type", text="") + + if lamp.mitsuba_lamp.type == 'ENV': + lamp.type = 'HEMI' + else: + lamp.type = lamp.mitsuba_lamp.type + + split = layout.split() + + col = split.column() + + if lamp.type == 'HEMI': + layout.prop(lamp.mitsuba_lamp, "envmap_type", text="Type") + + if not(lamp.type == 'HEMI' and + lamp.mitsuba_lamp.envmap_type == 'envmap'): + layout.prop(lamp, "color", text="Color") + else: + layout.prop(lamp.mitsuba_lamp, "envmap_file", text="HDRI file") + layout.prop(lamp.mitsuba_lamp, "intensity", text="Intensity") + layout.prop(lamp.mitsuba_lamp, "sampling_weight", text = "Sampling weight") + + # SPOT LAMP: Blender Properties + if lamp.type == 'SPOT': + wide_ui = context.region.width > narrowui + + if wide_ui: + #col = split.column() + col=layout.row() + else: + col=layout.column() + col.prop(lamp, "spot_size", text="Size") + col.prop(lamp, "spot_blend", text="Blend", slider=True) + col=layout.row() + col.prop(lamp, "show_cone") + + # AREA LAMP: Blender Properties + elif lamp.type == 'AREA': + + if wide_ui: + col=layout.row() + else: + col=layout.column() + col.row().prop(lamp, "shape", expand=True) + + sub = col.column(align=True) + if (lamp.shape == 'SQUARE'): + sub.prop(lamp, "size") + elif (lamp.shape == 'RECTANGLE'): + sub.prop(lamp, "size", text="Size X") + sub.prop(lamp, "size_y", text="Size Y") + elif wide_ui: + col = split.column() + + if lamp.type == 'HEMI': + layout.label('Note: these cover the whole sphere')