Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjy Cook <benjycook@hotmail.com>2011-07-04 15:35:29 +0400
committerBenjy Cook <benjycook@hotmail.com>2011-07-04 15:35:29 +0400
commita552d8e6104db06d94e2a51d533d7f34cfd3aa47 (patch)
treef6dac6516217d94c7c025bc52ad25446d651fe2d /release/scripts
parentde1c4fafc7ecd644dd9ba06dfc7a4f77b4d06683 (diff)
Finished Freeze constraint, and target space option for Freeze and Point constraints.
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/modules/mocap_constraints.py24
-rw-r--r--release/scripts/modules/retarget.py1
-rw-r--r--release/scripts/startup/ui_mocap.py32
3 files changed, 33 insertions, 24 deletions
diff --git a/release/scripts/modules/mocap_constraints.py b/release/scripts/modules/mocap_constraints.py
index 1892988c639..e12d510a6f9 100644
--- a/release/scripts/modules/mocap_constraints.py
+++ b/release/scripts/modules/mocap_constraints.py
@@ -23,7 +23,6 @@ from mathutils import *
### 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 @@ def updateConstraintBoneType(m_constraint, context):
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 @@ def setConstraint(m_constraint):
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 @@ def setConstraint(m_constraint):
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 @@ def setConstraint(m_constraint):
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
diff --git a/release/scripts/modules/retarget.py b/release/scripts/modules/retarget.py
index 64b9bb51eed..9a3ed4b70cb 100644
--- a/release/scripts/modules/retarget.py
+++ b/release/scripts/modules/retarget.py
@@ -348,6 +348,7 @@ def restoreObjMat(performer_obj, enduser_obj, perf_obj_mat, enduser_obj_mat, str
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():
diff --git a/release/scripts/startup/ui_mocap.py b/release/scripts/startup/ui_mocap.py
index f4762f38c54..71d291fd014 100644
--- a/release/scripts/startup/ui_mocap.py
+++ b/release/scripts/startup/ui_mocap.py
@@ -22,6 +22,15 @@ import bpy
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 @@ class MocapConstraint(bpy.types.PropertyGroup):
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 @@ def toggleIKBone(self, context):
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 @@ def updateIKRetarget():
updateIKRetarget()
-import retarget
-import mocap_tools
-
-
class MocapPanel(bpy.types.Panel):
# Motion capture retargeting panel
bl_label = "Mocap tools"
@@ -251,11 +256,10 @@ class MocapConstraintsPanel(bpy.types.Panel):
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')