~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/startup/bl_ui/properties_physics_cloth.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ##### BEGIN GPL LICENSE BLOCK #####
 
2
#
 
3
#  This program is free software; you can redistribute it and/or
 
4
#  modify it under the terms of the GNU General Public License
 
5
#  as published by the Free Software Foundation; either version 2
 
6
#  of the License, or (at your option) any later version.
 
7
#
 
8
#  This program is distributed in the hope that it will be useful,
 
9
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#  GNU General Public License for more details.
 
12
#
 
13
#  You should have received a copy of the GNU General Public License
 
14
#  along with this program; if not, write to the Free Software Foundation,
 
15
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
#
 
17
# ##### END GPL LICENSE BLOCK #####
 
18
 
 
19
# <pep8 compliant>
 
20
import bpy
 
21
from bpy.types import Menu, Panel
 
22
 
 
23
from bl_ui.properties_physics_common import (
 
24
    point_cache_ui,
 
25
    effector_weights_ui,
 
26
    )
 
27
 
 
28
 
 
29
def cloth_panel_enabled(md):
 
30
    return md.point_cache.is_baked is False
 
31
 
 
32
 
 
33
class CLOTH_MT_presets(Menu):
 
34
    bl_label = "Cloth Presets"
 
35
    preset_subdir = "cloth"
 
36
    preset_operator = "script.execute_preset"
 
37
    draw = Menu.draw_preset
 
38
 
 
39
 
 
40
class PhysicButtonsPanel():
 
41
    bl_space_type = 'PROPERTIES'
 
42
    bl_region_type = 'WINDOW'
 
43
    bl_context = "physics"
 
44
 
 
45
    @classmethod
 
46
    def poll(cls, context):
 
47
        ob = context.object
 
48
        rd = context.scene.render
 
49
        return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.cloth)
 
50
 
 
51
 
 
52
class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
 
53
    bl_label = "Cloth"
 
54
 
 
55
    def draw(self, context):
 
56
        layout = self.layout
 
57
 
 
58
        md = context.cloth
 
59
        ob = context.object
 
60
        cloth = md.settings
 
61
 
 
62
        split = layout.split()
 
63
 
 
64
        split.active = cloth_panel_enabled(md)
 
65
 
 
66
        col = split.column()
 
67
 
 
68
        col.label(text="Presets:")
 
69
        sub = col.row(align=True)
 
70
        sub.menu("CLOTH_MT_presets", text=bpy.types.CLOTH_MT_presets.bl_label)
 
71
        sub.operator("cloth.preset_add", text="", icon='ZOOMIN')
 
72
        sub.operator("cloth.preset_add", text="", icon='ZOOMOUT').remove_active = True
 
73
 
 
74
        col.label(text="Quality:")
 
75
        col.prop(cloth, "quality", text="Steps", slider=True)
 
76
 
 
77
        col.label(text="Material:")
 
78
        col.prop(cloth, "mass")
 
79
        col.prop(cloth, "structural_stiffness", text="Structural")
 
80
        col.prop(cloth, "bending_stiffness", text="Bending")
 
81
 
 
82
        col = split.column()
 
83
 
 
84
        col.label(text="Damping:")
 
85
        col.prop(cloth, "spring_damping", text="Spring")
 
86
        col.prop(cloth, "air_damping", text="Air")
 
87
        col.prop(cloth, "vel_damping", text="Velocity")
 
88
 
 
89
        col.prop(cloth, "use_pin_cloth", text="Pinning")
 
90
        sub = col.column()
 
91
        sub.active = cloth.use_pin_cloth
 
92
        sub.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="")
 
93
        sub.prop(cloth, "pin_stiffness", text="Stiffness")
 
94
 
 
95
        col.label(text="Pre roll:")
 
96
        col.prop(cloth, "pre_roll", text="Frame")
 
97
 
 
98
        # Disabled for now
 
99
        """
 
100
        if cloth.vertex_group_mass:
 
101
            layout.label(text="Goal:")
 
102
 
 
103
            col = layout.column_flow()
 
104
            col.prop(cloth, "goal_default", text="Default")
 
105
            col.prop(cloth, "goal_spring", text="Stiffness")
 
106
            col.prop(cloth, "goal_friction", text="Friction")
 
107
        """
 
