本文整理汇总了Python中kraken.core.objects.constraints.pose_constraint.PoseConstraint.addConstrainer方法的典型用法代码示例。如果您正苦于以下问题:Python PoseConstraint.addConstrainer方法的具体用法?Python PoseConstraint.addConstrainer怎么用?Python PoseConstraint.addConstrainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kraken.core.objects.constraints.pose_constraint.PoseConstraint
的用法示例。
在下文中一共展示了PoseConstraint.addConstrainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildXfoConnection
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
def buildXfoConnection(self, kConnection):
"""Builds the connection between the xfo and the connection.
Arguments:
kConnection -- Object, kraken connection to build.
Return:
True if successful.
"""
source = kConnection.getSource()
target = kConnection.getTarget()
if source is None or target is None:
raise Exception("Component connection '" + kConnection.getName() + "'is invalid! Missing Source or Target!")
constraint = PoseConstraint('_'.join([target.getName(), 'To', source.getName()]))
constraint.setMaintainOffset(True)
constraint.setConstrainee(target)
constraint.addConstrainer(source)
dccSceneItem = self.buildPoseConstraint(constraint)
self._registerSceneItemPair(kConnection, dccSceneItem)
return None
示例2: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
def __init__(self, name='Clavicle', parent=None):
Profiler.getInstance().push("Construct Clavicle Rig Component:" + name)
super(FabriceClavicleRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Clavicle
self.clavicleCtrlSpace = CtrlSpace('clavicle', parent=self.ctrlCmpGrp)
self.clavicleCtrl = Control('clavicle', parent=self.clavicleCtrlSpace, shape="cube")
self.clavicleCtrl.alignOnXAxis()
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.ctrlCmpGrp.setComponent(self)
self.clavicleDef = Joint('clavicle', parent=defCmpGrp)
self.clavicleDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
clavicleInputConstraint = PoseConstraint('_'.join([self.clavicleCtrl.getName(), 'To', self.spineEndInputTgt.getName()]))
clavicleInputConstraint.setMaintainOffset(True)
clavicleInputConstraint.addConstrainer(self.spineEndInputTgt)
self.clavicleCtrlSpace.addConstraint(clavicleInputConstraint)
# Constraint outputs
clavicleConstraint = PoseConstraint('_'.join([self.clavicleOutputTgt.getName(), 'To', self.clavicleCtrl.getName()]))
clavicleConstraint.addConstrainer(self.clavicleCtrl)
self.clavicleOutputTgt.addConstraint(clavicleConstraint)
# ===============
# Add Splice Ops
# ===============
# Add Deformer Splice Op
spliceOp = KLOperator('clavicleDeformerKLOp', 'PoseConstraintSolver', 'Kraken')
self.addOperator(spliceOp)
# Add Att Inputs
spliceOp.setInput('drawDebug', self.drawDebugInputAttr)
spliceOp.setInput('rigScale', self.rigScaleInputAttr)
# Add Xfo Inputs
spliceOp.setInput('constrainer', self.clavicleOutputTgt)
# Add Xfo Outputs
spliceOp.setOutput('constrainee', self.clavicleDef)
Profiler.getInstance().pop()
示例3: buildXfoConnection
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
def buildXfoConnection(self, componentInput):
"""Builds the constraint between the target and connection target.
Args:
componentInput (object): kraken component input to build connections for.
Returns:
bool: True if successful.
"""
if componentInput.isConnected() is False:
return False
connection = componentInput.getConnection()
connectionTarget = connection.getTarget()
inputTarget = componentInput.getTarget()
if connection.getDataType().endswith('[]'):
if componentInput.getIndex() > len(connection.getTarget()) - 1:
inputParent = componentInput.getParent()
inputParentDecoration = inputParent.getNameDecoration()
fullInputName = inputParent.getName() + inputParentDecoration + "." + componentInput.getName()
raise Exception(fullInputName + " index ("
+ str(componentInput.getIndex()) + ") is out of range ("
+ str(len(connection.getTarget()) - 1) + ")!")
connectionTarget = connection.getTarget()[componentInput.getIndex()]
else:
connectionTarget = connection.getTarget()
constraint = PoseConstraint('_'.join([inputTarget.getName(), 'To', connectionTarget.getName()]))
constraint.setMaintainOffset(True)
constraint.setConstrainee(inputTarget)
constraint.addConstrainer(connectionTarget)
dccSceneItem = self.buildPoseConstraint(constraint)
self._registerSceneItemPair(componentInput, dccSceneItem)
return True
示例4: FabriceHeadRig
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
class FabriceHeadRig(FabriceHead):
"""Fabrice Head Component Rig"""
def __init__(self, name='head', parent=None):
Profiler.getInstance().push("Construct Head Rig Component:" + name)
super(FabriceHeadRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Head Aim
self.headAimCtrlSpace = CtrlSpace('headAim', parent=self.ctrlCmpGrp)
self.headAimCtrl = Control('headAim', parent=self.headAimCtrlSpace, shape="sphere")
self.headAimCtrl.scalePoints(Vec3(0.35, 0.35, 0.35))
self.headAimCtrl.lockScale(x=True, y=True, z=True)
self.headAimUpV = Locator('headAimUpV', parent=self.headAimCtrl)
self.headAimUpV.setShapeVisibility(False)
# Head
self.headAim = Locator('headAim', parent=self.ctrlCmpGrp)
self.headAim.setShapeVisibility(False)
self.headCtrlSpace = CtrlSpace('head', parent=self.ctrlCmpGrp)
self.headCtrl = Control('head', parent=self.headCtrlSpace, shape="circle")
self.headCtrl.lockTranslation(x=True, y=True, z=True)
self.headCtrl.lockScale(x=True, y=True, z=True)
# Jaw
self.jawCtrlSpace = CtrlSpace('jawCtrlSpace', parent=self.headCtrl)
self.jawCtrl = Control('jaw', parent=self.jawCtrlSpace, shape="cube")
self.jawCtrl.lockTranslation(x=True, y=True, z=True)
self.jawCtrl.lockScale(x=True, y=True, z=True)
self.jawCtrl.setColor("orange")
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
headDef = Joint('head', parent=defCmpGrp)
headDef.setComponent(self)
jawDef = Joint('jaw', parent=defCmpGrp)
jawDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
self.headToAimConstraint = PoseConstraint('_'.join([self.headCtrlSpace.getName(), 'To', self.headAim.getName()]))
self.headToAimConstraint.setMaintainOffset(True)
self.headToAimConstraint.addConstrainer(self.headAim)
self.headCtrlSpace.addConstraint(self.headToAimConstraint)
# Constraint inputs
self.headAimInputConstraint = PoseConstraint('_'.join([self.headAimCtrlSpace.getName(), 'To', self.headBaseInputTgt.getName()]))
self.headAimInputConstraint.setMaintainOffset(True)
self.headAimInputConstraint.addConstrainer(self.headBaseInputTgt)
self.headAimCtrlSpace.addConstraint(self.headAimInputConstraint)
# # Constraint outputs
self.headOutputConstraint = PoseConstraint('_'.join([self.headOutputTgt.getName(), 'To', self.headCtrl.getName()]))
self.headOutputConstraint.addConstrainer(self.headCtrl)
self.headOutputTgt.addConstraint(self.headOutputConstraint)
self.jawOutputConstraint = PoseConstraint('_'.join([self.jawOutputTgt.getName(), 'To', self.jawCtrl.getName()]))
self.jawOutputConstraint.addConstrainer(self.jawCtrl)
self.jawOutputTgt.addConstraint(self.jawOutputConstraint)
# ==============
# Add Operators
# ==============
# Add Aim Canvas Op
# =================
self.headAimCanvasOp = CanvasOperator('headAimCanvasOp', 'Kraken.Solvers.DirectionConstraintSolver')
self.addOperator(self.headAimCanvasOp)
# Add Att Inputs
self.headAimCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
self.headAimCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
# Add Xfo Inputs
self.headAimCanvasOp.setInput('position', self.headBaseInputTgt)
self.headAimCanvasOp.setInput('upVector', self.headAimUpV)
self.headAimCanvasOp.setInput('atVector', self.headAimCtrl)
# Add Xfo Outputs
self.headAimCanvasOp.setOutput('constrainee', self.headAim)
# Add Deformer KL Op
# ==================
self.deformersToOutputsKLOp = KLOperator('headDeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
self.addOperator(self.deformersToOutputsKLOp)
#.........这里部分代码省略.........
示例5: SpineComponentRig
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
class SpineComponentRig(SpineComponent):
"""Spine Component"""
def __init__(self, name="spine", parent=None):
Profiler.getInstance().push("Construct Spine Rig Component:" + name)
super(SpineComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# COG
self.cogCtrlSpace = CtrlSpace('cog', parent=self.ctrlCmpGrp)
self.cogCtrl = Control('cog', parent=self.cogCtrlSpace, shape="circle")
self.cogCtrl.scalePoints(Vec3(6.0, 6.0, 6.0))
self.cogCtrl.setColor("orange")
self.cogCtrl.lockScale(True, True, True)
# Spine01
self.spine01CtrlSpace = CtrlSpace('spine01', parent=self.cogCtrl)
self.spine01Ctrl = Control('spine01', parent=self.spine01CtrlSpace, shape="circle")
self.spine01Ctrl.scalePoints(Vec3(4.0, 4.0, 4.0))
self.spine01Ctrl.lockScale(True, True, True)
# Spine02
self.spine02CtrlSpace = CtrlSpace('spine02', parent=self.spine01Ctrl)
self.spine02Ctrl = Control('spine02', parent=self.spine02CtrlSpace, shape="circle")
self.spine02Ctrl.scalePoints(Vec3(4.5, 4.5, 4.5))
self.spine02Ctrl.lockScale(True, True, True)
self.spine02Ctrl.setColor("blue")
# Spine04
self.spine04CtrlSpace = CtrlSpace('spine04', parent=self.cogCtrl)
self.spine04Ctrl = Control('spine04', parent=self.spine04CtrlSpace, shape="circle")
self.spine04Ctrl.scalePoints(Vec3(6.0, 6.0, 6.0))
self.spine04Ctrl.lockScale(True, True, True)
# Spine03
self.spine03CtrlSpace = CtrlSpace('spine03', parent=self.spine04Ctrl)
self.spine03Ctrl = Control('spine03', parent=self.spine03CtrlSpace, shape="circle")
self.spine03Ctrl.scalePoints(Vec3(4.5, 4.5, 4.5))
self.spine03Ctrl.lockScale(True, True, True)
self.spine03Ctrl.setColor("blue")
# Pelvis
self.pelvisCtrlSpace = CtrlSpace('pelvis', parent=self.spine01Ctrl)
self.pelvisCtrl = Control('pelvis', parent=self.pelvisCtrlSpace, shape="cube")
self.pelvisCtrl.alignOnYAxis(negative=True)
self.pelvisCtrl.scalePoints(Vec3(4.0, 0.375, 3.75))
self.pelvisCtrl.translatePoints(Vec3(0.0, -0.5, -0.25))
self.pelvisCtrl.lockTranslation(True, True, True)
self.pelvisCtrl.lockScale(True, True, True)
self.pelvisCtrl.setColor("blueLightMuted")
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
self.deformerJoints = []
self.spineOutputs = []
self.setNumDeformers(1)
pelvisDef = Joint('pelvis', parent=self.defCmpGrp)
pelvisDef.setComponent(self)
# =====================
# Create Component I/O
# =====================
# Setup component Xfo I/O's
self.spineVertebraeOutput.setTarget(self.spineOutputs)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.spineSrtInputConstraint = PoseConstraint('_'.join([self.cogCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
self.spineSrtInputConstraint.addConstrainer(self.globalSRTInputTgt)
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)
self.spineBaseOutputConstraint = PoseConstraint('_'.join([self.spineBaseOutputTgt.getName(), 'To', 'spineBase']))
self.spineBaseOutputConstraint.addConstrainer(self.spineOutputs[0])
self.spineBaseOutputTgt.addConstraint(self.spineBaseOutputConstraint)
self.pelvisOutputConstraint = PoseConstraint('_'.join([self.pelvisOutputTgt.getName(), 'To', self.pelvisCtrl.getName()]))
self.pelvisOutputConstraint.addConstrainer(self.pelvisCtrl)
self.pelvisOutputTgt.addConstraint(self.pelvisOutputConstraint)
self.spineEndOutputConstraint = PoseConstraint('_'.join([self.spineEndOutputTgt.getName(), 'To', 'spineEnd']))
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
#.........这里部分代码省略.........
self.addChild(armUpVCtrlSrtBuffer)
armUpVCtrlSrtBuffer.xfo.tr.copy(upVOffset)
armUpVCtrlSrtBuffer.addChild(armUpVCtrl)
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
bicepDef = Joint('bicep')
bicepDef.setComponent(self)
forearmDef = Joint('forearm')
forearmDef.setComponent(self)
wristDef = Joint('wrist')
wristDef.setComponent(self)
deformersLayer.addChild(bicepDef)
deformersLayer.addChild(forearmDef)
deformersLayer.addChild(wristDef)
# =====================
# Create Component I/O
# =====================
# Setup component Xfo I/O's
clavicleEndInput = Locator('clavicleEnd')
clavicleEndInput.xfo.copy(bicepXfo)
bicepOutput = Locator('bicep')
bicepOutput.xfo.copy(bicepXfo)
forearmOutput = Locator('forearm')
forearmOutput.xfo.copy(forearmXfo)
armEndXfo = Xfo()
armEndXfo.rot = forearmXfo.rot.clone()
armEndXfo.tr.copy(wristPosition)
armEndXfoOutput = Locator('armEndXfo')
armEndXfoOutput.xfo.copy(armEndXfo)
armEndPosOutput = Locator('armEndPos')
armEndPosOutput.xfo.copy(armEndXfo)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
bone1LenInputAttr = FloatAttribute('bone1Len', bicepLen, 0.0, 100.0)
bone2LenInputAttr = FloatAttribute('bone2Len', forearmLen, 0.0, 100.0)
fkikInputAttr = FloatAttribute('fkik', 0.0, 0.0, 1.0)
softIKInputAttr = BoolAttribute('softIK', True)
softDistInputAttr = FloatAttribute('softDist', 0.5, 0.0, 1.0)
stretchInputAttr = BoolAttribute('stretch', True)
stretchBlendInputAttr = FloatAttribute('stretchBlend', 0.0, 0.0, 1.0)
rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
# Connect attrs to control attrs
debugInputAttr.connect(armDebugInputAttr)
bone1LenInputAttr.connect(armBone1LenInputAttr)
bone2LenInputAttr.connect(armBone2LenInputAttr)
fkikInputAttr.connect(armFkikInputAttr)
softIKInputAttr.connect(armSoftIKInputAttr)
softDistInputAttr.connect(armSoftDistInputAttr)
stretchInputAttr.connect(armStretchInputAttr)
stretchBlendInputAttr.connect(armStretchBlendInputAttr)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
armRootInputConstraint = PoseConstraint('_'.join([armIKCtrl.getName(), 'To', clavicleEndInput.getName()]))
armRootInputConstraint.setMaintainOffset(True)
armRootInputConstraint.addConstrainer(clavicleEndInput)
bicepFKCtrlSrtBuffer.addConstraint(armRootInputConstraint)
# Constraint outputs
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
self.addInput(clavicleEndInput)
self.addOutput(bicepOutput)
self.addOutput(forearmOutput)
self.addOutput(armEndXfoOutput)
self.addOutput(armEndPosOutput)
# Add Attribute I/O's
self.addInput(debugInputAttr)
self.addInput(bone1LenInputAttr)
self.addInput(bone2LenInputAttr)
self.addInput(fkikInputAttr)
self.addInput(softIKInputAttr)
self.addInput(softDistInputAttr)
self.addInput(stretchInputAttr)
self.addInput(stretchBlendInputAttr)
self.addInput(rightSideInputAttr)
示例7: Locator
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
from kraken import plugins
from kraken.core.objects.locator import Locator
from kraken.core.objects.constraints.pose_constraint import PoseConstraint
from kraken.core.traverser.traverser import Traverser
locA = Locator("locatorA")
locB = Locator("locatorB")
constraint = PoseConstraint("A to B")
constraint.addConstrainer(locB)
constraint.setConstrainee(locA)
trav = Traverser()
trav.addRootItem(locA)
def callback(**args):
item = args.get('item', None)
print 'Visited '+item.getDecoratedPath()
trav.traverse(itemCallback = callback)
示例8: ArmComponentRig
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
class ArmComponentRig(ArmComponent):
"""Arm Component Rig"""
def __init__(self, name="arm", parent=None):
Profiler.getInstance().push("Construct Arm Rig Component:" + name)
super(ArmComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Bicep
self.bicepFKCtrlSpace = CtrlSpace("bicepFK", parent=self.ctrlCmpGrp)
self.bicepFKCtrl = Control("bicepFK", parent=self.bicepFKCtrlSpace, shape="cube")
self.bicepFKCtrl.alignOnXAxis()
# Forearm
self.forearmFKCtrlSpace = CtrlSpace("forearmFK", parent=self.bicepFKCtrl)
self.forearmFKCtrl = Control("forearmFK", parent=self.forearmFKCtrlSpace, shape="cube")
self.forearmFKCtrl.alignOnXAxis()
self.handCtrlSpace = CtrlSpace("hand", parent=self.ctrlCmpGrp)
self.handCtrl = Control("hand", parent=self.handCtrlSpace, shape="circle")
self.handCtrl.rotatePoints(0, 0, 90)
self.handCtrl.scalePoints(Vec3(1.0, 0.75, 0.75))
# Arm IK
self.armIKCtrlSpace = CtrlSpace("IK", parent=self.ctrlCmpGrp)
self.armIKCtrl = Control("IK", parent=self.armIKCtrlSpace, shape="pin")
# Add Params to IK control
armSettingsAttrGrp = AttributeGroup("DisplayInfo_ArmSettings", parent=self.armIKCtrl)
armDebugInputAttr = BoolAttribute("drawDebug", value=False, parent=armSettingsAttrGrp)
self.armBone0LenInputAttr = ScalarAttribute("bone1Len", value=0.0, parent=armSettingsAttrGrp)
self.armBone1LenInputAttr = ScalarAttribute("bone2Len", value=0.0, parent=armSettingsAttrGrp)
armIKBlendInputAttr = ScalarAttribute("fkik", value=0.0, minValue=0.0, maxValue=1.0, parent=armSettingsAttrGrp)
armSoftIKInputAttr = BoolAttribute("softIK", value=True, parent=armSettingsAttrGrp)
armSoftDistInputAttr = ScalarAttribute("softDist", value=0.0, minValue=0.0, parent=armSettingsAttrGrp)
armStretchInputAttr = BoolAttribute("stretch", value=True, parent=armSettingsAttrGrp)
armStretchBlendInputAttr = ScalarAttribute(
"stretchBlend", value=0.0, minValue=0.0, maxValue=1.0, parent=armSettingsAttrGrp
)
# Hand Params
handSettingsAttrGrp = AttributeGroup("DisplayInfo_HandSettings", parent=self.handCtrl)
handLinkToWorldInputAttr = ScalarAttribute("linkToWorld", 0.0, maxValue=1.0, parent=handSettingsAttrGrp)
self.drawDebugInputAttr.connect(armDebugInputAttr)
# UpV
self.armUpVCtrlSpace = CtrlSpace("UpV", parent=self.ctrlCmpGrp)
self.armUpVCtrl = Control("UpV", parent=self.armUpVCtrlSpace, shape="triangle")
self.armUpVCtrl.alignOnZAxis()
self.armUpVCtrl.rotatePoints(180, 0, 0)
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer("deformers")
defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
bicepDef = Joint("bicep", parent=defCmpGrp)
bicepDef.setComponent(self)
forearmDef = Joint("forearm", parent=defCmpGrp)
forearmDef.setComponent(self)
wristDef = Joint("wrist", parent=defCmpGrp)
wristDef.setComponent(self)
handDef = Joint("hand", parent=defCmpGrp)
handDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.armIKCtrlSpaceInputConstraint = PoseConstraint(
"_".join([self.armIKCtrlSpace.getName(), "To", self.globalSRTInputTgt.getName()])
)
self.armIKCtrlSpaceInputConstraint.setMaintainOffset(True)
self.armIKCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
self.armIKCtrlSpace.addConstraint(self.armIKCtrlSpaceInputConstraint)
self.armUpVCtrlSpaceInputConstraint = PoseConstraint(
"_".join([self.armUpVCtrlSpace.getName(), "To", self.globalSRTInputTgt.getName()])
)
self.armUpVCtrlSpaceInputConstraint.setMaintainOffset(True)
self.armUpVCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
self.armUpVCtrlSpace.addConstraint(self.armUpVCtrlSpaceInputConstraint)
self.armRootInputConstraint = PoseConstraint(
"_".join([self.bicepFKCtrlSpace.getName(), "To", self.clavicleEndInputTgt.getName()])
)
self.armRootInputConstraint.setMaintainOffset(True)
self.armRootInputConstraint.addConstrainer(self.clavicleEndInputTgt)
self.bicepFKCtrlSpace.addConstraint(self.armRootInputConstraint)
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
#.........这里部分代码省略.........
if location == "R":
footQuat = Quat(Vec3(0.5695, -0.6377, 0.4190), 0.3053)
footPos = Vec3(-1.841, 1.1516, -1.237)
else:
footQuat = Quat(Vec3(0.6377, -0.5695, 0.3053), 0.4190)
footPos = Vec3(1.841, 1.1516, -1.237)
footXfo.rot = footQuat.clone()
footXfo.tr.copy(footPos)
# Add Controls
footCtrlSrtBuffer = SrtBuffer('foot', parent=self)
footCtrlSrtBuffer.xfo.copy(footXfo)
footCtrl = CubeControl('foot', parent=footCtrlSrtBuffer)
footCtrl.alignOnXAxis()
footCtrl.scalePoints(Vec3(2.5, 1.5, 0.75))
footCtrl.xfo.copy(footCtrlSrtBuffer.xfo)
footCtrl.setColor(ctrlColor)
# Rig Ref objects
footRefSrt = Locator('footRef', parent=self)
footRefSrt.xfo.copy(footCtrlSrtBuffer.xfo)
# Add Component Params to IK control
footDebugInputAttr = BoolAttribute('debug', True)
footLinkToWorldInputAttr = FloatAttribute('linkToWorld', 1.0, 0.0, 1.0)
footSettingsAttrGrp = AttributeGroup("DisplayInfo_HandSettings")
footCtrl.addAttributeGroup(footSettingsAttrGrp)
footSettingsAttrGrp.addAttribute(footDebugInputAttr)
footSettingsAttrGrp.addAttribute(footLinkToWorldInputAttr)
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
footDef = Joint('foot')
footDef.setComponent(self)
deformersLayer.addChild(footDef)
# =====================
# Create Component I/O
# =====================
# Setup Component Xfo I/O's
legEndXfoInput = Locator('legEndXfo')
legEndXfoInput.xfo.copy(footCtrlSrtBuffer.xfo)
legEndPosInput = Locator('legEndPos')
legEndPosInput.xfo.copy(footCtrlSrtBuffer.xfo)
footEndOutput = Locator('handEnd')
footEndOutput.xfo.copy(footCtrlSrtBuffer.xfo)
footOutput = Locator('hand')
footOutput.xfo.copy(footCtrlSrtBuffer.xfo)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
linkToWorldInputAttr = FloatAttribute('linkToWorld', 0.0, 0.0, 1.0)
# Connect attrs to control attrs
debugInputAttr.connect(footDebugInputAttr)
linkToWorldInputAttr.connect(footLinkToWorldInputAttr)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
# Constraint outputs
handConstraint = PoseConstraint('_'.join([footOutput.getName(), 'To', footCtrl.getName()]))
handConstraint.addConstrainer(footCtrl)
footOutput.addConstraint(handConstraint)
handEndConstraint = PoseConstraint('_'.join([footEndOutput.getName(), 'To', footCtrl.getName()]))
handEndConstraint.addConstrainer(footCtrl)
footEndOutput.addConstraint(handEndConstraint)
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
self.addInput(legEndXfoInput)
self.addInput(legEndPosInput)
self.addOutput(footOutput)
self.addOutput(footEndOutput)
# Add Attribute I/O's
self.addInput(debugInputAttr)
self.addInput(rightSideInputAttr)
self.addInput(linkToWorldInputAttr)
示例10: StretchyLimbComponentRig
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
class StretchyLimbComponentRig(StretchyLimbComponent):
"""StretchyLimb Component"""
def __init__(self, name='limb', parent=None):
Profiler.getInstance().push("Construct StretchyLimb Rig Component:" + name)
super(StretchyLimbComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Upper (FK)
self.upperFKCtrlSpace = CtrlSpace('upperFK', parent=self.ctrlCmpGrp)
self.upperFKCtrl = Control('upperFK', parent=self.upperFKCtrlSpace, shape="cube")
self.upperFKCtrl.alignOnXAxis()
# Lower (FK)
self.lowerFKCtrlSpace = CtrlSpace('lowerFK', parent=self.upperFKCtrl)
self.lowerFKCtrl = Control('lowerFK', parent=self.lowerFKCtrlSpace, shape="cube")
self.lowerFKCtrl.alignOnXAxis()
# End (IK)
self.limbIKCtrlSpace = CtrlSpace('IK', parent=self.ctrlCmpGrp)
self.limbIKCtrl = Control('IK', parent=self.limbIKCtrlSpace, shape="pin")
# Add Component Params to IK control
# TODO: Move these separate control
limbSettingsAttrGrp = AttributeGroup("DisplayInfo_StretchyLimbSettings", parent=self.limbIKCtrl)
limbDrawDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=limbSettingsAttrGrp)
self.limbBone0LenInputAttr = ScalarAttribute('bone0Len', value=1.0, parent=limbSettingsAttrGrp)
self.limbBone1LenInputAttr = ScalarAttribute('bone1Len', value=1.0, parent=limbSettingsAttrGrp)
limbIKBlendInputAttr = ScalarAttribute('ikblend', value=1.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
limbSoftIKInputAttr = BoolAttribute('softIK', value=True, parent=limbSettingsAttrGrp)
limbSoftRatioInputAttr = ScalarAttribute('softRatio', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
limbStretchInputAttr = BoolAttribute('stretch', value=True, parent=limbSettingsAttrGrp)
limbStretchBlendInputAttr = ScalarAttribute('stretchBlend', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
limbSlideInputAttr = ScalarAttribute('slide', value=0.0, minValue=-1.0, maxValue=1.0, parent=limbSettingsAttrGrp)
limbPinInputAttr = ScalarAttribute('pin', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
self.rightSideInputAttr = BoolAttribute('rightSide', value=False, parent=limbSettingsAttrGrp)
self.drawDebugInputAttr.connect(limbDrawDebugInputAttr)
# UpV (IK Pole Vector)
self.limbUpVCtrlSpace = CtrlSpace('UpV', parent=self.ctrlCmpGrp)
self.limbUpVCtrl = Control('UpV', parent=self.limbUpVCtrlSpace, shape="triangle")
self.limbUpVCtrl.alignOnZAxis()
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
upperDef = Joint('upper', parent=self.defCmpGrp)
upperDef.setComponent(self)
lowerDef = Joint('lower', parent=self.defCmpGrp)
lowerDef.setComponent(self)
endDef = Joint('end', parent=self.defCmpGrp)
endDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.limbIKCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.limbIKCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
self.limbIKCtrlSpaceInputConstraint.setMaintainOffset(True)
self.limbIKCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
self.limbIKCtrlSpace.addConstraint(self.limbIKCtrlSpaceInputConstraint)
self.limbUpVCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.limbUpVCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
self.limbUpVCtrlSpaceInputConstraint.setMaintainOffset(True)
self.limbUpVCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
self.limbUpVCtrlSpace.addConstraint(self.limbUpVCtrlSpaceInputConstraint)
self.limbRootInputConstraint = PoseConstraint('_'.join([self.limbIKCtrl.getName(), 'To', self.limbParentInputTgt.getName()]))
self.limbRootInputConstraint.setMaintainOffset(True)
self.limbRootInputConstraint.addConstrainer(self.limbParentInputTgt)
self.upperFKCtrlSpace.addConstraint(self.limbRootInputConstraint)
# ===============
# Add Splice Ops
# ===============
# Add StretchyLimb Splice Op
self.limbIKKLOp = KLOperator('limbKLOp', 'TwoBoneStretchyIKSolver', 'Kraken')
self.addOperator(self.limbIKKLOp)
# Add Att Inputs
self.limbIKKLOp.setInput('drawDebug', self.drawDebugInputAttr)
self.limbIKKLOp.setInput('rigScale', self.rigScaleInputAttr)
self.limbIKKLOp.setInput('bone0Len', self.limbBone0LenInputAttr)
self.limbIKKLOp.setInput('bone1Len', self.limbBone1LenInputAttr)
self.limbIKKLOp.setInput('ikblend', limbIKBlendInputAttr)
self.limbIKKLOp.setInput('softIK', limbSoftIKInputAttr)
self.limbIKKLOp.setInput('softRatio', limbSoftRatioInputAttr)
self.limbIKKLOp.setInput('stretch', limbStretchInputAttr)
self.limbIKKLOp.setInput('stretchBlend', limbStretchBlendInputAttr)
#.........这里部分代码省略.........
示例11: FootComponentRig
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
class FootComponentRig(FootComponent):
"""Foot Component"""
def __init__(self, name="foot", parent=None):
Profiler.getInstance().push("Construct Neck Rig Component:" + name)
super(FootComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
self.ankleLenInputAttr = ScalarAttribute('ankleLen', 1.0, maxValue=1.0, parent=self.cmpInputAttrGrp)
self.toeLenInputAttr = ScalarAttribute('toeLen', 1.0, maxValue=1.0, parent=self.cmpInputAttrGrp)
self.rightSideInputAttr = BoolAttribute('rightSide', False, parent=self.cmpInputAttrGrp)
self.footAll = Locator('footAll', parent=self.ctrlCmpGrp)
self.footAll.setShapeVisibility(False)
self.ankleIKCtrlSpace = CtrlSpace('ankleIK', parent=self.footAll)
self.ankleIKCtrl = Control('ankleIK', parent=self.ankleIKCtrlSpace, shape="square")
self.ankleIKCtrl.alignOnXAxis(negative=True)
self.ankleIKCtrl.lockTranslation(True, True, True)
self.ankleIKCtrl.lockScale(True, True, True)
self.toeIKCtrlSpace = CtrlSpace('toeIK', parent=self.footAll)
self.toeIKCtrl = Control('toeIK', parent=self.toeIKCtrlSpace, shape="square")
self.toeIKCtrl.alignOnXAxis()
self.toeIKCtrl.lockTranslation(True, True, True)
self.toeIKCtrl.lockScale(True, True, True)
self.ankleFKCtrlSpace = CtrlSpace('ankleFK', parent=self.ctrlCmpGrp)
self.ankleFKCtrl = Control('ankleFK', parent=self.ankleFKCtrlSpace, shape="cube")
self.ankleFKCtrl.alignOnXAxis()
self.ankleFKCtrl.lockTranslation(True, True, True)
self.ankleFKCtrl.lockScale(True, True, True)
self.toeFKCtrlSpace = CtrlSpace('toeFK', parent=self.ankleFKCtrl)
self.toeFKCtrl = Control('toeFK', parent=self.toeFKCtrlSpace, shape="cube")
self.toeFKCtrl.alignOnXAxis()
self.toeFKCtrl.lockTranslation(True, True, True)
self.toeFKCtrl.lockScale(True, True, True)
self.footSettingsAttrGrp = AttributeGroup("DisplayInfo_FootSettings", parent=self.ankleIKCtrl)
self.footDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=self.footSettingsAttrGrp)
self.footRockInputAttr = ScalarAttribute('footRock', value=0.0, minValue=-1.0, maxValue=1.0, parent=self.footSettingsAttrGrp)
self.footBankInputAttr = ScalarAttribute('footBank', value=0.0, minValue=-1.0, maxValue=1.0, parent=self.footSettingsAttrGrp)
self.drawDebugInputAttr.connect(self.footDebugInputAttr)
self.pivotAll = Locator('pivotAll', parent=self.ctrlCmpGrp)
self.pivotAll.setShapeVisibility(False)
self.backPivotCtrl = Control('backPivot', parent=self.pivotAll, shape="axesHalfTarget")
self.backPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.backPivotCtrl.lockScale(True, True, True)
self.backPivotCtrlSpace = self.backPivotCtrl.insertCtrlSpace()
self.frontPivotCtrl = Control('frontPivot', parent=self.pivotAll, shape="axesHalfTarget")
self.frontPivotCtrl.rotatePoints(0.0, 180.0, 0.0)
self.frontPivotCtrl.lockScale(True, True, True)
self.frontPivotCtrlSpace = self.frontPivotCtrl.insertCtrlSpace()
self.frontPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.outerPivotCtrl = Control('outerPivot', parent=self.pivotAll, shape="axesHalfTarget")
self.outerPivotCtrl.rotatePoints(0.0, -90.0, 0.0)
self.outerPivotCtrl.lockScale(True, True, True)
self.outerPivotCtrlSpace = self.outerPivotCtrl.insertCtrlSpace()
self.outerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.innerPivotCtrl = Control('innerPivot', parent=self.pivotAll, shape="axesHalfTarget")
self.innerPivotCtrl.rotatePoints(0.0, 90.0, 0.0)
self.innerPivotCtrl.lockScale(True, True, True)
self.innerPivotCtrlSpace = self.innerPivotCtrl.insertCtrlSpace()
self.innerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
self.ankleDef = Joint('ankle', parent=self.defCmpGrp)
self.ankleDef.setComponent(self)
self.toeDef = Joint('toe', parent=self.defCmpGrp)
self.toeDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint to inputs
self.pivotAllInputConstraint = PoseConstraint('_'.join([self.pivotAll.getName(), 'To', self.ikHandleInputTgt.getName()]))
self.pivotAllInputConstraint.setMaintainOffset(True)
self.pivotAllInputConstraint.addConstrainer(self.ikHandleInputTgt)
self.pivotAll.addConstraint(self.pivotAllInputConstraint)
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
def __init__(self, name="mainSrt", parent=None):
Profiler.getInstance().push("Construct MainSrt Rig Component:" + name)
super(MainSrtComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Add Controls
self.mainSRTCtrlSpace = CtrlSpace("SRT", parent=self.ctrlCmpGrp)
self.mainSRTCtrl = Control("SRT", shape="circle", parent=self.mainSRTCtrlSpace)
self.mainSRTCtrl.lockScale(x=True, y=True, z=True)
self.offsetCtrlSpace = CtrlSpace("Offset", parent=self.mainSRTCtrl)
self.offsetCtrl = Control("Offset", shape="circle", parent=self.offsetCtrlSpace)
self.offsetCtrl.setColor("orange")
self.offsetCtrl.lockScale(x=True, y=True, z=True)
# Add Component Params to IK control
mainSrtSettingsAttrGrp = AttributeGroup("DisplayInfo_MainSrtSettings", parent=self.mainSRTCtrl)
self.rigScaleAttr = ScalarAttribute(
"rigScale", value=1.0, parent=mainSrtSettingsAttrGrp, minValue=0.1, maxValue=100.0
)
self.rigScaleOutputAttr.connect(self.rigScaleAttr)
# ==========
# Deformers
# ==========
# ==============
# Constrain I/O
# ==============
# Constraint inputs
# Constraint outputs
srtConstraint = PoseConstraint("_".join([self.srtOutputTgt.getName(), "To", self.mainSRTCtrl.getName()]))
srtConstraint.addConstrainer(self.mainSRTCtrl)
self.srtOutputTgt.addConstraint(srtConstraint)
offsetConstraint = PoseConstraint("_".join([self.offsetOutputTgt.getName(), "To", self.mainSRTCtrl.getName()]))
offsetConstraint.addConstrainer(self.offsetCtrl)
self.offsetOutputTgt.addConstraint(offsetConstraint)
# ===============
# Add Splice Ops
# ===============
# Add Rig Scale Splice Op
self.rigScaleKLOp = KLOperator("rigScaleKLOp", "RigScaleSolver", "Kraken")
self.addOperator(self.rigScaleKLOp)
# Add Att Inputs
self.rigScaleKLOp.setInput("drawDebug", self.drawDebugInputAttr)
self.rigScaleKLOp.setInput("rigScale", self.rigScaleOutputAttr)
# Add Xfo Inputs
# Add Xfo Outputs
self.rigScaleKLOp.setOutput("target", self.mainSRTCtrlSpace)
Profiler.getInstance().pop()
示例13: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
#.........这里部分代码省略.........
if location == "R":
handQuat = Quat(Vec3(-0.2301, -0.0865, -0.9331), 0.2623)
handPos = Vec3(-7.1886, 12.2819, 0.4906)
else:
handQuat = Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)
handPos = Vec3(7.1886, 12.2819, 0.4906)
handXfo.rot = handQuat.clone()
handXfo.tr.copy(handPos)
# Add Controls
handCtrlSrtBuffer = SrtBuffer('hand', parent=self)
handCtrlSrtBuffer.xfo.copy(handXfo)
handCtrl = CubeControl('hand', parent=handCtrlSrtBuffer)
handCtrl.alignOnXAxis()
handCtrl.scalePoints(Vec3(2.0, 0.75, 1.25))
handCtrl.xfo.copy(handCtrlSrtBuffer.xfo)
handCtrl.setColor(ctrlColor)
# Rig Ref objects
handRefSrt = Locator('handRef', parent=self)
handRefSrt.xfo.copy(handCtrlSrtBuffer.xfo)
# Add Component Params to IK control
handDebugInputAttr = BoolAttribute('debug', True)
handLinkToWorldInputAttr = FloatAttribute('linkToWorld', 0.0, 0.0, 1.0)
handSettingsAttrGrp = AttributeGroup("DisplayInfo_HandSettings")
handCtrl.addAttributeGroup(handSettingsAttrGrp)
handSettingsAttrGrp.addAttribute(handDebugInputAttr)
handSettingsAttrGrp.addAttribute(handLinkToWorldInputAttr)
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
handDef = Joint('hand')
handDef.setComponent(self)
deformersLayer.addChild(handDef)
# =====================
# Create Component I/O
# =====================
# Setup Component Xfo I/O's
armEndXfoInput = Locator('armEndXfo')
armEndXfoInput.xfo.copy(handCtrlSrtBuffer.xfo)
armEndPosInput = Locator('armEndPos')
armEndPosInput.xfo.copy(handCtrlSrtBuffer.xfo)
handEndOutput = Locator('handEnd')
handEndOutput.xfo.copy(handCtrlSrtBuffer.xfo)
handOutput = Locator('hand')
handOutput.xfo.copy(handCtrlSrtBuffer.xfo)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
linkToWorldInputAttr = FloatAttribute('linkToWorld', 0.0, 0.0, 1.0)
# Connect attrs to control attrs
debugInputAttr.connect(handDebugInputAttr)
linkToWorldInputAttr.connect(handLinkToWorldInputAttr)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
# Constraint outputs
handConstraint = PoseConstraint('_'.join([handOutput.getName(), 'To', handCtrl.getName()]))
handConstraint.addConstrainer(handCtrl)
handOutput.addConstraint(handConstraint)
handEndConstraint = PoseConstraint('_'.join([handEndOutput.getName(), 'To', handCtrl.getName()]))
handEndConstraint.addConstrainer(handCtrl)
handEndOutput.addConstraint(handEndConstraint)
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
self.addInput(armEndXfoInput)
self.addInput(armEndPosInput)
self.addOutput(handOutput)
self.addOutput(handEndOutput)
# Add Attribute I/O's
self.addInput(debugInputAttr)
self.addInput(rightSideInputAttr)
self.addInput(linkToWorldInputAttr)
示例14: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
#.........这里部分代码省略.........
spine02CtrlSrtBuffer.xfo.tr.copy(spine02Position)
spine02Ctrl = CircleControl('spine02', parent=spine02CtrlSrtBuffer)
spine02Ctrl.scalePoints(Vec3(4.5, 4.5, 4.5))
spine02Ctrl.xfo.tr.copy(spine02Position)
spine02Ctrl.setColor("blue")
# Spine03
spine03CtrlSrtBuffer = SrtBuffer('spine03', parent=spine02Ctrl)
spine03CtrlSrtBuffer.xfo.tr.copy(spine03Position)
spine03Ctrl = CircleControl('spine03', parent=spine03CtrlSrtBuffer)
spine03Ctrl.scalePoints(Vec3(4.5, 4.5, 4.5))
spine03Ctrl.xfo.tr.copy(spine03Position)
spine03Ctrl.setColor("blue")
# Spine04
spine04CtrlSrtBuffer = SrtBuffer('spine04', parent=cogCtrl)
spine04CtrlSrtBuffer.xfo.tr.copy(spine04Position)
spine04Ctrl = CircleControl('spine04', parent=spine04CtrlSrtBuffer)
spine04Ctrl.scalePoints(Vec3(6.0, 6.0, 6.0))
spine04Ctrl.xfo.tr.copy(spine04Position)
spine04Ctrl.setColor("yellow")
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
spine01Def = Joint('spine01')
spine01Def.setComponent(self)
spine02Def = Joint('spine02')
spine02Def.setComponent(self)
spine03Def = Joint('spine03')
spine03Def.setComponent(self)
spine04Def = Joint('spine04')
spine04Def.setComponent(self)
deformersLayer.addChild(spine01Def)
deformersLayer.addChild(spine02Def)
deformersLayer.addChild(spine03Def)
deformersLayer.addChild(spine04Def)
# =====================
# Create Component I/O
# =====================
# Setup component Xfo I/O's
spine01Output = Locator('spine01')
spine01Output.xfo.tr.copy(spine01Ctrl.xfo.tr)
spine02Output = Locator('spine02')
spine02Output.xfo.tr.copy(spine01Ctrl.xfo.tr)
spine03Output = Locator('spine03')
spine03Output.xfo.tr.copy(spine01Ctrl.xfo.tr)
spine04Output = Locator('spine04')
spine04Output.xfo.tr.copy(spine01Ctrl.xfo.tr)
spineBaseOutput = Locator('spineBase')
spineBaseOutput.xfo.tr.copy(spine01Ctrl.xfo.tr)
spineEndOutput = Locator('spineEnd')
spineEndOutput.xfo.tr.copy(spine03Ctrl.xfo.tr)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
# Constraint outputs
spineBaseOutputConstraint = PoseConstraint('_'.join([spineBaseOutput.getName(), 'To', 'spineBase']))
spineBaseOutputConstraint.addConstrainer(spine01Ctrl)
spineBaseOutput.addConstraint(spineBaseOutputConstraint)
spineEndOutputConstraint = PoseConstraint('_'.join([spineEndOutput.getName(), 'To', 'spineEnd']))
spineEndOutputConstraint.addConstrainer(spine04Ctrl)
spineEndOutput.addConstraint(spineEndOutputConstraint)
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
self.addOutput(spine01Output)
self.addOutput(spine02Output)
self.addOutput(spine03Output)
self.addOutput(spine04Output)
self.addOutput(spineBaseOutput)
self.addOutput(spineEndOutput)
# Add Attribute I/O's
self.addInput(debugInputAttr)
示例15: __init__
# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import addConstrainer [as 别名]
#.........这里部分代码省略.........
jawCtrl.translatePoints(Vec3(0, -0.25, 0))
jawCtrl.xfo.tr.copy(jawPosition)
jawCtrl.setColor("orange")
jawCtrlSrtBuffer = SrtBuffer('jawSrtBuffer')
headCtrl.addChild(jawCtrlSrtBuffer)
jawCtrlSrtBuffer.xfo.copy(jawCtrl.xfo)
jawCtrlSrtBuffer.addChild(jawCtrl)
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
headDef = Joint('head')
headDef.setComponent(self)
jawDef = Joint('jaw')
jawDef.setComponent(self)
eyeLeftDef = Joint('eyeLeft')
eyeLeftDef.setComponent(self)
eyeRightDef = Joint('eyeRight')
eyeRightDef.setComponent(self)
deformersLayer.addChild(headDef)
deformersLayer.addChild(jawDef)
deformersLayer.addChild(eyeLeftDef)
deformersLayer.addChild(eyeRightDef)
# =====================
# Create Component I/O
# =====================
# Setup component Xfo I/O's
headBaseInput = Locator('headBase')
headBaseInput.xfo.copy(headCtrl.xfo)
headOutput = Locator('head')
headOutput.xfo.copy(headCtrl.xfo)
jawOutput = Locator('jaw')
jawOutput.xfo.copy(jawCtrl.xfo)
eyeLOutput = Locator('eyeL')
eyeLOutput.xfo.copy(eyeLeftCtrl.xfo)
eyeROutput = Locator('eyeR')
eyeROutput.xfo.copy(eyeRightCtrl.xfo)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
# ==============
# Constrain I/O
# ==============
# Constraint inputs
headInputConstraint = PoseConstraint('_'.join([headCtrlSrtBuffer.getName(), 'To', headBaseInput.getName()]))
headInputConstraint.setMaintainOffset(True)
headInputConstraint.addConstrainer(headBaseInput)
headCtrlSrtBuffer.addConstraint(headInputConstraint)
# Constraint outputs
headOutputConstraint = PoseConstraint('_'.join([headOutput.getName(), 'To', headCtrl.getName()]))
headOutputConstraint.setMaintainOffset(True)
headOutputConstraint.addConstrainer(headCtrl)
headOutput.addConstraint(headOutputConstraint)
jawOutputConstraint = PoseConstraint('_'.join([jawOutput.getName(), 'To', jawCtrl.getName()]))
jawOutputConstraint.setMaintainOffset(True)
jawOutputConstraint.addConstrainer(jawCtrl)
jawOutput.addConstraint(jawOutputConstraint)
eyeLOutputConstraint = PoseConstraint('_'.join([eyeLOutput.getName(), 'To', eyeLeftCtrl.getName()]))
eyeLOutputConstraint.setMaintainOffset(True)
eyeLOutputConstraint.addConstrainer(eyeLeftCtrl)
eyeLOutput.addConstraint(eyeLOutputConstraint)
eyeROutputConstraint = PoseConstraint('_'.join([eyeROutput.getName(), 'To', eyeRightCtrl.getName()]))
eyeROutputConstraint.setMaintainOffset(True)
eyeROutputConstraint.addConstrainer(eyeRightCtrl)
eyeROutput.addConstraint(eyeROutputConstraint)
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
self.addInput(headBaseInput)
self.addOutput(headOutput)
self.addOutput(jawOutput)
self.addOutput(eyeLOutput)
self.addOutput(eyeROutput)
# Add Attribute I/O's
self.addInput(debugInputAttr)
self.addInput(rightSideInputAttr)