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                 md = self.cloth_modifier(context)               
71                 cloth = md.collision_settings
72                 
73                 col = layout.column_flow()
74                 col.itemR(cloth, "collision_quality", slider=True)
75                 col.itemR(cloth, "friction")
76                 col.itemR(cloth, "min_distance", text="MinDistance")
77                 
78                 
79                 layout.itemR(cloth, "enable_self_collision", text="Self Collision")
80                 
81                 col = layout.column_flow()
82                 col.itemR(cloth, "self_collision_quality", slider=True)
83                 col.itemR(cloth, "self_min_distance", text="MinDistance")
84
85 class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
86         __idname__ = "Physic_PT_stiffness"
87         __label__ = "Cloth Stiffness Scaling"
88         
89         def draw_header(self, context):
90                 layout = self.layout
91                 md = self.cloth_modifier(context)
92                 cloth = md.settings
93         
94                 layout.itemR(cloth, "stiffness_scaling", text="")
95
96         def draw(self, context):
97                 layout = self.layout
98                 md = self.cloth_modifier(context)
99                 cloth = md.settings
100                 
101                 split = layout.split()
102                 
103                 sub = split.column()
104                 sub.itemL(text="Structural Stiffness:")
105                 sub.column().itemR(cloth, "structural_stiffness_vertex_group", text="VGroup")
106                 sub.itemR(cloth, "structural_stiffness_max", text="Max")
107                 
108                 sub = split.column()
109                 sub.itemL(text="Bending Stiffness:")
110                 sub.column().itemR(cloth, "bending_vertex_group", text="VGroup")
111                 sub.itemR(cloth, "bending_stiffness_max", text="Max")
112                 
113 bpy.types.register(Physic_PT_cloth)
114 bpy.types.register(Physic_PT_cloth_collision)
115 bpy.types.register(Physic_PT_cloth_stiffness)