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