2.5: Render/Game Engine
[blender-staging.git] / release / ui / buttons_physics_fluid.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                 rd = context.scene.render_data
12                 return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
13                 
14 class PHYSICS_PT_fluid(PhysicButtonsPanel):
15         __idname__ = "PHYSICS_PT_fluid"
16         __label__ = "Fluid"
17
18         def draw(self, context):
19                 layout = self.layout
20                 md = context.fluid
21                 ob = context.object
22
23                 split = layout.split()
24                 split.operator_context = "EXEC_DEFAULT"
25
26                 if md:
27                         # remove modifier + settings
28                         split.set_context_pointer("modifier", md)
29                         split.itemO("object.modifier_remove", text="Remove")
30
31                         row = split.row(align=True)
32                         row.itemR(md, "render", text="")
33                         row.itemR(md, "realtime", text="")
34                         
35                         fluid = md.settings
36                         
37                 else:
38                         # add modifier
39                         split.item_enumO("object.modifier_add", "type", "FLUID_SIMULATION", text="Add")
40                         split.itemL()
41                         
42                         fluid = None
43                 
44                 
45                 if fluid:
46                         
47                         col = layout.column(align=True)
48                         col.itemR(fluid, "type")
49
50                         if fluid.type == 'DOMAIN':
51                                 layout.itemO("fluid.bake", text="BAKE")
52                                 split = layout.split()
53                                 
54                                 col = split.column()
55                                 col.itemL(text="Resolution:")
56                                 colsub = col.column()
57                                 colsub.itemR(fluid, "resolution", text="Final")
58                                 colsub.itemL(text="Render Display:")
59                                 colsub.itemR(fluid, "render_display_mode", text="")
60                                 col.itemL(text="Time:")
61                                 colsub = col.column(align=True)
62                                 colsub.itemR(fluid, "start_time", text="Start")
63                                 colsub.itemR(fluid, "end_time", text="End")
64                                 
65                                 col = split.column()
66                                 colsub = col.column()
67                                 colsub.itemL(text="Required Memory: " + fluid.memory_estimate)
68                                 colsub.itemR(fluid, "preview_resolution", text="Preview")
69                                 colsub.itemL(text="Viewport Display:")
70                                 colsub.itemR(fluid, "viewport_display_mode", text="")
71                                 colsub = col.column()
72                                 colsub.itemL(text="")
73                                 colsub.itemR(fluid, "reverse_frames")
74                                 colsub.itemR(fluid, "generate_speed_vectors")
75                                 
76                                 layout.itemL(text="Path:")
77                                 layout.itemR(fluid, "path", text="")
78                                 
79                         if fluid.type == 'FLUID':
80                                 split = layout.split()
81                                 col = split.column()
82                                 col.itemL(text="Volume Initialization:")
83                                 col.itemR(fluid, "volume_initialization", text="")
84                                 col.itemR(fluid, "export_animated_mesh")
85                                 col = split.column()
86                                 col.itemL(text="Initial Velocity:")
87                                 col.itemR(fluid, "initial_velocity", text="")
88                                 
89                         if fluid.type == 'OBSTACLE':
90                                 split = layout.split()
91                                 col = split.column()
92                                 col.itemL(text="Volume Initialization:")
93                                 col.itemR(fluid, "volume_initialization", text="")
94                                 col.itemR(fluid, "export_animated_mesh")
95                                 col = split.column()
96                                 col.itemL(text="Slip Type:")
97                                 colsub=col.column(align=True)
98                                 colsub.itemR(fluid, "slip_type", text="")
99                                 if fluid.slip_type == 'PARTIALSLIP':
100                                         colsub.itemR(fluid, "partial_slip_amount", slider=True, text="Amount")
101                                         
102                                 col.itemR(fluid, "impact_factor")
103                                 
104                         if fluid.type == 'INFLOW':
105                                 split = layout.split()
106                                 col = split.column()
107                                 col.itemL(text="Volume Initialization:")
108                                 col.itemR(fluid, "volume_initialization", text="")
109                                 col.itemR(fluid, "export_animated_mesh")
110                                 col.itemR(fluid, "local_coordinates")
111                                 
112                                 col = split.column()
113                                 col.itemL(text="Inflow Velocity:")
114                                 col.itemR(fluid, "inflow_velocity", text="")
115                                 
116                         if fluid.type == 'OUTFLOW':
117                                 split = layout.split()
118                                 col = split.column()
119                                 col.itemL(text="Volume Initialization:")
120                                 col.itemR(fluid, "volume_initialization", text="")
121                                 col.itemR(fluid, "export_animated_mesh")
122                                 col = split.column()
123                                 
124                         if fluid.type == 'PARTICLE':
125                                 split = layout.split()
126                                 
127                                 col = split.column()
128                                 col.itemL(text="Influence:")
129                                 colsub = col.column(align=True)
130                                 colsub.itemR(fluid, "particle_influence", text="Size")
131                                 colsub.itemR(fluid, "alpha_influence", text="Alpha")
132                                 col.itemL(text="Path:")
133                                 
134                                 layout.itemR(fluid, "path", text="")
135                                 
136                                 col = split.column()
137                                 col.itemL(text="Type:")
138                                 col.itemR(fluid, "drops")
139                                 col.itemR(fluid, "floats")
140                                 col.itemR(fluid, "tracer")
141                                 
142                         if fluid.type == 'CONTROL':
143                                 split = layout.split()
144                                 
145                                 col = split.column()
146                                 col.itemL(text="")
147                                 col.itemR(fluid, "quality", slider=True)
148                                 col.itemR(fluid, "reverse_frames")
149                                 
150                                 col = split.column()
151                                 col.itemL(text="Time:")
152                                 col=col.column(align=True)
153                                 col.itemR(fluid, "start_time", text="Start")
154                                 col.itemR(fluid, "end_time", text="End")
155                                 
156                                 split = layout.split()
157                                 
158                                 col = split.column()
159                                 col.itemL(text="Attraction Force:")
160                                 col=col.column(align=True)
161                                 col.itemR(fluid, "attraction_strength", text="Strength")
162                                 col.itemR(fluid, "attraction_radius", text="Radius")
163                                 
164                                 col = split.column()
165                                 col.itemL(text="Velocity Force:")
166                                 col=col.column(align=True)
167                                 col.itemR(fluid, "velocity_strength", text="Strength")
168                                 col.itemR(fluid, "velocity_radius", text="Radius")
169
170 class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
171         __idname__ = "PHYSICS_PT_domain_gravity"
172         __label__ = "Domain World"
173         __default_closed__ = True
174         
175         def poll(self, context):
176                 md = context.fluid
177                 if md:
178                         settings = md.settings
179                         if settings:
180                                 return (settings.type == 'DOMAIN')
181                 
182                 return False
183
184         def draw(self, context):
185                 layout = self.layout
186                 fluid = context.fluid.settings
187                 
188                 split = layout.split()
189                 
190                 col = split.column()
191                 col.itemL(text="Gravity:")
192                 col.itemR(fluid, "gravity", text="")
193                 
194                 col.itemL(text="Real World Size:")
195                 col.itemR(fluid, "real_world_size", text="Metres")
196                 
197                 col = split.column()
198                 col.itemL(text="Viscosity Presets:")
199                 colsub=col.column(align=True)
200                 colsub.itemR(fluid, "viscosity_preset", text="")
201                 
202                 if fluid.viscosity_preset == 'MANUAL':
203                         colsub.itemR(fluid, "viscosity_base", text="Base")
204                         colsub.itemR(fluid, "viscosity_exponent", text="Exponent", slider=True)
205                 else:
206                         colsub.itemL(text="")
207                         colsub.itemL(text="")
208                         
209                 col.itemL(text="Optimization:")
210                 col=col.column(align=True)
211                 col.itemR(fluid, "grid_levels", slider=True)
212                 col.itemR(fluid, "compressibility", slider=True)
213         
214 class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
215         __idname__ = "PHYSICS_PT_domain_boundary"
216         __label__ = "Domain Boundary"
217         __default_closed__ = True
218         
219         def poll(self, context):
220                 md = context.fluid
221                 if md:
222                         settings = md.settings
223                         if settings:
224                                 return (settings.type == 'DOMAIN')
225                 
226                 return False
227
228         def draw(self, context):
229                 layout = self.layout
230                 fluid = context.fluid.settings
231                 
232                 split = layout.split()
233                 col = split.column()
234                 col.itemL(text="Slip Type:")
235                 col=col.column(align=True)
236                 col.itemR(fluid, "slip_type", text="")
237                 if fluid.slip_type == 'PARTIALSLIP':
238                         col.itemR(fluid, "partial_slip_amount", slider=True, text="Amount")
239                 col = split.column()
240                 col.itemL(text="Surface:")
241                 col=col.column(align=True)
242                 col.itemR(fluid, "surface_smoothing", text="Smoothing")
243                 col.itemR(fluid, "surface_subdivisions", text="Subdivisions")   
244                 
245 class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
246         __idname__ = "PHYSICS_PT_domain_particles"
247         __label__ = "Domain Particles"
248         __default_closed__ = True
249         
250         def poll(self, context):
251                 md = context.fluid
252                 if md:
253                         settings = md.settings
254                         if settings:
255                                 return (settings.type == 'DOMAIN')
256                 
257                 return False
258
259         def draw(self, context):
260                 layout = self.layout
261                 fluid = context.fluid.settings
262                 
263                 col=layout.column(align=True)
264                 col.itemR(fluid, "tracer_particles")
265                 col.itemR(fluid, "generate_particles")
266
267 bpy.types.register(PHYSICS_PT_fluid)
268 bpy.types.register(PHYSICS_PT_domain_gravity)
269 bpy.types.register(PHYSICS_PT_domain_boundary)
270 bpy.types.register(PHYSICS_PT_domain_particles)