copy icon in the material buttons list view so you can copy the current set of materi...
[blender-staging.git] / release / scripts / ui / buttons_material.py
index 448cb36e1305107abff88b393aa7766a8e02864e..03e11e003e20267ff028bcf7314b1025ed8e1b10 100644 (file)
@@ -1,6 +1,19 @@
        
 import bpy
 
+def active_node_mat(mat):
+       # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
+       # which settings from node-materials are used
+       if mat:
+               mat_node = mat.active_node_material
+               if mat_node:
+                       return mat_node
+               else:
+                       return mat
+
+       return None
+
+
 class MaterialButtonsPanel(bpy.types.Panel):
        __space_type__ = 'PROPERTIES'
        __region_type__ = 'WINDOW'
@@ -46,6 +59,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
                        col = row.column(align=True)
                        col.itemO("object.material_slot_add", icon='ICON_ZOOMIN', text="")
                        col.itemO("object.material_slot_remove", icon='ICON_ZOOMOUT', text="")
+                       col.itemO("object.material_slot_copy", icon='ICON_COPYDOWN', text="")
 
                        if ob.mode == 'EDIT':
                                row = layout.row(align=True)
@@ -74,14 +88,14 @@ class MATERIAL_PT_shading(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
 
                if mat.type in ('SURFACE', 'WIRE'):
                        split = layout.split()
@@ -117,7 +131,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                tan = mat.strand
                
                split = layout.split()
@@ -152,7 +166,7 @@ class MATERIAL_PT_physics(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               phys = context.material.physics
+               phys = context.material.physics # dont use node material
                
                split = layout.split()
                
@@ -171,14 +185,14 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                
                split = layout.split()
                
@@ -211,14 +225,14 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
        
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                
                split = layout.split()
                
@@ -244,14 +258,14 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material  
+               mat = active_node_mat(context.material)
                
                split = layout.split()
                
@@ -298,14 +312,14 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                
                layout.active = (not mat.shadeless)
                
@@ -351,12 +365,12 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
        
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw_header(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                sss = mat.subsurface_scattering
                
                self.layout.active = (not mat.shadeless)
@@ -365,7 +379,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                sss = mat.subsurface_scattering
 
                layout.active = sss.enabled     
@@ -396,19 +410,19 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
        
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
        
        def draw_header(self, context): 
-               raym = context.material.raytrace_mirror
+               raym = active_node_mat(context.material).raytrace_mirror
 
                self.layout.itemR(raym, "enabled", text="")
        
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                raym = mat.raytrace_mirror
                
                layout.active = raym.enabled
@@ -451,19 +465,19 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
                
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw_header(self, context): 
-               mat = context.material
+               mat = active_node_mat(context.material)
 
                self.layout.itemR(mat, "transparency", text="")
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                rayt = mat.raytrace_transparency
                
                row = layout.row()
@@ -517,7 +531,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                halo = mat.halo
 
                split = layout.split()
@@ -569,7 +583,7 @@ class MATERIAL_PT_flare(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                halo = mat.halo
 
                layout.active = halo.flare_mode
@@ -609,6 +623,22 @@ class VolumeButtonsPanel(bpy.types.Panel):
                mat = context.material
                engine = context.scene.render_data.engine
                return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES)
+
+class MATERIAL_PT_volume_density(VolumeButtonsPanel):
+       __label__ = "Density"
+       __default_closed__ = False
+       COMPAT_ENGINES = set(['BLENDER_RENDER'])
+
+       def draw(self, context):
+               layout = self.layout
+
+               vol = context.material.volume # dont use node material
+               
+               split = layout.split()
+               row = split.row()
+               row.itemR(vol, "density")
+               row.itemR(vol, "density_scale")
+
                
 class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
        __label__ = "Shading"
@@ -618,54 +648,58 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
-               row = layout.row()
-               row.itemR(vol, "density")
-               row.itemR(vol, "scattering")
-
                split = layout.split()
                
                col = split.column()
-               col.itemR(vol, "absorption")
-               col.itemR(vol, "absorption_color", text="")
-
+               col.itemR(vol, "scattering")
+               col.itemR(vol, "asymmetry")
+               col.itemR(vol, "transmission_color")
+               
                col = split.column()
-               col.itemR(vol, "emission")
-               col.itemR(vol, "emission_color", text="")
+               sub = col.column(align=True)
+               sub.itemR(vol, "emission")
+               sub.itemR(vol, "emission_color", text="")
+               sub = col.column(align=True)
+               sub.itemR(vol, "reflection")
+               sub.itemR(vol, "reflection_color", text="")     
 
-class MATERIAL_PT_volume_scattering(VolumeButtonsPanel):
-       __label__ = "Scattering"
+class MATERIAL_PT_volume_lighting(VolumeButtonsPanel):
+       __label__ = "Lighting"
        __default_closed__ = False
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
 
        def draw(self, context):
                layout = self.layout
                
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
                split = layout.split()
                
                col = split.column()
-               col.itemR(vol, "scattering_mode", text="")
-               if vol.scattering_mode == 'SINGLE_SCATTERING':
+               col.itemR(vol, "lighting_mode", text="")
+               
+               col = split.column()
+               
+               if vol.lighting_mode == 'SHADED':
+                       col.itemR(vol, "external_shadows")
                        col.itemR(vol, "light_cache")
                        sub = col.column()
                        sub.active = vol.light_cache
                        sub.itemR(vol, "cache_resolution")
-               elif vol.scattering_mode in ('MULTIPLE_SCATTERING', 'SINGLE_PLUS_MULTIPLE_SCATTERING'):
+               elif vol.lighting_mode in ('MULTIPLE_SCATTERING', 'SHADED_PLUS_MULTIPLE_SCATTERING'):
+                       sub = col.column()
+                       sub.enabled = True
+                       sub.active = False
+                       sub.itemR(vol, "light_cache")
                        col.itemR(vol, "cache_resolution")
                        
                        sub = col.column(align=True)
                        sub.itemR(vol, "ms_diffusion")
                        sub.itemR(vol, "ms_spread")
                        sub.itemR(vol, "ms_intensity")
-               
-               col = split.column()
-               # col.itemL(text="Anisotropic Scattering:")
-               col.itemR(vol, "phase_function", text="")
-               if vol.phase_function in ('SCHLICK', 'HENYEY-GREENSTEIN'):
-                       col.itemR(vol, "asymmetry")
+
 
 class MATERIAL_PT_volume_transp(VolumeButtonsPanel):
        __label__= "Transparency"
@@ -674,7 +708,7 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                
                layout.itemR(mat, "transparency_method", expand=True)
                
@@ -686,23 +720,22 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
                split = layout.split()
                
                col = split.column()
                col.itemL(text="Step Calculation:")
                col.itemR(vol, "step_calculation", text="")
-               sub = col.column(align=True)
-               sub.itemR(vol, "step_size")
-               sub.itemR(vol, "shading_step_size")
+               col = col.column(align=True)
+               col.itemR(vol, "step_size")
                
                col = split.column()
                col.itemL()
                col.itemR(vol, "depth_cutoff")
-               col.itemR(vol, "density_scale")
 
+bpy.types.register(MATERIAL_PT_volume_density)
 bpy.types.register(MATERIAL_PT_volume_shading)
-bpy.types.register(MATERIAL_PT_volume_scattering)
+bpy.types.register(MATERIAL_PT_volume_lighting)
 bpy.types.register(MATERIAL_PT_volume_transp)
 bpy.types.register(MATERIAL_PT_volume_integration)