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 01:25:54 +0400
committerBenjy Cook <benjycook@hotmail.com>2011-07-04 01:25:54 +0400
commite35806470408d01ddaf844c8ebd93fbc2cfdd68d (patch)
tree3b706b3e48075d10bd9a409abe1459e603033ab5 /release/scripts/modules
parent775ab37ad55daca119e6b59e693f3c9b77ca2ce2 (diff)
Added smoothing variables to constraint creation, and now Active checkbox is functional.Also initial work was done on the freeze constraint.
Diffstat (limited to 'release/scripts/modules')
-rw-r--r--release/scripts/modules/mocap_constraints.py53
1 files changed, 36 insertions, 17 deletions
diff --git a/release/scripts/modules/mocap_constraints.py b/release/scripts/modules/mocap_constraints.py
index 1251786d882..1892988c639 100644
--- a/release/scripts/modules/mocap_constraints.py
+++ b/release/scripts/modules/mocap_constraints.py
@@ -41,6 +41,12 @@ def getConsObj(bone):
cons_obj = bone
return cons_obj
+def consObjToBone(cons_obj):
+ if cons_obj.name[-3:] == "Org":
+ return cons_obj.name[:-3]
+ else:
+ return cons_obj.name
+
### And and Remove Constraints (called from operators)
@@ -53,7 +59,7 @@ def addNewConstraint(m_constraint, cons_obj):
c_type = "FLOOR"
real_constraint = cons_obj.constraints.new(c_type)
real_constraint.name = "Mocap constraint " + str(len(cons_obj.constraints))
- m_constraint.real_constraint_bone = cons_obj.name
+ m_constraint.real_constraint_bone = consObjToBone(cons_obj)
m_constraint.real_constraint = real_constraint.name
setConstraint(m_constraint)
@@ -62,21 +68,14 @@ def removeConstraint(m_constraint, cons_obj):
oldConstraint = cons_obj.constraints[m_constraint.real_constraint]
cons_obj.constraints.remove(oldConstraint)
-### Update functions. There are 3: UpdateType, UpdateBone
+### Update functions. There are 2: UpdateType/UpdateBone
### and update for the others.
def updateConstraint(self, context):
setConstraint(self)
-
-def updateConstraintType(m_constraint, context):
- pass
- #If the constraint exists, we need to remove it
- #Then create a new one.
-
-
-def updateConstraintTargetBone(m_constraint, context):
+def updateConstraintBoneType(m_constraint, context):
#If the constraint exists, we need to remove it
#from the old bone
obj = context.active_object
@@ -103,7 +102,10 @@ def setConstraint(m_constraint):
real_constraint = cons_obj.constraints[m_constraint.real_constraint]
#frame changing section
- fcurves = obj.animation_data.action.fcurves
+ if isinstance(cons_obj, bpy.types.PoseBone):
+ 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.
@@ -111,17 +113,14 @@ def setConstraint(m_constraint):
fcurve = fcurve[0]
for i in range(len(fcurve.keyframe_points) - 1, 0, -1):
fcurve.keyframe_points.remove(fcurve.keyframe_points[i])
- s, e = bpy.context.scene.frame_start, bpy.context.scene.frame_end
- real_constraint.influence = 0
- real_constraint.keyframe_insert(data_path="influence", frame=s)
- real_constraint.keyframe_insert(data_path="influence", frame=e)
s, e = m_constraint.s_frame, m_constraint.e_frame
+ s_in, s_out = m_constraint.smooth_in, m_constraint.smooth_out
real_constraint.influence = 1
real_constraint.keyframe_insert(data_path="influence", frame=s)
real_constraint.keyframe_insert(data_path="influence", frame=e)
real_constraint.influence = 0
- real_constraint.keyframe_insert(data_path="influence", frame=s - 10)
- real_constraint.keyframe_insert(data_path="influence", frame=e + 10)
+ real_constraint.keyframe_insert(data_path="influence", frame=s - s_in)
+ real_constraint.keyframe_insert(data_path="influence", frame=e + s_out)
#Set the blender constraint parameters
if m_constraint.type == "point":
@@ -139,3 +138,23 @@ def setConstraint(m_constraint):
real_constraint.use_min_x = True
real_constraint.use_min_y = True
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.max_x = x
+ real_constraint.max_y = y
+ real_constraint.max_z = z
+ real_constraint.min_x = x
+ real_constraint.min_y = y
+ real_constraint.min_z = z
+ real_constraint.use_max_x = True
+ real_constraint.use_max_y = True
+ real_constraint.use_max_z = True
+ real_constraint.use_min_x = True
+ real_constraint.use_min_y = True
+ real_constraint.use_min_z = True
+
+ # active check
+ real_constraint.mute = not m_constraint.active \ No newline at end of file