108
 
 
109
        key = ob.data.shape_keys
 
110
 
 
111
        if key:
 
112
            col.label(text="Rest Shape Key:")
 
113
            col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="")
 
114
 
 
115
 
 
116
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
 
117
    bl_label = "Cloth Cache"
 
118
    bl_options = {'DEFAULT_CLOSED'}
 
119
 
 
120
    @classmethod
 
121
    def poll(cls, context):
 
122
        return context.cloth
 
123
 
 
124
    def draw(self, context):
 
125
        md = context.cloth
 
126
        point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
 
127
 
 
128
 
 
129
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
 
130
    bl_label = "Cloth Collision"
 
131
    bl_options = {'DEFAULT_CLOSED'}
 
132
 
 
133
    @classmethod
 
134
    def poll(cls, context):
 
135
        return context.cloth
 
136
 
 
137
    def draw_header(self, context):
 
138
        cloth = context.cloth.collision_settings
 
139
 
 
140
        self.layout.active = cloth_panel_enabled(context.cloth)
 
141
        self.layout.prop(cloth, "use_collision", text="")
 
142
 
 
143
    def draw(self, context):
 
144
        layout = self.layout
 
145
 
 
146
        cloth = context.cloth.collision_settings
 
147
        md = context.cloth
 
148
 
 
149
        layout.active = cloth.use_collision and cloth_panel_enabled(md)
 
150
 
 
151
        split = layout.split()
 
152
 
 
153
        col = split.column()
 
154
        col.prop(cloth, "collision_quality", slider=True, text="Quality")
 
155
        col.prop(cloth, "distance_min", slider=True, text="Distance")
 
156
        col.prop(cloth, "repel_force", slider=True, text="Repel")
 
157
        col.prop(cloth, "distance_repel", slider=True, text="Repel Distance")
 
158
        col.prop(cloth, "friction")
 
159
 
 
160
        col = split.column()
 
161
        col.prop(cloth, "use_self_collision", text="Self Collision")
 
162
        sub = col.column()
 
163
        sub.active = cloth.use_self_collision
 
164
        sub.prop(cloth, "self_collision_quality", slider=True, text="Quality")
 
165
        sub.prop(cloth, "self_distance_min", slider=True, text="Distance")
 
166
 
 
167
        layout.prop(cloth, "group")
 
168
 
 
169
 
 
170
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
 
171
    bl_label = "Cloth Stiffness Scaling"
 
172
    bl_options = {'DEFAULT_CLOSED'}
 
173
 
 
174
    @classmethod
 
175
    def poll(cls, context):
 
176
        return context.cloth
 
177
 
 
178
    def draw_header(self, context):
 
179
        cloth = context.cloth.settings
 
180
 
 
181
        self.layout.active = cloth_panel_enabled(context.cloth)
 
182
        self.layout.prop(cloth, "use_stiffness_scale", text="")
 
183
 
 
184
    def draw(self, context):
 
185
        layout = self.layout
 
186
 
 
187
        md = context.cloth
 
188
        ob = context.object
 
189
        cloth = context.cloth.settings
 
190
 
 
191
        layout.active = cloth.use_stiffness_scale       and cloth_panel_enabled(md)
 
192
 
 
193
        split = layout.split()
 
194
 
 
195
        col = split.column()
 
196
        col.label(text="Structural Stiffness:")
 
197
        col.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
 
198
        col.prop(cloth, "structural_stiffness_max", text="Max")
 
199
 
 
200
        col = split.column()
 
201
        col.label(text="Bending Stiffness:")
 
202
        col.prop_search(cloth, "vertex_group_bending", ob, "vertex_groups", text="")
 
203
        col.prop(cloth, "bending_stiffness_max", text="Max")
 
204
 
 
205
 
 
206
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
 
207
    bl_label = "Cloth Field Weights"
 
208
    bl_options = {'DEFAULT_CLOSED'}
 
209
 
 
210
    @classmethod
 
211
    def poll(cls, context):
 
212
        return (context.cloth)
 
213
 
 
214
    def draw(self, context):
 
215
        cloth = context.cloth.settings
 
216
        effector_weights_ui(self, context, cloth.effector_weights)
 
217
 
 
218
if __name__ == "__main__":  # only for live edit.
 
219
    bpy.utils.register_module(__name__)