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
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')
-rw-r--r--release/scripts/modules/mocap_constraints.py53
-rw-r--r--release/scripts/startup/ui_mocap.py20
2 files changed, 53 insertions, 20 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
diff --git a/release/scripts/startup/ui_mocap.py b/release/scripts/startup/ui_mocap.py
index 4273eb74984..f4762f38c54 100644
--- a/release/scripts/startup/ui_mocap.py
+++ b/release/scripts/startup/ui_mocap.py
@@ -37,7 +37,7 @@ class MocapConstraint(bpy.types.PropertyGroup):
constrained_bone = bpy.props.StringProperty(name="Bone",
default="",
description="Constrained Bone",
- update=updateConstraintTargetBone)
+ update=updateConstraintBoneType)
constrained_boneB = bpy.props.StringProperty(name="Bone (2)",
default="",
description="Other Constrained Bone (optional, depends on type)",
@@ -50,6 +50,16 @@ class MocapConstraint(bpy.types.PropertyGroup):
default=500,
description="End frame of constrain",
update=updateConstraint)
+ smooth_in = bpy.props.IntProperty(name="In",
+ default=10,
+ description="Amount of frames to smooth in",
+ update=updateConstraint,
+ min=0)
+ smooth_out = bpy.props.IntProperty(name="Out",
+ default=10,
+ description="Amount of frames to smooth out",
+ update=updateConstraint,
+ min=0)
targetMesh = bpy.props.StringProperty(name="Mesh",
default="",
description="Target of Constraint - Mesh (optional, depends on type)",
@@ -83,7 +93,7 @@ class MocapConstraint(bpy.types.PropertyGroup):
("floor", "Stay above", "Bone does not cross specified mesh object eg floor"),
("distance", "Maintain distance", "Target bones maintained specified distance")],
description="Type of constraint",
- update=updateConstraint)
+ update=updateConstraintBoneType)
real_constraint = bpy.props.StringProperty()
real_constraint_bone = bpy.props.StringProperty()
@@ -231,6 +241,10 @@ class MocapConstraintsPanel(bpy.types.Panel):
frameRow.label("Frame Range:")
frameRow.prop(m_constraint, 's_frame')
frameRow.prop(m_constraint, 'e_frame')
+ smoothRow = box.row()
+ smoothRow.label("Smoothing:")
+ smoothRow.prop(m_constraint, 'smooth_in')
+ smoothRow.prop(m_constraint, 'smooth_out')
targetRow = box.row()
targetLabelCol = targetRow.column()
targetLabelCol.label("Target settings:")
@@ -329,4 +343,4 @@ def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
- register()
+ register() \ No newline at end of file