blender/release/scripts/startup/bl_ui/properties_constraint.py

886 lines
27 KiB
Python
Raw Normal View History

# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2010-02-12 13:34:04 +00:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
from bpy.types import Panel
2011-09-20 18:29:19 +00:00
class ConstraintButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "constraint"
def draw_constraint(self, context, con):
layout = self.layout
box = layout.template_constraint(con)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, con.type)(context, box, con)
if con.type not in {'RIGID_BODY_JOINT', 'NULL'}:
box.prop(con, "influence")
def space_template(self, layout, con, target=True, owner=True):
if target or owner:
2009-11-17 15:59:54 +00:00
split = layout.split(percentage=0.2)
split.label(text="Space:")
row = split.row()
if target:
row.prop(con, "target_space", text="")
if target and owner:
row.label(icon='ARROW_LEFTRIGHT')
if owner:
row.prop(con, "owner_space", text="")
def target_template(self, layout, con, subtargets=True):
2010-09-07 15:17:42 +00:00
layout.prop(con, "target") # XXX limiting settings for only 'curves' or some type of object
if con.target and subtargets:
if con.target.type == 'ARMATURE':
layout.prop_search(con, "subtarget", con.target.data, "bones", text="Bone")
if hasattr(con, "head_tail"):
row = layout.row()
row.label(text="Head/Tail:")
row.prop(con, "head_tail", text="")
elif con.target.type in {'MESH', 'LATTICE'}:
layout.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
def ik_template(self, layout, con):
# only used for iTaSC
layout.prop(con, "pole_target")
if con.pole_target and con.pole_target.type == 'ARMATURE':
layout.prop_search(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
if con.pole_target:
row = layout.row()
row.label()
row.prop(con, "pole_angle")
split = layout.split(percentage=0.33)
col = split.column()
2010-03-07 09:53:59 +00:00
col.prop(con, "use_tail")
col.prop(con, "use_stretch")
col = split.column()
col.prop(con, "chain_count")
def CHILD_OF(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
col = split.column()
col.label(text="Location:")
col.prop(con, "use_location_x", text="X")
col.prop(con, "use_location_y", text="Y")
col.prop(con, "use_location_z", text="Z")
col = split.column()
col.label(text="Rotation:")
col.prop(con, "use_rotation_x", text="X")
col.prop(con, "use_rotation_y", text="Y")
col.prop(con, "use_rotation_z", text="Z")
col = split.column()
col.label(text="Scale:")
col.prop(con, "use_scale_x", text="X")
col.prop(con, "use_scale_y", text="Y")
col.prop(con, "use_scale_z", text="Z")
row = layout.row()
row.operator("constraint.childof_set_inverse")
row.operator("constraint.childof_clear_inverse")
2009-11-17 15:59:54 +00:00
def TRACK_TO(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
row.label(text="To:")
2010-08-21 04:51:00 +00:00
row.prop(con, "track_axis", expand=True)
row = layout.row()
row.prop(con, "up_axis", text="Up")
row.prop(con, "use_target_z")
self.space_template(layout, con)
2009-11-17 15:59:54 +00:00
def IK(self, context, layout, con):
2011-11-11 03:28:46 +00:00
if context.object.pose.ik_solver == 'ITASC':
layout.prop(con, "ik_type")
getattr(self, 'IK_' + con.ik_type)(context, layout, con)
else:
# Standard IK constraint
self.target_template(layout, con)
layout.prop(con, "pole_target")
if con.pole_target and con.pole_target.type == 'ARMATURE':
layout.prop_search(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
if con.pole_target:
row = layout.row()
row.prop(con, "pole_angle")
row.label()
split = layout.split()
col = split.column()
col.prop(con, "iterations")
col.prop(con, "chain_count")
col = split.column()
col.prop(con, "use_tail")
col.prop(con, "use_stretch")
layout.label(text="Weight:")
split = layout.split()
col = split.column()
row = col.row(align=True)
row.prop(con, "use_location", text="")
sub = row.row()
sub.active = con.use_location
sub.prop(con, "weight", text="Position", slider=True)
col = split.column()
row = col.row(align=True)
row.prop(con, "use_rotation", text="")
sub = row.row()
sub.active = con.use_rotation
sub.prop(con, "orient_weight", text="Rotation", slider=True)
def IK_COPY_POSE(self, context, layout, con):
self.target_template(layout, con)
self.ik_template(layout, con)
row = layout.row()
row.label(text="Axis Ref:")
row.prop(con, "reference_axis", expand=True)
split = layout.split(percentage=0.33)
split.row().prop(con, "use_location")
row = split.row()
row.prop(con, "weight", text="Weight", slider=True)
row.active = con.use_location
split = layout.split(percentage=0.33)
row = split.row()
row.label(text="Lock:")
row = split.row()
row.prop(con, "lock_location_x", text="X")
row.prop(con, "lock_location_y", text="Y")
row.prop(con, "lock_location_z", text="Z")
split.active = con.use_location
split = layout.split(percentage=0.33)
2010-03-07 09:53:59 +00:00
split.row().prop(con, "use_rotation")
row = split.row()
row.prop(con, "orient_weight", text="Weight", slider=True)
row.active = con.use_rotation
split = layout.split(percentage=0.33)
row = split.row()
row.label(text="Lock:")
row = split.row()
row.prop(con, "lock_rotation_x", text="X")
row.prop(con, "lock_rotation_y", text="Y")
row.prop(con, "lock_rotation_z", text="Z")
split.active = con.use_rotation
def IK_DISTANCE(self, context, layout, con):
self.target_template(layout, con)
self.ik_template(layout, con)
layout.prop(con, "limit_mode")
row = layout.row()
row.prop(con, "weight", text="Weight", slider=True)
row.prop(con, "distance", text="Distance", slider=True)
def FOLLOW_PATH(self, context, layout, con):
self.target_template(layout, con)
layout.operator("constraint.followpath_path_animate", text="Animate Path", icon='ANIM_DATA')
split = layout.split()
col = split.column()
col.prop(con, "use_curve_follow")
col.prop(con, "use_curve_radius")
col = split.column()
col.prop(con, "use_fixed_location")
if con.use_fixed_location:
col.prop(con, "offset_factor", text="Offset")
else:
col.prop(con, "offset")
row = layout.row()
row.label(text="Forward:")
2010-08-21 04:51:00 +00:00
row.prop(con, "forward_axis", expand=True)
row = layout.row()
row.prop(con, "up_axis", text="Up")
row.label()
def LIMIT_ROTATION(self, context, layout, con):
split = layout.split()
2009-11-17 15:59:54 +00:00
col = split.column(align=True)
col.prop(con, "use_limit_x")
sub = col.column()
sub.active = con.use_limit_x
sub.prop(con, "min_x", text="Min")
sub.prop(con, "max_x", text="Max")
col = split.column(align=True)
col.prop(con, "use_limit_y")
sub = col.column()
sub.active = con.use_limit_y
sub.prop(con, "min_y", text="Min")
sub.prop(con, "max_y", text="Max")
col = split.column(align=True)
col.prop(con, "use_limit_z")
sub = col.column()
sub.active = con.use_limit_z
sub.prop(con, "min_z", text="Min")
sub.prop(con, "max_z", text="Max")
layout.prop(con, "use_transform_limit")
row = layout.row()
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def LIMIT_LOCATION(self, context, layout, con):
split = layout.split()
col = split.column()
col.prop(con, "use_min_x")
sub = col.column()
sub.active = con.use_min_x
sub.prop(con, "min_x", text="")
col.prop(con, "use_max_x")
sub = col.column()
sub.active = con.use_max_x
sub.prop(con, "max_x", text="")
col = split.column()
col.prop(con, "use_min_y")
sub = col.column()
sub.active = con.use_min_y
sub.prop(con, "min_y", text="")
col.prop(con, "use_max_y")
sub = col.column()
sub.active = con.use_max_y
sub.prop(con, "max_y", text="")
col = split.column()
col.prop(con, "use_min_z")
sub = col.column()
sub.active = con.use_min_z
sub.prop(con, "min_z", text="")
col.prop(con, "use_max_z")
sub = col.column()
sub.active = con.use_max_z
sub.prop(con, "max_z", text="")
row = layout.row()
row.prop(con, "use_transform_limit")
row.label()
row = layout.row()
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def LIMIT_SCALE(self, context, layout, con):
split = layout.split()
col = split.column()
col.prop(con, "use_min_x")
sub = col.column()
sub.active = con.use_min_x
sub.prop(con, "min_x", text="")
col.prop(con, "use_max_x")
sub = col.column()
sub.active = con.use_max_x
sub.prop(con, "max_x", text="")
col = split.column()
col.prop(con, "use_min_y")
sub = col.column()
sub.active = con.use_min_y
sub.prop(con, "min_y", text="")
col.prop(con, "use_max_y")
sub = col.column()
sub.active = con.use_max_y
sub.prop(con, "max_y", text="")
col = split.column()
col.prop(con, "use_min_z")
sub = col.column()
sub.active = con.use_min_z
sub.prop(con, "min_z", text="")
col.prop(con, "use_max_z")
sub = col.column()
sub.active = con.use_max_z
sub.prop(con, "max_z", text="")
row = layout.row()
row.prop(con, "use_transform_limit")
row.label()
row = layout.row()
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def COPY_ROTATION(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
col = split.column()
col.prop(con, "use_x", text="X")
sub = col.column()
sub.active = con.use_x
sub.prop(con, "invert_x", text="Invert")
col = split.column()
col.prop(con, "use_y", text="Y")
sub = col.column()
sub.active = con.use_y
sub.prop(con, "invert_y", text="Invert")
col = split.column()
col.prop(con, "use_z", text="Z")
sub = col.column()
sub.active = con.use_z
sub.prop(con, "invert_z", text="Invert")
layout.prop(con, "use_offset")
self.space_template(layout, con)
def COPY_LOCATION(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
col = split.column()
col.prop(con, "use_x", text="X")
sub = col.column()
sub.active = con.use_x
sub.prop(con, "invert_x", text="Invert")
col = split.column()
col.prop(con, "use_y", text="Y")
sub = col.column()
sub.active = con.use_y
sub.prop(con, "invert_y", text="Invert")
col = split.column()
col.prop(con, "use_z", text="Z")
sub = col.column()
sub.active = con.use_z
sub.prop(con, "invert_z", text="Invert")
layout.prop(con, "use_offset")
self.space_template(layout, con)
def COPY_SCALE(self, context, layout, con):
self.target_template(layout, con)
row = layout.row(align=True)
row.prop(con, "use_x", text="X")
row.prop(con, "use_y", text="Y")
row.prop(con, "use_z", text="Z")
layout.prop(con, "use_offset")
self.space_template(layout, con)
2010-01-31 14:46:28 +00:00
def MAINTAIN_VOLUME(self, context, layout, con):
row = layout.row()
row.label(text="Free:")
2010-08-21 04:51:00 +00:00
row.prop(con, "free_axis", expand=True)
layout.prop(con, "volume")
row = layout.row()
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def COPY_TRANSFORMS(self, context, layout, con):
self.target_template(layout, con)
self.space_template(layout, con)
2010-01-31 14:46:28 +00:00
#def SCRIPT(self, context, layout, con):
def ACTION(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
2012-02-04 11:10:41 +00:00
col = split.column()
col.label(text="From Target:")
col.prop(con, "transform_channel", text="")
col.prop(con, "target_space", text="")
2012-02-04 11:10:41 +00:00
col = split.column()
col.label(text="To Action:")
col.prop(con, "action", text="")
col.prop(con, "use_bone_object_action")
2012-02-04 11:10:41 +00:00
split = layout.split()
2012-02-04 11:10:41 +00:00
col = split.column(align=True)
col.label(text="Target Range:")
col.prop(con, "min", text="Min")
col.prop(con, "max", text="Max")
2012-02-04 11:10:41 +00:00
col = split.column(align=True)
col.label(text="Action Range:")
col.prop(con, "frame_start", text="Start")
col.prop(con, "frame_end", text="End")
def LOCKED_TRACK(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
row.label(text="To:")
2010-08-21 04:51:00 +00:00
row.prop(con, "track_axis", expand=True)
row = layout.row()
row.label(text="Lock:")
2010-08-21 04:51:00 +00:00
row.prop(con, "lock_axis", expand=True)
def LIMIT_DISTANCE(self, context, layout, con):
self.target_template(layout, con)
col = layout.column(align=True)
col.prop(con, "distance")
col.operator("constraint.limitdistance_reset")
row = layout.row()
row.label(text="Clamp Region:")
row.prop(con, "limit_mode", text="")
row = layout.row()
row.prop(con, "use_transform_limit")
row.label()
self.space_template(layout, con)
def STRETCH_TO(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
row.prop(con, "rest_length", text="Rest Length")
row.operator("constraint.stretchto_reset", text="Reset")
layout.prop(con, "bulge", text="Volume Variation")
row = layout.row()
row.label(text="Volume:")
row.prop(con, "volume", expand=True)
row.label(text="Plane:")
row.prop(con, "keep_axis", expand=True)
def FLOOR(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
row.prop(con, "use_sticky")
row.prop(con, "use_rotation")
layout.prop(con, "offset")
row = layout.row()
row.label(text="Min/Max:")
row.prop(con, "floor_location", expand=True)
2010-01-31 14:46:28 +00:00
self.space_template(layout, con)
def RIGID_BODY_JOINT(self, context, layout, con):
self.target_template(layout, con, subtargets=False)
layout.prop(con, "pivot_type")
layout.prop(con, "child")
row = layout.row()
row.prop(con, "use_linked_collision", text="Linked Collision")
row.prop(con, "show_pivot", text="Display Pivot")
split = layout.split()
col = split.column(align=True)
col.label(text="Pivot:")
col.prop(con, "pivot_x", text="X")
col.prop(con, "pivot_y", text="Y")
col.prop(con, "pivot_z", text="Z")
col = split.column(align=True)
col.label(text="Axis:")
col.prop(con, "axis_x", text="X")
col.prop(con, "axis_y", text="Y")
col.prop(con, "axis_z", text="Z")
if con.pivot_type == 'CONE_TWIST':
layout.label(text="Limits:")
split = layout.split()
2011-01-01 07:20:34 +00:00
col = split.column()
col.prop(con, "use_angular_limit_x", text="Angle X")
sub = col.column()
sub.active = con.use_angular_limit_x
sub.prop(con, "limit_angle_max_x", text="")
2011-01-01 07:20:34 +00:00
col = split.column()
col.prop(con, "use_angular_limit_y", text="Angle Y")
sub = col.column()
sub.active = con.use_angular_limit_y
sub.prop(con, "limit_angle_max_y", text="")
col = split.column()
col.prop(con, "use_angular_limit_z", text="Angle Z")
sub = col.column()
sub.active = con.use_angular_limit_z
sub.prop(con, "limit_angle_max_z", text="")
elif con.pivot_type == 'GENERIC_6_DOF':
layout.label(text="Limits:")
split = layout.split()
col = split.column(align=True)
col.prop(con, "use_limit_x", text="X")
sub = col.column()
sub.active = con.use_limit_x
sub.prop(con, "limit_min_x", text="Min")
sub.prop(con, "limit_max_x", text="Max")
col = split.column(align=True)
col.prop(con, "use_limit_y", text="Y")
sub = col.column()
sub.active = con.use_limit_y
sub.prop(con, "limit_min_y", text="Min")
sub.prop(con, "limit_max_y", text="Max")
col = split.column(align=True)
col.prop(con, "use_limit_z", text="Z")
sub = col.column()
sub.active = con.use_limit_z
sub.prop(con, "limit_min_z", text="Min")
sub.prop(con, "limit_max_z", text="Max")
split = layout.split()
col = split.column(align=True)
col.prop(con, "use_angular_limit_x", text="Angle X")
sub = col.column()
sub.active = con.use_angular_limit_x
sub.prop(con, "limit_angle_min_x", text="Min")
sub.prop(con, "limit_angle_max_x", text="Max")
col = split.column(align=True)
col.prop(con, "use_angular_limit_y", text="Angle Y")
sub = col.column()
sub.active = con.use_angular_limit_y
sub.prop(con, "limit_angle_min_y", text="Min")
sub.prop(con, "limit_angle_max_y", text="Max")
col = split.column(align=True)
col.prop(con, "use_angular_limit_z", text="Angle Z")
sub = col.column()
sub.active = con.use_angular_limit_z
sub.prop(con, "limit_angle_min_z", text="Min")
sub.prop(con, "limit_angle_max_z", text="Max")
2011-01-01 07:20:34 +00:00
elif con.pivot_type == 'HINGE':
layout.label(text="Limits:")
split = layout.split()
row = split.row(align=True)
col = row.column()
col.prop(con, "use_angular_limit_x", text="Angle X")
col = row.column()
col.active = con.use_angular_limit_x
col.prop(con, "limit_angle_min_x", text="Min")
col = row.column()
col.active = con.use_angular_limit_x
col.prop(con, "limit_angle_max_x", text="Max")
2011-01-01 07:20:34 +00:00
def CLAMP_TO(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
row.label(text="Main Axis:")
row.prop(con, "main_axis", expand=True)
layout.prop(con, "use_cyclic")
def TRANSFORM(self, context, layout, con):
self.target_template(layout, con)
layout.prop(con, "use_motion_extrapolate", text="Extrapolate")
2009-11-17 15:59:54 +00:00
col = layout.column()
col.row().label(text="Source:")
col.row().prop(con, "map_from", expand=True)
2009-11-17 15:59:54 +00:00
split = layout.split()
2009-11-17 15:59:54 +00:00
sub = split.column(align=True)
sub.label(text="X:")
sub.prop(con, "from_min_x", text="Min")
sub.prop(con, "from_max_x", text="Max")
sub = split.column(align=True)
sub.label(text="Y:")
sub.prop(con, "from_min_y", text="Min")
sub.prop(con, "from_max_y", text="Max")
sub = split.column(align=True)
sub.label(text="Z:")
sub.prop(con, "from_min_z", text="Min")
sub.prop(con, "from_max_z", text="Max")
col = layout.column()
row = col.row()
row.label(text="Source to Destination Mapping:")
2011-06-24 03:30:50 +00:00
# note: chr(187) is the ASCII arrow ( >> ). Blender Text Editor can't
2011-10-17 06:58:07 +00:00
# open it. Thus we are using the hard-coded value instead.
row = col.row()
row.prop(con, "map_to_x_from", expand=False, text="")
row.label(text=" %s X" % chr(187))
row = col.row()
row.prop(con, "map_to_y_from", expand=False, text="")
row.label(text=" %s Y" % chr(187))
row = col.row()
row.prop(con, "map_to_z_from", expand=False, text="")
row.label(text=" %s Z" % chr(187))
split = layout.split()
col = split.column()
col.label(text="Destination:")
col.row().prop(con, "map_to", expand=True)
2009-11-17 15:59:54 +00:00
split = layout.split()
2009-11-17 15:59:54 +00:00
col = split.column()
col.label(text="X:")
2009-11-17 15:59:54 +00:00
sub = col.column(align=True)
sub.prop(con, "to_min_x", text="Min")
sub.prop(con, "to_max_x", text="Max")
col = split.column()
col.label(text="Y:")
2009-11-17 15:59:54 +00:00
sub = col.column(align=True)
sub.prop(con, "to_min_y", text="Min")
sub.prop(con, "to_max_y", text="Max")
col = split.column()
col.label(text="Z:")
2009-11-17 15:59:54 +00:00
sub = col.column(align=True)
sub.prop(con, "to_min_z", text="Min")
sub.prop(con, "to_max_z", text="Max")
self.space_template(layout, con)
def SHRINKWRAP(self, context, layout, con):
self.target_template(layout, con, False)
layout.prop(con, "distance")
layout.prop(con, "shrinkwrap_type")
if con.shrinkwrap_type == 'PROJECT':
row = layout.row(align=True)
row.prop(con, "use_x")
row.prop(con, "use_y")
row.prop(con, "use_z")
def DAMPED_TRACK(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
row.label(text="To:")
2010-08-21 04:51:00 +00:00
row.prop(con, "track_axis", expand=True)
def SPLINE_IK(self, context, layout, con):
self.target_template(layout, con)
col = layout.column()
col.label(text="Spline Fitting:")
col.prop(con, "chain_count")
col.prop(con, "use_even_divisions")
col.prop(con, "use_chain_offset")
col = layout.column()
col.label(text="Chain Scaling:")
col.prop(con, "use_y_stretch")
col.prop(con, "xz_scale_mode")
col.prop(con, "use_curve_radius")
def PIVOT(self, context, layout, con):
self.target_template(layout, con)
== Pivot Constraint == This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples. == Usage Examples == === Foot Roll === 1. Add 'Pivot' Constraint to the bone without any target. 2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head. 3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'. === See Saw === 1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive. 2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied. 3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation. == Notes == * The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this. * The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again. * For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
if con.target:
col = layout.column()
col.prop(con, "offset", text="Pivot Offset")
== Pivot Constraint == This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples. == Usage Examples == === Foot Roll === 1. Add 'Pivot' Constraint to the bone without any target. 2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head. 3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'. === See Saw === 1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive. 2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied. 3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation. == Notes == * The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this. * The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again. * For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
else:
col = layout.column()
col.prop(con, "use_relative_location")
if con.use_relative_location:
col.prop(con, "offset", text="Relative Pivot Point")
== Pivot Constraint == This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples. == Usage Examples == === Foot Roll === 1. Add 'Pivot' Constraint to the bone without any target. 2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head. 3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'. === See Saw === 1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive. 2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied. 3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation. == Notes == * The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this. * The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again. * For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
else:
col.prop(con, "offset", text="Absolute Pivot Point")
== Pivot Constraint == This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples. == Usage Examples == === Foot Roll === 1. Add 'Pivot' Constraint to the bone without any target. 2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head. 3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'. === See Saw === 1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive. 2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied. 3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation. == Notes == * The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this. * The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again. * For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
col = layout.column()
col.prop(con, "rotation_range", text="Pivot When")
@staticmethod
def _getConstraintClip(context, con):
if not con.use_active_clip:
return con.clip
else:
return context.scene.active_clip
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
def FOLLOW_TRACK(self, context, layout, con):
clip = self._getConstraintClip(context, con)
row = layout.row()
row.prop(con, "use_active_clip")
row.prop(con, "use_3d_position")
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
col = layout.column()
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
if not con.use_active_clip:
col.prop(con, "clip")
row = col.row()
row.prop(con, "frame_method", expand=True)
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
if clip:
tracking = clip.tracking
col.prop_search(con, "object", tracking, "objects", icon='OBJECT_DATA')
tracking_object = tracking.objects.get(con.object, tracking.objects[0])
col.prop_search(con, "track", tracking_object, "tracks", icon='ANIM_DATA')
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
col.prop(con, "camera")
row = col.row()
row.active = not con.use_3d_position
row.prop(con, "depth_object")
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
layout.operator("clip.constraint_to_fcurve")
def CAMERA_SOLVER(self, context, layout, con):
layout.prop(con, "use_active_clip")
if not con.use_active_clip:
layout.prop(con, "clip")
layout.operator("clip.constraint_to_fcurve")
def OBJECT_SOLVER(self, context, layout, con):
clip = self._getConstraintClip(context, con)
layout.prop(con, "use_active_clip")
if not con.use_active_clip:
layout.prop(con, "clip")
if clip:
layout.prop_search(con, "object", clip.tracking, "objects", icon='OBJECT_DATA')
layout.prop(con, "camera")
row = layout.row()
row.operator("constraint.objectsolver_set_inverse")
row.operator("constraint.objectsolver_clear_inverse")
layout.operator("clip.constraint_to_fcurve")
def SCRIPT(self, context, layout, con):
2013-02-28 15:31:20 +00:00
layout.label("Blender 2.6 doesn't support python constraints yet")
class OBJECT_PT_constraints(ConstraintButtonsPanel, Panel):
bl_label = "Object Constraints"
bl_context = "constraint"
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
return (context.object)
def draw(self, context):
layout = self.layout
2013-03-11 02:19:58 +00:00
obj = context.object
2013-03-11 02:19:58 +00:00
if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
box = layout.box()
box.alert = True
box.label(icon='INFO', text="See Bone Constraints tab to Add Constraints to active bone")
else:
layout.operator_menu_enum("object.constraint_add", "type", text="Add Object Constraint")
2013-03-11 02:19:58 +00:00
for con in obj.constraints:
self.draw_constraint(context, con)
class BONE_PT_constraints(ConstraintButtonsPanel, Panel):
bl_label = "Bone Constraints"
bl_context = "bone_constraint"
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
return (context.pose_bone)
def draw(self, context):
layout = self.layout
layout.operator_menu_enum("pose.constraint_add", "type", text="Add Bone Constraint")
for con in context.pose_bone.constraints:
self.draw_constraint(context, con)
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)