1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Panel
24 class PHYSICS_PT_rigidbody_constraint_panel:
25 bl_space_type = 'PROPERTIES'
26 bl_region_type = 'WINDOW'
27 bl_context = "physics"
30 class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel):
31 bl_label = "Rigid Body Constraint"
32 COMPAT_ENGINES = {'BLENDER_RENDER'}
35 def poll(cls, context):
37 view_render = context.scene.view_render
38 return (ob and ob.rigid_body_constraint and view_render.engine in cls.COMPAT_ENGINES)
40 def draw(self, context):
44 rbc = ob.rigid_body_constraint
46 layout.prop(rbc, "type")
49 row.prop(rbc, "enabled")
50 row.prop(rbc, "disable_collisions")
52 layout.prop(rbc, "object1")
53 layout.prop(rbc, "object2")
55 if rbc.type != 'MOTOR':
57 row.prop(rbc, "use_breaking")
59 sub.active = rbc.use_breaking
60 sub.prop(rbc, "breaking_threshold", text="Threshold")
63 row.prop(rbc, "use_override_solver_iterations", text="Override Iterations")
65 sub.active = rbc.use_override_solver_iterations
66 sub.prop(rbc, "solver_iterations", text="Iterations")
68 if rbc.type == 'HINGE':
69 col = layout.column(align=True)
72 row = col.row(align=True)
73 sub = row.row(align=True)
75 sub.prop(rbc, "use_limit_ang_z", toggle=True)
76 sub = row.row(align=True)
77 sub.active = rbc.use_limit_ang_z
78 sub.prop(rbc, "limit_ang_z_lower", text="Lower")
79 sub.prop(rbc, "limit_ang_z_upper", text="Upper")
81 elif rbc.type == 'SLIDER':
82 col = layout.column(align=True)
85 row = col.row(align=True)
86 sub = row.row(align=True)
88 sub.prop(rbc, "use_limit_lin_x", toggle=True)
89 sub = row.row(align=True)
90 sub.active = rbc.use_limit_lin_x
91 sub.prop(rbc, "limit_lin_x_lower", text="Lower")
92 sub.prop(rbc, "limit_lin_x_upper", text="Upper")
94 elif rbc.type == 'PISTON':
95 col = layout.column(align=True)
98 row = col.row(align=True)
99 sub = row.row(align=True)
101 sub.prop(rbc, "use_limit_lin_x", toggle=True)
102 sub = row.row(align=True)
103 sub.active = rbc.use_limit_lin_x
104 sub.prop(rbc, "limit_lin_x_lower", text="Lower")
105 sub.prop(rbc, "limit_lin_x_upper", text="Upper")
107 col = layout.column(align=True)
109 row = col.row(align=True)
110 sub = row.row(align=True)
112 sub.prop(rbc, "use_limit_ang_x", toggle=True)
113 sub = row.row(align=True)
114 sub.active = rbc.use_limit_ang_x
115 sub.prop(rbc, "limit_ang_x_lower", text="Lower")
116 sub.prop(rbc, "limit_ang_x_upper", text="Upper")
118 elif rbc.type == 'MOTOR':
119 col = layout.column(align=True)
120 col.label("Linear motor:")
122 row = col.row(align=True)
123 sub = row.row(align=True)
125 sub.prop(rbc, "use_motor_lin", toggle=True, text="Enable")
126 sub = row.row(align=True)
127 sub.active = rbc.use_motor_lin
128 sub.prop(rbc, "motor_lin_target_velocity", text="Target Velocity")
129 sub.prop(rbc, "motor_lin_max_impulse", text="Max Impulse")
131 col.label("Angular motor:")
133 row = col.row(align=True)
134 sub = row.row(align=True)
136 sub.prop(rbc, "use_motor_ang", toggle=True, text="Enable")
137 sub = row.row(align=True)
138 sub.active = rbc.use_motor_ang
139 sub.prop(rbc, "motor_ang_target_velocity", text="Target Velocity")
140 sub.prop(rbc, "motor_ang_max_impulse", text="Max Impulse")
142 elif rbc.type in {'GENERIC', 'GENERIC_SPRING'}:
143 col = layout.column(align=True)
146 row = col.row(align=True)
147 sub = row.row(align=True)
149 sub.prop(rbc, "use_limit_lin_x", toggle=True)
150 sub = row.row(align=True)
151 sub.active = rbc.use_limit_lin_x
152 sub.prop(rbc, "limit_lin_x_lower", text="Lower")
153 sub.prop(rbc, "limit_lin_x_upper", text="Upper")
155 row = col.row(align=True)
156 sub = row.row(align=True)
158 sub.prop(rbc, "use_limit_lin_y", toggle=True)
159 sub = row.row(align=True)
160 sub.active = rbc.use_limit_lin_y
161 sub.prop(rbc, "limit_lin_y_lower", text="Lower")
162 sub.prop(rbc, "limit_lin_y_upper", text="Upper")
164 row = col.row(align=True)
165 sub = row.row(align=True)
167 sub.prop(rbc, "use_limit_lin_z", toggle=True)
168 sub = row.row(align=True)
169 sub.active = rbc.use_limit_lin_z
170 sub.prop(rbc, "limit_lin_z_lower", text="Lower")
171 sub.prop(rbc, "limit_lin_z_upper", text="Upper")
173 col = layout.column(align=True)
175 row = col.row(align=True)
176 sub = row.row(align=True)
178 sub.prop(rbc, "use_limit_ang_x", toggle=True)
179 sub = row.row(align=True)
180 sub.active = rbc.use_limit_ang_x
181 sub.prop(rbc, "limit_ang_x_lower", text="Lower")
182 sub.prop(rbc, "limit_ang_x_upper", text="Upper")
184 row = col.row(align=True)
185 sub = row.row(align=True)
187 sub.prop(rbc, "use_limit_ang_y", toggle=True)
188 sub = row.row(align=True)
189 sub.active = rbc.use_limit_ang_y
190 sub.prop(rbc, "limit_ang_y_lower", text="Lower")
191 sub.prop(rbc, "limit_ang_y_upper", text="Upper")
193 row = col.row(align=True)
194 sub = row.row(align=True)
196 sub.prop(rbc, "use_limit_ang_z", toggle=True)
197 sub = row.row(align=True)
198 sub.active = rbc.use_limit_ang_z
199 sub.prop(rbc, "limit_ang_z_lower", text="Lower")
200 sub.prop(rbc, "limit_ang_z_upper", text="Upper")
202 if rbc.type == 'GENERIC_SPRING':
203 col = layout.column(align=True)
204 col.label("Springs:")
206 row = col.row(align=True)
207 sub = row.row(align=True)
209 sub.prop(rbc, "use_spring_x", toggle=True, text="X Axis")
210 sub = row.row(align=True)
211 sub.active = rbc.use_spring_x
212 sub.prop(rbc, "spring_stiffness_x", text="Stiffness")
213 sub.prop(rbc, "spring_damping_x", text="Damping")
215 row = col.row(align=True)
216 sub = row.row(align=True)
218 sub.prop(rbc, "use_spring_y", toggle=True, text="Y Axis")
219 sub = row.row(align=True)
220 sub.active = rbc.use_spring_y
221 sub.prop(rbc, "spring_stiffness_y", text="Stiffness")
222 sub.prop(rbc, "spring_damping_y", text="Damping")
224 row = col.row(align=True)
225 sub = row.row(align=True)
227 sub.prop(rbc, "use_spring_z", toggle=True, text="Z Axis")
228 sub = row.row(align=True)
229 sub.active = rbc.use_spring_z
230 sub.prop(rbc, "spring_stiffness_z", text="Stiffness")
231 sub.prop(rbc, "spring_damping_z", text="Damping")
233 col = layout.column(align=True)
235 row = col.row(align=True)
236 sub = row.row(align=True)
238 sub.prop(rbc, "use_spring_ang_x", toggle=True, text="X Angle")
239 sub = row.row(align=True)
240 sub.active = rbc.use_spring_ang_x
241 sub.prop(rbc, "spring_stiffness_ang_x", text="Stiffness")
242 sub.prop(rbc, "spring_damping_ang_x", text="Damping")
244 row = col.row(align=True)
245 sub = row.row(align=True)
247 sub.prop(rbc, "use_spring_ang_y", toggle=True, text="Y Angle")
248 sub = row.row(align=True)
249 sub.active = rbc.use_spring_ang_y
250 sub.prop(rbc, "spring_stiffness_ang_y", text="Stiffness")
251 sub.prop(rbc, "spring_damping_ang_y", text="Damping")
253 row = col.row(align=True)
254 sub = row.row(align=True)
256 sub.prop(rbc, "use_spring_ang_z", toggle=True, text="Z Angle")
257 sub = row.row(align=True)
258 sub.active = rbc.use_spring_ang_z
259 sub.prop(rbc, "spring_stiffness_ang_z", text="Stiffness")
260 sub.prop(rbc, "spring_damping_ang_z", text="Damping")
264 PHYSICS_PT_rigid_body_constraint,
267 if __name__ == "__main__": # only for live edit.
268 from bpy.utils import register_class