* Added Subsurface Scattering Presets.
authorThomas Dinges <blender@dingto.org>
Sun, 22 Nov 2009 00:03:42 +0000 (00:03 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 22 Nov 2009 00:03:42 +0000 (00:03 +0000)
Note: Add doesn't work, it writes some text into the file, not the values. (Maybe because the values are arrays?!)
Campbell, please check :)

12 files changed:
release/scripts/op/preset_sss.py [new file with mode: 0644]
release/scripts/presets/sss/Apple.py [new file with mode: 0644]
release/scripts/presets/sss/Chicken.py [new file with mode: 0644]
release/scripts/presets/sss/Cream.py [new file with mode: 0644]
release/scripts/presets/sss/Ketchup.py [new file with mode: 0644]
release/scripts/presets/sss/Marble.py [new file with mode: 0644]
release/scripts/presets/sss/Potato.py [new file with mode: 0644]
release/scripts/presets/sss/Skin1.py [new file with mode: 0644]
release/scripts/presets/sss/Skin2.py [new file with mode: 0644]
release/scripts/presets/sss/Skin_Milk.py [new file with mode: 0644]
release/scripts/presets/sss/Whole_Milk.py [new file with mode: 0644]
release/scripts/ui/properties_material.py

diff --git a/release/scripts/op/preset_sss.py b/release/scripts/op/preset_sss.py
new file mode 100644 (file)
index 0000000..3d92858
--- /dev/null
@@ -0,0 +1,60 @@
+# ##### 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import bpy
+import os
+
+class AddPreset(bpy.types.Operator):
+    '''Add a Subsurface Scattering Preset'''
+    bl_idname = "sss.preset_add"
+    bl_label = "Add Subsurface Scattering Preset"
+    
+    name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen= 64, default= "New Preset")
+    
+    _preset_values = [
+        "bpy.context.active_object.active_material.subsurface_scattering.radius",
+        "bpy.context.active_object.active_material.subsurface_scattering.color",
+    ]
+    
+    _last_preset = "" # hack to avoid remaking
+    
+    def _as_filename(self, name): # could reuse for other presets
+        for char in " !@#$%^&*(){}:\";'[]<>,./?":
+            name = name.replace('.', '_')
+        return name.lower()
+
+    def execute(self, context):
+        filename = self._as_filename(self.properties.name) + ".py"
+        
+        target_path = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "sss", filename)
+        print(target_path)
+        file_preset = open(target_path, 'w')
+        
+        for rna_path in self._preset_values:
+            file_preset.write("%s = %s\n" % (rna_path, eval(rna_path)))
+        
+        file_preset.close()
+        
+        return ('FINISHED',)
+
+    def invoke(self, context, event):
+        wm = context.manager
+        wm.invoke_props_popup(self, event)
+        return ('RUNNING_MODAL',)
+
+bpy.ops.add(AddPreset)
diff --git a/release/scripts/presets/sss/Apple.py b/release/scripts/presets/sss/Apple.py
new file mode 100644 (file)
index 0000000..474769c
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 11.605, 3.884, 1.754
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.430, 0.210, 0.168
diff --git a/release/scripts/presets/sss/Chicken.py b/release/scripts/presets/sss/Chicken.py
new file mode 100644 (file)
index 0000000..6253de0
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 9.436, 3.348, 1.790
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.439, 0.216, 0.141
diff --git a/release/scripts/presets/sss/Cream.py b/release/scripts/presets/sss/Cream.py
new file mode 100644 (file)
index 0000000..f0a5292
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 15.028, 4.664, 2.541
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.987, 0.943, 0.827
diff --git a/release/scripts/presets/sss/Ketchup.py b/release/scripts/presets/sss/Ketchup.py
new file mode 100644 (file)
index 0000000..caece1e
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 4.762, 0.575, 0.394
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.222, 0.008, 0.002
diff --git a/release/scripts/presets/sss/Marble.py b/release/scripts/presets/sss/Marble.py
new file mode 100644 (file)
index 0000000..ea894f6
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 8.509, 5.566, 3.951
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.925, 0.905, 0.884
diff --git a/release/scripts/presets/sss/Potato.py b/release/scripts/presets/sss/Potato.py
new file mode 100644 (file)
index 0000000..89407df
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 14.266, 7.228, 2.036
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.855, 0.740, 0.292
diff --git a/release/scripts/presets/sss/Skin1.py b/release/scripts/presets/sss/Skin1.py
new file mode 100644 (file)
index 0000000..42fb1fa
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 3.673, 1.367, 0.683
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.574, 0.313, 0.174
diff --git a/release/scripts/presets/sss/Skin2.py b/release/scripts/presets/sss/Skin2.py
new file mode 100644 (file)
index 0000000..52b649e
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 4.821, 1.694, 1.090
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.749, 0.571, 0.467
diff --git a/release/scripts/presets/sss/Skin_Milk.py b/release/scripts/presets/sss/Skin_Milk.py
new file mode 100644 (file)
index 0000000..2e5b19d
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 18.424, 10.443, 3.502
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.889, 0.888, 0.796
diff --git a/release/scripts/presets/sss/Whole_Milk.py b/release/scripts/presets/sss/Whole_Milk.py
new file mode 100644 (file)
index 0000000..4cb6ccf
--- /dev/null
@@ -0,0 +1,2 @@
+bpy.context.active_object.active_material.subsurface_scattering.radius = 10.899, 6.575, 2.508
+bpy.context.active_object.active_material.subsurface_scattering.color = 0.947, 0.931, 0.852
index e85ad30e6f6db90c31ac24194283ff3e5792220a..15e9df3443f7c2ef99d9c1637dc5b0c0ece83132 100644 (file)
@@ -22,6 +22,18 @@ 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
@@ -475,10 +487,15 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
         sss = mat.subsurface_scattering
         wide_ui = context.region.width > narrowui
 
-        layout.active = sss.enabled
+        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()
 
         split = layout.split()
-        split.active = (not mat.shadeless)
 
         col = split.column()
         col.itemR(sss, "ior")
@@ -861,6 +878,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_PT_volume_density)
 bpy.types.register(MATERIAL_PT_volume_shading)