FBX exporter conversion almost done.
[blender.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                 return (ob and ob.type == 'MESH')
12                 
13 class PHYSICS_PT_fluid(PhysicButtonsPanel):
14         __idname__ = "PHYSICS_PT_fluid"
15         __label__ = "Fluid"
16
17         def draw(self, context):
18                 layout = self.layout
19                 md = context.fluid
20                 ob = context.object
21
22                 split = layout.split()
23                 split.operator_context = "EXEC_DEFAULT"
24
25                 if md:
26                         # remove modifier + settings
27                         split.set_context_pointer("modifier", md)
28                         split.itemO("OBJECT_OT_modifier_remove", text="Remove")
29
30                         row = split.row(align=True)
31                         row.itemR(md, "render", text="")
32                         row.itemR(md, "realtime", text="")
33                 else:
34                         # add modifier
35                         split.item_enumO("OBJECT_OT_modifier_add", "type", "FLUID_SIMULATION", text="Add")
36                         split.itemL()
37
38                 if md:
39                         fluid = md.settings
40
41                         col = layout.column(align=True)
42                         row = col.row()
43                         row.item_enumR(fluid, "type", "DOMAIN")
44                         row.item_enumR(fluid, "type", "FLUID")
45                         row.item_enumR(fluid, "type", "OBSTACLE")
46                         row = col.row()
47                         row.item_enumR(fluid, "type", "INFLOW")
48                         row.item_enumR(fluid, "type", "OUTFLOW")
49                         row.item_enumR(fluid, "type", "PARTICLE")
50                         row.item_enumR(fluid, "type", "CONTROL")
51
52                         if fluid.type == 'DOMAIN':
53                                 layout.itemO("FLUID_OT_bake", text="BAKE")
54                                 layout.itemL(text="Required Memory: " + fluid.memory_estimate)
55                                 
56                                 layout.itemL(text="Resolution:")
57                                 
58                                 split = layout.split()
59                                 
60                                 col = split.column()
61                                 colsub = col.column(align=True)
62                                 colsub.itemR(fluid, "resolution", text="Final")
63                                 colsub.itemR(fluid, "render_display_mode", text="")
64                                 colsub = col.column(align=True)
65                                 colsub.itemL(text="Time:")
66                                 colsub.itemR(fluid, "start_time", text="Start")
67                                 colsub.itemR(fluid, "end_time", text="End")
68                                 
69                                 col = split.column()
70                                 colsub = col.column(align=True)
71                                 colsub.itemR(fluid, "preview_resolution", text="Preview", slider=True)
72                                 colsub.itemR(fluid, "viewport_display_mode", text="")
73                                 colsub = col.column()
74                                 colsub.itemR(fluid, "reverse_frames")
75                                 colsub.itemR(fluid, "generate_speed_vectors")
76                                 colsub.itemR(fluid, "path", text="")
77                                 
78                         if fluid.type in ('FLUID', 'OBSTACLE', 'INFLOW', 'OUTFLOW'):
79                                 layout.itemR(fluid, "volume_initialization")
80                                 
81                         if fluid.type == 'FLUID':
82                                 row = layout.row()
83                                 row.column().itemR(fluid, "initial_velocity")
84                                 row.itemR(fluid, "export_animated_mesh")
85                                 
86                         if fluid.type == 'OBSTACLE':
87                                 row = layout.row()
88                                 row.itemL()
89                                 row.itemR(fluid, "export_animated_mesh")
90                                 layout.itemR(fluid, "slip_type", expand=True)
91                                 if fluid.slip_type == 'PARTIALSLIP':
92                                         layout.itemR(fluid, "partial_slip_amount", text="Amount")
93                                         
94                                 layout.itemR(fluid, "impact_factor")
95                                 
96                         if fluid.type == 'INFLOW':
97                                 row = layout.row()
98                                 row.column().itemR(fluid, "inflow_velocity")
99                                 row.itemR(fluid, "export_animated_mesh")
100                                 layout.itemR(fluid, "local_coordinates")
101                                 
102                         if fluid.type == 'OUTFLOW':
103                                 row = layout.row()
104                                 row.itemL()
105                                 row.itemR(fluid, "export_animated_mesh")
106                                 
107                         if fluid.type == 'PARTICLE':
108                                 split = layout.split()
109                                 
110                                 col = split.column()
111                                 col.itemL(text="Type:")
112                                 col.itemR(fluid, "drops")
113                                 col.itemR(fluid, "floats")
114                                 col.itemR(fluid, "tracer")
115                                 
116                                 col = split.column()
117                                 col.itemL(text="Influence:")
118                                 col.itemR(fluid, "particle_influence", text="Particle")
119                                 col.itemR(fluid, "alpha_influence", text="Alpha")
120                                 
121                                 layout.itemR(fluid, "path")
122                                 
123                         if fluid.type == 'CONTROL':
124                                 split = layout.split()
125                                 
126                                 col = split.column()
127                                 col.itemL(text="Time:")
128                                 col.itemR(fluid, "start_time", text="Start")
129                                 col.itemR(fluid, "end_time", text="End")
130                                 
131                                 col = split.column()
132                                 col.itemR(fluid, "quality", slider=True)
133                                 col.itemR(fluid, "reverse_frames")
134                                 
135                                 split = layout.split()
136                                 
137                                 col = split.column()
138                                 col.itemL(text="Attraction:")
139                                 col.itemR(fluid, "attraction_strength", text="Strength")
140                                 col.itemR(fluid, "attraction_radius", text="Radius")
141                                 
142                                 col = split.column()
143                                 col.itemL(text="Velocity:")
144                                 col.itemR(fluid, "velocity_strength", text="Strength")
145                                 col.itemR(fluid, "velocity_radius", text="Radius")
146
147 class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
148         __idname__ = "PHYSICS_PT_domain_gravity"
149         __label__ = "Domain World/Gravity"
150         __default_closed__ = True
151         
152         def poll(self, context):
153                 md = context.fluid
154                 if md:
155                         return (md.settings.type == 'DOMAIN')
156
157         def draw(self, context):
158                 layout = self.layout
159                 fluid = context.fluid.settings
160                 
161                 split = layout.split()
162                 
163                 col = split.column()
164                 col.itemR(fluid, "gravity")
165                 
166                 col = split.column(align=True)
167                 col.itemL(text="Viscosity:")
168                 col.itemR(fluid, "viscosity_preset", text="")
169                 if fluid.viscosity_preset == 'MANUAL':
170                         col.itemR(fluid, "viscosity_base", text="Base")
171                         col.itemR(fluid, "viscosity_exponent", text="Exponent")
172                         
173                 col = layout.column_flow()
174                 col.itemR(fluid, "real_world_size")
175                 col.itemR(fluid, "grid_levels")
176                 col.itemR(fluid, "compressibility")
177         
178 class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
179         __idname__ = "PHYSICS_PT_domain_boundary"
180         __label__ = "Domain Boundary"
181         __default_closed__ = True
182         
183         def poll(self, context):
184                 md = context.fluid
185                 if md:
186                         return (md.settings.type == 'DOMAIN')
187
188         def draw(self, context):
189                 layout = self.layout
190                 fluid = context.fluid.settings
191                 
192                 layout.itemL(text="Slip:")
193                 
194                 layout.itemR(fluid, "slip_type", expand=True)
195                 if fluid.slip_type == 'PARTIALSLIP':
196                         layout.itemR(fluid, "partial_slip_amount", text="Amount")
197                 
198                 layout.itemL(text="Surface:")
199                 row = layout.row()
200                 row.itemR(fluid, "surface_smoothing", text="Smoothing")
201                 row.itemR(fluid, "surface_subdivisions", text="Subdivisions")
202                 
203 class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
204         __idname__ = "PHYSICS_PT_domain_particles"
205         __label__ = "Domain Particles"
206         __default_closed__ = True
207         
208         def poll(self, context):
209                 md = context.fluid
210                 if md:
211                         return (md.settings.type == 'DOMAIN')
212
213         def draw(self, context):
214                 layout = self.layout
215                 fluid = context.fluid.settings
216                 
217                 layout.itemR(fluid, "tracer_particles")
218                 layout.itemR(fluid, "generate_particles")
219
220 bpy.types.register(PHYSICS_PT_fluid)
221 bpy.types.register(PHYSICS_PT_domain_gravity)
222 bpy.types.register(PHYSICS_PT_domain_boundary)
223 bpy.types.register(PHYSICS_PT_domain_particles)