* Minor cleanups.
authorThomas Dinges <blender@dingto.org>
Sun, 22 Nov 2009 10:32:37 +0000 (10:32 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 22 Nov 2009 10:32:37 +0000 (10:32 +0000)
* Added Cloth Presets. Patch by nudelZ. Thanks!

release/scripts/op/presets.py
release/scripts/presets/cloth/cotton.py [new file with mode: 0644]
release/scripts/presets/cloth/denim.py [new file with mode: 0644]
release/scripts/presets/cloth/leather.py [new file with mode: 0644]
release/scripts/presets/cloth/rubber.py [new file with mode: 0644]
release/scripts/presets/cloth/silk.py [new file with mode: 0644]
release/scripts/ui/properties_physics_cloth.py

index 7088fb1adc9ff6f2421cf0ac13a3fc5c74688206..dbc7b71b9160b18d3d5c3f19a2da26fbe82241ec 100644 (file)
@@ -23,6 +23,7 @@ from wm import AddPresetBase
 
 
 class AddPresetRender(AddPresetBase):
+    '''Add a Render Preset.'''
     bl_idname = "render.preset_add"
     bl_label = "Add Render Preset"
     name = AddPresetBase.name
@@ -41,6 +42,7 @@ class AddPresetRender(AddPresetBase):
 
 
 class AddPresetSSS(AddPresetBase):
+    '''Add a Subsurface Scattering Preset.'''
     bl_idname = "material.sss_preset_add"
     bl_label = "Add SSS Preset"
     name = AddPresetBase.name
@@ -62,8 +64,26 @@ class AddPresetSSS(AddPresetBase):
     ]
 
     preset_path = os.path.join("presets", "sss")
+    
+class AddPresetCloth(AddPresetBase):
+    '''Add a Cloth Preset.'''
+    bl_idname = "cloth.preset_add"
+    bl_label = "Add Cloth Preset"
+    name = AddPresetBase.name
+    
+    preset_values = [
+        "bpy.context.active_object.modifiers['Cloth'].settings.quality",
+        "bpy.context.active_object.modifiers['Cloth'].settings.mass",
+        "bpy.context.active_object.modifiers['Cloth'].settings.structural_stiffness",
+        "bpy.context.active_object.modifiers['Cloth'].settings.bending_stiffness",
+        "bpy.context.active_object.modifiers['Cloth'].settings.spring_damping",
+        "bpy.context.active_object.modifiers['Cloth'].settings.air_damping",
+    ]
+    
+    preset_path = os.path.join("presets", "cloth")
 
 bpy.ops.add(AddPresetRender)
 bpy.ops.add(AddPresetSSS)
