Smoke:
[blender.git] / release / scripts / ui / buttons_physics_smoke.py
1
2 import bpy
3
4 from buttons_physics_common import point_cache_ui
5 from buttons_physics_common import effector_weights_ui
6
7 class PhysicButtonsPanel(bpy.types.Panel):
8         __space_type__ = 'PROPERTIES'
9         __region_type__ = 'WINDOW'
10         __context__ = "physics"
11
12         def poll(self, context):
13                 ob = context.object
14                 rd = context.scene.render_data
15                 return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
16                 
17 class PHYSICS_PT_smoke(PhysicButtonsPanel):
18         __label__ = "Smoke"
19
20         def draw(self, context):
21                 layout = self.layout
22                 
23                 md = context.smoke
24                 ob = context.object
25
26                 split = layout.split()
27                 split.operator_context = 'EXEC_DEFAULT'
28
29                 if md:
30                         # remove modifier + settings
31                         split.set_context_pointer("modifier", md)
32                         split.itemO("object.modifier_remove", text="Remove")
33
34                         row = split.row(align=True)
35                         row.itemR(md, "render", text="")
36                         row.itemR(md, "realtime", text="")
37                         
38                 else:
39                         # add modifier
40                         split.item_enumO("object.modifier_add", "type", 'SMOKE', text="Add")
41                         split.itemL()
42
43                 if md:
44                         layout.itemR(md, "smoke_type", expand=True)
45                 
46                         if md.smoke_type == 'TYPE_DOMAIN':
47                                 
48                                 domain = md.domain_settings
49                                 
50                                 split = layout.split()
51                                 
52                                 col = split.column()
53                                 col.itemL(text="Resolution:")
54                                 col.itemR(domain, "maxres", text="Divisions")
55                                 
56                                 col = split.column()
57                                 col.itemL(text="Behavior:")
58                                 col.itemR(domain, "alpha")
59                                 col.itemR(domain, "beta")
60                                 col.itemR(domain, "dissolve_smoke", text="Dissolve")
61                                 sub = col.column()
62                                 sub.active = domain.dissolve_smoke
63                                 sub.itemR(domain, "dissolve_speed", text="Time")
64                                 sub.itemR(domain, "dissolve_smoke_log", text="Slow")
65                                 
66                         elif md.smoke_type == 'TYPE_FLOW':
67                                 
68                                 flow = md.flow_settings
69                                 
70                                 split = layout.split()
71                                 
72                                 col = split.column()
73                                 col.itemR(flow, "outflow")
74                                 col.itemL(text="Particle System:")
75                                 col.item_pointerR(flow, "psys", ob, "particle_systems", text="")
76                                 
77                                 if md.flow_settings.outflow:                            
78                                         col = split.column()
79                                 else:
80                                         col = split.column()
81                                         col.itemL(text="Behavior:")
82                                         col.itemR(flow, "temperature")
83                                         col.itemR(flow, "density")
84                                         
85                         #elif md.smoke_type == 'TYPE_COLL':
86                         #       layout.itemS()
87
88 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
89         __label__ = "Smoke Groups"
90         __default_closed__ = True
91         
92         def poll(self, context):
93                 md = context.smoke
94                 return md and (md.smoke_type == 'TYPE_DOMAIN')
95
96         def draw(self, context):
97                 layout = self.layout
98                 
99                 group = context.smoke.domain_settings
100                 
101                 split = layout.split()
102                 
103                 col = split.column()
104                 col.itemL(text="Flow Group:")
105                 col.itemR(group, "fluid_group", text="")
106                                 
107                 #col.itemL(text="Effector Group:")
108                 #col.itemR(group, "eff_group", text="")
109                                 
110                 col = split.column()
111                 col.itemL(text="Collision Group:")
112                 col.itemR(group, "coll_group", text="")
113
114 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
115         __label__ = "Smoke Cache"
116         __default_closed__ = True
117
118         def poll(self, context):
119                 md = context.smoke
120                 return md and (md.smoke_type == 'TYPE_DOMAIN')
121
122         def draw(self, context):
123                 layout = self.layout
124
125                 md = context.smoke.domain_settings
126                 cache = md.point_cache_low
127                         
128                 point_cache_ui(self, cache, cache.baked==False, 0, 1)
129                                         
130 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
131         __label__ = "Smoke High Resolution"
132         __default_closed__ = True
133         
134         def poll(self, context):
135                 md = context.smoke
136                 return md and (md.smoke_type == 'TYPE_DOMAIN')
137
138         def draw_header(self, context): 
139                 high = context.smoke.domain_settings
140         
141                 self.layout.itemR(high, "highres", text="")
142                 
143         def draw(self, context):
144                 layout = self.layout
145                 
146                 md = context.smoke.domain_settings
147
148                 split = layout.split()
149                         
150                 col = split.column()
151                 col.itemL(text="Resolution:")
152                 col.itemR(md, "amplify", text="Divisions")
153                         
154                 col = split.column()
155                 col.itemL(text="Noise Method:")
156                 col.row().itemR(md, "noise_type", text="")
157                 col.itemR(md, "strength")
158                 col.itemR(md, "viewhighres")
159                 
160 class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
161         __label__ = "Smoke High Resolution Cache"
162         __default_closed__ = True
163
164         def poll(self, context):
165                 md = context.smoke
166                 return md and (md.smoke_type == 'TYPE_DOMAIN') and md.domain_settings.highres
167
168         def draw(self, context):
169                 layout = self.layout
170
171                 md = context.smoke.domain_settings
172                 cache = md.point_cache_high
173                         
174                 point_cache_ui(self, cache, cache.baked==False, 0, 1)
175                 
176 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel):
177         __label__ = "Smoke Field Weights"
178         __default_closed__ = True
179         
180         def poll(self, context):
181                 return (context.smoke)
182         
183         def draw(self, context):
184                 domain = context.smoke.domain_settings
185                 effector_weights_ui(self, domain.effector_weights)
186                                         
187 bpy.types.register(PHYSICS_PT_smoke)
188 bpy.types.register(PHYSICS_PT_smoke_field_weights)
189 bpy.types.register(PHYSICS_PT_smoke_cache)
190 bpy.types.register(PHYSICS_PT_smoke_highres)
191 bpy.types.register(PHYSICS_PT_smoke_groups)
192 bpy.types.register(PHYSICS_PT_smoke_cache_highres)