本文整理汇总了Python中kraken.core.objects.joint.Joint类的典型用法代码示例。如果您正苦于以下问题:Python Joint类的具体用法?Python Joint怎么用?Python Joint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Joint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setNumDeformers
def setNumDeformers(self, numDeformers):
# Add more deformers and outputs
if numDeformers > len(self.boneOutputsTgt):
for i in xrange(len(self.boneOutputsTgt), numDeformers):
name = 'bone' + str(i + 1).zfill(2)
legOutput = ComponentOutput(name, parent=self.outputHrcGrp)
self.boneOutputsTgt.append(legOutput)
boneDef = Joint(name, parent=self.defCmpGrp)
boneDef.setComponent(self)
self.deformerJoints.append(boneDef)
# Remove extra deformers and outputs
elif numDeformers < len(self.boneOutputsTgt):
numExtraOutputs = len(self.boneOutputsTgt) - numDeformers
numExtraDefs = len(self.deformerJoints) - numDeformers
for i in xrange(numExtraOutputs):
extraOutput = self.boneOutputsTgt.pop()
extraDef = self.deformerJoints.pop()
extraOutput.getParent().removeChild(extraOutput)
extraDef.getParent().removeChild(extraDef)
return True
示例2: setNumDeformers
def setNumDeformers(self, numDeformers):
# Add new deformers and outputs
for i in xrange(len(self.tailOutputs), numDeformers):
name = 'tail' + str(i + 1).zfill(2)
tailOutput = ComponentOutput(name, parent=self.outputHrcGrp)
self.tailOutputs.append(tailOutput)
for i in xrange(len(self.deformerJoints), numDeformers):
name = 'tail' + str(i + 1).zfill(2)
tailDef = Joint(name, parent=self.defCmpGrp)
tailDef.setComponent(self)
self.deformerJoints.append(tailDef)
return True
示例3: setNumDeformers
def setNumDeformers(self, numDeformers):
# Add new deformers and outputs
for i in xrange(len(self.boneOutputsTgt), numDeformers):
name = 'bone' + str(i + 1).zfill(2)
tentacleOutput = ComponentOutput(name, parent=self.outputHrcGrp)
self.boneOutputsTgt.append(tentacleOutput)
for i in xrange(len(self.deformerJoints), numDeformers):
name = 'bone' + str(i + 1).zfill(2)
boneDef = Joint(name, parent=self.defCmpGrp)
boneDef.setComponent(self)
self.deformerJoints.append(boneDef)
return True
示例4: __init__
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()
示例5: __init__
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()
示例6: __init__
def __init__(self, name, parent=None, location='M'):
super(FootComponent, self).__init__(name, parent, location)
# =========
# Controls
# =========
# Setup component attributes
defaultAttrGroup = self.getAttributeGroupByIndex(0)
defaultAttrGroup.addAttribute(BoolAttribute("toggleDebugging", True))
# Default values
if location == 'R':
ctrlColor = "red"
footPosition = Vec3(-7.1886, 12.2819, 0.4906)
footUpV = Vec3(-1.7454, 0.1922, -1.7397)
footEndPosition = Vec3(-2.0939, 0.4288, 0.0944)
else:
ctrlColor = "greenBright"
footPosition = Vec3(7.1886, 12.2819, 0.4906)
footUpV = Vec3(1.7454, 0.1922, -1.7397)
footEndPosition = Vec3(2.0939, 0.4288, 0.0944)
# Calculate Clavicle Xfo
rootToEnd = footEndPosition.subtract(footPosition).unit()
rootToUpV = footUpV.subtract(footPosition).unit()
bone1ZAxis = rootToEnd.cross(rootToUpV).unit()
bone1Normal = rootToEnd.cross(bone1ZAxis).unit()
footXfo = Xfo()
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)
#.........这里部分代码省略.........
示例7: __init__
def __init__(self, name, parent=None, location='M'):
super(NeckComponent, self).__init__(name, parent, location)
# Setup component attributes
defaultAttrGroup = self.getAttributeGroupByIndex(0)
defaultAttrGroup.addAttribute(BoolAttribute("toggleDebugging", True))
# Default values
neckPosition = Vec3(0.0, 16.5572, -0.6915)
neckUpV = Vec3()
neckUpV.copy(neckPosition)
neckUpV = neckUpV.add(Vec3(0.0, 0.0, -1.0)).unit()
neckEndPosition = Vec3(0.0, 17.4756, -0.421)
# Calculate Clavicle Xfo
rootToEnd = neckEndPosition.subtract(neckPosition).unit()
rootToUpV = neckUpV.subtract(neckPosition).unit()
bone1ZAxis = rootToUpV.cross(rootToEnd).unit()
bone1Normal = bone1ZAxis.cross(rootToEnd).unit()
neckXfo = Xfo()
neckXfo.setFromVectors(rootToEnd, bone1Normal, bone1ZAxis, neckPosition)
# Add Guide Controls
neckCtrlSrtBuffer = SrtBuffer('neck', parent=self)
neckCtrlSrtBuffer.xfo.copy(neckXfo)
neckCtrl = PinControl('neck', parent=neckCtrlSrtBuffer)
neckCtrl.scalePoints(Vec3(1.25, 1.25, 1.25))
neckCtrl.translatePoints(Vec3(0, 0, -0.5))
neckCtrl.rotatePoints(90, 0, 90)
neckCtrl.xfo.copy(neckXfo)
neckCtrl.setColor("orange")
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
neckDef = Joint('neck', parent=deformersLayer)
neckDef.setComponent(self)
# =====================
# Create Component I/O
# =====================
# Setup Component Xfo I/O's
neckEndInput = Locator('neckBase')
neckEndInput.xfo.copy(neckXfo)
neckEndOutput = Locator('neckEnd')
neckEndOutput.xfo.copy(neckXfo)
neckOutput = Locator('neck')
neckOutput.xfo.copy(neckXfo)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
# ==============
# Constrain I/O
# ==============
# Constraint inputs
clavicleInputConstraint = PoseConstraint('_'.join([neckCtrl.getName(), 'To', neckEndInput.getName()]))
clavicleInputConstraint.setMaintainOffset(True)
clavicleInputConstraint.addConstrainer(neckEndInput)
neckCtrlSrtBuffer.addConstraint(clavicleInputConstraint)
# Constraint outputs
neckEndConstraint = PoseConstraint('_'.join([neckEndOutput.getName(), 'To', neckCtrl.getName()]))
neckEndConstraint.addConstrainer(neckCtrl)
neckEndOutput.addConstraint(neckEndConstraint)
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
self.addInput(neckEndInput)
self.addOutput(neckEndOutput)
self.addOutput(neckOutput)
# Add Attribute I/O's
self.addInput(debugInputAttr)
self.addInput(rightSideInputAttr)
示例8: __init__
def __init__(self, name='head', parent=None):
Profiler.getInstance().push("Construct Head Rig Component:" + name)
super(HeadComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Head
self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape='circle')
self.headCtrl.lockScale(x=True, y=True, z=True)
self.headCtrl.lockTranslation(x=True, y=True, z=True)
self.headCtrlSpace = self.headCtrl.insertCtrlSpace()
self.headCtrl.rotatePoints(0, 0, 90)
self.headCtrl.scalePoints(Vec3(3, 3, 3))
self.headCtrl.translatePoints(Vec3(0, 1, 0.25))
# Eye Left
self.eyeLeftCtrl = Control('eyeLeft', parent=self.ctrlCmpGrp, shape='sphere')
self.eyeLeftCtrl.lockScale(x=True, y=True, z=True)
self.eyeLeftCtrl.lockTranslation(x=True, y=True, z=True)
self.eyeLeftCtrlSpace = self.eyeLeftCtrl.insertCtrlSpace()
self.eyeLeftCtrl.rotatePoints(0, 90, 0)
self.eyeLeftCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.eyeLeftCtrl.setColor('blueMedium')
# Eye Right
self.eyeRightCtrl = Control('eyeRight', parent=self.ctrlCmpGrp, shape='sphere')
self.eyeRightCtrl.lockScale(x=True, y=True, z=True)
self.eyeRightCtrl.lockTranslation(x=True, y=True, z=True)
self.eyeRightCtrlSpace = self.eyeRightCtrl.insertCtrlSpace()
self.eyeRightCtrl.rotatePoints(0, 90, 0)
self.eyeRightCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.eyeRightCtrl.setColor('blueMedium')
# LookAt Control
self.lookAtCtrl = Control('lookAt', parent=self.ctrlCmpGrp, shape='square')
self.lookAtCtrl.lockScale(x=True, y=True, z=True)
self.lookAtCtrl.rotatePoints(90, 0, 0)
self.lookAtCtrlSpace = self.lookAtCtrl.insertCtrlSpace()
self.eyeLeftBase = Transform('eyeLeftBase', parent=self.headCtrl)
self.eyeRightBase = Transform('eyeRightBase', parent=self.headCtrl)
self.eyeLeftUpV = Transform('eyeLeftUpV', parent=self.headCtrl)
self.eyeRightUpV = Transform('eyeRightUpV', parent=self.headCtrl)
self.eyeLeftAtV = Transform('eyeLeftAtV', parent=self.lookAtCtrl)
self.eyeRightAtV = Transform('eyeRightAtV', parent=self.lookAtCtrl)
# Jaw
self.jawCtrl = Control('jaw', parent=self.headCtrl, shape='cube')
self.jawCtrlSpace = self.jawCtrl.insertCtrlSpace()
self.jawCtrl.lockScale(x=True, y=True, z=True)
self.jawCtrl.lockTranslation(x=True, y=True, z=True)
self.jawCtrl.alignOnYAxis(negative=True)
self.jawCtrl.alignOnZAxis()
self.jawCtrl.scalePoints(Vec3(1.45, 0.65, 1.25))
self.jawCtrl.translatePoints(Vec3(0, -0.25, 0))
self.jawCtrl.setColor('orange')
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
headDef = Joint('head', parent=self.defCmpGrp)
headDef.setComponent(self)
jawDef = Joint('jaw', parent=self.defCmpGrp)
jawDef.setComponent(self)
eyeLeftDef = Joint('eyeLeft', parent=self.defCmpGrp)
eyeLeftDef.setComponent(self)
eyeRightDef = Joint('eyeRight', parent=self.defCmpGrp)
eyeRightDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.headInputConstraint = PoseConstraint('_'.join([self.headCtrlSpace.getName(), 'To', self.neckRefInputTgt.getName()]))
self.headInputConstraint.setMaintainOffset(True)
self.headInputConstraint.addConstrainer(self.neckRefInputTgt)
self.headCtrlSpace.addConstraint(self.headInputConstraint)
# 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)
self.eyeLOutputConstraint = PoseConstraint('_'.join([self.eyeLOutputTgt.getName(), 'To', self.eyeLeftCtrl.getName()]))
#.........这里部分代码省略.........
示例9: NeckComponentRig
class NeckComponentRig(NeckComponent):
"""Neck Component"""
def __init__(self, name="neck", parent=None):
Profiler.getInstance().push("Construct Neck Rig Component:" + name)
super(NeckComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Neck
self.neck01Ctrl = Control('neck01', parent=self.ctrlCmpGrp, shape="pin")
self.neck01Ctrl.setColor("orange")
self.neck01Ctrl.lockTranslation(True, True, True)
self.neck01Ctrl.lockScale(True, True, True)
self.neck01CtrlSpace = self.neck01Ctrl.insertCtrlSpace(name='neck01')
self.neck02Ctrl = Control('neck02', parent=self.neck01Ctrl, shape="pin")
self.neck02Ctrl.setColor("orange")
self.neck02Ctrl.lockTranslation(True, True, True)
self.neck02Ctrl.lockScale(True, True, True)
self.neck02CtrlSpace = self.neck02Ctrl.insertCtrlSpace(name='neck02')
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.addItem('defCmpGrp', self.defCmpGrp)
self.neck01Def = Joint('neck01', parent=self.defCmpGrp)
self.neck01Def.setComponent(self)
self.neck02Def = Joint('neck02', parent=self.defCmpGrp)
self.neck02Def.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
neckInputConstraintName = '_'.join([self.neck01CtrlSpace.getName(),
'To',
self.neckBaseInputTgt.getName()])
self.neckInputCnstr = self.neck01CtrlSpace.constrainTo(
self.neckBaseInputTgt,
'Pose',
maintainOffset=True,
name=neckInputConstraintName)
# Constraint outputs
neck01OutCnstrName = '_'.join([self.neck01OutputTgt.getName(),
'To',
self.neck01Ctrl.getName()])
self.neck01OutCnstr = self.neck01OutputTgt.constrainTo(
self.neck01Ctrl,
'Pose',
maintainOffset=False,
name=neck01OutCnstrName)
neck02OutCnstrName = '_'.join([self.neck02OutputTgt.getName(),
'To',
self.neck02Ctrl.getName()])
self.neck02OutCnstr = self.neck02OutputTgt.constrainTo(
self.neck02Ctrl,
'Pose',
maintainOffset=False,
name=neck02OutCnstrName)
neckEndCnstrName = '_'.join([self.neckEndOutputTgt.getName(),
'To',
self.neck02Ctrl.getName()])
self.neckEndCnstr = self.neckEndOutputTgt.constrainTo(
self.neck02Ctrl,
'Pose',
maintainOffset=True,
name=neckEndCnstrName)
# ==============
# Add Operators
# ==============
# Add Deformer KL Op
self.neckDeformerKLOp = KLOperator('neckDeformerKLOp',
'MultiPoseConstraintSolver',
'Kraken')
self.addOperator(self.neckDeformerKLOp)
# Add Att Inputs
#.........这里部分代码省略.........
示例10: __init__
#.........这里部分代码省略.........
armSettingsAttrGrp.addAttribute(armDebugInputAttr)
armSettingsAttrGrp.addAttribute(armBone1LenInputAttr)
armSettingsAttrGrp.addAttribute(armBone2LenInputAttr)
armSettingsAttrGrp.addAttribute(armFkikInputAttr)
armSettingsAttrGrp.addAttribute(armSoftIKInputAttr)
armSettingsAttrGrp.addAttribute(armSoftDistInputAttr)
armSettingsAttrGrp.addAttribute(armStretchInputAttr)
armSettingsAttrGrp.addAttribute(armStretchBlendInputAttr)
# UpV
upVXfo = xfoFromDirAndUpV(bicepPosition, wristPosition, forearmPosition)
upVXfo.tr.copy(forearmPosition)
upVOffset = Vec3(0, 0, 5)
upVOffset = upVXfo.transformVector(upVOffset)
armUpVCtrl = TriangleControl('UpV')
armUpVCtrl.xfo.tr.copy(upVOffset)
armUpVCtrl.alignOnZAxis()
armUpVCtrl.rotatePoints(180, 0, 0)
armUpVCtrl.setColor(ctrlColor)
armUpVCtrlSrtBuffer = SrtBuffer('UpV')
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')
示例11: __init__
def __init__(self, name, parent=None, location='M'):
super(SpineComponent, self).__init__(name, parent, location)
# =========
# Controls
# =========
# Setup component attributes
defaultAttrGroup = self.getAttributeGroupByIndex(0)
defaultAttrGroup.addAttribute(BoolAttribute("toggleDebugging", True))
# Default values
cogPosition = Vec3(0.0, 11.1351, -0.1382)
spine01Position = Vec3(0.0, 11.1351, -0.1382)
spine02Position = Vec3(0.0, 11.8013, -0.1995)
spine03Position = Vec3(0.0, 12.4496, -0.3649)
spine04Position = Vec3(0.0, 13.1051, -0.4821)
# COG
cogCtrlSrtBuffer = SrtBuffer('cog', parent=self)
cogCtrlSrtBuffer.xfo.tr.copy(cogPosition)
cogCtrl = CircleControl('cog', parent=cogCtrlSrtBuffer)
cogCtrl.scalePoints(Vec3(6.0, 6.0, 6.0))
cogCtrl.xfo.tr.copy(cogPosition)
cogCtrl.setColor("orange")
# Spine01
spine01CtrlSrtBuffer = SrtBuffer('spine01', parent=cogCtrl)
spine01CtrlSrtBuffer.xfo.tr.copy(spine01Position)
spine01Ctrl = CircleControl('spine01', parent=spine01CtrlSrtBuffer)
spine01Ctrl.scalePoints(Vec3(4.0, 4.0, 4.0))
spine01Ctrl.xfo.tr.copy(spine01Position)
spine01Ctrl.setColor("yellow")
# Spine02
spine02CtrlSrtBuffer = SrtBuffer('spine02', parent=spine01Ctrl)
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')
#.........这里部分代码省略.........
示例12: FabriceClavicleRig
class FabriceClavicleRig(FabriceClavicle):
"""Clavicle Component"""
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()
def loadData(self, data=None):
"""Load a saved guide representation from persisted data.
Arguments:
data -- object, The JSON data object.
Return:
True if successful.
"""
super(FabriceClavicleRig, self).loadData( data )
self.clavicleCtrlSpace.xfo = data['clavicleXfo']
self.clavicleCtrl.xfo = data['clavicleXfo']
self.clavicleCtrl.setCurveData(data['clavicleCtrlCrvData'])
# ============
# Set IO Xfos
# ============
self.spineEndInputTgt.xfo = data['clavicleXfo']
self.clavicleOutputTgt.xfo = data['clavicleXfo']
示例13: HandComponentRig
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
#.........这里部分代码省略.........
示例14: __init__
def __init__(self, name, parent=None, location='M'):
super(ClavicleComponent, self).__init__(name, parent, location)
# =========
# Controls
# =========
# Setup component attributes
defaultAttrGroup = self.getAttributeGroupByIndex(0)
defaultAttrGroup.addAttribute(BoolAttribute("toggleDebugging", True))
# Default values
if location == 'R':
ctrlColor = "red"
claviclePosition = Vec3(-0.1322, 15.403, -0.5723)
clavicleUpV = Vec3()
clavicleUpV.copy(claviclePosition)
clavicleUpV = clavicleUpV.add(Vec3(0.0, 1.0, 0.0)).unit()
clavicleEndPosition = Vec3(-2.27, 15.295, -0.753)
else:
ctrlColor = "greenBright"
claviclePosition = Vec3(0.1322, 15.403, -0.5723)
clavicleUpV = Vec3()
clavicleUpV.copy(claviclePosition)
clavicleUpV = clavicleUpV.add(Vec3(0.0, 1.0, 0.0)).unit()
clavicleEndPosition = Vec3(2.27, 15.295, -0.753)
# Calculate Clavicle Xfo
rootToEnd = clavicleEndPosition.subtract(claviclePosition).unit()
rootToUpV = clavicleUpV.subtract(claviclePosition).unit()
bone1ZAxis = rootToUpV.cross(rootToEnd).unit()
bone1Normal = bone1ZAxis.cross(rootToEnd).unit()
clavicleXfo = Xfo()
clavicleXfo.setFromVectors(rootToEnd, bone1Normal, bone1ZAxis, claviclePosition)
# Add Controls
clavicleCtrl = CubeControl('clavicle', parent=self)
clavicleCtrl.alignOnXAxis()
clavicleLen = claviclePosition.subtract(clavicleEndPosition).length()
clavicleCtrl.scalePoints(Vec3(clavicleLen, 0.75, 0.75))
if location == "R":
clavicleCtrl.translatePoints(Vec3(0.0, 0.0, -1.0))
else:
clavicleCtrl.translatePoints(Vec3(0.0, 0.0, 1.0))
clavicleCtrl.xfo.copy(clavicleXfo)
clavicleCtrl.setColor(ctrlColor)
clavicleCtrlSrtBuffer = SrtBuffer('clavicle', parent=self)
clavicleCtrlSrtBuffer.xfo.copy(clavicleCtrl.xfo)
clavicleCtrlSrtBuffer.addChild(clavicleCtrl)
# ==========
# Deformers
# ==========
container = self.getParent().getParent()
deformersLayer = container.getChildByName('deformers')
clavicleDef = Joint('clavicle')
clavicleDef.setComponent(self)
deformersLayer.addChild(clavicleDef)
# =====================
# Create Component I/O
# =====================
# Setup Component Xfo I/O's
spineEndInput = Locator('spineEnd')
spineEndInput.xfo.copy(clavicleXfo)
clavicleEndOutput = Locator('clavicleEnd')
clavicleEndOutput.xfo.copy(clavicleXfo)
clavicleOutput = Locator('clavicle')
clavicleOutput.xfo.copy(clavicleXfo)
# Setup componnent Attribute I/O's
debugInputAttr = BoolAttribute('debug', True)
rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
armFollowBodyOutputAttr = FloatAttribute('followBody', 0.0, 0.0, 1.0)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
clavicleInputConstraint = PoseConstraint('_'.join([clavicleCtrl.getName(), 'To', spineEndInput.getName()]))
clavicleInputConstraint.setMaintainOffset(True)
clavicleInputConstraint.addConstrainer(spineEndInput)
clavicleCtrlSrtBuffer.addConstraint(clavicleInputConstraint)
# Constraint outputs
clavicleConstraint = PoseConstraint('_'.join([clavicleOutput.getName(), 'To', clavicleCtrl.getName()]))
clavicleConstraint.addConstrainer(clavicleCtrl)
clavicleOutput.addConstraint(clavicleConstraint)
clavicleEndConstraint = PoseConstraint('_'.join([clavicleEndOutput.getName(), 'To', clavicleCtrl.getName()]))
clavicleEndConstraint.addConstrainer(clavicleCtrl)
#.........这里部分代码省略.........
示例15: __init__
def __init__(self, name='head', parent=None):
Profiler.getInstance().push("Construct Head Rig Component:" + name)
super(HeadComponentRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Head
self.headCtrlSpace = CtrlSpace('head', parent=self.ctrlCmpGrp)
self.headCtrl = Control('head', parent=self.headCtrlSpace, shape="circle")
self.headCtrl.rotatePoints(0, 0, 90)
self.headCtrl.scalePoints(Vec3(3, 3, 3))
self.headCtrl.translatePoints(Vec3(0, 1, 0.25))
# Eye Left
self.eyeLeftCtrlSpace = CtrlSpace('eyeLeft', parent=self.headCtrl)
self.eyeLeftCtrl = Control('eyeLeft', parent=self.eyeLeftCtrlSpace, shape="sphere")
self.eyeLeftCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.eyeLeftCtrl.setColor("blueMedium")
# Eye Right
self.eyeRightCtrlSpace = CtrlSpace('eyeRight', parent=self.headCtrl)
self.eyeRightCtrl = Control('eyeRight', parent=self.eyeRightCtrlSpace, shape="sphere")
self.eyeRightCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.eyeRightCtrl.setColor("blueMedium")
# Jaw
self.jawCtrlSpace = CtrlSpace('jawCtrlSpace', parent=self.headCtrl)
self.jawCtrl = Control('jaw', parent=self.jawCtrlSpace, shape="cube")
self.jawCtrl.alignOnYAxis(negative=True)
self.jawCtrl.alignOnZAxis()
self.jawCtrl.scalePoints(Vec3(1.45, 0.65, 1.25))
self.jawCtrl.translatePoints(Vec3(0, -0.25, 0))
self.jawCtrl.setColor("orange")
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
headDef = Joint('head', parent=defCmpGrp)
headDef.setComponent(self)
jawDef = Joint('jaw', parent=defCmpGrp)
jawDef.setComponent(self)
eyeLeftDef = Joint('eyeLeft', parent=defCmpGrp)
eyeLeftDef.setComponent(self)
eyeRightDef = Joint('eyeRight', parent=defCmpGrp)
eyeRightDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
headInputConstraint = PoseConstraint('_'.join([self.headCtrlSpace.getName(), 'To', self.headBaseInputTgt.getName()]))
headInputConstraint.setMaintainOffset(True)
headInputConstraint.addConstrainer(self.headBaseInputTgt)
self.headCtrlSpace.addConstraint(headInputConstraint)
# # Constraint outputs
headOutputConstraint = PoseConstraint('_'.join([self.headOutputTgt.getName(), 'To', self.headCtrl.getName()]))
headOutputConstraint.addConstrainer(self.headCtrl)
self.headOutputTgt.addConstraint(headOutputConstraint)
jawOutputConstraint = PoseConstraint('_'.join([self.jawOutputTgt.getName(), 'To', self.jawCtrl.getName()]))
jawOutputConstraint.addConstrainer(self.jawCtrl)
self.jawOutputTgt.addConstraint(jawOutputConstraint)
eyeLOutputConstraint = PoseConstraint('_'.join([self.eyeLOutputTgt.getName(), 'To', self.eyeLeftCtrl.getName()]))
eyeLOutputConstraint.addConstrainer(self.eyeLeftCtrl)
self.eyeLOutputTgt.addConstraint(eyeLOutputConstraint)
eyeROutputConstraint = PoseConstraint('_'.join([self.eyeROutputTgt.getName(), 'To', self.eyeRightCtrl.getName()]))
eyeROutputConstraint.addConstrainer(self.eyeRightCtrl)
self.eyeROutputTgt.addConstraint(eyeROutputConstraint)
# ==================
# Add Component I/O
# ==================
# Add Xfo I/O's
# self.addInput(self.headBaseInputTgt)
# self.addOutput(self.headOutputTgt)
# self.addOutput(self.jawOutputTgt)
# self.addOutput(self.eyeLOutputTgt)
# self.addOutput(self.eyeROutputTgt)
# Add Attribute I/O's
# self.addInput(self.drawDebugInputAttr)
# ===============
#.........这里部分代码省略.........