remove use of gettext: _("...") style translation now its handled by rna.
[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
23 from bl_ui.properties_physics_common import (
24     basic_force_field_settings_ui,
25     basic_force_field_falloff_ui,
26     )
27
28
29 class PhysicButtonsPanel():
30     bl_space_type = 'PROPERTIES'
31     bl_region_type = 'WINDOW'
32     bl_context = "physics"
33
34     @classmethod
35     def poll(cls, context):
36         rd = context.scene.render
37         return (context.object) and (not rd.use_game_engine)
38
39
40 class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
41     bl_label = "Force Fields"
42
43     @classmethod
44     def poll(cls, context):
45         ob = context.object
46         rd = context.scene.render
47         return (not rd.use_game_engine) and (ob.field) and (ob.field.type != 'NONE')
48
49     def draw(self, context):
50         layout = self.layout
51
52         ob = context.object
53         field = ob.field
54
55         split = layout.split(percentage=0.2)
56         split.label(text="Type:")
57
58         split.prop(field, "type", text="")
59
60         if field.type not in {'NONE', 'GUIDE', 'TEXTURE'}:
61             split = layout.split(percentage=0.2)
62             split.label(text="Shape:")
63             split.prop(field, "shape", text="")
64
65         split = layout.split()
66
67         if field.type == 'NONE':
68             return  # nothing to draw
69         elif field.type == 'GUIDE':
70             col = split.column()
71             col.prop(field, "guide_minimum")
72             col.prop(field, "guide_free")
73             col.prop(field, "falloff_power")
74             col.prop(field, "use_guide_path_add")
75             col.prop(field, "use_guide_path_weight")
76
77             col = split.column()
78             col.label(text="Clumping:")
79             col.prop(field, "guide_clump_amount")
80             col.prop(field, "guide_clump_shape")
81
82             row = layout.row()
83             row.prop(field, "use_max_distance")
84             sub = row.row()
85             sub.active = field.use_max_distance
86             sub.prop(field, "distance_max")
87
88             layout.separator()
89
90             layout.prop(field, "guide_kink_type")
91             if (field.guide_kink_type != 'NONE'):
92                 layout.prop(field, "guide_kink_axis")
93
94                 split = layout.split()
95
96                 col = split.column()
97                 col.prop(field, "guide_kink_frequency")
98                 col.prop(field, "guide_kink_shape")
99
100                 col = split.column()
101                 col.prop(field, "guide_kink_amplitude")
102
103         elif field.type == 'TEXTURE':
104             col = split.column()
105             col.prop(field, "strength")
106             col.prop(field, "texture", text="")
107             col.prop(field, "texture_mode", text="")
108             col.prop(field, "texture_nabla")
109
110             col = split.column()
111             col.prop(field, "use_object_coords")
112             col.prop(field, "use_root_coords")
113             col.prop(field, "use_2d_force")
114         else:
115             basic_force_field_settings_ui(self, context, field)
116
117         if field.type not in {'NONE', 'GUIDE'}:
118
119             layout.label(text="Falloff:")
120             layout.prop(field, "falloff_type", expand=True)
121
122             basic_force_field_falloff_ui(self, context, field)
123
124             if field.falloff_type == 'CONE':
125                 layout.separator()
126
127                 split = layout.split(percentage=0.35)
128
129                 col = split.column()
130                 col.label(text="Angular:")
131                 col.prop(field, "use_radial_min", text="Use Minimum")
132                 col.prop(field, "use_radial_max", text="Use Maximum")
133
134                 col = split.column()
135                 col.prop(field, "radial_falloff", text="Power")
136
137                 sub = col.column()
138                 sub.active = field.use_radial_min
139                 sub.prop(field, "radial_min", text="Angle")
140
141                 sub = col.column()
142                 sub.active = field.use_radial_max
143                 sub.prop(field, "radial_max", text="Angle")
144
145             elif field.falloff_type == 'TUBE':
146                 layout.separator()
147
148                 split = layout.split(percentage=0.35)
149
150                 col = split.column()
151                 col.label(text="Radial:")
152                 col.prop(field, "use_radial_min", text="Use Minimum")
153                 col.prop(field, "use_radial_max", text="Use Maximum")
154
155                 col = split.column()
156                 col.prop(field, "radial_falloff", text="Power")
157
158                 sub = col.column()
159                 sub.active = field.use_radial_min
160                 sub.prop(field, "radial_min", text="Distance")
161
162                 sub = col.column()
163                 sub.active = field.use_radial_max
164                 sub.prop(field, "radial_max", text="Distance")
165
166
167 class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
168     bl_label = "Collision"
169     #bl_options = {'DEFAULT_CLOSED'}
170
171     @classmethod
172     def poll(cls, context):
173         ob = context.object
174         rd = context.scene.render
175         return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.collision)
176
177     def draw(self, context):
178         layout = self.layout
179
180         md = context.collision
181
182         split = layout.split()
183
184         coll = md.settings
185
186         if coll:
187             settings = context.object.collision
188
189             layout.active = settings.use
190
191             split = layout.split()
192
193             col = split.column()
194             col.label(text="Particle:")
195             col.prop(settings, "permeability", slider=True)
196             col.prop(settings, "stickness")
197             col.prop(settings, "use_particle_kill")
198             col.label(text="Particle Damping:")
199             sub = col.column(align=True)
200             sub.prop(settings, "damping_factor", text="Factor", slider=True)
201             sub.prop(settings, "damping_random", text="Random", slider=True)
202
203             col.label(text="Particle Friction:")
204             sub = col.column(align=True)
205             sub.prop(settings, "friction_factor", text="Factor", slider=True)
206             sub.prop(settings, "friction_random", text="Random", slider=True)
207
208             col = split.column()
209             col.label(text="Soft Body and Cloth:")
210             sub = col.column(align=True)
211             sub.prop(settings, "thickness_outer", text="Outer", slider=True)
212             sub.prop(settings, "thickness_inner", text="Inner", slider=True)
213
214             col.label(text="Soft Body Damping:")
215             col.prop(settings, "damping", text="Factor", slider=True)
216
217             col.label(text="Force Fields:")
218             col.prop(settings, "absorption", text="Absorption")
219
220 if __name__ == "__main__":  # only for live edit.
221     bpy.utils.register_module(__name__)