2.5 Buttons
[blender.git] / release / ui / buttons_physic_cloth.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "physics"
8
9         def cloth_modifier(self, context):
10                 ob = context.active_object
11                 for md in ob.modifiers:
12                         if md.type == 'CLOTH':
13                                 return md
14
15                 return None
16         
17         def poll(self, context):
18                 md = self.cloth_modifier(context)
19                 return (md != None)
20                 
21 class Physic_PT_cloth(PhysicButtonsPanel):
22         __idname__ = "Physic_PT_cloth"
23         __label__ = "Cloth"
24
25         def draw(self, context):
26                 layout = self.layout
27                 md = self.cloth_modifier(context)
28                 cloth = md.settings
29                 
30                 split = layout.split()
31                 
32                 col = split.column()
33                 col.itemR(cloth, "quality", slider=True)
34                 col.itemR(cloth, "gravity")
35                 col.itemR(cloth, "mass")
36                 col.itemR(cloth, "mass_vertex_group", text="Vertex Group")
37
38                 col = split.column()
39                 col.itemL(text="Stiffness:")
40                 col.itemR(cloth, "structural_stiffness", text="Structural")
41                 col.itemR(cloth, "bending_stiffness", text="Bending")
42                 col.itemL(text="Damping:")
43                 col.itemR(cloth, "spring_damping", text="Spring")
44                 col.itemR(cloth, "air_damping", text="Air")
45                 
46                 # Disabled for now
47                 """
48                 if cloth.mass_vertex_group:
49                         layout.itemL(text="Goal:")
50                 
51                         col = layout.column_flow()
52                         col.itemR(cloth, "goal_default", text="Default")
53                         col.itemR(cloth, "goal_spring", text="Stiffness")
54                         col.itemR(cloth, "goal_friction", text="Friction")
55                 """
56         
57 class Physic_PT_cloth_collision(PhysicButtonsPanel):
58         __idname__ = "Physic_PT_clothcollision"
59         __label__ = "Cloth Collision"
60         
61         def draw_header(self, context):
62                 layout = self.layout
63                 md = self.cloth_modifier(context)                       
64                 cloth = md.collision_settings
65         
66                 layout.itemR(cloth, "enable_collision", text="")
67
68         def draw(self, context):
69                 layout = self.layout
70                 
71                 md = self.cloth_modifier(context)
72                 cloth = md.collision_settings
73                 layout.active = cloth.enable_collision  
74                 
75                 col = layout.column_flow()
76                 col.itemR(cloth, "collision_quality", slider=True)
77                 col.itemR(cloth, "friction")
78                 col.itemR(cloth, "min_distance", text="MinDistance")
79                 
80                 
81                 layout.itemR(cloth, "enable_self_collision", text="Self Collision")
82                 
83                 col = layout.column_flow()
84                 col.active = cloth.enable_self_collision
85                 col.itemR(cloth, "self_collision_quality", slider=True)
86                 col.itemR(cloth, "self_min_distance", text="MinDistance")
87
88 class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
89         __idname__ = "Physic_PT_stiffness"
90         __label__ = "Cloth Stiffness Scaling"
91         
92         def draw_header(self, context):
93                 layout = self.layout
94                 md = self.cloth_modifier(context)
95                 cloth = md.settings
96         
97                 layout.itemR(cloth, "stiffness_scaling", text="")
98
99         def draw(self, context):
100                 layout = self.layout
101                 
102                 md = self.cloth_modifier(context)
103                 cloth = md.settings
104                 layout.active = cloth.stiffness_scaling 
105                 
106                 split = layout.split()
107                 
108                 sub = split.column()
109                 sub.itemL(text="Structural Stiffness:")
110                 sub.column().itemR(cloth, "structural_stiffness_vertex_group", text="VGroup")
111                 sub.itemR(cloth, "structural_stiffness_max", text="Max")
112                 
113                 sub = split.column()
114                 sub.itemL(text="Bending Stiffness:")
115                 sub.column().itemR(cloth, "bending_vertex_group", text="VGroup")
116                 sub.itemR(cloth, "bending_stiffness_max", text="Max")
117                 
118 bpy.types.register(Physic_PT_cloth)
119 bpy.types.register(Physic_PT_cloth_collision)
120 bpy.types.register(Physic_PT_cloth_stiffness)