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