def createFkReverseCTRLS(): self.REVERSE_MOD.getJoints = [] for joint in self.reverse_spine_chain_joints: rev_ctrl = Control.Control( name=joint.replace(NC.JOINT, NC.CTRL), shape=sl.sl[self.config['CONTROLS']['Spine_FK_Rev'] ['shape']], scale=self.config['CONTROLS']['Spine_FK_Rev']['scale'], matchTransforms=(False, 1, 0), color=('index', 20), ) self.REVERSE_MOD.getJoints.append(joint) pm.parent(rev_ctrl.control.getShape(), joint, relative=True, shape=True) pm.delete(rev_ctrl.control) pm.rename(joint, NC.getNameNoSuffix(joint)) adb.AutoSuffix([joint]) adb.lockAttr_func( joint, ['tx', 'ty', 'tz', 'sx', 'sy', 'sz', 'radius']) self.nameStructure['Suffix'] = NC.VISRULE shapes = [x.getShape() for x in self.reverse_spine_chain_joints] moduleBase.ModuleBase.setupVisRule( shapes, self.REVERSE_MOD.VISRULE_GRP, '{Side}__{Basename}_FK_Reverse_CTRL__{Suffix}'.format( **self.nameStructure), False) self.setupVisRule( self.reverse_spine_chain_joints, self.REVERSE_MOD.VISRULE_GRP, '{Side}__{Basename}_FK_Reverse_JNT__{Suffix}'.format( **self.nameStructure), False) return self.REVERSE_MOD.getJoints
def createloc(sub=pm.selected()): """Creates locator at the Pivot of the object selected """ locs = [] for sel in sub: loc_align = pm.spaceLocator(n='{}_Distance__{}'.format( NC.getNameNoSuffix(sel), NC.LOC)) locs.append(loc_align) pm.matchTransform(loc_align, sel, rot=True, pos=True) pm.select(locs, add=True) return locs
def setupVisRule(self, tansformList, parent, name=False, defaultValue=True): """ Edit : for setting up the visrule for Fk shapes ctrl Original one from ModuleBase """ if name: visRuleGrp = pm.group(n=name, em=1, parent=parent) else: visRuleGrp = pm.group(n='{}_{}__{}'.format( NC.getNameNoSuffix(tansformList[0]), NC.getSuffix(tansformList[0]), NC.VISRULE), em=1, parent=parent) visRuleGrp.v.set(0) visRuleAttr = adbAttr.NodeAttr([visRuleGrp]) visRuleAttr.addAttr('vis', 'enum', eName="2:0") self.nameStructure['Suffix'] = NC.ADDLINEAR_SUFFIX addDouble = pm.shadingNode( 'addDoubleLinear', asUtility=1, n='{Side}__{Basename}_visrule__{Suffix}'.format( **self.nameStructure)) self.nameStructure['Suffix'] = NC.REVERSE_SUFFIX reverse = pm.shadingNode( 'reverse', asUtility=1, n='{Side}__{Basename}_visrule__{Suffix}'.format( **self.nameStructure)) addDouble.input2.set(1) pm.connectAttr('{}.{}'.format(visRuleGrp, visRuleAttr.name), '{}.inputX'.format(reverse), f=1) pm.connectAttr('{}.outputX'.format(reverse), '{}.input1'.format(addDouble), f=1) for transform in tansformList: pm.connectAttr('{}.output'.format(addDouble), '{}.drawStyle'.format(transform)) adb.lockAttr_func( visRuleGrp, ['tx', 'ty', 'tz', 'rx', 'ry', 'rx', 'rz', 'sx', 'sy', 'sz', 'v']) return visRuleGrp, visRuleAttr.name
def setupVisRule(tansformList, parent, name=False, defaultValue=True): """ setup VisRule group for a tansform. Connect the tansform visibility to the visRule group Arguments: tansform {List} -- Control to connect parent {transform} -- parent of the VisRule group """ if name: visRuleGrp = pm.group(n=name, em=1, parent=parent) else: visRuleGrp = pm.group(n='{}_{}__{}'.format(NC.getNameNoSuffix(tansformList[0]), NC.getSuffix(tansformList[0]), NC.VISRULE), em=1, parent=parent) visRuleGrp.v.set(0) visRuleAttr = adbAttr.NodeAttr([visRuleGrp]) visRuleAttr.addAttr('vis', defaultValue) for transform in tansformList: pm.connectAttr('{}.{}'.format(visRuleGrp, visRuleAttr.name), '{}.v'.format(transform)) adb.lockAttr_func(visRuleGrp, ['tx', 'ty', 'tz', 'rx', 'ry', 'rx', 'rz', 'sx', 'sy', 'sz','v']) return visRuleGrp, visRuleAttr.name
def createFkRegularCTRLS(self): self.RESULT_MOD.getJoints = [] for joint in self.spine_chain_joints: ctrl = Control.Control( name=joint.replace(NC.JOINT, NC.CTRL), shape=sl.sl[self.config['CONTROLS']['Spine_FK_Reg']['shape']], scale=self.config['CONTROLS']['Spine_FK_Reg']['scale'], matchTransforms=(False, 1, 0), color=('index', 21)) for att in ['tx', 'ty', 'tz', 'sx', 'sy', 'sz', 'radius']: pm.PyNode(joint).setAttr(att, lock=True, channelBox=False, keyable=False) self.RESULT_MOD.getJoints.append(joint) pm.parent(ctrl.control.getShape(), joint, relative=True, shape=True) pm.delete(ctrl.control) pm.rename(joint, NC.getNameNoSuffix(joint)) adb.AutoSuffix([joint]) self.nameStructure['Suffix'] = NC.VISRULE shapes = [x.getShape() for x in self.spine_chain_joints] moduleBase.ModuleBase.setupVisRule( shapes, self.RESULT_MOD.VISRULE_GRP, '{Side}__{Basename}_FK_CTRL__{Suffix}'.format( **self.nameStructure), False) self.setupVisRule( self.spine_chain_joints, self.RESULT_MOD.VISRULE_GRP, '{Side}__{Basename}_FK_JNT__{Suffix}'.format(**self.nameStructure), False) return self.RESULT_MOD.getJoints
def maximumSetup(self): # DUPLICATED IK JOINT CHAIN self.ik_NonStretch_joint = [ pm.duplicate(joint, parentOnly=True)[0] for joint in self.ikJnts ] pm.parent(self.ik_NonStretch_joint[-1], self.ik_NonStretch_joint[-2]) pm.parent(self.ik_NonStretch_joint[-2], self.ik_NonStretch_joint[0]) [ pm.PyNode(jnt).rename('{}_NonStetch__{}'.format( NC.getNameNoSuffix(jnt), NC.JOINT)) for jnt in self.ik_NonStretch_joint ] nonStretch_IkHandle, nonStretch_IkHandle_effector = pm.ikHandle( n='{}_NonStetch__{}'.format(self.NAME, NC.IKHANDLE_SUFFIX), sj=self.ik_NonStretch_joint[0], ee=self.ik_NonStretch_joint[-1]) nonStretch_IkHandle.v.set(0) self.nonStretch_IkHandle = nonStretch_IkHandle adb.makeroot_func(self.nonStretch_IkHandle) pm.poleVectorConstraint(self.poleVector_ctrl, nonStretch_IkHandle, weight=1) adb.matrixConstraint(self.ik_ctrl, self.nonStretch_IkHandle.getParent()) self.setFinalHiearchy(RIG_GRP_LIST=[ self.nonStretch_IkHandle.getParent(), self.ik_NonStretch_joint[0] ]) # MAXIMUM NODES self.decompStart_node = pm.shadingNode('decomposeMatrix', asUtility=1, n='{}_startVec__{}'.format( self.NAME, NC.DECOMPOSEMAT_SUFFIX)) self.decompEnd_node = pm.shadingNode('decomposeMatrix', asUtility=1, n='{}_endVec__{}'.format( self.NAME, NC.DECOMPOSEMAT_SUFFIX)) self.md_max_node = pm.shadingNode('multiplyDivide', asUtility=1, n='{}_maxFactor__{}'.format( self.NAME, NC.MULTIPLY_DIVIDE_SUFFIX)) self.clam_node = pm.shadingNode('clamp', asUtility=1, n='{}_max__{}'.format( self.NAME, NC.CLAMP_SUFFIX)) self.initialVec_node = pm.shadingNode('plusMinusAverage', asUtility=1, n='{}_initalVec__{}'.format( self.NAME, NC.PLUS_MIN_AVER_SUFFIX)) self.initialVec_node.operation.set(2) self.addVec_node = pm.shadingNode('plusMinusAverage', asUtility=1, n='{}_addVect__{}'.format( self.NAME, NC.PLUS_MIN_AVER_SUFFIX)) self.maximumToggle_node = pm.shadingNode( 'blendColors', asUtility=1, n='{}_maximumToggle__{}'.format(self.NAME, NC.PLUS_MIN_AVER_SUFFIX)) # connections maximum system self.ik_NonStretch_joint[-1].worldMatrix[ 0] >> self.decompStart_node.inputMatrix self.ik_ctrl.worldMatrix[0] >> self.decompEnd_node.inputMatrix self.decompStart_node.outputTranslate >> self.md_max_node.input1 self.decompEnd_node.outputTranslate >> self.initialVec_node.input3D[0] self.decompStart_node.outputTranslate >> self.initialVec_node.input3D[1] self.initialVec_node.output3D >> self.addVec_node.input3D[0] self.decompStart_node.outputTranslate >> self.addVec_node.input3D[1] self.addVec_node.output3D >> self.clam_node.input self.md_max_node.output >> self.clam_node.max self.clam_node.output >> self.maximumToggle_node.color1 self.decompEnd_node.outputTranslate >> self.maximumToggle_node.color2 self.outputLoc = pm.spaceLocator( n='{}_Ouput__{}'.format(self.NAME, NC.LOC)) self.maximumToggle_node.output >> self.outputLoc.translate self.outputLoc.inheritsTransform.set(0) self.outputLoc.v.set(0) pm.parentConstraint(self.outputLoc, self.posLoc[1].getParent(), mo=1)