patch from William
[blender-staging.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 == "MAGNET":
57                         sub.itemR(field, "strength")
58                         sub = split.column()
59                         sub.itemR(field, "planar")
60                         
61                 if field.type == "HARMONIC":
62                         sub.itemR(field, "strength")
63                         sub.itemR(field, "harmonic_damping", text="Damping")
64                         sub = split.column()
65                         sub.itemR(field, "surface")
66                         sub.itemR(field, "planar")
67                         
68                 if field.type == "TEXTURE":
69                         sub.itemR(field, "strength")
70                         sub.itemR(field, "texture", text="")
71                         sub.itemR(field, "texture_mode")
72                         sub.itemR(field, "texture_nabla")
73                         sub = split.column()
74                         sub.itemR(field, "use_coordinates")
75                         sub.itemR(field, "root_coordinates")
76                         sub.itemR(field, "force_2d")
77                         
78                 if field.type in ("HARMONIC", "SPHERICAL", "CHARGE", "WIND", "VORTEX", "TEXTURE", "MAGNET"):
79                 
80                         
81                         layout.itemS()                  
82                         layout.itemL(text="Falloff:")
83                         layout.itemR(field, "falloff_type", expand=True)
84                         
85                         row = layout.row()
86                         row.itemR(field, "falloff_power", text="Power")
87                         row.itemR(field, "positive_z", text="Positive Z")
88                         
89                         split = layout.split()
90                         sub = split.column()
91                         
92                         sub.itemR(field, "use_min_distance", text="Minimum")
93                         colsub1 = sub.column()
94                         colsub1.active = field.use_min_distance
95                         colsub1.itemR(field, "minimum_distance", text="Distance")
96                         
97                         sub = split.column()
98                         
99                         sub.itemR(field, "use_max_distance", text="Maximum")
100                         colsub2 = sub.column()
101                         colsub2.active = field.use_max_distance
102                         colsub2.itemR(field, "maximum_distance", text="Distance")
103                         
104                         if field.falloff_type == "CONE":
105                                 layout.itemS()  
106                                 layout.itemL(text="Angular:")
107                                 
108                                 row = layout.row()
109                                 row.itemR(field, "radial_falloff", text="Power")
110                                 row.itemL(text="")
111                                 
112                                 split = layout.split()
113                                 sub = split.column()
114                                 
115                                 sub.itemR(field, "use_radial_min", text="Minimum")      
116                                 colsub1 = sub.column()
117                                 colsub1.active = field.use_radial_min
118                                 colsub1.itemR(field, "radial_minimum", text="Angle")
119                                 
120                                 sub = split.column()
121                                 
122                                 sub.itemR(field, "use_radial_max", text="Maximum")
123                                 colsub2 = sub.column()
124                                 colsub2.active = field.use_radial_max
125                                 colsub2.itemR(field, "radial_maximum", text="Angle")
126                                 
127                         if field.falloff_type == "TUBE":
128                                 
129                                 layout.itemS()  
130                                 layout.itemL(text="Radial:")    
131                                 row = layout.row()
132                                 row.itemR(field, "radial_falloff", text="Power")
133                                 row.itemL(text="")
134                                 
135                                 split = layout.split()
136                                 sub = split.column()
137                                 
138                                 sub.itemR(field, "use_radial_min", text="Minimum")      
139                                 colsub1 = sub.column()
140                                 colsub1.active = field.use_radial_min
141                                 colsub1.itemR(field, "radial_minimum", text="Distance")
142                                 
143                                 sub = split.column()
144                                 
145                                 sub.itemR(field, "use_radial_max", text="Maximum")
146                                 colsub2 = sub.column()
147                                 colsub2.active = field.use_radial_max
148                                 colsub2.itemR(field, "radial_maximum", text="Distance")
149                                 
150                 #if ob.type in "CURVE":
151                         #if field.type == "GUIDE":
152                                 #colsub = col.column(align=True)
153                         
154                 #if field.type != "NONE":
155                         #layout.itemR(field, "strength")
156
157                 #if field.type in ("HARMONIC", "SPHERICAL", "CHARGE", "LENNARDj"):
158                         #if ob.type in ("MESH", "SURFACE", "FONT", "CURVE"):
159                                 #layout.itemR(field, "surface")
160
161 class PHYSICS_PT_collision(PhysicButtonsPanel):
162         __idname__ = "PHYSICS_PT_collision"
163         __label__ = "Collision"
164         __default_closed__ = True
165         
166         def poll(self, context):
167                 ob = context.object
168                 return (ob and ob.type == 'MESH')
169
170         def draw_header(self, context):
171                 settings = context.object.collision
172                 self.layout.itemR(settings, "enabled", text="")
173
174         def draw(self, context):
175                 layout = self.layout
176                 md = context.collision
177                 settings = context.object.collision
178
179                 layout.active = settings.enabled
180                 
181                 split = layout.split()
182                 
183                 col = split.column()
184                 col.itemL(text="Particle:")
185                 col.itemR(settings, "permeability", slider=True)
186                 col.itemL(text="Particle Damping:")
187                 colsub = col.column(align=True)
188                 colsub.itemR(settings, "damping_factor", text="Factor", slider=True)
189                 colsub.itemR(settings, "random_damping", text="Random", slider=True)
190                 
191                 col.itemL(text="Soft Body and Cloth:")
192                 colsub = col.column(align=True)
193                 colsub.itemR(settings, "outer_thickness", text="Outer", slider=True)
194                 colsub.itemR(settings, "inner_thickness", text="Inner", slider=True)
195                 
196                 col.itemL(text="Force Fields:")
197                 layout.itemR(md, "absorption", text="Absorption")
198                 
199                 col = split.column()
200                 col.itemL(text="")
201                 col.itemR(settings, "kill_particles")
202                 col.itemL(text="Particle Friction:")
203                 colsub = col.column(align=True)
204                 colsub.itemR(settings, "friction_factor", text="Factor", slider=True)
205                 colsub.itemR(settings, "random_friction", text="Random", slider=True)
206                 col.itemL(text="Soft Body Damping:")
207                 col.itemR(settings, "damping", text="Factor", slider=True)
208                 
209 bpy.types.register(PHYSICS_PT_field)
210 bpy.types.register(PHYSICS_PT_collision)