~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/startup/bl_ui/properties_physics_fluid.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
from bpy.types import Panel, Menu
 
22
 
 
23
 
 
24
class FLUID_MT_presets(Menu):
 
25
    bl_label = "Fluid Presets"
 
26
    preset_subdir = "fluid"
 
27
    preset_operator = "script.execute_preset"
 
28
    draw = Menu.draw_preset
 
29
 
 
30
 
 
31
class PhysicButtonsPanel():
 
32
    bl_space_type = 'PROPERTIES'
 
33
    bl_region_type = 'WINDOW'
 
34
    bl_context = "physics"
 
35
 
 
36
    @classmethod
 
37
    def poll(cls, context):
 
38
        ob = context.object
 
39
        rd = context.scene.render
 
40
        return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.fluid)
 
41
 
 
42
 
 
43
class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
 
44
    bl_label = "Fluid"
 
45
 
 
46
    def draw(self, context):
 
47
        layout = self.layout
 
48
 
 
49
        md = context.fluid
 
50
        fluid = md.settings
 
51
 
 
52
        col = layout.column()
 
53
        if fluid is None:
 
54
            col.label("Built without fluids")
 
55
            return
 
56
 
 
57
        col.prop(fluid, "type")
 
58
        if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID', 'OBSTACLE'}:
 
59
            col.prop(fluid, "use")
 
60
 
 
61
        layout = layout.column()
 
62
        if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID', 'OBSTACLE'}:
 
63
            layout.active = fluid.use
 
64
 
 
65
        if fluid.type == 'DOMAIN':
 
66
            # odd formatting here so translation script can extract string
 
67
            layout.operator("fluid.bake", text="Bake (Req. Memory:" + " %s)" % fluid.memory_estimate, icon='MOD_FLUIDSIM')
 
68
            split = layout.split()
 
69
 
 
70
            col = split.column()
 
71
            col.label(text="Resolution:")
 
72
            col.prop(fluid, "resolution", text="Final")
 
73
            col.label(text="Render Display:")
 
74
            col.prop(fluid, "render_display_mode", text="")
 
75
 
 
76
            col = split.column()
 
77
            col.label()
 
78
            col.prop(fluid, "preview_resolution", text="Preview")
 
79
            col.label(text="Viewport Display:")
 
80
            col.prop(fluid, "viewport_display_mode", text="")
 
81
 
 
82
            split = layout.split()
 
83
 
 
84
            col = split.column()
 
85
            col.label(text="Time:")
 
86
            sub = col.column(align=True)
 
87
            sub.prop(fluid, "start_time", text="Start")
 
88
            sub.prop(fluid, "end_time", text="End")
 
89
            col.prop(fluid, "simulation_rate", text="Speed")
 
90
 
 
91
            col = split.column()
 
92
            col.label()
 
93
            col.prop(fluid, "use_speed_vectors")
 
94
            col.prop(fluid, "use_reverse_frames")
 
95
            col.prop(fluid, "frame_offset", text="Offset")
 
96
 
 
97
            layout.prop(fluid, "filepath", text="")
 
98
 
 
99
        elif fluid.type == 'FLUID':
 
100
            split = layout.split()
 
101
 
 
102
            col = split.column()
 
103
            col.label(text="Volume Initialization:")
 
104
            col.prop(fluid, "volume_initialization", text="")
 
105
            col.prop(fluid, "use_animated_mesh")
 
106
 
 
107
            col = split.column()
 
108
            col.label(text="Initial Velocity:")
 
109
            col.prop(fluid, "initial_velocity", text="")
 
110
 
 
111
        elif fluid.type == 'OBSTACLE':
 
112
            split = layout.split()
 
113
 
 
114
            col = split.column()
 
115
            col.label(text="Volume Initialization:")
 
116
            col.prop(fluid, "volume_initialization", text="")
 
117
            col.prop(fluid, "use_animated_mesh")
 
118
 
 
119
            col = split.column()
 
120
            col.label(text="Slip Type:")
 
121
            col.prop(fluid, "slip_type", text="")
 
122
            if fluid.slip_type == 'PARTIALSLIP':
 
123
                col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
 
124
 
 
125
            col.label(text="Impact:")
 
126
            col.prop(fluid, "impact_factor", text="Factor")
 
127
 
 
128
        elif fluid.type == 'INFLOW':
 
129
            split = layout.split()
 
130
 
 
131
            col = split.column()
 
132
            col.label(text="Volume Initialization:")
 
133
            col.prop(fluid, "volume_initialization", text="")
 
134
            col.prop(fluid, "use_animated_mesh")
 
135
            row = col.row()
 
136
            row.active = not fluid.use_animated_mesh
 
137
            row.prop(fluid, "use_local_coords")
 
138
 
 
139
            col = split.column()
 
140
            col.label(text="Inflow Velocity:")
 
141
            col.prop(fluid, "inflow_velocity", text="")
 
142
 
 
143
        elif fluid.type == 'OUTFLOW':
 
144
            col = layout.column()
 
145
            col.label(text="Volume Initialization:")
 
146
            col.prop(fluid, "volume_initialization", text="")
 
147
            col.prop(fluid, "use_animated_mesh")
 
148
 
 
149
        elif fluid.type == 'PARTICLE':
 
150
            split = layout.split()
 
151
 
 
152
            col = split.column()
 
153
            col.label(text="Influence:")
 
154
            col.prop(fluid, "particle_influence", text="Size")
 
155
            col.prop(fluid, "alpha_influence", text="Alpha")
 
156
 
 
157
            col = split.column()
 
