2.5:
[blender.git] / release / ui / buttons_physics_smoke.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
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_smoke(PhysicButtonsPanel):
15         __label__ = "Smoke"
16
17         def draw(self, context):
18                 layout = self.layout
19                 
20                 md = context.smoke
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                 else:
36                         # add modifier
37                         split.item_enumO("object.modifier_add", "type", 'SMOKE', text="Add")
38                         split.itemL()
39
40                 if md:
41                         layout.itemR(md, "smoke_type", expand=True)
42                 
43                         if md.smoke_type == 'TYPE_DOMAIN':
44                                 
45                                 domain = md.domain_settings
46                                 
47                                 split = layout.split()
48                                 
49                                 col = split.column()
50                                 col.itemL(text="Resolution:")
51                                 col.itemR(domain, "maxres", text="Divisions")
52
53                                 col.itemL(text="Display:")
54                                 col.itemR(domain, "visibility", text="Resolution")
55                                 col.itemR(domain, "color", slider=True)
56                                 sub = col.column()
57                                 sub.active = domain.highres
58                                 sub.itemR(domain, "viewhighres")
59                                 
60                                 col = split.column()
61                                 col.itemL(text="Behavior:")
62                                 col.itemR(domain, "alpha")
63                                 col.itemR(domain, "beta")
64                                 col.itemR(domain, "dissolve_smoke", text="Dissolve")
65                                 sub = col.column()
66                                 sub.active = domain.dissolve_smoke
67                                 sub.itemR(domain, "dissolve_speed", text="Speed")
68                                 sub.itemR(domain, "dissolve_smoke_log", text="Slow")
69                                 
70                         elif md.smoke_type == 'TYPE_FLOW':
71                                 
72                                 flow = md.flow_settings
73                                 
74                                 split = layout.split()
75                                 
76                                 col = split.column()
77                                 col.itemR(flow, "outflow")
78                                 col.itemL(text="Particle System:")
79                                 col.item_pointerR(flow, "psys", ob, "particle_systems", text="")
80                                 
81                                 if md.flow_settings.outflow:                            
82                                         col = split.column()
83                                 else:
84                                         col = split.column()
85                                         col.itemL(text="Behavior:")
86                                         col.itemR(flow, "temperature")
87                                         col.itemR(flow, "density")
88                                         
89                         #elif md.smoke_type == 'TYPE_COLL':
90                         #       layout.itemS()
91                         
92 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
93         __label__ = "Smoke High Resolution"
94         __default_closed__ = True
95         
96         def poll(self, context):
97                 md = context.smoke
98                 if md:
99                                 return (md.smoke_type == 'TYPE_DOMAIN')
100                 
101                 return False
102
103         def draw_header(self, context):
104                 layout = self.layout
105                 
106                 high = context.smoke.domain_settings
107         
108                 layout.itemR(high, "highres", text="")
109                 
110         def draw(self, context):
111                 layout = self.layout
112                 
113                 high = context.smoke.domain_settings
114                 
115                 layout.active = high.highres
116                 
117                 split = layout.split()
118                 
119                 col = split.column()
120                 col.itemL(text="Resolution:")
121                 col.itemR(high, "amplify", text="Divisions")
122                 
123                 sub = split.column()
124                 sub.itemL(text="Noise Method:")
125                 sub.row().itemR(high, "noise_type", text="")
126                 sub.itemR(high, "strength")
127                         
128 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
129         __label__ = "Smoke Groups"
130         __default_closed__ = True
131         
132         def poll(self, context):
133                 md = context.smoke
134                 if md:
135                                 return (md.smoke_type == 'TYPE_DOMAIN')
136                 
137                 return False
138
139         def draw(self, context):
140                 layout = self.layout
141                 
142                 group = context.smoke.domain_settings
143                 
144                 split = layout.split()
145                 
146                 col = split.column()
147                 col.itemL(text="Flow Group:")
148                 col.itemR(group, "fluid_group", text="")
149                                 
150                 #col.itemL(text="Effector Group:")
151                 #col.itemR(group, "eff_group", text="")
152                                 
153                 col = split.column()
154                 col.itemL(text="Collision Group:")
155                 col.itemR(group, "coll_group", text="")
156
157 bpy.types.register(PHYSICS_PT_smoke)
158 bpy.types.register(PHYSICS_PT_smoke_highres)
159 bpy.types.register(PHYSICS_PT_smoke_groups)