a564704e80fff98f9e46b324f93c07867f90c0ac
[blender.git] / release / scripts / startup / bl_ui / properties_physics_dynamicpaint.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
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.
7 #
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.
12 #
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.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class PhysicButtonsPanel():
24     bl_space_type = 'PROPERTIES'
25     bl_region_type = 'WINDOW'
26     bl_context = "physics"
27
28     @classmethod
29     def poll(cls, context):
30         ob = context.object
31         rd = context.scene.render
32         return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.dynamic_paint)
33
34
35 class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, bpy.types.Panel):
36     bl_label = "Dynamic Paint"
37
38     def draw(self, context):
39         layout = self.layout
40
41         md = context.dynamic_paint
42         ob = context.object
43
44         if md:
45             layout.prop(md, "dynamicpaint_type", expand=True)
46
47             if md.dynamicpaint_type == 'CANVAS':
48                 canvas = md.canvas_settings
49                 
50                 layout.operator("dpaint.bake", text="Bake Dynamic Paint", icon='MOD_FLUIDSIM')
51                 if len(canvas.ui_info) != 0:
52                     layout.label(text=canvas.ui_info)
53
54                 col = layout.column()
55                 col.label(text="Quality:")
56                 col.prop(canvas, "resolution")
57                 col.prop(canvas, "use_anti_aliasing")
58                 
59                 col = layout.column()
60                 col.label(text="Frames:")
61                 split = col.split()
62                 
63                 col = split.column(align=True)
64                 col.prop(canvas, "start_frame", text="Start")
65                 col.prop(canvas, "end_frame", text="End")
66                 
67                 col = split.column()
68                 col.prop(canvas, "substeps")
69                 
70
71             elif md.dynamicpaint_type == 'PAINT':
72                 paint = md.paint_settings
73                 
74                 layout.prop(paint, "do_paint")
75                 
76                 split = layout.split()
77
78                 col = split.column()
79                 col.active = paint.do_paint
80                 col.prop(paint, "absolute_alpha")
81                 col.prop(paint, "paint_erase")
82                 col.prop(paint, "paint_wetness", text="Wetness")
83                 
84                 col = split.column()
85                 col.active = paint.do_paint
86                 sub = col.column()
87                 sub.active = (paint.paint_source != "PSYS");
88                 sub.prop(paint, "use_material")
89                 if paint.use_material and paint.paint_source != "PSYS":
90                     col.prop(paint, "material", text="")
91                 else:
92                     col.prop(paint, "paint_color", text="")
93                 col.prop(paint, "paint_alpha", text="Alpha")
94                 
95                 layout.label()
96                 layout.prop(paint, "do_displace")
97
98
99 class PHYSICS_PT_dp_output(PhysicButtonsPanel, bpy.types.Panel):
100     bl_label = "Dynamic Paint: Output"
101     bl_options = {'DEFAULT_CLOSED'}
102
103     @classmethod
104     def poll(cls, context):
105         md = context.dynamic_paint
106         return md and (md.dynamicpaint_type == 'CANVAS')
107
108     def draw(self, context):
109         layout = self.layout
110
111         canvas = context.dynamic_paint.canvas_settings
112
113         col = layout.column()
114         col.prop(canvas, "output_paint")
115         sub = col.column()
116         sub.active = canvas.output_paint
117         sub.prop(canvas, "paint_output_path", text="")
118         sub.prop(canvas, "premultiply", text="Premultiply alpha")
119         
120         layout.separator()
121
122         col = layout.column()
123         col.prop(canvas, "output_wet")
124         sub = col.column()
125         sub.active = canvas.output_wet
126         sub.prop(canvas, "wet_output_path", text="")
127         
128         layout.separator()
129
130         col = layout.column()
131         col.prop(canvas, "output_disp")
132         sub = col.column()
133         sub.active = canvas.output_disp
134         sub.prop(canvas, "displace_output_path", text="")
135         sub.prop(canvas, "displacement", text="Strength")
136
137         split = sub.split()
138         sub = split.column()
139         sub.prop(canvas, "disp_type", text="Type")
140         sub = split.column()
141         sub.prop(canvas, "disp_format", text="Format")
142
143
144 class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, bpy.types.Panel):
145     bl_label = "Dynamic Paint: Advanced"
146     bl_options = {'DEFAULT_CLOSED'}
147
148     @classmethod
149     def poll(cls, context):
150         md = context.dynamic_paint
151         return md and (md.dynamicpaint_type == 'CANVAS')
152
153     def draw(self, context):
154         layout = self.layout
155
156         canvas = context.dynamic_paint.canvas_settings
157         ob = context.object
158
159         col = layout.column()
160         split = col.split(percentage=0.7)
161         split.prop(canvas, "dry_speed", text="Dry Time")
162         split.prop(canvas, "use_dry_log", text="Slow")
163
164         col = layout.column()
165         col.prop(canvas, "use_dissolve_paint")
166         sub = col.column()
167         sub.active = canvas.use_dissolve_paint
168         sub.prop(canvas, "dissolve_speed", text="Time")
169
170         col = layout.column()
171         col.prop(canvas, "use_flatten_disp", text="Flatten Displace")
172         sub = col.column()
173         sub.active = canvas.use_flatten_disp
174         sub.prop(canvas, "flatten_speed", text="Time")
175         
176         layout.separator()
177                 
178         layout.prop_search(canvas, "uv_layer", ob.data, "uv_textures")
179
180 class PHYSICS_PT_dp_effects(PhysicButtonsPanel, bpy.types.Panel):
181     bl_label = "Dynamic Paint: Effects"
182     bl_options = {'DEFAULT_CLOSED'}
183
184     @classmethod
185     def poll(cls, context):
186         md = context.dynamic_paint
187         return md and (md.dynamicpaint_type == 'CANVAS')
188
189     def draw(self, context):
190         layout = self.layout
191
192         canvas = context.dynamic_paint.canvas_settings
193
194         layout.prop(canvas, "effect_ui", expand=True)
195
196         if canvas.effect_ui == "SPREAD":
197             layout.prop(canvas, "use_spread")
198             col = layout.column()
199             col.active = canvas.use_spread
200             col.prop(canvas, "spread_speed")
201
202         elif canvas.effect_ui == "DRIP":
203             layout.prop(canvas, "use_drip")
204             col = layout.column()
205             col.active = canvas.use_drip
206             col.prop(canvas, "drip_speed")
207
208         elif canvas.effect_ui == "SHRINK":
209             layout.prop(canvas, "use_shrink")
210             col = layout.column()
211             col.active = canvas.use_shrink
212             col.prop(canvas, "shrink_speed")
213
214 class PHYSICS_PT_dp_advanced_paint(PhysicButtonsPanel, bpy.types.Panel):
215     bl_label = "Dynamic Paint: Advanced"
216     bl_options = {'DEFAULT_CLOSED'}
217
218     @classmethod
219     def poll(cls, context):
220         md = context.dynamic_paint
221         return md and (md.dynamicpaint_type == 'PAINT')
222
223     def draw(self, context):
224         layout = self.layout
225
226         paint = context.dynamic_paint.paint_settings
227         ob = context.object
228                 
229         split = layout.split()
230         col = split.column()
231         col.prop(paint, "paint_source")
232
233         if paint.paint_source == "PSYS":
234             col.prop_search(paint, "psys", ob, "particle_systems", text="")
235             if paint.psys:
236                 col.label(text="Particle effect:")
237                 sub = col.column()
238                 sub.active = not paint.use_part_radius
239                 sub.prop(paint, "solid_radius", text="Solid Radius")
240                 col.prop(paint, "use_part_radius", text="Use Particle's Radius")
241                 col.prop(paint, "smooth_radius", text="Smooth radius")
242
243         elif paint.paint_source == "DISTANCE" or paint.paint_source == "VOLDIST":
244             col.prop(paint, "paint_distance", text="Paint Distance")
245             split = layout.row().split()
246             sub = split.column()
247             sub.prop(paint, "prox_facealigned", text="Face Aligned")
248             sub = split.column()
249             sub.prop(paint, "prox_falloff", text="Falloff")
250             if paint.prox_falloff == "RAMP":
251                 col = layout.row().column()
252                 col.label(text="Falloff Ramp:")
253                 col.prop(paint, "prox_ramp_alpha", text="Only Use Alpha")
254                 col.template_color_ramp(paint, "paint_ramp", expand=True)
255
256 def register():
257     bpy.utils.register_module(__name__)
258
259
260 def unregister():
261     bpy.utils.register_module(__name__)
262
263 if __name__ == "__main__":
264     register()