本文整理汇总了Python中kraken.core.objects.control.Control类的典型用法代码示例。如果您正苦于以下问题:Python Control类的具体用法?Python Control怎么用?Python Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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()
示例2: __init__
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()
示例3: __init__
def __init__(self, name="mainSrt", parent=None, data=None):
Profiler.getInstance().push("Construct MainSrt Guide Component:" + name)
super(MainSrtComponentGuide, self).__init__(name, parent)
# =========
# Attributes
# =========
# Add Component Params to IK control
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.mainSrtSizeInputAttr = ScalarAttribute(
"mainSrtSize", value=5.0, minValue=1.0, maxValue=50.0, parent=guideSettingsAttrGrp
)
# =========
# Controls
# =========
# Guide Controls
self.mainSrtCtrl = Control("mainSrt", parent=self.ctrlCmpGrp, shape="circle")
if data is None:
data = {
"location": "M",
"mainSrtSize": self.mainSrtSizeInputAttr.getValue(),
"mainSrtXfo": Xfo(tr=Vec3(0.0, 0.0, 0.0)),
}
self.loadData(data)
Profiler.getInstance().pop()
示例4: __init__
def __init__(self, name='clavicle', parent=None):
Profiler.getInstance().push("Construct Clavicle Guide Component:" + name)
super(FabriceClavicleGuide, self).__init__(name, parent)
# =========
# Controls
# =========
# Guide Controls
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.clavicleCtrl = Control('clavicle', parent=self.ctrlCmpGrp, shape="cube")
self.clavicleCtrl.alignOnXAxis()
self.clavicleCtrl.scalePoints(Vec3(1.0, 0.25, 0.25))
data = {
"name": name,
"location": "L",
"clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
'clavicleCtrlCrvData': self.clavicleCtrl.getCurveData()
}
self.loadData(data)
Profiler.getInstance().pop()
示例5: __init__
def __init__(self, name='spine', parent=None, *args, **kwargs):
Profiler.getInstance().push("Construct Spine Guide Component:" + name)
super(SpineComponentGuide, self).__init__(name, parent, *args, **kwargs)
# =========
# Controls
# ========
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.numDeformersAttr = IntegerAttribute('numDeformers', value=1, minValue=0, maxValue=20, parent=guideSettingsAttrGrp)
# Guide Controls
self.cog = Control('cogPosition', parent=self.ctrlCmpGrp, shape="sphere")
self.cog.scalePoints(Vec3(1.2, 1.2, 1.2))
self.cog.setColor('red')
self.spine01Ctrl = Control('spine01Position', parent=self.ctrlCmpGrp, shape='sphere')
self.spine02Ctrl = Control('spine02Position', parent=self.ctrlCmpGrp, shape='sphere')
self.spine03Ctrl = Control('spine03Position', parent=self.ctrlCmpGrp, shape='sphere')
self.spine04Ctrl = Control('spine04Position', parent=self.ctrlCmpGrp, shape='sphere')
data = {
'name': name,
'location': 'M',
'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),
'numDeformers': 6
}
self.loadData(data)
Profiler.getInstance().pop()
示例6: __init__
def __init__(self, name='clavicle', parent=None, data=None):
Profiler.getInstance().push("Construct Clavicle Guide Component:" + name)
super(ClavicleComponentGuide, self).__init__(name, parent)
# =========
# Controls
# =========
# Guide Controls
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.clavicleCtrl = Control('clavicle', parent=self.ctrlCmpGrp, shape="sphere")
self.clavicleUpVCtrl = Control('clavicleUpV', parent=self.ctrlCmpGrp, shape="triangle")
self.clavicleUpVCtrl.setColor('red')
self.clavicleEndCtrl = Control('clavicleEnd', parent=self.ctrlCmpGrp, shape="sphere")
if data is None:
data = {
"name": name,
"location": "L",
"clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
"clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
"clavicleEndXfo": Xfo(Vec3(2.27, 15.295, -0.753))
}
self.loadData(data)
Profiler.getInstance().pop()
示例7: addFinger
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
deformersToCtrlsKLOp.setInput('drawDebug', self.drawDebugInputAttr)
deformersToCtrlsKLOp.setInput('rigScale', self.rigScaleInputAttr)
# Add Xfo Inputs
deformersToCtrlsKLOp.setInput('constrainers', fingerCtrls)
# Add Xfo Outputs
deformersToCtrlsKLOp.setOutput('constrainees', fingerJoints)
return deformersToCtrlsKLOp
示例8: resizeDigits
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()
示例9: setNumControls
def setNumControls(self, numControls):
# Add more controls
if numControls > len(self.fkCtrlSpaces):
for i in xrange(len(self.fkCtrlSpaces), numControls):
if i==0:
parent = self.ctrlCmpGrp
else:
parent = self.fkCtrls[i - 1]
boneName = 'bone' + str(i + 1).zfill(2) + 'FK'
boneFKCtrlSpace = CtrlSpace(boneName, parent=parent)
boneFKCtrl = Control(boneName, parent=boneFKCtrlSpace, shape="cube")
boneFKCtrl.alignOnXAxis()
boneFKCtrl.lockScale(x=True, y=True, z=True)
boneFKCtrl.lockTranslation(x=True, y=True, z=True)
self.fkCtrlSpaces.append(boneFKCtrlSpace)
self.fkCtrls.append(boneFKCtrl)
# Remove extra ctrls
elif numControls < len(self.fkCtrlSpaces):
numExtraCtrls = len(self.fkCtrls) - numControls
for i in xrange(numExtraCtrls):
extraCtrlSpace = self.fkCtrlSpaces.pop()
extraCtrl = self.fkCtrls.pop()
extraCtrlSpace.getParent().removeChild(extraCtrlSpace)
extraCtrl.getParent().removeChild(extraCtrl)
示例10: __init__
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()
示例11: updateNumDeformers
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
示例12: updateNumJointControls
def updateNumJointControls(self, numJoints):
"""Load a saved guide representation from persisted data.
Arguments:
numJoints -- object, The number of joints inthe chain.
Return:
True if successful.
"""
if numJoints == 0:
raise IndexError("'numJoints' must be > 0")
if numJoints + 1 > len(self.jointCtrls):
for i in xrange(len(self.jointCtrls), numJoints + 1):
if i == 0:
ctrlParent = self.ctrlCmpGrp
else:
ctrlParent = self.jointCtrls[i - 1]
newCtrl = Control('chain' + str(i + 1).zfill(2), parent=ctrlParent, shape="sphere")
newCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))
# Generate thew new ctrl off the end of the existing one.
newCtrl.xfo = self.jointCtrls[i-1].xfo.multiply(Xfo(Vec3(10.0, 0.0, 0.0)))
self.jointCtrls.append(newCtrl)
elif numJoints + 1 < len(self.jointCtrls):
numExtraCtrls = len(self.jointCtrls) - (numJoints + 1)
for i in xrange(numExtraCtrls):
extraCtrl = self.jointCtrls.pop()
extraCtrl.getParent().removeChild(extraCtrl)
# Reset the control positions based on new number of joints
jointPositions = self.generateGuidePositions(numJoints)
for i in xrange(len(self.jointCtrls)):
self.jointCtrls[i].xfo.tr = jointPositions[i]
return True
示例13: __init__
def __init__(self, name='FKChain', parent=None, data=None):
Profiler.getInstance().push("Construct FKCHain Guide Component:" + name)
super(FKChainComponentGuide, self).__init__(name, parent)
# =========
# Controls
# =========
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
self.numJoints = IntegerAttribute('numJoints', value=4, minValue=1, maxValue=20, parent=guideSettingsAttrGrp)
self.numJoints.setValueChangeCallback(self.updateNumJointControls)
self.jointCtrls = []
if data is None:
numJoints = self.numJoints.getValue()
jointPositions = self.generateGuidePositions(numJoints)
for i in xrange(numJoints + 1):
if i == 0:
ctrlParent = self.ctrlCmpGrp
else:
ctrlParent = self.jointCtrls[i - 1]
newCtrl = Control('chain' + str(i + 1).zfill(2), parent=ctrlParent, shape="sphere")
newCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))
self.jointCtrls.append(newCtrl)
data = {
"location": "L",
"jointPositions": jointPositions,
"numJoints": self.numJoints.getValue()
}
self.loadData(data)
Profiler.getInstance().pop()
示例14: __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()
示例15: __init__
def __init__(self, name='foot', parent=None, *args, **kwargs):
Profiler.getInstance().push("Construct Foot Component:" + name)
super(FootComponentGuide, self).__init__(name, parent, *args, **kwargs)
# =========
# Controls
# ========
guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
# Guide Controls
self.ankleCtrl = Control('ankle', parent=self.ctrlCmpGrp, shape="pin")
self.toeCtrl = Control('toe', parent=self.ctrlCmpGrp, shape="pin")
self.toeCtrl.rotatePoints(-90.0, 0.0, 0.0)
self.toeTipCtrl = Control('toeTip', parent=self.ctrlCmpGrp, shape="pin")
self.toeTipCtrl.rotatePoints(-90.0, 0.0, 0.0)
self.backPivotCtrl = Control('backPivot', parent=self.ctrlCmpGrp, shape="axesHalfTarget")
self.backPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.frontPivotCtrl = Control('frontPivot', parent=self.ctrlCmpGrp, shape="axesHalfTarget")
self.frontPivotCtrl.rotatePoints(0.0, 180.0, 0.0)
self.frontPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.outerPivotCtrl = Control('outerPivot', parent=self.ctrlCmpGrp, shape="axesHalfTarget")
self.outerPivotCtrl.rotatePoints(0.0, -90.0, 0.0)
self.outerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.innerPivotCtrl = Control('innerPivot', parent=self.ctrlCmpGrp, shape="axesHalfTarget")
self.innerPivotCtrl.rotatePoints(0.0, 90.0, 0.0)
self.innerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
self.default_data = {
"name": name,
"location": 'L',
"ankleXfo": Xfo(Vec3(1.75, 1.15, -1.25)),
"toeXfo": Xfo(Vec3(1.75, 0.4, 0.25)),
"toeTipXfo": Xfo(Vec3(1.75, 0.4, 1.5)),
"backPivotXfo": Xfo(Vec3(1.75, 0.0, -2.5)),
"frontPivotXfo": Xfo(Vec3(1.75, 0.0, 2.0)),
"outerPivotXfo": Xfo(Vec3(2.5, 0.0, -1.25)),
"innerPivotXfo": Xfo(Vec3(1.0, 0.0, -1.25))
}
self.loadData(self.default_data)
Profiler.getInstance().pop()