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