Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-22 03:22:29 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-22 03:22:29 +0300
commit9e2ed891054ccdcea315259c0d4a11d57325762a (patch)
tree9b79a962eb28318a221d178ae06be9e641c5828f
parent6db600dddc213fd2fdbf917e1301b26c8fe4a362 (diff)
SSS presets, Thomas and I added these at the same time, however I meant to make this a more general system.
this commit shows how to add a preset using the base preset class and menu with minimal effort.
-rw-r--r--release/scripts/op/presets.py25
-rw-r--r--release/scripts/ui/properties_material.py35
2 files changed, 40 insertions, 20 deletions
diff --git a/release/scripts/op/presets.py b/release/scripts/op/presets.py
index 8198cbde820..71044956816 100644
--- a/release/scripts/op/presets.py
+++ b/release/scripts/op/presets.py
@@ -25,7 +25,6 @@ from wm import AddPresetBase
class AddPresetRender(AddPresetBase):
bl_idname = "render.preset_add"
bl_label = "Add Render Preset"
-
name = AddPresetBase.name
preset_values = [
@@ -41,6 +40,30 @@ class AddPresetRender(AddPresetBase):
preset_path = os.path.join("presets", "render")
+class AddPresetSSS(AddPresetBase):
+ bl_idname = "material.sss_preset_add"
+ bl_label = "Add Render Preset"
+ name = AddPresetBase.name
+
+ preset_values = [
+ "bpy.context.material.subsurface_scattering.back",
+ "bpy.context.material.subsurface_scattering.color[0]",
+ "bpy.context.material.subsurface_scattering.color[1]",
+ "bpy.context.material.subsurface_scattering.color[2]",
+ "bpy.context.material.subsurface_scattering.color_factor",
+ "bpy.context.material.subsurface_scattering.error_tolerance",
+ "bpy.context.material.subsurface_scattering.front",
+ "bpy.context.material.subsurface_scattering.ior",
+ "bpy.context.material.subsurface_scattering.radius[0]",
+ "bpy.context.material.subsurface_scattering.radius[1]",
+ "bpy.context.material.subsurface_scattering.radius[2]",
+ "bpy.context.material.subsurface_scattering.scale",
+ "bpy.context.material.subsurface_scattering.texture_factor",
+ ]
+
+ preset_path = os.path.join("presets", "sss")
+
bpy.ops.add(AddPresetRender)
+bpy.ops.add(AddPresetSSS)
diff --git a/release/scripts/ui/properties_material.py b/release/scripts/ui/properties_material.py
index 15e9df3443f..8a5f359a355 100644
--- a/release/scripts/ui/properties_material.py
+++ b/release/scripts/ui/properties_material.py
@@ -22,18 +22,6 @@ import bpy
narrowui = 180
-class SSS_MT_presets(bpy.types.Menu):
- '''
- Creates the menu items by scanning scripts/templates
- '''
- bl_label = "Subsurface Scattering Presets"
-
- def draw(self, context):
- import os
- template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "sss")
- self.path_menu(template_dir, "script.python_file_run")
-
-
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
@@ -47,6 +35,15 @@ def active_node_mat(mat):
return None
+class MATERIAL_MT_sss_presets(bpy.types.Menu):
+ bl_label = "SSS Presets"
+
+ def draw(self, context):
+ import os
+ template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "sss")
+ self.path_menu(template_dir, "script.python_file_run")
+
+
class MaterialButtonsPanel(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@@ -487,15 +484,15 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
sss = mat.subsurface_scattering
wide_ui = context.region.width > narrowui
- layout.active = (sss.enabled) and (not mat.shadeless)
-
row = layout.row().split()
sub = row.row(align=True).split(percentage=0.75)
- sub.itemM("SSS_MT_presets", text="Presets")
- sub.itemO("sss.preset_add", text="Add")
- row.itemL()
+ sub.itemM("MATERIAL_MT_sss_presets", text="Presets")
+ sub.itemO("material.sss_preset_add", text="Add")
+
+ layout.active = sss.enabled
split = layout.split()
+ split.active = (not mat.shadeless)
col = split.column()
col.itemR(sss, "ior")
@@ -878,8 +875,8 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
col = split.column()
col.itemL()
col.itemR(vol, "depth_cutoff")
-
-bpy.types.register(SSS_MT_presets)
+
+bpy.types.register(MATERIAL_MT_sss_presets)
bpy.types.register(MATERIAL_PT_volume_density)
bpy.types.register(MATERIAL_PT_volume_shading)