[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38082] branches/soc-2011-pepper/release/ scripts: Finished Freeze constraint, and target space option for Freeze and Point constraints.
Benjy Cook
benjycook at hotmail.com
Mon Jul 4 13:35:30 CEST 2011
Revision: 38082
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38082
Author: benjycook
Date: 2011-07-04 11:35:29 +0000 (Mon, 04 Jul 2011)
Log Message:
-----------
Finished Freeze constraint, and target space option for Freeze and Point constraints.
Modified Paths:
--------------
branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
branches/soc-2011-pepper/release/scripts/modules/retarget.py
branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py
Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py 2011-07-04 11:28:39 UTC (rev 38081)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py 2011-07-04 11:35:29 UTC (rev 38082)
@@ -23,7 +23,6 @@
### 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])
@@ -85,9 +84,10 @@
cons_obj = getConsObj(bone)
removeConstraint(m_constraint, cons_obj)
#Regardless, after that we create a new constraint
- bone = bones[m_constraint.constrained_bone]
- cons_obj = getConsObj(bone)
- addNewConstraint(m_constraint, cons_obj)
+ if m_constraint.constrained_bone:
+ bone = bones[m_constraint.constrained_bone]
+ cons_obj = getConsObj(bone)
+ addNewConstraint(m_constraint, cons_obj)
# Function that copies all settings from m_constraint to the real Blender constraints
@@ -106,6 +106,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.
@@ -120,11 +121,10 @@
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.target_space = "WORLD" # temporary for now, just World is supported
+ real_constraint.owner_space = m_constraint.targetSpace
x, y, z = m_constraint.targetPoint
real_constraint.max_x = x
real_constraint.max_y = y
@@ -140,9 +140,13 @@
real_constraint.use_min_z = True
if m_constraint.type == "freeze":
- real_constraint.target_space = "WORLD"
- bpy.context.scene.frame_set(m_constraint.s_frame)
- x, y, z = cons_obj.location.copy()
+ 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)
+ else:
+ x, y, z = cons_obj.matrix_world.to_translation()
+
real_constraint.max_x = x
real_constraint.max_y = y
real_constraint.max_z = z
Modified: branches/soc-2011-pepper/release/scripts/modules/retarget.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/retarget.py 2011-07-04 11:28:39 UTC (rev 38081)
+++ branches/soc-2011-pepper/release/scripts/modules/retarget.py 2011-07-04 11:35:29 UTC (rev 38082)
@@ -348,6 +348,7 @@
empty.parent = stride_bone
performer_obj.matrix_world = perf_obj_mat
enduser_obj.matrix_world = enduser_obj_mat
+ enduser_obj.parent = stride_bone
def totalRetarget():
Modified: branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py 2011-07-04 11:28:39 UTC (rev 38081)
+++ branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py 2011-07-04 11:35:29 UTC (rev 38082)
@@ -22,6 +22,15 @@
from bpy.props import *
from bpy import *
+import mocap_constraints
+import retarget
+import mocap_tools
+### reloads modules (for testing purposes only)
+from imp import reload
+reload(mocap_constraints)
+reload(retarget)
+reload(mocap_tools)
+
from mocap_constraints import *
# MocapConstraint class
@@ -72,17 +81,13 @@
default=False,
description="Constraint has been baked to NLA layer",
update=updateConstraint)
- targetFrame = bpy.props.IntProperty(name="Frame",
- default=1,
- description="Target of Constraint - Frame (optional, depends on type)",
- update=updateConstraint)
targetPoint = bpy.props.FloatVectorProperty(name="Point", size=3,
subtype="XYZ", default=(0.0, 0.0, 0.0),
description="Target of Constraint - Point",
update=updateConstraint)
targetSpace = bpy.props.EnumProperty(
- items=[("world", "World Space", "Evaluate target in global space"),
- ("object", "Object space", "Evaluate target in object space"),
+ items=[("WORLD", "World Space", "Evaluate target in global space"),
+ ("LOCAL", "Object space", "Evaluate target in object space"),
("constrained_boneB", "Other Bone Space", "Evaluate target in specified other bone space")],
name="Space",
description="In which space should Point type target be evaluated",
@@ -111,7 +116,11 @@
print(self.name + " IK toggled ON!")
ik = self.constraints.new('IK')
#ik the whole chain up to the root, excluding
- chainLen = len(self.bone.parent_recursive)
+ chainLen = 0
+ for parent_bone in self.parent_recursive:
+ chainLen+=1
+ if hasIKConstraint(parent_bone):
+ break
ik.chain_count = chainLen
for bone in self.parent_recursive:
if bone.is_in_ik_chain:
@@ -159,10 +168,6 @@
updateIKRetarget()
-import retarget
-import mocap_tools
-
-
class MocapPanel(bpy.types.Panel):
# Motion capture retargeting panel
bl_label = "Mocap tools"
@@ -251,11 +256,10 @@
targetPropCol = targetRow.column()
if m_constraint.type == "floor":
targetPropCol.prop_search(m_constraint, 'targetMesh', bpy.data, "objects")
- if m_constraint.type == "freeze":
- targetPropCol.prop(m_constraint, 'targetFrame')
+ if m_constraint.type == "point" or m_constraint.type == "freeze":
+ box.prop(m_constraint, 'targetSpace')
if m_constraint.type == "point":
targetPropCol.prop(m_constraint, 'targetPoint')
- box.prop(m_constraint, 'targetSpace')
checkRow = box.row()
checkRow.prop(m_constraint, 'active')
checkRow.prop(m_constraint, 'baked')
More information about the Bf-blender-cvs
mailing list