FBX exporter conversion almost done.
[blender.git] / release / ui / buttons_physics_softbody.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 poll(self, context):
10                 ob = context.object
11                 return (ob and ob.type == 'MESH')
12                 
13 class PHYSICS_PT_softbody(PhysicButtonsPanel):
14         __idname__ = "PHYSICS_PT_softbody"
15         __label__ = "Soft Body"
16
17         def draw(self, context):
18                 layout = self.layout
19                 md = context.soft_body
20                 ob = context.object
21
22                 split = layout.split()
23                 split.operator_context = "EXEC_DEFAULT"
24
25                 if md:
26                         # remove modifier + settings
27                         split.set_context_pointer("modifier", md)
28                         split.itemO("OBJECT_OT_modifier_remove", text="Remove")
29
30                         row = split.row(align=True)
31                         row.itemR(md, "render", text="")
32                         row.itemR(md, "realtime", text="")
33                 else:
34                         # add modifier
35                         split.item_enumO("OBJECT_OT_modifier_add", "type", "SOFTBODY", text="Add")
36                         split.itemL("")
37                         
38                 if md:
39                         softbody = md.settings
40
41                         # General
42                         split = layout.split()
43                         
44                         col = split.column()
45                         col.itemL(text="Object:")
46                         col.itemR(softbody, "mass")
47                         col.itemR(softbody, "friction")
48
49                         col = split.column()
50                         col.itemL(text="Simulation:")
51                         col.itemR(softbody, "gravity")
52                         col.itemR(softbody, "speed")
53                         
54                         
55 class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
56         __idname__ = "PHYSICS_PT_softbody_goal"
57         __label__ = "Soft Body Goal"
58         
59         def poll(self, context):
60                 return (context.soft_body != None)
61                 
62         def draw_header(self, context):
63                 layout = self.layout
64                 softbody = context.soft_body.settings
65         
66                 layout.itemR(softbody, "use_goal", text="")
67                 
68         def draw(self, context):
69                 layout = self.layout
70                 md = context.soft_body
71                 ob = context.object
72
73                 split = layout.split()
74                         
75                 if md:
76                         softbody = md.settings
77                         layout.active = softbody.use_goal
78
79                         # Goal 
80                         split = layout.split()
81
82                         col = split.column()
83                         col.itemL(text="Goal Strengths:")
84                         col.itemR(softbody, "goal_default", text="Default")
85                         subcol = col.column(align=True)
86                         subcol.itemR(softbody, "goal_min", text="Minimum")
87                         subcol.itemR(softbody, "goal_max", text="Maximum")
88                         
89                         col = split.column()
90                         col.itemL(text="Goal Settings:")
91                         col.itemR(softbody, "goal_spring", text="Stiffness")
92                         col.itemR(softbody, "goal_friction", text="Damping")
93                         layout.item_pointerR(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
94
95 class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
96         __idname__ = "PHYSICS_PT_softbody_edge"
97         __label__ = "Soft Body Edges"
98         
99         def poll(self, context):
100                 return (context.soft_body != None)
101                 
102         def draw_header(self, context):
103                 layout = self.layout
104                 softbody = context.soft_body.settings
105         
106                 layout.itemR(softbody, "use_edges", text="")
107                 
108         def draw(self, context):
109                 layout = self.layout
110                 md = context.soft_body
111                 ob = context.object
112
113                 split = layout.split()
114                         
115                 if md:
116                         softbody = md.settings
117                         
118                         layout.active = softbody.use_edges
119                         
120                         split = layout.split()
121                         
122                         col = split.column()
123                         col.itemL(text="Springs:")
124                         col.itemR(softbody, "pull")
125                         col.itemR(softbody, "push")
126                         col.itemR(softbody, "damp")
127                         col.itemR(softbody, "plastic")
128                         col.itemR(softbody, "bending")
129                         col.itemR(softbody, "spring_length", text="Length")
130                         
131                         col = split.column()
132                         col.itemR(softbody, "stiff_quads")
133                         subcol = col.column()
134                         subcol.active = softbody.stiff_quads
135                         subcol.itemR(softbody, "shear")
136                         
137                         col.itemR(softbody, "new_aero", text="Aero")
138                         subcol = col.column()
139                         subcol.active = softbody.new_aero
140                         subcol.itemR(softbody, "aero", text="Factor", enabled=softbody.new_aero)
141
142                         col.itemL(text="Collision:")
143                         col.itemR(softbody, "edge_collision", text="Edge")
144                         col.itemR(softbody, "face_collision", text="Face")
145                         
146 class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
147         __idname__ = "PHYSICS_PT_softbody_collision"
148         __label__ = "Soft Body Collision"
149         
150         def poll(self, context):
151                 return (context.soft_body != None)
152                 
153         def draw_header(self, context):
154                 layout = self.layout
155                 softbody = context.soft_body.settings
156         
157                 layout.itemR(softbody, "self_collision", text="")
158                 
159         def draw(self, context):
160                 layout = self.layout
161                 md = context.soft_body
162                 ob = context.object
163
164                 split = layout.split()
165                         
166                 if md:
167                         softbody = md.settings
168
169                         layout.active = softbody.self_collision
170                         layout.itemL(text="Collision Type:")
171                         layout.itemR(softbody, "collision_type", expand=True)
172                         
173                         col = layout.column(align=True)
174                         col.itemL(text="Ball:")
175                         col.itemR(softbody, "ball_size", text="Size")
176                         col.itemR(softbody, "ball_stiff", text="Stiffness")
177                         col.itemR(softbody, "ball_damp", text="Dampening")
178
179 class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
180         __idname__ = "PHYSICS_PT_softbody_solver"
181         __label__ = "Soft Body Solver"
182         
183         def poll(self, context):
184                 return (context.soft_body != None)
185                 
186         def draw(self, context):
187                 layout = self.layout
188                 md = context.soft_body
189                 ob = context.object
190
191                 split = layout.split()
192                         
193                 if md:
194                         softbody = md.settings
195
196                         # Solver
197                         split = layout.split()
198                         
199                         col = split.column(align=True)
200                         col.itemL(text="Step Size:")
201                         col.itemR(softbody, "minstep")
202                         col.itemR(softbody, "maxstep")
203                         col.itemR(softbody, "auto_step", text="Auto-Step")
204                         
205                         col = split.column()
206                         col.itemR(softbody, "error_limit")
207
208                         col.itemL(text="Helpers:")
209                         col.itemR(softbody, "choke")
210                         col.itemR(softbody, "fuzzy")
211                         
212                         layout.itemL(text="Diagnostics:")
213                         layout.itemR(softbody, "diagnose")
214         
215 bpy.types.register(PHYSICS_PT_softbody)
216 bpy.types.register(PHYSICS_PT_softbody_goal)
217 bpy.types.register(PHYSICS_PT_softbody_edge)
218 bpy.types.register(PHYSICS_PT_softbody_collision)
219 bpy.types.register(PHYSICS_PT_softbody_solver)