158
            col.label(text="Type:")
 
159
            col.prop(fluid, "use_drops")
 
160
            col.prop(fluid, "use_floats")
 
161
            col.prop(fluid, "show_tracer")
 
162
 
 
163
            layout.prop(fluid, "filepath", text="")
 
164
 
 
165
        elif fluid.type == 'CONTROL':
 
166
            split = layout.split()
 
167
 
 
168
            col = split.column()
 
169
            col.label(text="")
 
170
            col.prop(fluid, "quality", slider=True)
 
171
            col.prop(fluid, "use_reverse_frames")
 
172
 
 
173
            col = split.column()
 
174
            col.label(text="Time:")
 
175
            sub = col.column(align=True)
 
176
            sub.prop(fluid, "start_time", text="Start")
 
177
            sub.prop(fluid, "end_time", text="End")
 
178
 
 
179
            split = layout.split()
 
180
 
 
181
            col = split.column()
 
182
            col.label(text="Attraction Force:")
 
183
            sub = col.column(align=True)
 
184
            sub.prop(fluid, "attraction_strength", text="Strength")
 
185
            sub.prop(fluid, "attraction_radius", text="Radius")
 
186
 
 
187
            col = split.column()
 
188
            col.label(text="Velocity Force:")
 
189
            sub = col.column(align=True)
 
190
            sub.prop(fluid, "velocity_strength", text="Strength")
 
191
            sub.prop(fluid, "velocity_radius", text="Radius")
 
192
 
 
193
 
 
194
class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
 
195
    bl_label = "Domain World"
 
196
    bl_options = {'DEFAULT_CLOSED'}
 
197
 
 
198
    @classmethod
 
199
    def poll(cls, context):
 
200
        md = context.fluid
 
201
        return md and md.settings and (md.settings.type == 'DOMAIN')
 
202
 
 
203
    def draw(self, context):
 
204
        layout = self.layout
 
205
 
 
206
        fluid = context.fluid.settings
 
207
        scene = context.scene
 
208
 
 
209
        split = layout.split()
 
210
 
 
211
        col = split.column()
 
212
        if scene.use_gravity:
 
213
            col.label(text="Use Scene Gravity", icon='SCENE_DATA')
 
214
            sub = col.column()
 
215
            sub.enabled = False
 
216
            sub.prop(fluid, "gravity", text="")
 
217
        else:
 
218
            col.label(text="Gravity:")
 
219
            col.prop(fluid, "gravity", text="")
 
220
 
 
221
        if scene.unit_settings.system != 'NONE':
 
222
            col.label(text="Use Scene Size Units", icon='SCENE_DATA')
 
223
            sub = col.column()
 
224
            sub.enabled = False
 
225
            sub.prop(fluid, "simulation_scale", text="Metres")
 
226
        else:
 
227
            col.label(text="Real World Size:")
 
228
            col.prop(fluid, "simulation_scale", text="Metres")
 
229
 
 
230
        col = split.column()
 
231
        col.label(text="Viscosity Presets:")
 
232
        sub = col.row(align=True)
 
233
        sub.menu("FLUID_MT_presets", text=bpy.types.FLUID_MT_presets.bl_label)
 
234
        sub.operator("fluid.preset_add", text="", icon='ZOOMIN')
 
235
        sub.operator("fluid.preset_add", text="", icon='ZOOMOUT').remove_active = True
 
236
 
 
237
        subsub = col.column(align=True)
 
238
        subsub.prop(fluid, "viscosity_base", text="Base")
 
239
        subsub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True)
 
240
 
 
241
        col.label(text="Optimization:")
 
242
        col.prop(fluid, "grid_levels", slider=True)
 
243
        col.prop(fluid, "compressibility", slider=True)
 
244
 
 
245
 
 
246
class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
 
247
    bl_label = "Domain Boundary"
 
248
    bl_options = {'DEFAULT_CLOSED'}
 
249
 
 
250
    @classmethod
 
251
    def poll(cls, context):
 
252
        md = context.fluid
 
253
        return md and md.settings and (md.settings.type == 'DOMAIN')
 
254
 
 
255
    def draw(self, context):
 
256
        layout = self.layout
 
257
 
 
258
        fluid = context.fluid.settings
 
259
 
 
260
        split = layout.split()
 
261
 
 
262
        col = split.column()
 
263
        col.label(text="Slip Type:")
 
264
        col.prop(fluid, "slip_type", text="")
 
265
        if fluid.slip_type == 'PARTIALSLIP':
 
266
            col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
 
267
        col.prop(fluid, "surface_noobs")
 
268
 
 
269
        col = split.column()
 
270
        col.label(text="Surface:")
 
271
        col.prop(fluid, "surface_smooth", text="Smoothing")
 
272
        col.prop(fluid, "surface_subdivisions", text="Subdivisions")
 
273
 
 
274
 
 
275
class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel):
 
276
    bl_label = "Domain Particles"
 
277
    bl_options = {'DEFAULT_CLOSED'}
 
278
 
 
279
    @classmethod
 
280
    def poll(cls, context):
 
281
        md = context.fluid
 
282
        return md and md.settings and (md.settings.type == 'DOMAIN')
 
283
 
 
284
    def draw(self, context):
 
285
        layout = self.layout
 
286
 
 
287
        fluid = context.fluid.settings
 
288
 
 
289
        col = layout.column(align=True)
 
290
        col.prop(fluid, "tracer_particles")
 
291
        col.prop(fluid, "generate_particles")
 
292
 
 
293
if __name__ == "__main__":  # only for live edit.
 
294
    bpy.utils.register_module(__name__)