[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38117] branches/soc-2011-pepper/release/ scripts/modules: Added One-Sided distance constraint.
Benjy Cook
benjycook at hotmail.com
Tue Jul 5 12:56:34 CEST 2011
Revision: 38117
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38117
Author: benjycook
Date: 2011-07-05 10:56:34 +0000 (Tue, 05 Jul 2011)
Log Message:
-----------
Added One-Sided distance constraint. Also fixed some bugs and syntax in constraint and retarget scripts
Modified Paths:
--------------
branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
branches/soc-2011-pepper/release/scripts/modules/retarget.py
Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py 2011-07-05 10:55:35 UTC (rev 38116)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py 2011-07-05 10:56:34 UTC (rev 38117)
@@ -23,6 +23,7 @@
### Utility Functions
+
def hasIKConstraint(pose_bone):
#utility function / predicate, returns True if given bone has IK constraint
return ("IK" in [constraint.type for constraint in pose_bone.constraints])
@@ -40,6 +41,7 @@
cons_obj = bone
return cons_obj
+
def consObjToBone(cons_obj):
if cons_obj.name[-3:] == "Org":
return cons_obj.name[:-3]
@@ -74,6 +76,7 @@
def updateConstraint(self, context):
setConstraint(self)
+
def updateConstraintBoneType(m_constraint, context):
#If the constraint exists, we need to remove it
#from the old bone
@@ -106,7 +109,7 @@
fcurves = obj.animation_data.action.fcurves
else:
fcurves = cons_obj.animation_data.action.fcurves
-
+
influence_RNA = real_constraint.path_from_id("influence")
fcurve = [fcurve for fcurve in fcurves if fcurve.data_path == influence_RNA]
#clear the fcurve and set the frames.
@@ -121,7 +124,7 @@
real_constraint.keyframe_insert(data_path="influence", frame=e)
real_constraint.influence = 0
real_constraint.keyframe_insert(data_path="influence", frame=s - s_in)
- real_constraint.keyframe_insert(data_path="influence", frame=e + s_out)
+ real_constraint.keyframe_insert(data_path="influence", frame=e + s_out)
#Set the blender constraint parameters
if m_constraint.type == "point":
real_constraint.owner_space = m_constraint.targetSpace
@@ -140,7 +143,7 @@
real_constraint.use_min_z = True
if m_constraint.type == "freeze":
- real_constraint.owner_space = m_constraint.targetSpace
+ real_constraint.owner_space = m_constraint.targetSpace
bpy.context.scene.frame_set(s)
if isinstance(cons_obj, bpy.types.PoseBone):
x, y, z = cons_obj.center + (cons_obj.vector / 2)
@@ -159,6 +162,12 @@
real_constraint.use_min_x = True
real_constraint.use_min_y = True
real_constraint.use_min_z = True
-
+
+ if m_constraint.type == "distance" and m_constraint.constrained_boneB:
+ real_constraint.owner_space = "WORLD"
+ real_constraint.target = getConsObj(bones[m_constraint.constrained_boneB])
+ real_constraint.limit_mode = "LIMITDIST_ONSURFACE"
+ real_constraint.distance = m_constraint.targetDist
+
# active check
- real_constraint.mute = not m_constraint.active
\ No newline at end of file
+ real_constraint.mute = not m_constraint.active
Modified: branches/soc-2011-pepper/release/scripts/modules/retarget.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/retarget.py 2011-07-05 10:55:35 UTC (rev 38116)
+++ branches/soc-2011-pepper/release/scripts/modules/retarget.py 2011-07-05 10:56:34 UTC (rev 38117)
@@ -200,7 +200,7 @@
for t in range(s_frame, e_frame):
scene.frame_set(t)
end_bone = end_bones[root]
- end_bone.location = Vector((0,0,0))
+ end_bone.location = Vector((0, 0, 0))
end_bone.keyframe_insert("location")
bakeTransform(end_bone)
@@ -369,7 +369,7 @@
turnOffIK(enduser_obj)
inter_obj, inter_arm = createIntermediate(performer_obj, enduser_obj, bonemap, bonemapr, root, s_frame, e_frame, scene)
retargetEnduser(inter_obj, enduser_obj, root, s_frame, e_frame, scene)
- stride_bone = copyTranslation(performer_obj, enduser_obj, ["RightFoot", "LeftFoot"], bonemap, bonemapr, root, s_frame, e_frame, scene,enduser_obj_mat)
+ stride_bone = copyTranslation(performer_obj, enduser_obj, ["RightFoot", "LeftFoot"], bonemap, bonemapr, root, s_frame, e_frame, scene, enduser_obj_mat)
IKRetarget(bonemap, bonemapr, performer_obj, enduser_obj, s_frame, e_frame, scene)
restoreObjMat(performer_obj, enduser_obj, perf_obj_mat, enduser_obj_mat, stride_bone)
bpy.ops.object.mode_set(mode='OBJECT')
@@ -377,4 +377,4 @@
bpy.ops.object.delete()
if __name__ == "__main__":
- totalRetarget()
\ No newline at end of file
+ totalRetarget()
More information about the Bf-blender-cvs
mailing list