2.5: Modifiers & Menus
[blender-staging.git] / release / ui / buttons_data_modifier.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
6         __region_type__ = "WINDOW"
7         __context__ = "modifier"
8         
9 class DATA_PT_modifiers(DataButtonsPanel):
10         __label__ = "Modifiers"
11
12         def draw(self, context):
13                 layout = self.layout
14                 
15                 ob = context.object
16
17                 row = layout.row()
18                 row.item_menu_enumO("object.modifier_add", "type")
19                 row.itemL()
20
21                 for md in ob.modifiers:
22                         box = layout.template_modifier(md)
23                         if box:
24                                 # match enum type to our functions, avoids a lookup table.
25                                 getattr(self, md.type)(box, ob, md)
26         
27         # the mt.type enum is (ab)used for a lookup on function names
28         # ...to avoid lengthy if statements
29         # so each type must have a function here.
30         def ARMATURE(self, layout, ob, md):
31                 layout.itemR(md, "object")
32                 
33                 split = layout.split(percentage=0.5)
34                 split.itemL(text="Vertex Group:")
35                 sub = split.split(percentage=0.7)
36                 sub.item_pointerR(md, "vertex_group", ob, "vertex_groups", text="")
37                 subsub = sub.row()
38                 subsub.active = md.vertex_group
39                 subsub.itemR(md, "invert")
40                 
41                 layout.itemS()
42                 
43                 split = layout.split()
44
45                 col = split.column()
46                 col.itemL(text="Bind To:")
47                 col.itemR(md, "use_vertex_groups", text="Vertex Groups")
48                 col.itemR(md, "use_bone_envelopes", text="Bone Envelopes")
49                 
50                 col = split.column()
51                 col.itemL(text="Deformation:")
52                 col.itemR(md, "quaternion")
53                 col.itemR(md, "multi_modifier")
54                 
55         def ARRAY(self, layout, ob, md):
56                 layout.itemR(md, "fit_type")
57                 if md.fit_type == 'FIXED_COUNT':
58                         layout.itemR(md, "count")
59                 elif md.fit_type == 'FIT_LENGTH':
60                         layout.itemR(md, "length")
61                 elif md.fit_type == 'FIT_CURVE':
62                         layout.itemR(md, "curve")
63
64                 layout.itemS()
65                 
66                 split = layout.split()
67                 
68                 col = split.column()
69                 col.itemR(md, "constant_offset")
70                 sub = col.column()
71                 sub.active = md.constant_offset
72                 sub.itemR(md, "constant_offset_displacement", text="")
73
74                 col.itemS()
75
76                 col.itemR(md, "merge_adjacent_vertices", text="Merge")
77                 sub = col.column()
78                 sub.active = md.merge_adjacent_vertices
79                 sub.itemR(md, "merge_end_vertices", text="First Last")
80                 sub.itemR(md, "merge_distance", text="Distance")
81                 
82                 col = split.column()
83                 col.itemR(md, "relative_offset")
84                 sub = col.column()
85                 sub.active = md.relative_offset
86                 sub.itemR(md, "relative_offset_displacement", text="")
87
88                 col.itemS()
89
90                 col.itemR(md, "add_offset_object")
91                 sub = col.column()
92                 sub.active = md.add_offset_object
93                 sub.itemR(md, "offset_object", text="")
94
95                 layout.itemS()
96                 
97                 col = layout.column()
98                 col.itemR(md, "start_cap")
99                 col.itemR(md, "end_cap")
100         
101         def BEVEL(self, layout, ob, md):
102                 row = layout.row()
103                 row.itemR(md, "width")
104                 row.itemR(md, "only_vertices")
105                 
106                 layout.itemL(text="Limit Method:")
107                 layout.row().itemR(md, "limit_method", expand=True)
108                 if md.limit_method == 'ANGLE':
109                         layout.itemR(md, "angle")
110                 elif md.limit_method == 'WEIGHT':
111                         layout.row().itemR(md, "edge_weight_method", expand=True)
112                         
113         def BOOLEAN(self, layout, ob, md):
114                 layout.itemR(md, "operation")
115                 layout.itemR(md, "object")
116                 
117         def BUILD(self, layout, ob, md):
118                 split = layout.split()
119                 
120                 col = split.column()
121                 col.itemR(md, "start")
122                 col.itemR(md, "length")
123
124                 col = split.column()
125                 col.itemR(md, "randomize")
126                 sub = col.column()
127                 sub.active = md.randomize
128                 sub.itemR(md, "seed")
129
130         def CAST(self, layout, ob, md):
131                 layout.itemR(md, "cast_type")
132                 layout.itemR(md, "object")
133                 if md.object:
134                         layout.itemR(md, "use_transform")
135                 
136                 flow = layout.column_flow()
137                 flow.itemR(md, "x")
138                 flow.itemR(md, "y")
139                 flow.itemR(md, "z")
140                 flow.itemR(md, "factor")
141                 flow.itemR(md, "radius")
142                 flow.itemR(md, "size")
143
144                 layout.itemR(md, "from_radius")
145                 
146                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
147                 
148         def CLOTH(self, layout, ob, md):
149                 layout.itemL(text="See Cloth panel.")
150                 
151         def COLLISION(self, layout, ob, md):
152                 layout.itemL(text="See Collision panel.")
153                 
154         def CURVE(self, layout, ob, md):
155                 layout.itemR(md, "object")
156                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
157                 layout.itemR(md, "deform_axis")
158                 
159         def DECIMATE(self, layout, ob, md):
160                 layout.itemR(md, "ratio")
161                 layout.itemR(md, "face_count")
162                 
163         def DISPLACE(self, layout, ob, md):
164                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
165                 layout.itemR(md, "texture")
166                 layout.itemR(md, "midlevel")
167                 layout.itemR(md, "strength")
168                 layout.itemR(md, "direction")
169                 layout.itemR(md, "texture_coordinates")
170                 if md.texture_coordinates == 'OBJECT':
171                         layout.itemR(md, "texture_coordinate_object", text="Object")
172                 elif md.texture_coordinates == 'UV' and ob.type == 'MESH':
173                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
174         
175         def EDGE_SPLIT(self, layout, ob, md):
176                 split = layout.split()
177                 
178                 col = split.column()
179                 col.itemR(md, "use_edge_angle", text="Edge Angle")
180                 sub = col.column()
181                 sub.active = md.use_edge_angle
182                 sub.itemR(md, "split_angle")
183                 
184                 col = split.column()
185                 col.itemR(md, "use_sharp", text="Sharp Edges")
186                 
187         def EXPLODE(self, layout, ob, md):
188                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
189                 layout.itemR(md, "protect")
190
191                 flow = layout.column_flow(2)
192                 flow.itemR(md, "split_edges")
193                 flow.itemR(md, "unborn")
194                 flow.itemR(md, "alive")
195                 flow.itemR(md, "dead")
196
197                 layout.itemO("object.explode_refresh", text="Refresh");
198                 
199         def FLUID_SIMULATION(self, layout, ob, md):
200                 layout.itemL(text="See Fluid panel.")
201                 
202         def HOOK(self, layout, ob, md):
203                 layout.itemR(md, "object")
204                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
205
206                 split = layout.split()
207                 split.itemR(md, "falloff")
208                 split.itemR(md, "force", slider=True)
209
210                 layout.itemS()
211
212                 row = layout.row()
213                 row.itemO("object.hook_reset", text="Reset")
214                 row.itemO("object.hook_recenter", text="Recenter")
215
216                 if ob.mode == 'EDIT':
217                         row = layout.row()
218                         row.itemO("object.hook_select", text="Select")
219                         row.itemO("object.hook_assign", text="Assign")
220                 
221         def LATTICE(self, layout, ob, md):
222                 layout.itemR(md, "object")
223                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
224                 
225         def MASK(self, layout, ob, md):
226                 layout.itemR(md, "mode")
227                 if md.mode == 'ARMATURE':
228                         layout.itemR(md, "armature")
229                 elif md.mode == 'VERTEX_GROUP':
230                         layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
231                 layout.itemR(md, "inverse")
232                 
233         def MESH_DEFORM(self, layout, ob, md):
234                 layout.itemR(md, "object")
235                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
236                 layout.itemR(md, "invert")
237
238                 layout.itemS()
239                 
240                 layout.itemO("object.meshdeform_bind", text="Bind")
241                 row = layout.row()
242                 row.itemR(md, "precision")
243                 row.itemR(md, "dynamic")
244                 
245         def MIRROR(self, layout, ob, md):
246                 layout.itemR(md, "merge_limit")
247                 split = layout.split()
248                 
249                 col = split.column()
250                 col.itemR(md, "x")
251                 col.itemR(md, "y")
252                 col.itemR(md, "z")
253                 
254                 col = split.column()
255                 col.itemL(text="Textures:")
256                 col.itemR(md, "mirror_u")
257                 col.itemR(md, "mirror_v")
258                 
259                 col = split.column()
260                 col.itemR(md, "clip", text="Do Clipping")
261                 col.itemR(md, "mirror_vertex_groups", text="Vertex Group")
262                 
263                 layout.itemR(md, "mirror_object")
264                 
265         def MULTIRES(self, layout, ob, md):
266                 layout.itemR(md, "subdivision_type")
267                 layout.itemO("object.multires_subdivide", text="Subdivide")
268                 layout.itemR(md, "level")
269         
270         def PARTICLE_INSTANCE(self, layout, ob, md):
271                 layout.itemR(md, "object")
272                 layout.itemR(md, "particle_system_number")
273                 
274                 flow = layout.column_flow()
275                 flow.itemR(md, "normal")
276                 flow.itemR(md, "children")
277                 flow.itemR(md, "size")
278                 flow.itemR(md, "path")
279                 if md.path:
280                         flow.itemR(md, "keep_shape")
281                 flow.itemR(md, "unborn")
282                 flow.itemR(md, "alive")
283                 flow.itemR(md, "dead")
284                 flow.itemL(md, "")
285                 if md.path:
286                         flow.itemR(md, "axis", text="")
287                 
288                 if md.path:
289                         row = layout.row()
290                         row.itemR(md, "position", slider=True)
291                         row.itemR(md, "random_position", text = "Random", slider=True)
292                 
293         def PARTICLE_SYSTEM(self, layout, ob, md):
294                 layout.itemL(text="See Particle panel.")
295                 
296         def SHRINKWRAP(self, layout, ob, md):
297                 layout.itemR(md, "target")
298                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
299                 layout.itemR(md, "offset")
300                 layout.itemR(md, "subsurf_levels")
301                 layout.itemR(md, "mode")
302                 if md.mode == 'PROJECT':
303                         layout.itemR(md, "subsurf_levels")
304                         layout.itemR(md, "auxiliary_target")
305                 
306                         row = layout.row()
307                         row.itemR(md, "x")
308                         row.itemR(md, "y")
309                         row.itemR(md, "z")
310                 
311                         flow = layout.column_flow()
312                         flow.itemR(md, "negative")
313                         flow.itemR(md, "positive")
314                         flow.itemR(md, "cull_front_faces")
315                         flow.itemR(md, "cull_back_faces")
316                 elif md.mode == 'NEAREST_SURFACEPOINT':
317                         layout.itemR(md, "keep_above_surface")
318                 
319         def SIMPLE_DEFORM(self, layout, ob, md):
320                 layout.itemR(md, "mode")
321                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
322                 layout.itemR(md, "origin")
323                 layout.itemR(md, "relative")
324                 layout.itemR(md, "factor")
325                 layout.itemR(md, "limits")
326                 if md.mode in ('TAPER', 'STRETCH'):
327                         layout.itemR(md, "lock_x_axis")
328                         layout.itemR(md, "lock_y_axis")
329                         
330         def SMOKE(self, layout, ob, md):
331                 layout.itemL(text="See Smoke panel.")
332         
333         def SMOOTH(self, layout, ob, md):
334                 split = layout.split()
335                 
336                 col = split.column()
337                 col.itemR(md, "x")
338                 col.itemR(md, "y")
339                 col.itemR(md, "z")
340                 
341                 col = split.column()
342                 col.itemR(md, "factor")
343                 col.itemR(md, "repeat")
344                 
345                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
346                 
347         def SOFT_BODY(self, layout, ob, md):
348                 layout.itemL(text="See Soft Body panel.")
349         
350         def SUBSURF(self, layout, ob, md):
351                 layout.row().itemR(md, "subdivision_type", expand=True)
352                 
353                 flow = layout.column_flow()
354                 flow.itemR(md, "levels", text="Preview")
355                 flow.itemR(md, "render_levels", text="Render")
356                 flow.itemR(md, "optimal_draw", text="Optimal Display")
357                 flow.itemR(md, "subsurf_uv")
358
359         def SURFACE(self, layout, ob, md):
360                 layout.itemL(text="See Fields panel.")
361         
362         def UV_PROJECT(self, layout, ob, md):
363                 if ob.type == 'MESH':
364                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
365                         layout.itemR(md, "image")
366                         layout.itemR(md, "override_image")
367
368                         split = layout.split()
369
370                         col = split.column()
371                         col.itemL(text="Aspect Ratio:")
372
373                         sub = col.column(align=True)
374                         sub.itemR(md, "horizontal_aspect_ratio", text="Horizontal")
375                         sub.itemR(md, "vertical_aspect_ratio", text="Vertical")
376
377                         col = split.column()
378                         col.itemL(text="Projectors:")
379
380                         sub = col.column(align=True)
381                         sub.itemR(md, "num_projectors", text="Number")
382                         for proj in md.projectors:
383                                 sub.itemR(proj, "object", text="")
384                 
385         def WAVE(self, layout, ob, md):
386                 split = layout.split()
387                 
388                 col = split.column()
389                 col.itemL(text="Motion:")
390                 col.itemR(md, "x")
391                 col.itemR(md, "y")
392                 col.itemR(md, "cyclic")
393                 
394                 col = split.column()
395                 col.itemR(md, "normals")
396                 sub = col.row(align=True)
397                 sub.active = md.normals
398                 sub.itemR(md, "x_normal", text="X", toggle=True)
399                 sub.itemR(md, "y_normal", text="Y", toggle=True)
400                 sub.itemR(md, "z_normal", text="Z", toggle=True)
401                 
402                 flow = layout.column_flow()
403                 flow.itemR(md, "time_offset")
404                 flow.itemR(md, "lifetime")
405                 flow.itemR(md, "damping_time")
406                 flow.itemR(md, "falloff_radius")
407                 flow.itemR(md, "start_position_x")
408                 flow.itemR(md, "start_position_y")
409                 
410                 layout.itemR(md, "start_position_object")
411                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
412                 layout.itemR(md, "texture")
413                 layout.itemR(md, "texture_coordinates")
414                 if md.texture_coordinates == 'MAP_UV' and ob.type == 'MESH':
415                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
416                 elif md.texture_coordinates == 'OBJECT':
417                         layout.itemR(md, "texture_coordinates_object")
418                 
419                 flow = layout.column_flow()
420                 flow.itemR(md, "speed", slider=True)
421                 flow.itemR(md, "height", slider=True)
422                 flow.itemR(md, "width", slider=True)
423                 flow.itemR(md, "narrowness", slider=True)
424
425 bpy.types.register(DATA_PT_modifiers)