1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
22 from bl_ui.properties_physics_common import (
27 class PhysicButtonsPanel():
28 bl_space_type = 'PROPERTIES'
29 bl_region_type = 'WINDOW'
30 bl_context = "physics"
33 def poll(cls, context):
35 rd = context.scene.render
36 return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.dynamic_paint)
39 class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, bpy.types.Panel):
40 bl_label = "Dynamic Paint"
42 def draw(self, context):
45 md = context.dynamic_paint
49 layout.prop(md, "ui_type", expand=True)
51 if (md.ui_type == "CANVAS"):
52 canvas = md.canvas_settings
55 layout.operator("dpaint.type_toggle", text="Add Canvas").type = 'CANVAS'
57 layout.operator("dpaint.type_toggle", text="Remove Canvas", icon='X').type = 'CANVAS'
59 surface = canvas.canvas_surfaces.active
61 row.template_list(canvas, "canvas_surfaces", canvas.canvas_surfaces, "active_index", rows=2)
63 col = row.column(align=True)
64 col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="")
65 col.operator("dpaint.surface_slot_remove", icon='ZOOMOUT', text="")
68 layout.prop(surface, "name")
69 layout.prop(surface, "surface_format", expand=False)
72 if surface.surface_format != "VERTEX":
73 col.label(text="Quality:")
74 col.prop(surface, "image_resolution")
75 col.prop(surface, "use_anti_aliasing")
78 col.label(text="Frames:")
81 col = split.column(align=True)
82 col.prop(surface, "start_frame", text="Start")
83 col.prop(surface, "end_frame", text="End")
86 col.prop(surface, "substeps")
88 elif (md.ui_type == "BRUSH"):
89 brush = md.brush_settings
92 layout.operator("dpaint.type_toggle", text="Add Brush").type = 'BRUSH'
94 layout.operator("dpaint.type_toggle", text="Remove Brush", icon='X').type = 'BRUSH'
96 layout.prop(brush, "brush_settings_context", expand=True, icon_only=True)
98 if (brush.brush_settings_context == "GENERAL"):
99 split = layout.split()
102 col.prop(brush, "absolute_alpha")
103 col.prop(brush, "paint_erase")
104 col.prop(brush, "paint_wetness", text="Wetness")
108 sub.active = (brush.paint_source != "PSYS");
109 sub.prop(brush, "use_material")
110 if brush.use_material and brush.paint_source != "PSYS":
111 col.prop(brush, "material", text="")
112 col.prop(brush, "paint_alpha", text="Alpha Factor")
114 col.prop(brush, "paint_color", text="")
115 col.prop(brush, "paint_alpha", text="Alpha")
117 elif (brush.brush_settings_context == "WAVE"):
118 layout.prop(brush, "wave_type")
119 if (brush.wave_type != "REFLECT"):
120 split = layout.split(percentage=0.6)
121 split.prop(brush, "wave_factor")
122 elif (brush.brush_settings_context == "VELOCITY"):
123 col = layout.row().column()
124 col.label(text="Velocity Settings:")
125 split = layout.split()
127 col.prop(brush, "velocity_alpha")
128 col.prop(brush, "velocity_color")
130 col.prop(brush, "velocity_depth")
131 sub = layout.row().column()
132 sub.active = (brush.velocity_alpha or brush.velocity_color or brush.velocity_depth)
133 sub.prop(brush, "max_velocity")
134 sub.template_color_ramp(brush, "velocity_ramp", expand=True)
136 layout.label(text="Smudge:")
137 layout.prop(brush, "do_smudge")
138 layout.prop(brush, "smudge_strength")
140 layout.label(text="-WIP-")
143 class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, bpy.types.Panel):
144 bl_label = "Dynamic Paint: Advanced"
147 def poll(cls, context):
148 md = context.dynamic_paint
149 return md and (md.ui_type == "CANVAS") and (md.canvas_settings) and (md.canvas_settings.canvas_surfaces.active)
151 def draw(self, context):
154 canvas = context.dynamic_paint.canvas_settings
155 surface = canvas.canvas_surfaces.active
158 layout.prop(surface, "surface_type", expand=False)
161 if (surface.surface_type == "PAINT"):
162 layout.label(text="Wetmap drying:")
163 split = layout.split(percentage=0.8)
164 split.prop(surface, "dry_speed", text="Dry Time")
165 split.prop(surface, "use_dry_log", text="Slow")
167 if (surface.surface_type != "WAVE"):
168 if (surface.surface_type == "DISPLACE"):
169 layout.prop(surface, "use_dissolve", text="Dissolve:")
170 elif (surface.surface_type == "WEIGHT"):
171 layout.prop(surface, "use_dissolve", text="Fade:")
173 layout.prop(surface, "use_dissolve", text="Dissolve:")
174 sub = layout.column()
175 sub.active = surface.use_dissolve
176 split = sub.split(percentage=0.8)
177 split.prop(surface, "dissolve_speed", text="Time")
178 split.prop(surface, "use_dissolve_log", text="Slow")
180 if (surface.surface_type == "WAVE"):
181 layout.prop(surface, "wave_open_borders")
183 split = layout.split()
185 col = split.column(align=True)
186 col.prop(surface, "wave_timescale")
187 col.prop(surface, "wave_speed")
189 col = split.column(align=True)
190 col.prop(surface, "wave_damping")
191 col.prop(surface, "wave_spring")
193 layout.label(text="Brush Group:")
194 layout.prop(surface, "brush_group", text="")
197 class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, bpy.types.Panel):
198 bl_label = "Dynamic Paint: Output"
199 bl_options = {'DEFAULT_CLOSED'}
202 def poll(cls, context):
203 md = context.dynamic_paint
204 if (not (md and (md.ui_type == "CANVAS") and (md.canvas_settings))):
206 surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
207 return (surface and not (surface.surface_format=="VERTEX" and (surface.surface_type=="DISPLACE" or surface.surface_type=="WAVE")))
209 def draw(self, context):
212 canvas = context.dynamic_paint.canvas_settings
213 surface = canvas.canvas_surfaces.active
216 # vertex format outputs
217 if (surface.surface_format == "VERTEX"):
218 if (surface.surface_type == "PAINT"):
221 row.prop_search(surface, "output_name", ob.data, "vertex_colors", text="Paintmap layer: ")
223 if (surface.output_exists(object=ob, index=0)):
225 col = row.column(align=True)
226 col.operator("dpaint.output_toggle", icon=ic, text="").index = 0
230 row.prop_search(surface, "output_name2", ob.data, "vertex_colors", text="Wetmap layer: ")
232 if (surface.output_exists(object=ob, index=1)):
234 col = row.column(align=True)
235 col.operator("dpaint.output_toggle", icon=ic, text="").index = 1
236 if (surface.surface_type == "WEIGHT"):
238 row.prop_search(surface, "output_name", ob, "vertex_groups", text="Vertex Group: ")
240 if (surface.output_exists(object=ob, index=0)):
242 col = row.column(align=True)
243 col.operator("dpaint.output_toggle", icon=ic, text="").index = 0
245 # image format outputs
246 if (surface.surface_format == "IMAGE"):
247 col = layout.column()
248 col.label(text="UV layer:")
249 col.prop_search(surface, "uv_layer", ob.data, "uv_textures", text="")
252 col = layout.column()
253 col.prop(surface, "image_output_path", text="Output directory")
254 col.prop(surface, "image_fileformat", text="Image Format")
256 if (surface.surface_type == "PAINT"):
259 col.prop(surface, "do_output1", text="Output Paintmaps:")
261 sub.prop(surface, "premultiply", text="Premultiply alpha")
262 sub.active = surface.do_output1
263 sub = layout.column()
264 sub.active = surface.do_output1
265 sub.prop(surface, "output_name", text="Filename: ")
267 col = layout.column()
268 col.prop(surface, "do_output2", text="Output Wetmaps:")
270 sub.active = surface.do_output2
271 sub.prop(surface, "output_name2", text="Filename: ")
273 col.prop(surface, "output_name", text="Filename: ")
274 if (surface.surface_type == "DISPLACE"):
275 col.prop(surface, "disp_type", text="Displace Type")
278 layout.operator("dpaint.bake", text="Bake Image Sequence", icon='MOD_DYNAMICPAINT')
279 if len(canvas.ui_info) != 0:
280 layout.label(text=canvas.ui_info)
283 class PHYSICS_PT_dp_effects(PhysicButtonsPanel, bpy.types.Panel):
284 bl_label = "Dynamic Paint: Effects"
285 bl_options = {'DEFAULT_CLOSED'}
288 def poll(cls, context):
289 md = context.dynamic_paint
290 if (not (md and (md.ui_type == "CANVAS") and (md.canvas_settings))):
292 surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
293 return surface and (surface.surface_type == "PAINT")
295 def draw(self, context):
298 canvas = context.dynamic_paint.canvas_settings
299 surface = canvas.canvas_surfaces.active
301 layout.prop(surface, "effect_ui", expand=True)
303 if surface.effect_ui == "SPREAD":
304 layout.prop(surface, "use_spread")
305 col = layout.column()
306 col.active = surface.use_spread
307 col.prop(surface, "spread_speed")
309 elif surface.effect_ui == "DRIP":
310 layout.prop(surface, "use_drip")
311 col = layout.column()
312 col.active = surface.use_drip
313 effector_weights_ui(self, context, surface.effector_weights)
314 split = layout.split()
316 layout.label(text="Surface Movement:")
317 split = layout.split()
319 col.prop(surface, "drip_velocity", slider=True)
321 col.prop(surface, "drip_acceleration", slider=True)
323 elif surface.effect_ui == "SHRINK":
324 layout.prop(surface, "use_shrink")
325 col = layout.column()
326 col.active = surface.use_shrink
327 col.prop(surface, "shrink_speed")
330 class PHYSICS_PT_dp_cache(PhysicButtonsPanel, bpy.types.Panel):
331 bl_label = "Dynamic Paint: Cache"
332 bl_options = {'DEFAULT_CLOSED'}
335 def poll(cls, context):
336 md = context.dynamic_paint
337 return md and (md.ui_type == "CANVAS") and (md.canvas_settings) and \
338 (md.canvas_settings.canvas_surfaces.active) and (md.canvas_settings.canvas_surfaces.active.uses_cache)
340 def draw(self, context):
343 surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
344 cache = surface.point_cache
346 point_cache_ui(self, context, cache, (cache.is_baked is False), 'DYNAMIC_PAINT')
349 class PHYSICS_PT_dp_advanced_brush(PhysicButtonsPanel, bpy.types.Panel):
350 bl_label = "Dynamic Paint: Advanced"
351 bl_options = {'DEFAULT_CLOSED'}
354 def poll(cls, context):
355 md = context.dynamic_paint
356 return md and (md.ui_type == "BRUSH") and (md.brush_settings)
358 def draw(self, context):
361 brush = context.dynamic_paint.brush_settings
364 split = layout.split()
366 col.prop(brush, "paint_source")
368 if brush.paint_source == "PSYS":
369 col.prop_search(brush, "psys", ob, "particle_systems", text="")
371 col.label(text="Particle effect:")
373 sub.active = not brush.use_part_radius
374 sub.prop(brush, "solid_radius", text="Solid Radius")
375 col.prop(brush, "use_part_radius", text="Use Particle's Radius")
376 col.prop(brush, "smooth_radius", text="Smooth radius")
377 elif brush.paint_source in {'VOLUME', 'VOLDIST'}:
378 split = layout.row().split(percentage=0.4)
380 sub.prop(brush, "accept_nonclosed")
381 if brush.accept_nonclosed:
383 sub.prop(brush, "ray_dir")
386 if brush.paint_source in {'DISTANCE', 'VOLDIST', 'POINT'}:
387 col.prop(brush, "paint_distance", text="Paint Distance")
388 split = layout.row().split(percentage=0.4)
390 if (brush.paint_source != 'POINT'):
391 sub.prop(brush, "prox_facealigned")
393 sub.prop(brush, "prox_falloff", text="Falloff")
394 if brush.paint_source == "VOLDIST":
395 col = layout.row().column()
396 col.prop(brush, "prox_inverse")
397 if brush.prox_falloff == "RAMP":
398 col = layout.row().column()
400 col.prop(brush, "prox_ramp_alpha", text="Only Use Alpha")
401 col.template_color_ramp(brush, "paint_ramp", expand=True)
404 bpy.utils.register_module(__name__)
408 bpy.utils.register_module(__name__)
410 if __name__ == "__main__":