本文整理汇总了Python中kraken.core.objects.control.Control.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python Control.setColor方法的具体用法?Python Control.setColor怎么用?Python Control.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kraken.core.objects.control.Control
的用法示例。
在下文中一共展示了Control.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateNumDeformers
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
def updateNumDeformers(self, count):
"""Generate the guide controls for the variable outputes array.
Arguments:
count -- object, The number of joints inthe chain.
Return:
True if successful.
"""
if count == 0:
raise IndexError("'count' must be > 0")
vertebraeOutputs = self.tailVertebraeOutput.getTarget()
if count > len(vertebraeOutputs):
for i in xrange(len(vertebraeOutputs), count):
debugCtrl = Control('spine' + str(i+1).zfill(2), parent=self.outputHrcGrp, shape="vertebra")
debugCtrl.rotatePoints(0, -90, 0)
debugCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
debugCtrl.setColor('turqoise')
vertebraeOutputs.append(debugCtrl)
elif count < len(vertebraeOutputs):
numExtraCtrls = len(vertebraeOutputs) - count
for i in xrange(numExtraCtrls):
extraCtrl = vertebraeOutputs.pop()
self.outputHrcGrp.removeChild(extraCtrl)
return True
示例2: resizeDigits
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
def resizeDigits(self, numJoints):
initNumJoints = numJoints
for finger in self.fingers.keys():
if finger == "thumb":
numJoints = 3
else:
numJoints = initNumJoints
if numJoints + 1 == len(self.fingers[finger]):
continue
elif numJoints + 1 > len(self.fingers[finger]):
for i in xrange(len(self.fingers[finger]), numJoints + 1):
prevDigit = self.fingers[finger][i - 1]
digitCtrl = Control(finger + str(i + 1).zfill(2), parent=prevDigit, shape='sphere')
digitCtrl.setColor('orange')
digitCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))
digitCtrl.lockScale(True, True, True)
self.fingers[finger].append(digitCtrl)
elif numJoints + 1 < len(self.fingers[finger]):
numExtraCtrls = len(self.fingers[finger]) - (numJoints + 1)
for i in xrange(numExtraCtrls):
removedJoint = self.fingers[finger].pop()
removedJoint.getParent().removeChild(removedJoint)
self.placeFingers()
示例3: NeckComponentRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
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.neckCtrlSpace = CtrlSpace('neck', parent=self.ctrlCmpGrp)
self.neckCtrl = Control('neck', parent=self.neckCtrlSpace, shape="pin")
self.neckCtrl.scalePoints(Vec3(1.25, 1.25, 1.25))
self.neckCtrl.translatePoints(Vec3(0, 0, -0.5))
self.neckCtrl.rotatePoints(90, 0, 90)
self.neckCtrl.setColor("orange")
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
neckDef = Joint('neck', parent=defCmpGrp)
neckDef.setComponent(self)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
clavicleInputConstraint = PoseConstraint('_'.join([self.neckCtrlSpace.getName(), 'To', self.neckBaseInputTgt.getName()]))
clavicleInputConstraint.setMaintainOffset(True)
clavicleInputConstraint.addConstrainer(self.neckBaseInputTgt)
self.neckCtrlSpace.addConstraint(clavicleInputConstraint)
# Constraint outputs
neckOutputConstraint = PoseConstraint('_'.join([self.neckOutputTgt.getName(), 'To', self.neckCtrl.getName()]))
neckOutputConstraint.addConstrainer(self.neckCtrl)
self.neckOutputTgt.addConstraint(neckOutputConstraint)
neckEndConstraint = PoseConstraint('_'.join([self.neckEndOutputTgt.getName(), 'To', self.neckCtrl.getName()]))
neckEndConstraint.addConstrainer(self.neckCtrl)
self.neckEndOutputTgt.addConstraint(neckEndConstraint)
# ===============
# Add Splice Ops
# ===============
#Add Deformer Splice Op
spliceOp = KLOperator('neckDeformerKLOp', 'PoseConstraintSolver', 'Kraken')
self.addOperator(spliceOp)
# Add Att Inputs
spliceOp.setInput('drawDebug', self.drawDebugInputAttr)
spliceOp.setInput('rigScale', self.rigScaleInputAttr)
# Add Xfo Inputstrl)
spliceOp.setInput('constrainer', self.neckEndOutputTgt)
# Add Xfo Outputs
spliceOp.setOutput('constrainee', neckDef)
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(NeckComponentRig, self).loadData( data )
self.neckCtrlSpace.xfo = data['neckXfo']
self.neckCtrl.xfo = data['neckXfo']
# ============
# Set IO Xfos
# ============
self.neckBaseInputTgt.xfo = data['neckXfo']
self.neckEndOutputTgt.xfo = data['neckXfo']
self.neckOutputTgt.xfo = data['neckXfo']
示例4: HeadComponentGuide
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class HeadComponentGuide(HeadComponent):
"""Head Component Guide"""
def __init__(self, name='head', parent=None, *args, **kwargs):
Profiler.getInstance().push("Construct Head Guide Component:" + name)
super(HeadComponentGuide, self).__init__(name, parent, *args, **kwargs)
# =========
# Controls
# =========
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
sphereCtrl = Control('sphere', shape='sphere')
sphereCtrl.scalePoints(Vec3(0.375, 0.375, 0.375))
self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape='square')
self.headCtrl.rotatePoints(90, 0, 0)
self.headCtrl.translatePoints(Vec3(0.0, 0.5, 0.0))
self.headCtrl.scalePoints(Vec3(1.8, 2.0, 2.0))
self.eyeLeftCtrl = Control('eyeLeft', parent=self.headCtrl, shape='arrow_thin')
self.eyeLeftCtrl.translatePoints(Vec3(0, 0, 0.5))
self.eyeLeftCtrl.rotatePoints(0, 90, 0)
self.eyeLeftCtrl.appendCurveData(sphereCtrl.getCurveData())
self.eyeRightCtrl = Control('eyeRight', parent=self.headCtrl, shape='arrow_thin')
self.eyeRightCtrl.translatePoints(Vec3(0, 0, 0.5))
self.eyeRightCtrl.rotatePoints(0, 90, 0)
self.eyeRightCtrl.appendCurveData(sphereCtrl.getCurveData())
self.jawCtrl = Control('jaw', parent=self.headCtrl, shape='square')
self.jawCtrl.rotatePoints(90, 0, 0)
self.jawCtrl.rotatePoints(0, 90, 0)
self.jawCtrl.translatePoints(Vec3(0.0, -0.5, 0.5))
self.jawCtrl.scalePoints(Vec3(1.0, 0.8, 1.5))
self.jawCtrl.setColor('orange')
eyeXAlignOri = Quat()
eyeXAlignOri.setFromAxisAndAngle(Vec3(0, 1, 0), Math_degToRad(-90))
self.default_data = {
"name": name,
"location": "M",
"headXfo": Xfo(Vec3(0.0, 17.5, -0.5)),
"headCrvData": self.headCtrl.getCurveData(),
"eyeLeftXfo": Xfo(tr=Vec3(0.375, 18.5, 0.5), ori=eyeXAlignOri),
"eyeLeftCrvData": self.eyeLeftCtrl.getCurveData(),
"eyeRightXfo": Xfo(tr=Vec3(-0.375, 18.5, 0.5), ori=eyeXAlignOri),
"eyeRightCrvData": self.eyeRightCtrl.getCurveData(),
"jawXfo": Xfo(Vec3(0.0, 17.875, -0.275)),
"jawCrvData": self.jawCtrl.getCurveData()
}
self.loadData(self.default_data)
Profiler.getInstance().pop()
# =============
# Data Methods
# =============
def saveData(self):
"""Save the data for the component to be persisted.
Return:
The JSON data object
"""
data = super(HeadComponentGuide, self).saveData()
data['headXfo'] = self.headCtrl.xfo
data['headCrvData'] = self.headCtrl.getCurveData()
data['eyeLeftXfo'] = self.eyeLeftCtrl.xfo
data['eyeLeftCrvData'] = self.eyeLeftCtrl.getCurveData()
data['eyeRightXfo'] = self.eyeRightCtrl.xfo
data['eyeRightCrvData'] = self.eyeRightCtrl.getCurveData()
data['jawXfo'] = self.jawCtrl.xfo
data['jawCrvData'] = self.jawCtrl.getCurveData()
return data
def loadData(self, data):
"""Load a saved guide representation from persisted data.
Arguments:
data -- object, The JSON data object.
Return:
True if successful.
"""
super(HeadComponentGuide, self).loadData(data)
self.headCtrl.xfo = data.get('headXfo', self.default_data['headXfo'])
#.........这里部分代码省略.........
示例5: HeadComponentRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class HeadComponentRig(HeadComponent):
"""Head Component Rig"""
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)
#.........这里部分代码省略.........
示例6: FabriceHeadGuide
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class FabriceHeadGuide(FabriceHead):
"""Fabrice Head Component Guide"""
def __init__(self, name='head', parent=None):
Profiler.getInstance().push("Construct Head Guide Component:" + name)
super(FabriceHeadGuide, self).__init__(name, parent)
# =========
# Controls
# =========
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape="circle")
self.headCtrl.rotatePoints(90.0, 0.0, 0.0)
self.headCtrl.scalePoints(Vec3(3.5, 3.5, 3.5))
self.jawCtrl = Control('jaw', parent=self.ctrlCmpGrp, shape="cube")
self.jawCtrl.alignOnZAxis()
self.jawCtrl.scalePoints(Vec3(2.0, 0.5, 2.0))
self.jawCtrl.alignOnYAxis(negative=True)
self.jawCtrl.setColor('orange')
data = {
"name": name,
"location": "M",
"headXfo": Xfo(Vec3(0.0, 1.67, 1.75)),
"headCtrlCrvData": self.headCtrl.getCurveData(),
"jawPosition": Vec3(0.0, 1.2787, 2.0078),
"jawCtrlCrvData": self.jawCtrl.getCurveData(),
}
self.loadData(data)
Profiler.getInstance().pop()
# =============
# Data Methods
# =============
def saveData(self):
"""Save the data for the component to be persisted.
Return:
The JSON data object
"""
data = super(FabriceHeadGuide, self).saveData()
data['headXfo'] = self.headCtrl.xfo
data['headCtrlCrvData'] = self.headCtrl.getCurveData()
data['jawPosition'] = self.jawCtrl.xfo.tr
data['jawCtrlCrvData'] = self.jawCtrl.getCurveData()
return data
def loadData(self, data):
"""Load a saved guide representation from persisted data.
Arguments:
data -- object, The JSON data object.
Return:
True if successful.
"""
super(FabriceHeadGuide, self).loadData( data )
self.headCtrl.xfo = data['headXfo']
self.headCtrl.setCurveData(data['headCtrlCrvData'])
self.jawCtrl.xfo.tr = data['jawPosition']
self.jawCtrl.setCurveData(data['jawCtrlCrvData'])
return True
def getRigBuildData(self):
"""Returns the Guide data used by the Rig Component to define the layout of the final rig..
Return:
The JSON rig data object.
"""
data = super(FabriceHeadGuide, self).getRigBuildData()
data['headXfo'] = self.headCtrl.xfo
data['headCtrlCrvData'] = self.headCtrl.getCurveData()
data['jawPosition'] = self.jawCtrl.xfo.tr
data['jawCtrlCrvData'] = self.jawCtrl.getCurveData()
return data
# ==============
# Class Methods
#.........这里部分代码省略.........
示例7: FabriceHeadRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [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)
#.........这里部分代码省略.........
示例8: NeckComponentRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
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
#.........这里部分代码省略.........
示例9: FabriceTailRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class FabriceTailRig(FabriceTail):
"""Fabrice Tail Component"""
def __init__(self, name="fabriceTail", parent=None):
Profiler.getInstance().push("Construct Tail Rig Component:" + name)
super(FabriceTailRig, self).__init__(name, parent)
# =========
# Controls
# =========
# Tail Base
# self.tailBaseCtrlSpace = CtrlSpace('tailBase', parent=self.ctrlCmpGrp)
# self.tailBaseCtrl = Control('tailBase', parent=self.tailBaseCtrlSpace, shape="circle")
# self.tailBaseCtrl.rotatePoints(90, 0, 0)
# self.tailBaseCtrl.scalePoints(Vec3(2.0, 2.0, 2.0))
# self.tailBaseCtrl.setColor("greenBlue")
# Tail Base Handle
self.tailBaseHandleCtrlSpace = CtrlSpace('tailBaseHandle', parent=self.ctrlCmpGrp)
self.tailBaseHandleCtrl = Control('tailBaseHandle', parent=self.tailBaseHandleCtrlSpace, shape="pin")
self.tailBaseHandleCtrl.lockScale(x=True, y=True, z=True)
self.tailBaseHandleCtrl.setColor("turqoise")
# Tail End Handle
self.tailEndHandleCtrlSpace = CtrlSpace('tailEndHandle', parent=self.ctrlCmpGrp)
self.tailEndHandleCtrl = Control('tailEndHandle', parent=self.tailEndHandleCtrlSpace, shape="pin")
self.tailEndHandleCtrl.lockScale(x=True, y=True, z=True)
self.tailEndHandleCtrl.setColor("turqoise")
# Tail End
self.tailEndCtrlSpace = CtrlSpace('tailEnd', parent=self.tailEndHandleCtrl)
self.tailEndCtrl = Control('tailEnd', parent=self.tailEndCtrlSpace, shape="pin")
self.tailEndCtrl.lockScale(x=True, y=True, z=True)
self.tailEndCtrl.setColor("greenBlue")
# ==========
# Deformers
# ==========
deformersLayer = self.getOrCreateLayer('deformers')
self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
self.deformerJoints = []
self.tailOutputs = []
self.setNumDeformers(1)
# =====================
# Create Component I/O
# =====================
# Setup component Xfo I/O's
self.tailVertebraeOutput.setTarget(self.tailOutputs)
# ==============
# Constrain I/O
# ==============
# Constraint inputs
self.tailBaseHandleInputConstraint = PoseConstraint('_'.join([self.tailBaseHandleCtrlSpace.getName(), 'To', self.spineEndCtrlInputTgt.getName()]))
self.tailBaseHandleInputConstraint.addConstrainer(self.spineEndCtrlInputTgt)
self.tailBaseHandleInputConstraint.setMaintainOffset(True)
self.tailBaseHandleCtrlSpace.addConstraint(self.tailBaseHandleInputConstraint)
self.tailEndHandleInputConstraint = PoseConstraint('_'.join([self.tailEndHandleCtrlSpace.getName(), 'To', self.cogInputTgt.getName()]))
self.tailEndHandleInputConstraint.addConstrainer(self.cogInputTgt)
self.tailEndHandleInputConstraint.setMaintainOffset(True)
self.tailEndHandleCtrlSpace.addConstraint(self.tailEndHandleInputConstraint)
# Constraint outputs
self.tailBaseOutputConstraint = PoseConstraint('_'.join([self.tailBaseOutputTgt.getName(), 'To', 'spineBase']))
self.tailBaseOutputConstraint.addConstrainer(self.tailOutputs[0])
self.tailBaseOutputTgt.addConstraint(self.tailBaseOutputConstraint)
self.tailEndOutputConstraint = PoseConstraint('_'.join([self.tailEndOutputTgt.getName(), 'To', 'spineEnd']))
self.tailEndOutputConstraint.addConstrainer(self.tailOutputs[0])
self.tailEndOutputTgt.addConstraint(self.tailEndOutputConstraint)
# ===============
# Add Splice Ops
# ===============
# Add Tail Splice Op
self.bezierTailKLOp = KLOperator('tailKLOp', 'BezierSpineSolver', 'Kraken')
self.addOperator(self.bezierTailKLOp)
# Add Att Inputs
self.bezierTailKLOp.setInput('drawDebug', self.drawDebugInputAttr)
self.bezierTailKLOp.setInput('rigScale', self.rigScaleInputAttr)
self.bezierTailKLOp.setInput('length', self.lengthInputAttr)
# Add Xfo Inputs
self.bezierTailKLOp.setInput('base', self.spineEndInputTgt)
self.bezierTailKLOp.setInput('baseHandle', self.tailBaseHandleCtrl)
self.bezierTailKLOp.setInput('tipHandle', self.tailEndHandleCtrl)
self.bezierTailKLOp.setInput('tip', self.tailEndCtrl)
# Add Xfo Outputs
self.bezierTailKLOp.setOutput('outputs', self.tailOutputs)
#.........这里部分代码省略.........
示例10: HandComponentGuide
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class HandComponentGuide(HandComponent):
"""Hand Component Guide"""
def __init__(self, name='hand', parent=None, *args, **kwargs):
Profiler.getInstance().push("Construct Hand Guide Component:" + name)
super(HandComponentGuide, self).__init__(name, parent, *args, **kwargs)
# =========
# Controls
# =========
# Guide Controls
self.guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.digitNamesAttr = StringAttribute('digitNames', value="thumb,index,middle,ring,pinky", parent=self.guideSettingsAttrGrp)
self.digitNamesAttr.setValueChangeCallback(self.updateFingers)
self.numJointsAttr = IntegerAttribute('numJoints', value=4, minValue=2, maxValue=20, parent=self.guideSettingsAttrGrp)
self.numJointsAttr.setValueChangeCallback(self.resizeDigits)
self.fingers = OrderedDict()
self.handCtrl = Control('hand', parent=self.ctrlCmpGrp, shape="square")
self.handCtrl.rotatePoints(0.0, 0.0, 90.0)
self.handCtrl.scalePoints(Vec3(1.0, 0.75, 1.0))
self.handCtrl.setColor('yellow')
self.handGuideSettingsAttrGrp = AttributeGroup("Settings", parent=self.handCtrl)
self.ctrlShapeToggle = BoolAttribute('ctrlShape_vis', value=False, parent=self.handGuideSettingsAttrGrp)
self.handDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=self.handGuideSettingsAttrGrp)
self.drawDebugInputAttr.connect(self.handDebugInputAttr)
self.guideCtrlHrcGrp = HierarchyGroup('controlShapes', parent=self.ctrlCmpGrp)
self.default_data = {
"name": name,
"location": "L",
"handXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
"digitNames": self.digitNamesAttr.getValue(),
"numJoints": self.numJointsAttr.getValue(),
"fingers": self.fingers
}
self.loadData(self.default_data)
Profiler.getInstance().pop()
# =============
# Data Methods
# =============
def saveData(self):
"""Save the data for the component to be persisted.
Return:
The JSON data object
"""
data = super(HandComponentGuide, self).saveData()
data['handXfo'] = self.handCtrl.xfo
data['digitNames'] = self.digitNamesAttr.getValue()
data['numJoints'] = self.numJointsAttr.getValue()
fingerXfos = {}
fingerShapeCtrlData = {}
for finger in self.fingers.keys():
fingerXfos[finger] = [x.xfo for x in self.fingers[finger]]
fingerShapeCtrlData[finger] = []
for i, digit in enumerate(self.fingers[finger]):
if i != len(self.fingers[finger]) - 1:
fingerShapeCtrlData[finger].append(digit.shapeCtrl.getCurveData())
data['fingersGuideXfos'] = fingerXfos
data['fingerShapeCtrlData'] = fingerShapeCtrlData
return data
def loadData(self, data):
"""Load a saved guide representation from persisted data.
Arguments:
data -- object, The JSON data object.
Return:
True if successful.
"""
super(HandComponentGuide, self).loadData(data)
self.handCtrl.xfo = data.get('handXfo')
self.numJointsAttr.setValue(data.get('numJoints'))
self.digitNamesAttr.setValue(data.get('digitNames'))
fingersGuideXfos = data.get('fingersGuideXfos')
fingerShapeCtrlData = data.get('fingerShapeCtrlData')
#.........这里部分代码省略.........
示例11: addFinger
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
def addFinger(self, name):
digitSizeAttributes = []
fingerGuideCtrls = []
firstDigitCtrl = Control(name + "01", parent=self.handCtrl, shape='sphere')
firstDigitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))
firstDigitShapeCtrl = Control(name + "Shp01", parent=self.guideCtrlHrcGrp, shape='square')
firstDigitShapeCtrl.setColor('yellow')
firstDigitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
firstDigitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
fingerGuideCtrls.append(firstDigitShapeCtrl)
firstDigitCtrl.shapeCtrl = firstDigitShapeCtrl
firstDigitVisAttr = firstDigitShapeCtrl.getVisibilityAttr()
firstDigitVisAttr.connect(self.ctrlShapeToggle)
triangleCtrl = Control('tempCtrl', parent=None, shape='triangle')
triangleCtrl.rotatePoints(90.0, 0.0, 0.0)
triangleCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
triangleCtrl.translatePoints(Vec3(0.0, 0.0875, 0.0))
firstDigitCtrl.appendCurveData(triangleCtrl.getCurveData())
firstDigitCtrl.lockScale(True, True, True)
digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=firstDigitCtrl)
digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
digitSizeAttributes.append(digitSizeAttr)
# Set Finger
self.fingers[name] = []
self.fingers[name].append(firstDigitCtrl)
parent = firstDigitCtrl
numJoints = self.numJointsAttr.getValue()
if name == "thumb":
numJoints = 3
for i in xrange(2, numJoints + 2):
digitCtrl = Control(name + str(i).zfill(2), parent=parent, shape='sphere')
if i != numJoints + 1:
digitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))
digitCtrl.appendCurveData(triangleCtrl.getCurveData())
digitShapeCtrl = Control(name + 'Shp' + str(i).zfill(2), parent=self.guideCtrlHrcGrp, shape='circle')
digitShapeCtrl.setColor('yellow')
digitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
digitShapeCtrl.getVisibilityAttr().connect(self.ctrlShapeToggle)
digitCtrl.shapeCtrl = digitShapeCtrl
if i == 2:
digitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
else:
digitShapeCtrl.rotatePoints(0.0, 0.0, 90.0)
fingerGuideCtrls.append(digitShapeCtrl)
# Add size attr to all but last guide control
digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=digitCtrl)
digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
digitSizeAttributes.append(digitSizeAttr)
else:
digitCtrl.scalePoints(Vec3(0.0875, 0.0875, 0.0875))
digitCtrl.lockScale(True, True, True)
self.fingers[name].append(digitCtrl)
parent = digitCtrl
# ===========================
# Create Canvas Operators
# ===========================
# Add Finger Guide Canvas Op
fingerGuideCanvasOp = CanvasOperator(name + 'FingerGuideOp', 'Kraken.Solvers.Biped.BipedFingerGuideSolver')
self.addOperator(fingerGuideCanvasOp)
# Add Att Inputs
fingerGuideCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
fingerGuideCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
# Add Xfo Inputs
fingerGuideCanvasOp.setInput('controls', self.fingers[name])
fingerGuideCanvasOp.setInput('planeSizes', digitSizeAttributes)
# Add Xfo Outputs
fingerGuideCanvasOp.setOutput('result', fingerGuideCtrls)
fingerGuideCanvasOp.setOutput('forceEval', firstDigitCtrl.getVisibilityAttr())
return firstDigitCtrl
示例12: HeadComponentRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class HeadComponentRig(HeadComponent):
"""Head Component Rig"""
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)
#.........这里部分代码省略.........
示例13: MainSrtComponentRig
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class MainSrtComponentRig(MainSrtComponent):
"""MainSrt Component Rig"""
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()
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(MainSrtComponentRig, self).loadData(data)
# ================
# Resize Controls
# ================
self.mainSRTCtrl.scalePoints(Vec3(data["mainSrtSize"], 1.0, data["mainSrtSize"]))
self.offsetCtrl.scalePoints(Vec3(data["mainSrtSize"] - 0.5, 1.0, data["mainSrtSize"] - 0.5))
# =======================
# Set Control Transforms
# =======================
self.mainSRTCtrlSpace.xfo = data["mainSrtXfo"]
self.mainSRTCtrl.xfo = data["mainSrtXfo"]
self.offsetCtrlSpace.xfo = data["mainSrtXfo"]
self.offsetCtrl.xfo = data["mainSrtXfo"]
# ============
# Set IO Xfos
# ============
self.srtOutputTgt = data["mainSrtXfo"]
self.offsetOutputTgt = data["mainSrtXfo"]
示例14: NeckComponentGuide
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class NeckComponentGuide(NeckComponent):
"""Neck Component Guide"""
def __init__(self, name='neck', parent=None, *args, **kwargs):
Profiler.getInstance().push('Construct Neck Component:' + name)
super(NeckComponentGuide, self).__init__(name, parent, *args, **kwargs)
# =========
# Controls
# =========
# Guide Controls
self.neckCtrl = Control('neck', parent=self.ctrlCmpGrp, shape='sphere')
self.neckCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.neckMidCtrl = Control('neckMid', parent=self.ctrlCmpGrp, shape='sphere')
self.neckMidCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.neckEndCtrl = Control('neckEnd', parent=self.ctrlCmpGrp, shape='sphere')
self.neckEndCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.neckCtrlShape = Control('neck', parent=self.ctrlCmpGrp, shape='pin')
self.neckCtrlShape.rotatePoints(90.0, 0.0, 0.0)
self.neckCtrlShape.rotatePoints(0.0, 90.0, 0.0)
self.neckCtrlShape.setColor('orange')
self.neckMidCtrlShape = Control('neckMid', parent=self.ctrlCmpGrp, shape='pin')
self.neckMidCtrlShape.rotatePoints(90.0, 0.0, 0.0)
self.neckMidCtrlShape.rotatePoints(0.0, 90.0, 0.0)
self.neckMidCtrlShape.setColor('orange')
# Guide Operator
self.neckGuideKLOp = KLOperator(name + 'GuideKLOp', 'NeckGuideSolver', 'Kraken')
self.addOperator(self.neckGuideKLOp)
# Add Att Inputs
self.neckGuideKLOp.setInput('drawDebug', self.drawDebugInputAttr)
self.neckGuideKLOp.setInput('rigScale', self.rigScaleInputAttr)
# Add Source Inputs
self.neckGuideKLOp.setInput('sources', [self.neckCtrl, self.neckMidCtrl, self.neckEndCtrl])
# Add Target Outputs
self.neckGuideKLOp.setOutput('targets', [self.neckCtrlShape, self.neckMidCtrlShape])
# Calculate default values
neckVec = Vec3(0.0, 16.00, -0.75)
neckMidVec = Vec3(0.0, 16.50, -0.50)
neckEndVec = Vec3(0.0, 17.00, -0.25)
upVector = Vec3(0.0, 0.0, -1.0)
neckOri = Quat()
neckOri.setFromDirectionAndUpvector((neckMidVec - neckVec).unit(),
((neckVec + upVector) - neckVec).unit())
neckMidOri = Quat()
neckMidOri.setFromDirectionAndUpvector((neckEndVec - neckMidVec).unit(),
((neckMidVec + upVector) - neckMidVec).unit())
self.default_data = {
"name": name,
"location": "M",
"neckXfo": Xfo(tr=neckVec, ori=neckOri),
"neckMidXfo": Xfo(tr=neckMidVec, ori=neckMidOri),
"neckEndXfo": Xfo(tr=neckEndVec, ori=neckMidOri),
"neckCrvData": self.neckCtrlShape.getCurveData(),
"neckMidCrvData": self.neckMidCtrlShape.getCurveData()
}
self.loadData(self.default_data)
Profiler.getInstance().pop()
# =============
# Data Methods
# =============
def saveData(self):
"""Save the data for the component to be persisted.
Return:
The JSON data object
"""
data = super(NeckComponentGuide, self).saveData()
data['neckXfo'] = self.neckCtrl.xfo
data['neckMidXfo'] = self.neckMidCtrl.xfo
data['neckEndXfo'] = self.neckEndCtrl.xfo
data['neckCrvData'] = self.neckCtrlShape.getCurveData()
data['neckMidCrvData'] = self.neckMidCtrlShape.getCurveData()
return data
def loadData(self, data):
"""Load a saved guide representation from persisted data.
Arguments:
#.........这里部分代码省略.........
示例15: ArmComponentGuide
# 需要导入模块: from kraken.core.objects.control import Control [as 别名]
# 或者: from kraken.core.objects.control.Control import setColor [as 别名]
class ArmComponentGuide(ArmComponent):
"""Arm Component Guide"""
def __init__(self, name="arm", parent=None):
Profiler.getInstance().push("Construct Arm Guide Component:" + name)
super(ArmComponentGuide, self).__init__(name, parent)
# ===========
# Attributes
# ===========
# Add Component Params to IK control
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.bicepFKCtrlSizeInputAttr = ScalarAttribute(
"bicepFKCtrlSize", value=1.75, minValue=0.0, maxValue=10.0, parent=guideSettingsAttrGrp
)
self.forearmFKCtrlSizeInputAttr = ScalarAttribute(
"forearmFKCtrlSize", value=1.5, minValue=0.0, maxValue=10.0, parent=guideSettingsAttrGrp
)
# =========
# Controls
# =========
# Guide Controls
self.bicepCtrl = Control("bicepFK", parent=self.ctrlCmpGrp, shape="sphere")
self.bicepCtrl.setColor("blue")
self.forearmCtrl = Control("forearmFK", parent=self.ctrlCmpGrp, shape="sphere")
self.forearmCtrl.setColor("blue")
self.wristCtrl = Control("wristFK", parent=self.ctrlCmpGrp, shape="sphere")
self.wristCtrl.setColor("blue")
self.handCtrl = Control("hand", parent=self.ctrlCmpGrp, shape="cube")
self.handCtrl.setColor("blue")
data = {
"name": name,
"location": "L",
"bicepXfo": Xfo(Vec3(2.27, 15.295, -0.753)),
"forearmXfo": Xfo(Vec3(5.039, 13.56, -0.859)),
"wristXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
"handXfo": Xfo(tr=Vec3(7.1886, 12.2819, 0.4906), ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
"bicepFKCtrlSize": 1.75,
"forearmFKCtrlSize": 1.5,
}
self.loadData(data)
Profiler.getInstance().pop()
# =============
# Data Methods
# =============
def saveData(self):
"""Save the data for the component to be persisted.
Return:
The JSON data object
"""
data = super(ArmComponentGuide, self).saveData()
data["bicepXfo"] = self.bicepCtrl.xfo
data["forearmXfo"] = self.forearmCtrl.xfo
data["wristXfo"] = self.wristCtrl.xfo
data["handXfo"] = self.handCtrl.xfo
return data
def loadData(self, data):
"""Load a saved guide representation from persisted data.
Arguments:
data -- object, The JSON data object.
Return:
True if successful.
"""
super(ArmComponentGuide, self).loadData(data)
self.bicepCtrl.xfo = data["bicepXfo"]
self.forearmCtrl.xfo = data["forearmXfo"]
self.wristCtrl.xfo = data["wristXfo"]
self.handCtrl.xfo = data["handXfo"]
return True
def getRigBuildData(self):
"""Returns the Guide data used by the Rig Component to define the layout of the final rig..
Return:
The JSON rig data object.
"""
data = super(ArmComponentGuide, self).getRigBuildData()
#.........这里部分代码省略.........