本文整理汇总了Python中maya.cmds.poleVectorConstraint函数的典型用法代码示例。如果您正苦于以下问题:Python poleVectorConstraint函数的具体用法?Python poleVectorConstraint怎么用?Python poleVectorConstraint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了poleVectorConstraint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: surfJnts
def surfJnts(name, pairL):
jntPairs = []
iks = []
j = 0
for pair in pairL:
jnts = []
i = 0
suff = ['_root', '_aim', '_up']
for point in pair:
cmds.select(point)
pos = cmds.xform(point, q=True, t=True, ws=True)
jnts.append(place.joint(0, name + str(j) + suff[i] + '_jnt', pad=2, rpQuery=False)[0])
i = i + 1
j = j + 1
# parent ik joints
cmds.parent(jnts[1], jnts[0])
# orient ik joints
cmds.joint(jnts[0], e=True, oj='zyx', secondaryAxisOrient='yup')
jnt.ZeroJointOrient(jnts[1])
# orient up vector jnt
cmds.parent(jnts[2], jnts[0])
jnt.ZeroJointOrient(jnts[2])
cmds.parent(jnts[2], w=True)
# append pairs to list
jntPairs.append(jnts)
# ik
ikhndl = cmds.ikHandle(sj=jnts[0], ee=jnts[1], sol='ikRPsolver', sticky='sticky')[0]
cmds.setAttr(ikhndl + '.visibility', False)
cmds.poleVectorConstraint(jnts[2], ikhndl)
iks.append(ikhndl)
# cleanup
place.cleanUp(jnts[0], SknJnts=True)
place.cleanUp(jnts[2], SknJnts=True)
place.cleanUp(ikhndl, World=True)
return jntPairs, iks
示例2: ikControllerConstraintsAlt
def ikControllerConstraintsAlt(constraint, target, constraint2, target2):
#3b. select parent of target joint
mc.select(constraint, target)
mc.parentConstraint(mo=1)
mc.select(constraint2, target2)
snapToPos()
mc.select(constraint2,target)
mc.poleVectorConstraint()
示例3: install
def install(self):
cmds.select(d=True)
# Create Ik joints
self.rig_info['ikjnts']=utils.createJoint(self.module_info['ikjnts'], self.rig_info['positions'], self.instance)
# Create Fk joints
self.rig_info['fkjnts']=utils.createJoint(self.module_info['fkjnts'], self.rig_info['positions'], self.instance)
# Create Rig joints
self.rig_info['rigjnts']=utils.createJoint(self.module_info['rigjnts'], self.rig_info['positions'], self.instance)
# Create Ik Rig
# Ik handle
#"ikcontrols": ["ctrl_ik_arm, ikh_arm", "ctrl_pv_arm"
# Generate a name for the ik handle using self.instance
ikhname = self.module_info["ikcontrols"][1].replace('_s_', self.instance)
self.rig_info['ikh']=cmds.ikHandle(n=ikhname, sj=self.rig_info['ikjnts'][0], ee=self.rig_info['ikjnts'][2], sol='ikRPsolver', p=2, w=1 )
ikctrlname = self.module_info["ikcontrols"][0].replace('_s_', self.instance)
self.rig_info['ikcontrol']=utils.createControl([[self.rig_info['positions'][2], ikctrlname, 'HandControl.ma']])[0]
pvpos = utils.calculatePVPosition([self.rig_info['ikjnts'][0], self.rig_info['ikjnts'][1], self.rig_info['ikjnts'][2]])
self.rig_info['pvcontrol']=utils.createControl([[pvpos, self.module_info["ikcontrols"][2], 'RectangleControl.ma']])[0]
# Make a control for arm settings
self.rig_info['setcontrol']=utils.createControl([[self.rig_info['positions'][2], 'ctrl_settings', 'RectangleControl.ma']])[0]
cmds.addAttr(self.rig_info['setcontrol'][1], ln='IK_FK', at="enum", en="fk:ik:", k=True )
# Parent ikh to ctrl
cmds.parent(self.rig_info['ikh'][0], self.rig_info['ikcontrol'][1])
# PV constraint
cmds.poleVectorConstraint(self.rig_info['pvcontrol'][1], self.rig_info['ikh'][0])
# orient constrain arm ik_wrist to ctrl_arm
cmds.orientConstraint(self.rig_info['ikcontrol'][1], self.rig_info['ikjnts'][2], mo=True)
# Create FK rig
self.rig_info['fkcontrols'] = utils.createControl([[self.rig_info['positions'][0], self.module_info["fkcontrols"][0], 'RectangleControl.ma'],
[self.rig_info['positions'][1], self.module_info["fkcontrols"][1], 'RectangleControl.ma'],
[self.rig_info['positions'][2], self.module_info["fkcontrols"][2], 'RectangleControl.ma']])
# Parent fk controls
cmds.parent(self.rig_info['fkcontrols'][2][0], self.rig_info['fkcontrols'][1][1])
cmds.parent(self.rig_info['fkcontrols'][1][0], self.rig_info['fkcontrols'][0][1])
# Connect Ik and Fk to Rig joints
switchattr = self.rig_info['setcontrol'][1] + '.IK_FK'
utils.connectThroughBC(self.rig_info['ikjnts'], self.rig_info['fkjnts'], self.rig_info['rigjnts'], self.instance, switchattr )
# Constrain fk joints to controls.
[cmds.parentConstraint(self.rig_info['fkcontrols'][i][1], self.rig_info['fkjnts'][i], mo=True) for i in range(len(self.rig_info['fkcontrols']))]
# SetupIk/Fk match scriptJob
"""
示例4: ikControllerConstraints
def ikControllerConstraints(constraint, target, constraint2, target2):
#3b. select parent of target joint
# got rid of selection
#mc.select(constraint, target)
mc.parentConstraint(constraint, target, mo=1)
#mc.select(constraint2, target2)
snapToPos([constraint2, target2])
#mc.select(constraint2,target)
mc.poleVectorConstraint(constraint2, target)
示例5: ikSolver
def ikSolver(rootJoint, endJoint, type, pvControl, handControl, parent):
ikHandle = mc.ikHandle(n=rootJoint.replace(nameLib.prefixNames.ikSuffix, "") + "_ikHandle", sj=rootJoint, ee=endJoint , sol="ikRPsolver")[0]
# hide solver
mc.setAttr(ikHandle + ".v", 0)
# add pc control to ikHandle
mc.poleVectorConstraint(pvControl, ikHandle)
# parent under hand control
mc.parent(ikHandle, handControl)
示例6: createIk
def createIk(ikJnts):
ikInfo = []
ikhName = ikJnts[2].replace('ikj', 'ikh')
ikh = cmds.ikHandle(n=ikhName, sj=ikJnts[0], ee=ikJnts[2], sol='ikRPsolver', p=2, w=.5 )
# Make a poleVector
pvCon = cmds.spaceLocator(n=ikhName+'_pv')
tmpCon = cmds.parentConstraint(ikJnts[1], pvCon, mo=False)
cmds.delete(tmpCon)
cmds.move(-1, pvCon, r=True, z=True )
cmds.makeIdentity(pvCon, apply=True )
# Creat a pv constraint
cmds.poleVectorConstraint( pvCon, ikh[0] )
return ikh
示例7: move_locator
def move_locator(locatorName, addPosition, effectorName):
sel = cmds.ls(locatorName)
# ピボットポイントをオブジェクトのバウンディングボックスの中心に設定
cmds.xform(locatorName, cp=True)
locator = cmds.spaceLocator(n="Dummy_Locator")
cmds.move(addPosition[0], addPosition[1], addPosition[2], ws=True)
cmds.delete("Dummy_Locator")
# 極ベクトル
cmds.poleVectorConstraint(locatorName, effectorName)
cmds.select(locatorName, deselect=True)
示例8: twoJointPV
def twoJointPV(name, ik, distance=1, constrain=True, size=1):
sj = cmds.ikHandle(ik, q=True, sj=True)
Gp = null2(name + '_PvGrp', sj, False)[0]
Pv = circle(name + '_PV', sj, 'diamond_ctrl', size * 1, 17, 8, 1, (0, 0, 1))[0]
cmds.parent(Pv, Gp)
X = cmds.getAttr(ik + '.poleVectorX')
Y = cmds.getAttr(ik + '.poleVectorY')
Z = cmds.getAttr(ik + '.poleVectorZ')
cmds.setAttr(Pv + '.translateX', distance * X)
cmds.setAttr(Pv + '.translateY', distance * Y)
cmds.setAttr(Pv + '.translateZ', distance * Z)
if constrain == True:
cmds.poleVectorConstraint(Pv, ik)
return Gp, Pv
示例9: setupPoleVec
def setupPoleVec(self):
middleName = rg.stripMiddle(self.m_joints.m_shoulder, 0, 3)
desiredName = self.m_name+"PoleVec_LOC"
self.m_poleVec = cmds.spaceLocator(n = desiredName)[0]
# Add to controls
rc.addToControlDict(self.m_allControls, "%s_IKPoleVec" %(self.m_baseName), self.m_poleVec)
rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_poleVec)
cmds.addAttr(
self.m_poleVec,
ln=self.m_poleVecPinAttr,
min=0,
max=1,
k=True,
dv=0
)
cmds.addAttr(
self.m_poleVec,
ln=self.m_maxStretchAttr,
at = "float",
min=0,
dv=10,
k=1
)
self.m_maxStretch = "%s.%s" %(self.m_poleVec, self.m_maxStretchAttr)
rc.orientControl(self.m_poleVec, self.m_joints.m_elbow1)
groups = rg.add3Groups(self.m_poleVec, ["_SDK", "_CONST", "_0"])
cmds.poleVectorConstraint(self.m_poleVec, self.m_ikHandle)
cmds.parent(groups[-1], self.m_group, r=1)
# Lock unused attributes
rc.lockAttrs(
self.m_poleVec,
["scale", "rotate"],
True,
False
)
axis , offset = self.getPoleVecAxis(2)
if axis != "":
cmds.setAttr("%s.t%s" %(groups[1], axis), offset)
#Create line
midGroup = cmds.group(em=1, n=self.m_name+"PoleVec_GRP")
cmds.parent(midGroup, self.m_group)
cmds.pointConstraint(self.m_joints.m_elbow1, midGroup)
cmds.pointConstraint(self.m_joints.m_elbow2, midGroup)
lineNodes = rc.createLine([self.m_poleVec, midGroup], self.m_sceneData, "mainCtrl")
cmds.parent(lineNodes[0], self.m_group)
示例10: targetAliasList
def targetAliasList(constraint):
'''
Return a list of targets (drivers) attribute aliases for the specified constraint node
@param constraint: The constraint node whose targets will be returned
@type constraint: str
'''
# Check Constraint
if not isConstraint(constraint):
raise Exception('Constraint "'+constraint+'" does not exist!!')
# Get Target List
targetList = []
constraintType = mc.objectType(constraint)
if constraintType == 'aimConstraint': targetList = mc.aimConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'geometryConstraint': targetList = mc.geometryConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'normalConstraint': targetList = mc.normalConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'orientConstraint': targetList = mc.orientConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'parentConstraint': targetList = mc.parentConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'pointConstraint': targetList = mc.pointConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'poleVectorConstraint': targetList = mc.poleVectorConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'scaleConstraint': targetList = mc.scaleConstraint(constraint,q=True,weightAliasList=True)
elif constraintType == 'tangentConstraint': targetList = mc.tangentConstraint(constraint,q=True,weightAliasList=True)
# Check Target List
if not targetList: targetList = []
# Return Result
return targetList
示例11: setupPV
def setupPV(self, IKHandle, type, x):
"""type can be "normal" (a control) or "noFlip" with hidden control and twist attribute. add to self.PVList """
# set values for this chain, side
thisChain = self.IKChains[x]
side = self.prefixList[x]
pv = "%s_%s_PV" % (side, self.limbName)
if type == "normal":
if x == 0:
thisPV = rig.createControl(pv, "sphere", self.jAxis1, "darkBlue")
if x == 1:
thisPV = rig.createControl(pv, "sphere", self.jAxis1, "darkRed")
thisGrp = cmds.group(pv, n="%s_%s" % (pv, self.groupSuffix))
# get pos of joints 0 and 2 to position pv group
topPosRaw = cmds.xform(thisChain[0], ws=True, q=True, t=True)
topPos = om.MVector(topPosRaw[0], topPosRaw[1], topPosRaw[2])
lowPosRaw = cmds.xform(thisChain[2], ws=True, q=True, t=True)
lowPos = om.MVector(lowPosRaw[0], lowPosRaw[1], lowPosRaw[2])
midPos = (topPos + lowPos) / 2
cmds.xform(thisGrp, ws=True, t=(midPos.x, midPos.y, midPos.z))
aim = cmds.aimConstraint(thisChain[1], thisGrp, aim=(0, 0, -1))
cmds.delete(aim)
cmds.xform(thisGrp, os=True, r=True, t=(0, 0, -10))
# strip control to translate
rig.stripToTranslate(thisPV)
# -----------capture all constraints as list?
# hook up pv
cmds.poleVectorConstraint(thisPV, IKHandle)
# add pv to list
self.PVList.append(thisPV)
# return pv
return thisPV
cmds.addAttr(thisPV, ln="follow", at="enum", en="world:foot")
if type == "noFlip":
pass
pass
示例12: createIkControls
def createIkControls(self):
# Create controls and solvers
wristControl = self.createWristControl()
poleVector = self.createPoleVector(distanceScale=5)
ikHandle = self.createIkHandle()[0]
# Create and constrain arm ik handle
cmds.pointConstraint(wristControl, ikHandle)
cmds.poleVectorConstraint(poleVector, ikHandle)
# Create null groups
self.utils.createNullGroup(wristControl)
self.utils.createNullGroup(poleVector)
# Lock controller attributes
self.utils.lockAttrs(wristControl, rotate=True, scale=True, visibility=True)
self.utils.lockAttrs(poleVector, rotate=True, scale=True, visibility=True)
示例13: bdRigIkArm
def bdRigIkArm(side):
ikChainStart = bdBuildDrvChain(side,'ik')
ikChainJoints = cmds.listRelatives(ikChainStart, ad=True,type='joint')
ikChainJoints.reverse()
ikBones = ikChainStart + ikChainJoints
print ikBones
armIk = cmds.ikHandle(sol= 'ikRPsolver',sticky='sticky', startJoint=ikBones[0],endEffector = ikBones[2],name = side + '_arm_ikHandle')
handIk = cmds.ikHandle(sol= 'ikSCsolver',sticky='sticky', startJoint=ikBones[2],endEffector = ikBones[3],name = side + '_hand_ikHandle')
ikHandlesGrp = cmds.group([armIk[0],handIk[0]],n=side + '_arm_ikHandles_grp')
wristPos = cmds.xform(ikBones[2],q=True,ws=True,t=True)
cmds.move(wristPos[0], wristPos[1], wristPos[2], [ikHandlesGrp + '.scalePivot',ikHandlesGrp + '.rotatePivot'])
pvAnim = cmds.ls(side + '_elbow_ik_anim', type='transform')[0]
if pvAnim:
cmds.poleVectorConstraint(pvAnim,armIk[0])
ikAnimCtrl = cmds.ls(side + '_hand_ik_anim',type='transform')[0]
cmds.parentConstraint(ikAnimCtrl, ikHandlesGrp)
示例14: create_ik_setup
def create_ik_setup(self):
"""Creates the IK setup."""
ik_leg = cmds.ikHandle(sj=self.ik_jnts[0], ee=self.ik_jnts[2], sol='ikRPsolver')
cmds.rename(ik_leg[1], '%s_%s_%s' % (self.side, 'leg', self.nc.effector))
ik_leg = cmds.rename(ik_leg[0], '%s_%s_%s' % (self.side, 'leg', self.nc.ikhandle))
ik_foot = cmds.ikHandle(sj=self.ik_jnts[2], ee=self.ik_jnts[3])
cmds.rename(ik_foot[1], '%s_%s_%s' % (self.side, 'foot', self.nc.effector))
ik_foot = cmds.rename(ik_foot[0], '%s_%s_%s' % (self.side, 'foot', self.nc.ikhandle))
ik_ball = cmds.ikHandle(sj=self.ik_jnts[3], ee=self.ik_jnts[4])
cmds.rename(ik_ball[1], '%s_%s_%s' % (self.side, 'ball', self.nc.effector))
ik_ball = cmds.rename(ik_ball[0], '%s_%s_%s' % (self.side, 'ball', self.nc.ikhandle))
cmds.parent(ik_leg, ik_foot, self.controls['ik'])
self.create_ik_stretch()
cmds.poleVectorConstraint(self.controls['knee'], ik_leg, weight=1)
self.create_knee_pin()
self._reverse_foot([ik_leg, ik_foot, ik_ball])
self._foot_attributes([ik_leg, ik_foot, ik_ball])
示例15: ikArmSetup
def ikArmSetup(self):
"""
#- ik arm setup
"""
cmds.select(cl = True)
for lr in self.lrPrefix:
cmds.select('%sshoulder_jnt' %lr, r = True)
cmds.duplicate(rr = True, n = '%sik_shoulder_jnt' %lr)
armChild = cmds.listRelatives('%sik_shoulder_jnt' %lr, ad = True, f = True)
cmds.rename(armChild[0], '%sik_wrist_jnt' %lr )
cmds.rename(armChild[1], '%sik_elbow_jnt' %lr )
if lr == self.left:
ctlColor = 6
else:
ctlColor = 12
controller.boxController('%sarm_ik_ctl' %lr, ctlColor, ['sc', 'vi'])
controller.arrowController('%sarm_polevector_ctl' %lr, ctlColor, ['ro', 'sc', 'vi'])
cmds.select('%sik_wrist_jnt' %lr, r = True)
cmds.select('%sarm_ik_ctl_grp' %lr, tgl = True)
cmds.pointConstraint(mo = False, weight = 1)
cmds.orientConstraint(mo = False, weight = 1)
cmds.delete('%sarm_ik_ctl_grp_pointConstraint1' %lr)
cmds.delete('%sarm_ik_ctl_grp_orientConstraint1' %lr)
cmds.select('%sarm_ik_ctl' %lr, r = True)
cmds.select('%sik_wrist_jnt' %lr, tgl = True)
cmds.orientConstraint(mo = False, weight = 1)
cmds.select('%sik_shoulder_jnt.rotatePivot' %lr, r = True)
cmds.select('%sik_wrist_jnt.rotatePivot' %lr, add = True)
cmds.ikHandle(n = '%sarm_ikHandle' %lr, sol = 'ikRPsolver')
self.util.parent('%sarm_ikHandle' %lr, '%sarm_ik_ctl' %lr)
polVecPos = poleVector.getPolVectorPos('%sik_shoulder_jnt' %lr, '%sik_elbow_jnt' %lr, '%sik_wrist_jnt' %lr, 1)
cmds.select('%sarm_polevector_ctl_grp' %lr, r = True)
cmds.move(polVecPos[0], polVecPos[1], polVecPos[2])
cmds.select('%sarm_polevector_ctl' %lr, r = True)
cmds.select('%sarm_ikHandle' %lr, tgl = True)
cmds.poleVectorConstraint(weight = 1)