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