Merge with 2.5 -r 21619:21756.
[blender.git] / release / ui / buttons_physics_field.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                 return (context.object != None)
11                 
12 class PHYSICS_PT_field(PhysicButtonsPanel):
13         __idname__ = "PHYSICS_PT_field"
14         __label__ = "Force Fields"
15         __default_closed__ = True
16
17         def draw(self, context):
18                 layout = self.layout
19                 ob = context.object
20                 field = ob.field
21
22                 #layout.active = field.enabled
23                 
24                 split = layout.split(percentage=0.3)
25                 
26                 split.itemL(text="Type:")
27                 split.itemR(field, "type", text=""
28                 )
29
30                 split = layout.split()
31                 
32                 sub = split.column()
33                                                         
34                 if field.type == "GUIDE":
35                         sub = col.column()
36                         sub.itemR(field, "guide_path_add")
37                         
38                 if field.type == "WIND":
39                         sub.itemR(field, "strength")
40                         sub = split.column()
41                         sub.itemR(field, "noise")
42                         sub.itemR(field, "seed")
43
44                 
45                 if field.type == "VORTEX":
46                         sub.itemR(field, "strength")
47                         sub = split.column()
48                         sub.itemL(text="")
49
50                 if field.type in ("SPHERICAL", "CHARGE", "LENNARDJ"):
51                         sub.itemR(field, "strength")
52                         sub = split.column()
53                         sub.itemR(field, "planar")
54                         sub.itemR(field, "surface")
55                         
56                 if field.type == "BOID":
57                         sub.itemR(field, "strength")
58                         sub = split.column()
59                         sub.itemR(field, "surface")
60                         
61                 if field.type == "MAGNET":
62                         sub.itemR(field, "strength")
63                         sub = split.column()
64                         sub.itemR(field, "planar")
65                         
66                 if field.type == "HARMONIC":
67                         sub.itemR(field, "strength")
68                         sub.itemR(field, "harmonic_damping", text="Damping")
69                         sub = split.column()
70                         sub.itemR(field, "surface")
71                         sub.itemR(field, "planar")
72                         
73                 if field.type == "TEXTURE":
74                         sub.itemR(field, "strength")
75                         sub.itemR(field, "texture", text="")
76                         sub.itemR(field, "texture_mode")
77                         sub.itemR(field, "texture_nabla")
78                         sub = split.column()
79                         sub.itemR(field, "use_coordinates")
80                         sub.itemR(field, "root_coordinates")
81                         sub.itemR(field, "force_2d")
82                         
83                 if field.type in ("HARMONIC", "SPHERICAL", "CHARGE", "WIND", "VORTEX", "TEXTURE", "MAGNET", "BOID"):
84                 
85                         
86                         layout.itemS()                  
87                         layout.itemL(text="Falloff:")
88                         layout.itemR(field, "falloff_type", expand=True)
89                         
90                         row = layout.row()
91                         row.itemR(field, "falloff_power", text="Power")
92                         row.itemR(field, "positive_z", text="Positive Z")
93                         
94                         layout.itemS()  
95                         split = layout.split()
96                         sub = split.column()
97                         
98                         sub.itemR(field, "use_min_distance", text="Minimum")
99                         colsub1 = sub.column()
100                         colsub1.active = field.use_min_distance
101                         colsub1.itemR(field, "minimum_distance", text="Distance")
102                         
103                         sub = split.column()
104                         
105                         sub.itemR(field, "use_max_distance", text="Maximum")
106                         colsub2 = sub.column()
107                         colsub2.active = field.use_max_distance
108                         colsub2.itemR(field, "maximum_distance", text="Distance")
109                         
110                         if field.falloff_type == "CONE":
111                                 layout.itemS()  
112                                 layout.itemL(text="Angular:")
113                                 
114                                 row = layout.row()
115                                 row.itemR(field, "radial_falloff", text="Power")
116                                 row.itemL(text="")
117                                 
118                                 split = layout.split()
119                                 sub = split.column()
120                                 
121                                 sub.itemR(field, "use_radial_min", text="Minimum")      
122                                 colsub1 = sub.column()
123                                 colsub1.active = field.use_radial_min
124                                 colsub1.itemR(field, "radial_minimum", text="Angle")
125                                 
126                                 sub = split.column()
127                                 
128                                 sub.itemR(field, "use_radial_max", text="Maximum")
129                                 colsub2 = sub.column()
130                                 colsub2.active = field.use_radial_max
131                                 colsub2.itemR(field, "radial_maximum", text="Angle")
132                                 
133                         if field.falloff_type == "TUBE":
134                                 
135                                 layout.itemS()  
136                                 layout.itemL(text="Radial:")    
137                                 row = layout.row()
138                                 row.itemR(field, "radial_falloff", text="Power")
139                                 row.itemL(text="")
140                                 
141                                 split = layout.split()
142                                 sub = split.column()
143                                 
144                                 sub.itemR(field, "use_radial_min", text="Minimum")      
145                                 colsub1 = sub.column()
146                                 colsub1.active = field.use_radial_min
147                                 colsub1.itemR(field, "radial_minimum", text="Distance")
148                                 
149                                 sub = split.column()
150                                 
151                                 sub.itemR(field, "use_radial_max", text="Maximum")
152                                 colsub2 = sub.column()
153                                 colsub2.active = field.use_radial_max
154                                 colsub2.itemR(field, "radial_maximum", text="Distance")
155                                 
156                 #if ob.type in "CURVE":
157                         #if field.type == "GUIDE":
158                                 #colsub = col.column(align=True)
159                         
160                 #if field.type != "NONE":
161                         #layout.itemR(field, "strength")
162
163                 #if field.type in ("HARMONIC", "SPHERICAL", "CHARGE", "LENNARDj"):
164                         #if ob.type in ("MESH", "SURFACE", "FONT", "CURVE"):
165                                 #layout.itemR(field, "surface")
166
167 class PHYSICS_PT_collision(PhysicButtonsPanel):
168         __idname__ = "PHYSICS_PT_collision"
169         __label__ = "Collision"
170         __default_closed__ = True
171         
172         def poll(self, context):
173                 ob = context.object
174                 return (ob and ob.type == 'MESH')
175
176         def draw_header(self, context):
177                 settings = context.object.collision
178                 self.layout.itemR(settings, "enabled", text="")
179
180         def draw(self, context):
181                 layout = self.layout
182                 md = context.collision
183                 settings = context.object.collision
184
185                 layout.active = settings.enabled
186                 
187                 split = layout.split()
188                 
189                 col = split.column()
190                 col.itemL(text="Particle:")
191                 col.itemR(settings, "permeability", slider=True)
192                 col.itemL(text="Particle Damping:")
193                 colsub = col.column(align=True)
194                 colsub.itemR(settings, "damping_factor", text="Factor", slider=True)
195                 colsub.itemR(settings, "random_damping", text="Random", slider=True)
196                 
197                 col.itemL(text="Soft Body and Cloth:")
198                 colsub = col.column(align=True)
199                 colsub.itemR(settings, "outer_thickness", text="Outer", slider=True)
200                 colsub.itemR(settings, "inner_thickness", text="Inner", slider=True)
201                 
202                 col.itemL(text="Force Fields:")
203                 layout.itemR(md, "absorption", text="Absorption")
204                 
205                 col = split.column()
206                 col.itemL(text="")
207                 col.itemR(settings, "kill_particles")
208                 col.itemL(text="Particle Friction:")
209                 colsub = col.column(align=True)
210                 colsub.itemR(settings, "friction_factor", text="Factor", slider=True)
211                 colsub.itemR(settings, "random_friction", text="Random", slider=True)
212                 col.itemL(text="Soft Body Damping:")
213                 col.itemR(settings, "damping", text="Factor", slider=True)
214                 
215 bpy.types.register(PHYSICS_PT_field)
216 bpy.types.register(PHYSICS_PT_collision)