+bpy.ops.add(AddPresetCloth)
 
 
diff --git a/release/scripts/presets/cloth/cotton.py b/release/scripts/presets/cloth/cotton.py
new file mode 100644 (file)
index 0000000..2771749
--- /dev/null
@@ -0,0 +1,6 @@
+bpy.context.active_object.modifiers['Cloth'].settings.quality = 5
+bpy.context.active_object.modifiers['Cloth'].settings.mass = 0.300
+bpy.context.active_object.modifiers['Cloth'].settings.structural_stiffness = 15.000
+bpy.context.active_object.modifiers['Cloth'].settings.bending_stiffness = 0.500
+bpy.context.active_object.modifiers['Cloth'].settings.spring_damping = 5.000
+bpy.context.active_object.modifiers['Cloth'].settings.air_damping = 1.000
diff --git a/release/scripts/presets/cloth/denim.py b/release/scripts/presets/cloth/denim.py
new file mode 100644 (file)
index 0000000..0d9be3c
--- /dev/null
@@ -0,0 +1,6 @@
+bpy.context.active_object.modifiers['Cloth'].settings.quality = 12
+bpy.context.active_object.modifiers['Cloth'].settings.mass = 1
+bpy.context.active_object.modifiers['Cloth'].settings.structural_stiffness = 40
+bpy.context.active_object.modifiers['Cloth'].settings.bending_stiffness = 10
+bpy.context.active_object.modifiers['Cloth'].settings.spring_damping = 25
+bpy.context.active_object.modifiers['Cloth'].settings.air_damping = 1
diff --git a/release/scripts/presets/cloth/leather.py b/release/scripts/presets/cloth/leather.py
new file mode 100644 (file)
index 0000000..f64608b
--- /dev/null
@@ -0,0 +1,6 @@
+bpy.context.active_object.modifiers['Cloth'].settings.quality = 15
+bpy.context.active_object.modifiers['Cloth'].settings.mass = 0.4
+bpy.context.active_object.modifiers['Cloth'].settings.structural_stiffness = 80
+bpy.context.active_object.modifiers['Cloth'].settings.bending_stiffness = 150
+bpy.context.active_object.modifiers['Cloth'].settings.spring_damping = 25
+bpy.context.active_object.modifiers['Cloth'].settings.air_damping = 1
diff --git a/release/scripts/presets/cloth/rubber.py b/release/scripts/presets/cloth/rubber.py
new file mode 100644 (file)
index 0000000..101c11b
--- /dev/null
@@ -0,0 +1,6 @@
+bpy.context.active_object.modifiers['Cloth'].settings.quality = 7
+bpy.context.active_object.modifiers['Cloth'].settings.mass = 3
+bpy.context.active_object.modifiers['Cloth'].settings.structural_stiffness = 15
+bpy.context.active_object.modifiers['Cloth'].settings.bending_stiffness = 25
+bpy.context.active_object.modifiers['Cloth'].settings.spring_damping = 25
+bpy.context.active_object.modifiers['Cloth'].settings.air_damping = 1
diff --git a/release/scripts/presets/cloth/silk.py b/release/scripts/presets/cloth/silk.py
new file mode 100644 (file)
index 0000000..21de166
--- /dev/null
@@ -0,0 +1,6 @@
+bpy.context.active_object.modifiers["Cloth"].settings.quality = 5
+bpy.context.active_object.modifiers["Cloth"].settings.mass = 0.150
+bpy.context.active_object.modifiers["Cloth"].settings.structural_stiffness = 5
+bpy.context.active_object.modifiers["Cloth"].settings.bending_stiffness = 0.05
+bpy.context.active_object.modifiers["Cloth"].settings.spring_damping = 0
+bpy.context.active_object.modifiers["Cloth"].settings.air_damping = 1
index 2dc818ab149d1178167f3f2b75602ad632dfa6a0..620225c6deeed5ae23c4814c8f12af65ebc70662 100644 (file)
@@ -28,6 +28,18 @@ from properties_physics_common import effector_weights_ui
 
 def cloth_panel_enabled(md):
     return md.point_cache.baked == False
+    
+
+class CLOTH_MT_presets(bpy.types.Menu):
+    '''
+    Creates the menu items by scanning scripts/templates
+    '''
+    bl_label = "Cloth Presets"
+
+    def draw(self, context):
+        import os
+        template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "cloth")
+        self.path_menu(template_dir, "script.python_file_run")
 
 
 class PhysicButtonsPanel(bpy.types.Panel):
@@ -78,7 +90,9 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel):
             col = split.column()
 
             col.itemL(text="Presets:")
-            col.itemL(text="TODO!")
+            sub = col.row(align=True).split(percentage=0.75)
+            sub.itemM("CLOTH_MT_presets", text="Presets")
+            sub.itemO("cloth.preset_add", text="Add")
 
             col.itemL(text="Quality:")
             col.itemR(cloth, "quality", text="Steps", slider=True)
@@ -213,6 +227,8 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel):
     def draw(self, context):
         cloth = context.cloth.settings
         effector_weights_ui(self, context, cloth.effector_weights)
+        
+bpy.types.register(CLOTH_MT_presets)
 
 bpy.types.register(PHYSICS_PT_cloth)
 bpy.types.register(PHYSICS_PT_cloth_cache)