本文整理汇总了Python中kraken.core.objects.joint.Joint.addConstraint方法的典型用法代码示例。如果您正苦于以下问题:Python Joint.addConstraint方法的具体用法?Python Joint.addConstraint怎么用?Python Joint.addConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kraken.core.objects.joint.Joint
的用法示例。
在下文中一共展示了Joint.addConstraint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FabriceSpineRig
# 需要导入模块: from kraken.core.objects.joint import Joint [as 别名]
# 或者: from kraken.core.objects.joint.Joint import addConstraint [as 别名]
class FabriceSpineRig(FabriceSpine):
"""Fabrice Spine Component"""
def __init__(self, name="spine", parent=None):
Profiler.getInstance().push("Construct Spine Rig Component:" + name)
super(FabriceSpineRig, self).__init__(name, parent)
# =========
# Controls
# =========
# COG
self.cogCtrlSpace = CtrlSpace('cog', parent=self.ctrlCmpGrp)
self.cogCtrl = Control('cog', parent=self.cogCtrlSpace, shape="circle")
self.cogCtrl.rotatePoints(90, 0, 0)
self.cogCtrl.scalePoints(Vec3(3.0, 3.0, 3.0))
self.cogCtrl.translatePoints(Vec3(0.0, 0.0, 0.2))
self.cogCtrl.lockScale(x=True, y=True, z=True)
self.cogCtrl.setColor("orange")
# Spine Base
self.spineBaseCtrlSpace = CtrlSpace('spineBase', parent=self.cogCtrl)
self.spineBaseCtrl = Control('spineBase', parent=self.spineBaseCtrlSpace, shape="pin")
self.spineBaseCtrl.rotatePoints(90, 0, 0)
self.spineBaseCtrl.translatePoints(Vec3(0, 1.0, 0))
self.spineBaseCtrl.lockScale(x=True, y=True, z=True)
# Spine Base Handle
self.spineBaseHandleCtrlSpace = CtrlSpace('spineBaseHandle', parent=self.spineBaseCtrl)
self.spineBaseHandleCtrl = Control('spineBaseHandle', parent=self.spineBaseHandleCtrlSpace, shape="pin")
self.spineBaseHandleCtrl.rotatePoints(90, 0, 0)
self.spineBaseHandleCtrl.translatePoints(Vec3(0, 1.0, 0))
self.spineBaseHandleCtrl.lockScale(x=True, y=True, z=True)
self.spineBaseHandleCtrl.setColor("orange")
# Spine End
self.spineEndCtrlSpace = CtrlSpace('spineEnd', parent=self.cogCtrl)
self.spineEndCtrl = Control('spineEnd', parent=self.spineEndCtrlSpace, shape="pin")
self.spineEndCtrl.rotatePoints(90, 0, 0)
self.spineEndCtrl.lockScale(x=True, y=True, z=True)
self.spineEndCtrl.translatePoints(Vec3(0, 1.0, 0))
# Spine End Handle
self.spineEndHandleCtrlSpace = CtrlSpace('spineEndHandle', parent=self.spineEndCtrl)
self.spineEndHandleCtrl = Control('spineEndHandle', parent=self.spineEndHandleCtrlSpace, shape="pin")
self.spineEndHandleCtrl.rotatePoints(90, 0, 0)
self.spineEndHandleCtrl.translatePoints(Vec3(0, 1.0, 0))
self.spineEndHandleCtrl.lockScale(x=True, y=True, z=True)
self.spineEndHandleCtrl.setColor("orange")
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.chestDef = Joint('chest', parent=self.defCmpGrp)
self.chestDef.setComponent(self)
self.deformerJoints = []
self.spineOutputs = []
self.setNumDeformers(1)
# =====================
# Create Component I/O
# =====================
# Setup component Xfo I/O's
self.spineVertebraeOutput.setTarget(self.spineOutputs)
# =====================
# Constraint Deformers
# =====================
self.chestDefConstraint = PoseConstraint('_'.join([self.chestDef.getName(), 'To', self.spineBaseOutputTgt.getName()]))
self.chestDefConstraint.addConstrainer(self.spineBaseOutputTgt)
self.chestDef.addConstraint(self.chestDefConstraint)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.spineSrtInputConstraint = PoseConstraint('_'.join([self.cogCtrlSpace.getName(), 'To', self.spineMainSrtInputTgt.getName()]))
self.spineSrtInputConstraint.addConstrainer(self.spineMainSrtInputTgt)
self.spineSrtInputConstraint.setMaintainOffset(True)
self.cogCtrlSpace.addConstraint(self.spineSrtInputConstraint)
# Constraint outputs
self.spineCogOutputConstraint = PoseConstraint('_'.join([self.spineCogOutputTgt.getName(), 'To', self.cogCtrl.getName()]))
self.spineCogOutputConstraint.addConstrainer(self.cogCtrl)
self.spineCogOutputTgt.addConstraint(self.spineCogOutputConstraint)
# Spine Base
self.spineBaseOutputPosConstraint = PositionConstraint('_'.join([self.spineBaseOutputTgt.getName(), 'PosTo', self.spineOutputs[0].getName()]))
self.spineBaseOutputPosConstraint.addConstrainer(self.spineOutputs[0])
self.spineBaseOutputTgt.addConstraint(self.spineBaseOutputPosConstraint)
self.spineBaseOutputOriConstraint = OrientationConstraint('_'.join([self.spineBaseOutputTgt.getName(), 'PosTo', self.cogCtrl.getName()]))
self.spineBaseOutputOriConstraint.addConstrainer(self.cogCtrl)
#.........这里部分代码省略.........
示例2: HandComponentRig
# 需要导入模块: from kraken.core.objects.joint import Joint [as 别名]
# 或者: from kraken.core.objects.joint.Joint import addConstraint [as 别名]
class HandComponentRig(HandComponent):
"""Hand Component"""
def __init__(self, name='Hand', parent=None):
Profiler.getInstance().push("Construct Hand Rig Component:" + name)
super(HandComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Hand
self.handCtrlSpace = CtrlSpace('hand', parent=self.ctrlCmpGrp)
self.handCtrl = Control('hand', parent=self.handCtrlSpace, shape="square")
self.handCtrl.rotatePoints(0, 0, 90.0)
self.handCtrl.lockScale(True, True, True)
self.handCtrl.lockTranslation(True, True, True)
# ==========
# Deformers
# ==========
self.deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=self.deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
self.handDef = Joint('hand', parent=self.defCmpGrp)
self.handDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.armEndInputConstraint = PoseConstraint('_'.join([self.handCtrlSpace.getName(), 'To', self.armEndInputTgt.getName()]))
self.armEndInputConstraint.setMaintainOffset(True)
self.armEndInputConstraint.addConstrainer(self.armEndInputTgt)
self.handCtrlSpace.addConstraint(self.armEndInputConstraint)
# Constraint outputs
self.handOutputConstraint = PoseConstraint('_'.join([self.handOutputTgt.getName(), 'To', self.handCtrl.getName()]))
self.handOutputConstraint.addConstrainer(self.handCtrl)
self.handOutputTgt.addConstraint(self.handOutputConstraint)
# Constraint deformers
self.handDefConstraint = PoseConstraint('_'.join([self.handDef.getName(), 'To', self.handCtrl.getName()]))
self.handDefConstraint.addConstrainer(self.handCtrl)
self.handDef.addConstraint(self.handDefConstraint)
Profiler.getInstance().pop()
def addFinger(self, name, data):
fingerCtrls = []
fingerJoints = []
parentCtrl = self.handCtrl
for i, joint in enumerate(data):
if i == 0:
jointName = name + 'Meta'
else:
jointName = name + str(i).zfill(2)
jointXfo = joint.get('xfo', Xfo())
jointCrvData = joint.get('curveData')
# Create Controls
newJointCtrlSpace = CtrlSpace(jointName, parent=parentCtrl)
newJointCtrl = Control(jointName, parent=newJointCtrlSpace, shape='square')
newJointCtrl.lockScale(True, True, True)
newJointCtrl.lockTranslation(True, True, True)
if jointCrvData is not None:
newJointCtrl.setCurveData(jointCrvData)
fingerCtrls.append(newJointCtrl)
# Create Deformers
jointDef = Joint(jointName, parent=self.defCmpGrp)
fingerJoints.append(jointDef)
# Create Constraints
# Set Xfos
newJointCtrlSpace.xfo = jointXfo
newJointCtrl.xfo = jointXfo
parentCtrl = newJointCtrl
# =================
# Create Operators
# =================
# Add Deformer KL Op
deformersToCtrlsKLOp = KLOperator(name + 'DeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
self.addOperator(deformersToCtrlsKLOp)
# Add Att Inputs
#.........这里部分代码省略.........