937df5c0ad953d12f0ddfad7f8dfb02e8ccb4502
[blender.git] / release / scripts / startup / bl_ui / properties_physics_field.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Panel
22 from blf import gettext as _
23
24 from bl_ui.properties_physics_common import (
25     basic_force_field_settings_ui,
26     basic_force_field_falloff_ui,
27     )
28
29
30 class PhysicButtonsPanel():
31     bl_space_type = 'PROPERTIES'
32     bl_region_type = 'WINDOW'
33     bl_context = "physics"
34
35     @classmethod
36     def poll(cls, context):
37         rd = context.scene.render
38         return (context.object) and (not rd.use_game_engine)
39
40
41 class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
42     bl_label = "Force Fields"
43
44     @classmethod
45     def poll(cls, context):
46         ob = context.object
47         rd = context.scene.render
48         return (not rd.use_game_engine) and (ob.field) and (ob.field.type != 'NONE')
49
50     def draw(self, context):
51         layout = self.layout
52
53         ob = context.object
54         field = ob.field
55
56         split = layout.split(percentage=0.2)
57         split.label(text=_("Type:"))
58
59         split.prop(field, "type", text="")
60
61         if field.type not in {'NONE', 'GUIDE', 'TEXTURE'}:
62             split = layout.split(percentage=0.2)
63             split.label(text=_("Shape:"))
64             split.prop(field, "shape", text="")
65
66         split = layout.split()
67
68         if field.type == 'NONE':
69             return  # nothing to draw
70         elif field.type == 'GUIDE':
71             col = split.column()
72             col.prop(field, "guide_minimum")
73             col.prop(field, "guide_free")
74             col.prop(field, "falloff_power")
75             col.prop(field, "use_guide_path_add")
76             col.prop(field, "use_guide_path_weight")
77
78             col = split.column()
79             col.label(text=_("Clumping:"))
80             col.prop(field, "guide_clump_amount")
81             col.prop(field, "guide_clump_shape")
82
83             row = layout.row()
84             row.prop(field, "use_max_distance")
85             sub = row.row()
86             sub.active = field.use_max_distance
87             sub.prop(field, "distance_max")
88
89             layout.separator()
90
91             layout.prop(field, "guide_kink_type")
92             if (field.guide_kink_type != 'NONE'):
93                 layout.prop(field, "guide_kink_axis")
94
95                 split = layout.split()
96
97                 col = split.column()
98                 col.prop(field, "guide_kink_frequency")
99                 col.prop(field, "guide_kink_shape")
100
101                 col = split.column()
102                 col.prop(field, "guide_kink_amplitude")
103
104         elif field.type == 'TEXTURE':
105             col = split.column()
106             col.prop(field, "strength")
107             col.prop(field, "texture", text="")
108             col.prop(field, "texture_mode", text="")
109             col.prop(field, "texture_nabla")
110
111             col = split.column()
112             col.prop(field, "use_object_coords")
113             col.prop(field, "use_root_coords")
114             col.prop(field, "use_2d_force")
115         else:
116             basic_force_field_settings_ui(self, context, field)
117
118         if field.type not in {'NONE', 'GUIDE'}:
119
120             layout.label(text=_("Falloff:"))
121             layout.prop(field, "falloff_type", expand=True)
122
123             basic_force_field_falloff_ui(self, context, field)
124
125             if field.falloff_type == 'CONE':
126                 layout.separator()
127
128                 split = layout.split(percentage=0.35)
129
130                 col = split.column()
131                 col.label(text=_("Angular:"))
132                 col.prop(field, "use_radial_min", text=_("Use Minimum"))
133                 col.prop(field, "use_radial_max", text=_("Use Maximum"))
134
135                 col = split.column()
136                 col.prop(field, "radial_falloff", text=_("Power"))
137
138                 sub = col.column()
139                 sub.active = field.use_radial_min
140                 sub.prop(field, "radial_min", text=_("Angle"))
141
142                 sub = col.column()
143                 sub.active = field.use_radial_max
144                 sub.prop(field, "radial_max", text=_("Angle"))
145
146             elif field.falloff_type == 'TUBE':
147                 layout.separator()
148
149                 split = layout.split(percentage=0.35)
150
151                 col = split.column()
152                 col.label(text=_("Radial:"))
153                 col.prop(field, "use_radial_min", text=_("Use Minimum"))
154                 col.prop(field, "use_radial_max", text=_("Use Maximum"))
155
156                 col = split.column()
157                 col.prop(field, "radial_falloff", text=_("Power"))
158
159                 sub = col.column()
160                 sub.active = field.use_radial_min
161                 sub.prop(field, "radial_min", text=_("Distance"))
162
163                 sub = col.column()
164                 sub.active = field.use_radial_max
165                 sub.prop(field, "radial_max", text=_("Distance"))
166
167
168 class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
169     bl_label = "Collision"
170     #bl_options = {'DEFAULT_CLOSED'}
171
172     @classmethod
173     def poll(cls, context):
174         ob = context.object
175         rd = context.scene.render
176         return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.collision)
177
178     def draw(self, context):
179         layout = self.layout
180
181         md = context.collision
182
183         split = layout.split()
184
185         coll = md.settings
186
187         if coll:
188             settings = context.object.collision
189
190             layout.active = settings.use
191
192             split = layout.split()
193
194             col = split.column()
195             col.label(text=_("Particle:"))
196             col.prop(settings, "permeability", slider=True)
197             col.prop(settings, "stickness")
198             col.prop(settings, "use_particle_kill")
199             col.label(text=_("Particle Damping:"))
200             sub = col.column(align=True)
201             sub.prop(settings, "damping_factor", text=_("Factor"), slider=True)
202             sub.prop(settings, "damping_random", text=_("Random"), slider=True)
203
204             col.label(text=_("Particle Friction:"))
205             sub = col.column(align=True)
206             sub.prop(settings, "friction_factor", text=_("Factor"), slider=True)
207             sub.prop(settings, "friction_random", text=_("Random"), slider=True)
208
209             col = split.column()
210             col.label(text=_("Soft Body and Cloth:"))
211             sub = col.column(align=True)
212             sub.prop(settings, "thickness_outer", text=_("Outer"), slider=True)
213             sub.prop(settings, "thickness_inner", text=_("Inner"), slider=True)
214
215             col.label(text=_("Soft Body Damping:"))
216             col.prop(settings, "damping", text=_("Factor"), slider=True)
217
218             col.label(text=_("Force Fields:"))
219             col.prop(settings, "absorption", text=_("Absorption"))
220
221 if __name__ == "__main__":  # only for live edit.
222     bpy.utils.register_module(__name__)