def __connect_guides(self, mod=None, side=None, obj=None, position=[0, 0, 0]): #--- this method creates the curve which connects the guide controls attr = attribute.Attribute() nd = node.Node() #--- create curves crv = cmds.curve(degree=1, point=self.position) cmds.parent(crv, self.gd.extras) crvShp = cmds.listRelatives(crv, allDescendents=True)[0] crvShp = cmds.rename(crvShp, crv + 'Shape') rel = cmds.listRelatives(crv, allDescendents=1)[0] #--- connect the cvs to the controls by matrix for i in range(len(obj)): #--- create decomposeMatrix nodes dcm = nd.decomposeMatrix(name=obj[i]) #--- connect the control with the decomposeMatrix attr.connectAttr(node=[obj[i], dcm], attribute=['worldMatrix[0]', 'inputMatrix']) attr.connectAttr( node=[dcm, rel], attribute=['outputTranslate', 'controlPoints[' + ` i ` + ']']) #--- set the displayType of the curve Shape to template attr.setColor(node=crvShp, displayType=1)
def __setup_fk_controls(self): #--- this method setups the fk controls nd = node.Node() #--- parent the fk controls properly ctl = self.controls_neck for i in range(len(ctl)): j = i + 1 if not j == len(ctl): cmds.parent(ctl[j].group, ctl[i].transform) #--- parentConstraint the ctl joints to the controls pac = nd.parentConstraint( objA=ctl[i].transform, objB=self.joints_fk[i], name=(self.side + '_' + self.mod + self.name[i][0].upper() + self.name[i][1:]), maintainOffset=True)[0] self.pac.append(pac) else: #--- parentConstraint the side last joint to the control pac = nd.parentConstraint( objA=ctl[i].transform, objB=self.joints_fk[i], name=(self.side + '_' + self.mod + self.name[i][0].upper() + self.name[i][1:]), maintainOffset=True)[0] self.pac.append(pac) #--- parentConstraint the first fk control to the sternum control nd.parentConstraint(objA=self.puppetObj.sternum_control.transform, objB=ctl[0].group)
def __create_connection_curve(self, obj=None, parent=None): #--- this method creates the curves whicht connects the guides attr = attribute.Attribute() nd = node.Node() #--- create the curve crv = cmds.curve(degree=1, point=self.position) cmds.parent(crv, self.extras) crvShp = cmds.listRelatives(crv, allDescendents=True)[0] crvShp = cmds.rename(crvShp, crv + 'Shape') rel = cmds.listRelatives(crv, allDescendents=1)[0] #--- connect the cvs to the controls by matrix for i in range(len(obj)): #--- create decomposeMatrix nodes dcm = nd.decomposeMatrix(name=obj[i]) #--- connect the control with the decomposeMatrix attr.connectAttr(node=[obj[i], dcm], attribute=['worldMatrix[0]', 'inputMatrix']) attr.connectAttr( node=[dcm, rel], attribute=['outputTranslate', 'controlPoints[' + ` i ` + ']']) #--- create the visibility connections of the main mod node if cmds.nodeType(obj[i]) == 'joint': attr.connectAttr(node=[self.main_mod, obj[i]], attribute=['showJoints', 'v']) attr.connectAttr(node=[self.main_mod, self.g_loc[i]], attribute=['showUpVectors', 'v']) #--- set the displayType of the curve Shape to template attr.setColor(node=crvShp, displayType=1)
def __create_modular_setup(self): #--- this method creates the modular based group setup nd = node.Node() iter = 1 for child in cmds.listRelatives(self.main_ctl, children=True): if cmds.ls(child, type='transform'): for i in cmds.listRelatives(child, children=True): n = self.guideObj.side + '_' + self.guideObj.mod + str( iter) if n in i: iter += 1 iter = str(iter) #--- create the main module group if cmds.objExists('MAIN_' + self.guideObj.mod + '_MOD'): self.main_mod_grp = 'MAIN_' + self.guideObj.mod + '_MOD' else: self.main_mod_grp = nd.transform(name='MAIN_' + self.guideObj.mod, suffix='MOD', parent=self.main_ctl) #--- create the side module group sides = [self.guideObj.gd.side] for side in sides: if cmds.objExists(side + '_' + self.guideObj.mod + iter + '_MOD'): self.side_mod_grp = side + '_' + self.guideObj.mod + iter + '_MOD' else: self.side_mod_grp = nd.transform( name=(side + '_' + self.guideObj.mod + iter), suffix='MOD', parent=self.main_mod_grp) #--- create the joint group for the side if cmds.objExists(side + '_' + self.guideObj.mod + iter + '_JOINTS'): self.side_jnt_grp = (side + '_' + self.guideObj.mod + iter + '_JOINTS') else: self.side_jnt_grp = nd.transform( name=(side + '_' + self.guideObj.mod + iter), suffix='JOINTS', parent=self.side_mod_grp) #--- create the control group for the side if cmds.objExists(side + '_' + self.guideObj.mod + iter + '_CONTROLS'): self.side_ctl_grp = (side + '_' + self.guideObj.mod + iter + '_CONTROLS') else: self.side_ctl_grp = nd.transform( name=(side + '_' + self.guideObj.mod + iter), suffix='CONTROLS', parent=self.side_mod_grp) #--- create the extraNodes group for the side if cmds.objExists(side + '_' + self.guideObj.mod + iter + '_EXTRANODES'): self.side_extra_grp = (side + '_' + self.guideObj.mod + iter + '_EXTRANODES') else: self.side_extra_grp = nd.transform( name=(side + '_' + self.guideObj.mod + iter), suffix='EXTRANODES', parent=self.side_mod_grp)
def __create_skeleton_setup(self): #--- this method creates the skeleton group nd = node.Node() if cmds.objExists('SKELETON'): self.skel_grp = 'SKELETON' else: #--- create the group self.skel_grp = nd.transform(name = 'SKELETON')
def setup_dropdown_menu(self): #--- this method setups the dropDown menu nd = node.Node() methods = dir(nd) for m in methods: if not m.startswith('__'): self.node_list.append(m) #--- add the method nodes to the dropDown list self.node_CMB.addItems(self.node_list)
def __setup_controls(self): #--- this method setups the fk controls nd = node.Node() #--- orientConstraint the joint to the control ctl = self.control ocn = nd.parentConstraint(objA=ctl.transform, objB=self.joints[0], name=self.side + '_' + self.mod + self.name, maintainOffset=False)[0] self.ocn = ocn
def __setup_controls(self): #--- this method setups the centre of gravity control nd = node.Node() #--- parentConstraint the joints to the controls nd.parentConstraint(objA=self.hip_control.transform, objB=self.joints[0], suffix='PAC', lock=True) nd.parentConstraint(objA=self.sternum_control.transform, objB=self.joints[-1], suffix='PAC', lock=True)
def __setup_joints(self): #--- this method connects the ik fk joints with the bind one attr = attribute.Attribute() nd = node.Node() #--- constraint fk joints to the bind ones self.pac = nd.parentConstraint(objA=self.joints_fk, objB=self.joints, maintainOffset=False) #--- connect the bind joints to the last joint of the puppetObj cmds.parent(self.joints[0], self.puppetObj.joints[-1]) #--- disable skin tag for fk in self.joints_fk: attr.setAttr(fk, ['SKIN'], 0)
def __setup_head_controls(self): #--- this method setups the fk controls nd = node.Node() #--- parentConstraint the ctl joints to the controls nd.parentConstraint(objA=self.control_head.transform, objB=self.joints[0], name=(self.side + '_' + self.mod + self.name[0][0].upper() + self.name[0][1:]), maintainOffset=True) nd.parentConstraint(objA=self.control_jaw.transform, objB=self.joints[1], name=(self.side + '_' + self.mod + self.name[1][0].upper() + self.name[1][1:]), maintainOffset=True)
def __create_main_control(self): #--- this method creates the main control nd = node.Node() #--- create main control if not cmds.objExists('C_' + self.character + 'Main_CTL'): main_ctl = control.Control(side='C', name=self.character + 'Main', suffix='CTL', size=5, shape=11, color=17, parent=self.rig_grp) self.main_ctl = main_ctl.transform else: self.main_ctl = 'C_' + self.character + 'Main_CTL'
def __mirror_guides(self): #--- this method mirrors the guides properly and set them up attr = attribute.Attribute() nd = node.Node() #--- create the mirror node and the proper connections guides = self.mirrorGuideObj mirrors = [] if isinstance(guides.name, list): for obj in range(len(guides.name)): mirror = nd.mirrorSwitch(name=(self.side + '_' + self.mod + guides.name[obj][0].upper() + guides.name[obj][1:])) attr.connectAttr(node=[guides.gd.g_ctl[obj], mirror], attribute=['worldMatrix', 'inputMatrix']) for axis in 'xyz': attr.lockAttr(node=[self.g_grp[obj]], attribute=['t', 'r'], lock=False, show=True) #--- connect outPos and outRot with translate and rotate attr.connectAttr(node=[mirror, self.g_grp[obj]], attribute=['op' + axis, 't' + axis]) attr.connectAttr(node=[mirror, self.g_grp[obj]], attribute=['or' + axis, 'r' + axis]) cmds.setAttr(mirror + '.ihi', 0) mirrors.append(mirror) else: mirror = nd.mirrorSwitch(name=(self.side + '_' + self.mod + guides.name[0].upper() + guides.name[1:])) attr.connectAttr(node=[guides.gd.g_ctl[0], mirror], attribute=['worldMatrix', 'inputMatrix']) for axis in 'xyz': attr.lockAttr(node=[self.g_grp[0]], attribute=['t', 'r'], lock=False, show=True) #--- connect outPos and outRot with translate and rotate attr.connectAttr(node=[mirror, self.g_grp[0]], attribute=['op' + axis, 't' + axis]) attr.connectAttr(node=[mirror, self.g_grp[0]], attribute=['or' + axis, 'r' + axis]) cmds.setAttr(mirror + '.ihi', 0) mirrors.append(mirror) self.mirrors = mirrors
def __create_flexiplane(self): #--- this method creates the spine flexiplane attr = attribute.Attribute() nd = node.Node() #--- create the first flexiplane for the humerus bone self.spine_flexiplane = flexiplane.FlexiPlane( character=self.character, mod=self.mod, side=self.side, name='vertebrae', color=self.color, size=self.size, length=5, rotation=[0, 0, 90], constraintTo=[ self.hip_control.transform, self.ribcage_control.transform ], constraintType='point', follow=False, parent=self.side_extra_grp, inheritsTransform=False)
def __setup_aim(self): #--- setup the aimConstraints for the joints nd = node.Node() #--- iterate through the joint groups for i in range(len(self.g_jnt_off)): if not len(self.g_jnt_off) > 1: #--- setup for all joints except the last one aim = nd.aimConstraint(target=self.g_loc[i], source=self.g_jnt_off[i], suffix='AIM', aimVector=self.aimVector, upVector=self.upVector, worldUpObject=self.g_loc[i], worldUpType='object') else: j = i + 1 if not j == len(self.g_jnt_off): #--- setup for all joints except the last one aim = nd.aimConstraint(target=self.g_jnt[j], source=self.g_jnt_off[i], suffix='AIM', aimVector=self.aimVector, upVector=self.upVector, worldUpObject=self.g_loc[i], worldUpType='object') else: #--- setup for the last joint if self.aimVector[0] == 1: self.aimVector = [-1, 0, 0] elif self.aimVector[1] == 1: self.aimVector = [0, -1, 0] elif self.aimVector[2] == 1: self.aimVector = [0, 0, -1] aim = nd.aimConstraint(target=self.g_jnt_off[i - 1], source=self.g_jnt_off[i], suffix='AIM', aimVector=self.aimVector, upVector=self.upVector, worldUpObject=self.g_loc[i], worldUpType='object')
def __setup_space_switch(self): #--- this method setups a space switch attr = attribute.Attribute() nd = node.Node() #--- create a world node and pointConstraint it world_grp = nd.transform(name=self.side + '_' + self.mod + 'WORLD', suffix='OFF', parent=self.joints[0]) cmds.parent(world_grp, self.side_extra_grp) nd.pointConstraint(objA=self.joints[0], objB=world_grp, suffix='PCN', maintainOffset=False, lock=True) #--- create a local node and parentConstraint it local_grp = nd.transform(name=self.side + '_' + self.mod + 'LOCAL', suffix='OFF', parent=self.joints[0]) cmds.parent(local_grp, self.side_extra_grp) nd.parentConstraint(objA=self.puppetObj.joints[-1], objB=local_grp, suffix='PAC', maintainOffset=True, lock=True) #--- orientConstraint the control group of the head ocn = nd.orientConstraint(objA=[world_grp, local_grp], objB=self.control_head.group, suffix='OCN', maintainOffset=True) #--- create switch ori setup rev = nd.reverse(name=self.side + '_' + self.mod + 'Follow') attr.connectAttr(node=[self.control_head.transform, rev], attribute=['follow', 'inputX']) attr.connectAttr(node=[rev, ocn], attribute=['outputX', world_grp + 'W0']) attr.connectAttr(node=[self.control_head.transform, ocn], attribute=['follow', local_grp + 'W1'])
def __create_puppet_setup(self): #--- this method creates the group setup properly nd = node.Node() #--- create the character group if self.character: if cmds.objExists('CHARACTER_' + self.character): self.char_grp = 'CHARACTER_' + self.character else: self.char_grp = nd.transform(name='CHARACTER_' + self.character) #--- get the skeleton group and parent it with the joints properly if cmds.objExists(self.character): child = cmds.listRelatives(self.character, children=True) cmds.parent(child, 'SKELETON') cmds.delete(self.character) cmds.parent('SKELETON', self.char_grp) cmds.select(clear=True) #--- create the RIG group if cmds.objExists('RIG'): self.rig_grp = 'RIG' else: self.rig_grp = nd.transform(name='RIG', parent=self.char_grp) else: raise Exception('You have to specify a proper character name!')
def __hook_setup(self): #--- unlock the self.hookChild attributes nd = node.Node() attr = attribute.Attribute() #--- unlock proper attributes on the child hooks try: attr.lockAttr(node=self.hookChild, attribute=['t', 'r', 's'], lock=False, show=True) if self.hookType: if self.hookType == 'parentConstraint': if isinstance(self.hookChild, list): for hook in self.hookChild: pac = nd.parentConstraint(objA=self.hookParent, objB=hook, name=self.mod + 'HOOK', suffix='PAC', maintainOffset=True) attr.lockAll(node=hook) attr.lockAttr(node=pac, attribute=['ihi']) else: pac = nd.parentConstraint(objA=self.hookParent, objB=self.hookChild, name=self.mod + 'HOOK', suffix='PAC', maintainOffset=True) attr.lockAll(node=self.hookChild) attr.lockAttr(node=pac, attribute=['ihi']) elif self.hookType == 'pointConstraint': if isinstance(self.hookChild, list): for hook in self.hookChild: pcn = nd.pointConstraint(objA=self.hookParent, objB=hook, name=self.mod + 'HOOK', suffix='PAC', maintainOffset=True) attr.lockAll(node=hook) attr.lockAttr(node=pcn, attribute=['ihi']) else: pcn = nd.pointConstraint(objA=self.hookParent, objB=self.hookChild, name=self.mod + 'HOOK', suffix='PAC', maintainOffset=True) attr.lockAll(node=self.hookChild) attr.lockAttr(node=pcn, attribute=['ihi']) elif self.hookType == 'orientConstraint': if isinstance(self.hookChild, list): for hook in self.hookChild: ocn = nd.orientConstraint(objA=self.hookParent, objB=hook, name=self.mod + 'HOOK', suffix='PAC', maintainOffset=True) attr.lockAll(node=hook) attr.lockAttr(node=ocn, attribute=['ihi']) else: ocn = nd.orientConstraint(objA=self.hookParent, objB=self.hookChild, name=self.mod + 'HOOK', suffix='PAC', maintainOffset=True) attr.lockAll(node=self.hookChild) attr.lockAttr(node=ocn, attribute=['ihi']) except: pass
def __head_eye_setup(self, character=None, eyesAmount=1, mouth=True, mirror=True): #--- this method creates the eye setup self.eye = eye.QuadrupedEyeGuide(character=character, eyesAmount=eyesAmount, mirror=mirror) #--- get the attr and nd tools nd = node.Node() attr = attribute.Attribute() #--- setup the connection lines of the guides if eyesAmount: for iter in range(eyesAmount): #--- connect the eye guides properly if mouth: self.__connect_guides( mod=self.eye.gd.mod, side=self.eye.gd.side, obj=[self.mouth.gd.g_jnt[0], self.eye.jnt[iter][0]], position=[ self.mouth.gd.position[0], self.eye.position[iter][0] ]) if mirror: self.__connect_guides(mod=self.eye.gd.mod, side=self.eye.gd.mirror_side, obj=[ self.mouth.gd.g_jnt[0], self.eye.mirror_ctl[iter][0] ], position=[ self.mouth.gd.position[0], self.eye.mirror_pos[iter][0] ]) #--- hook the eye guides to the mouth hook.Hook(mod=self.eye, hookParent=self.mouth.gd.g_ctl[0], hookChild=self.eye.grp[iter][0], hookType='parentConstraint') else: self.__connect_guides( mod=self.eye.gd.mod, side=self.eye.gd.side, obj=[self.gd.g_jnt[0], self.eye.jnt[iter][0]], position=[ self.gd.position[0], self.eye.position[iter][0] ]) if mirror: self.__connect_guides(mod=self.eye.gd.mod, side=self.eye.gd.mirror_side, obj=[ self.gd.g_jnt[0], self.eye.mirror_ctl[iter][0] ], position=[ self.gd.position[0], self.eye.mirror_pos[iter][0] ]) #--- hook the eye guides to the midSkull hook.Hook(mod=self.eye, hookParent=self.gd.g_ctl[0], hookChild=self.eye.grp[iter][0], hookType='parentConstraint')
def __finger_setup(self): #--- this method creates the finger guides and setup them properly attr = attribute.Attribute() nd = node.Node() #--- create the finger guide controls guide_names = [] for p in range(len(self.position)): #--- create an alphabetical iterator abc = string.uppercase #--- create the guide names guide_names.append(self.name + abc[p]) self.name = guide_names if self.mirrorGuideObj: self.upVectorOffset = [0, -6, 0] self.upVector = [0, -1, 0] #--- create the guides self.create(character=self.character, mod=self.mod, side=self.side, name=self.name, suffix=self.suffix, size=self.size, shape=self.shape, orientation=self.orientation, color=self.color, position=self.position, rotation=self.rotation, upVectorOffset=self.upVectorOffset, aimVector=self.aimVector, upVector=self.upVector, rotateOrder=self.rotateOrder, flip=self.flip, mirrorGuideObj=self.mirrorGuideObj) #--- unlock all necessary attributes from specified nodes attr.lockAttr(node=self.gd.g_grp, attribute=['t', 'r', 's'], lock=False, show=True) if not self.mirrorGuideObj: #--- parent the controls fk style for i in range(len(self.gd.g_grp)): j = i + 1 if not j == len(self.gd.g_grp): cmds.parent(self.gd.g_grp[j], self.gd.g_ctl[i]) #--- parent the first index to the given parent object if self.parent: if self.mirrorGuideObj: try: #--- hook the finger guide to the hand hook.Hook(mod=self.parent, hookParent=self.parent, hookChild=self, hookType=None, hookMessage=False) except: pass else: try: #--- hook the finger guide to the hand hook.Hook(mod=self.parent, hookParent=self.parent, hookChild=self, hookType='parentConstraint', hookMessage=False) except: pass #--- connect messages self.__connect_message() #--- mod specific cleanup self.__cleanup()
def __prepare_soft_hip(self): #--- this method prepares the soft hip system attr = attribute.Attribute() nd = node.Node() #--- create softHip groups self.soft_grp = nd.transform(name=self.side + '_' + self.mod + 'SoftSetup', suffix='GRP', parent=self.side_extra_grp) #--- LOCATORS #--- translate Y self.ty_loc = nd.locator(name=self.side + '_' + self.mod + 'SoftTY', suffix='LOC', position=[1, 0, 0], worldSpace=True, parent=self.soft_grp) #--- translate Y Target self.tyIk_loc = nd.locator(name=self.side + '_' + self.mod + 'SoftIkTY', suffix='LOC', position=[1, 0, 0], worldSpace=True, parent=self.soft_grp) #--- translate Z self.tz_loc = nd.locator(name=self.side + '_' + self.mod + 'SoftTZ', suffix='LOC', position=[1, 0, 0], worldSpace=True, parent=self.soft_grp) #--- translate Z Target self.tzIk_loc = nd.locator(name=self.side + '_' + self.mod + 'SoftIkTZ', suffix='LOC', position=[1, 0, 0], worldSpace=True, parent=self.soft_grp) #--- UTILITY NODES #--- multiplyDivide translation self.translate_mlt = nd.multiplyDivide( name=(self.side + '_' + self.mod + 'SoftTranslate'), input2Y=0.005, input2Z=0.005, lockAttr=['input2Y', 'input2Z']) #--- condition ty and tz self.ty_cnd = nd.condition(name=self.side + '_' + self.mod + 'SoftTY', secondTerm=0, operation=2, lockAttr='secondTerm') self.tz_cnd = nd.condition(name=self.side + '_' + self.mod + 'SoftTZ', secondTerm=0, operation=4, lockAttr='secondTerm') #--- remapValue ty and tz self.ty_rmv = nd.remapValue( name=self.side + '_' + self.mod + 'SoftTY', inputMin=-1, inputMax=2, outputMin=0, lockAttr=['inputMin', 'inputMax', 'outputMin']) self.tz_rmv = nd.remapValue( name=self.side + '_' + self.mod + 'SoftTZ', inputMin=-2, inputMax=1, outputMin=0, lockAttr=['inputMin', 'inputMax', 'outputMin']) #--- connect the utility nodes #--- translateY attr.connectAttr(node=[self.ty_loc, self.translate_mlt], attribute=['translateY', 'input1Y']) attr.connectAttr(node=[self.translate_mlt, self.ty_cnd], attribute=['outputY', 'colorIfFalseG']) attr.connectAttr(node=[self.ty_loc, self.ty_cnd], attribute=['translateY', 'firstTerm']) attr.connectAttr(node=[self.ty_loc, self.ty_cnd], attribute=['translateY', 'colorIfTrueG']) attr.connectAttr(node=[self.ty_cnd, self.ty_rmv], attribute=['outColorG', 'inputValue']) attr.connectAttr(node=[self.ty_loc, self.ty_rmv], attribute=['translateY', 'outputMax']) attr.connectAttr(node=[self.ty_rmv, self.tyIk_loc], attribute=['outValue', 'translateY']) #--- translateZ attr.connectAttr(node=[self.tz_loc, self.translate_mlt], attribute=['translateZ', 'input1Z']) attr.connectAttr(node=[self.translate_mlt, self.tz_cnd], attribute=['outputZ', 'colorIfFalseB']) attr.connectAttr(node=[self.tz_loc, self.tz_cnd], attribute=['translateZ', 'firstTerm']) attr.connectAttr(node=[self.tz_loc, self.tz_cnd], attribute=['translateZ', 'colorIfTrueB']) attr.connectAttr(node=[self.tz_cnd, self.tz_rmv], attribute=['outColorG', 'inputValue']) attr.connectAttr(node=[self.tz_loc, self.tz_rmv], attribute=['translateZ', 'outputMax']) attr.connectAttr(node=[self.tz_rmv, self.tzIk_loc], attribute=['outValue', 'translateZ']) #--- smoothRotate to value[1].float_Value attr.connectAttr( node=[self.control.transform, self.ty_rmv], attribute=['smoothRotateZ', 'value[1].value_FloatValue']) attr.connectAttr( node=[self.control.transform, self.tz_rmv], attribute=['smoothRotateY', 'value[1].value_FloatValue']) #--- CREATE JOINT CHAIN #--- create the rotationY setup self.soft_ry_jnt = jointchain.IkChain( side=self.side, name=[self.mod + 'SoftRotY1', self.mod + 'SoftRotY2'], suffix='JNT', position=[[0, 0, 0], [1, 0, 0]], ikSolver='ikSCSolver', mirror=False, radius=0.5, parentJoint=self.soft_grp, parentIk=self.tzIk_loc) #--- create the rotationZ setup self.soft_rz_jnt = jointchain.IkChain( side=self.side, name=[self.mod + 'SoftRotZ1', self.mod + 'SoftRotZ2'], suffix='JNT', position=[[0, 0, 0], [1, 0, 0]], ikSolver='ikSCSolver', mirror=False, radius=0.5, parentJoint=self.soft_grp, parentIk=self.tyIk_loc)
def __setup_control(self, name=None): #--- in this method you create the joint and upVector setup and reposition attr = attribute.Attribute() nd = node.Node() #--- create joint jnt = None jnt_grp = nd.transform(name=self.side + '_' + name, suffix='GOFF', parent=self.ctl.transform) if self.flip: if self.upVectorOffset[0]: jnt = joint.Joint(side=self.side, name=name, suffix='GJNT', radius=self.size * 0.9, orientation=[0, 180, 0]) elif self.upVectorOffset[1]: jnt = joint.Joint(side=self.side, name=name, suffix='GJNT', radius=self.size * 0.9, orientation=[0, 0, 180]) elif self.upVectorOffset[2]: jnt = joint.Joint(side=self.side, name=name, suffix='GJNT', radius=self.size * 0.9, orientation=[180, 0, 0]) else: jnt = joint.Joint(side=self.side, name=name, suffix='GJNT', radius=self.size * 0.9) #--- zero out the joints position attr.setAttr(node=jnt.name, attribute='t', value=[0, 0, 0]) #--- setup and connect the joint labels if self.side == 'L' or self.side == 'l' or self.side == 'Left' or self.side == 'left': cmds.setAttr(jnt.name + '.side', 1) elif self.side == 'R' or self.side == 'r' or self.side == 'Right' or self.side == 'right': cmds.setAttr(jnt.name + '.side', 2) elif self.side == 'C' or self.side == 'c' or self.side == 'Center' or self.side == 'center': cmds.setAttr(jnt.name + '.side', 0) cmds.setAttr(jnt.name + '.type', 18) cmds.setAttr(jnt.name + '.otherType', name[0].upper() + name[1:], type='string') cmds.connectAttr(self.main_mod + '.showLabels', jnt.name + '.drawLabel') #--- set the displayType of the joints attr.setColor(node=jnt.name, displayType=0) #--- upVector setup up_vector = nd.locator(name=self.side + '_' + name, suffix='GLOC', parent=self.ctl.transform) #--- offset the position of the locator attr.setAttr(node=up_vector, attribute='t', value=self.upVectorOffset) #--- set the color of the upVector locators attr.setColor(node=up_vector, color=self.color) #--- store the nodes properly self.g_jnt.append(jnt.name) self.g_jnt_off.append(jnt_grp) self.g_loc.append(up_vector)
def __setup_mod(self): #--- in this method you create the mod setup hierarchy nd = node.Node() attr = attribute.Attribute() #--- check and create the constant guides group if cmds.objExists('GUIDES'): self.guide_grp = 'GUIDES' else: self.guide_grp = nd.transform(name='GUIDES', suffix=None) #--- check character name for whitespaces if '' in self.character: character = self.character.replace(' ', '_') #--- check and create the dynamic character group if self.character: if cmds.objExists(self.character): self.char_grp = self.character else: self.char_grp = nd.transform(name=self.character, parent=self.guide_grp) else: if cmds.objExists('CHARACTER'): self.char_grp = 'CHARACTER' else: self.char_grp = nd.transform(name='CHARACTER', parent=self.guide_grp) #--- check if mod hierarchy exists, otherwise create it properly if self.mod: if cmds.objExists(self.mod + '_GMOD'): self.main_mod = self.mod + '_GMOD' if cmds.objExists(self.mod + '_GTMP'): self.extras = self.mod + '_GTMP' else: self.extras = nd.transform(name=self.mod, suffix='GTMP', parent=self.main_mod) if cmds.objExists(self.side + '_' + self.mod + '_' + 'GMOD'): self.side_mod = self.side + '_' + self.mod + '_' + 'GMOD' else: self.side_mod = nd.transform(name=self.side + '_' + self.mod, suffix='GMOD', parent=self.main_mod) else: self.main_mod = nd.transform(name=self.mod, suffix='GMOD', parent=self.char_grp) self.side_mod = nd.transform(name=self.side + '_' + self.mod, suffix='GMOD', parent=self.main_mod) self.extras = nd.transform(name=self.mod, suffix='GTMP', parent=self.main_mod) else: if cmds.objExists('MOD_GMOD'): self.main_mod = self.side + '_MOD_GMOD' if cmds.objExists(self.side + '_MOD_GMOD'): self.side_mod = self.side + '_MOD_GMOD' else: self.side_mod = nd.transform(name=self.side + '_MOD', suffix='GMOD', parent=self.main_mod) else: self.main_mod = nd.transform(name='MOD', suffix='GMOD', parent=self.char_grp) self.side_mod = nd.transform(name=self.side + '_MOD', suffix='GMOD', parent=self.main_mod)
def create_node(self): #--- this method gets the translation values nd = node.Node() #--- get proper naming self.get_description() #--- get attribute info self.get_attribute_info() #--- get value_info self.get_value_info() #--- get lock info self.get_box_info() #--- get dropDown info and call node function if self.node == 'addDoubleLinear': nd.addDoubleLinear(name = self.composed_name, suffix = self.suffix) elif self.node == 'addMatrix': nd.addMatrix(name = self.composed_name, suffix = self.suffix) elif self.node == 'aimConstraint': nd.aimConstraint(target = self.value1, source = self.value2, name = self.composed_name, suffix = self.suffix, aimVector = self.value3, upVector = self.value4, worldUpObject = self.value5, worldUpType = self.value6, skip = self.value7) elif self.node == 'angleBetween': nd.angleBetween(name = self.composed_name, suffix = self.suffix) elif self.node == 'arrayMapper': nd.arrayMapper(name = self.composed_name, suffix = self.suffix) elif self.node == 'blendColors': nd.blendColors(name = self.composed_name, suffix = self.suffix, blender = self.value1, color1R = self.value2, color1G = self.value3, color1B = self.value4, color2R = self.value5, color2G = self.value6, color2B = self.value7, lockAttr = self.lock) elif self.node == 'blendTwoAttr': nd.blendTwoAttr(name = self.composed_name, suffix = self.suffix) elif self.node == 'bump2d': nd.bump2d(name = self.composed_name, suffix = self.suffix) elif self.node == 'bump3d': nd.bump3d(name=self.composed_name, suffix = self.suffix) elif self.node == 'choice': nd.choice(name=self.composed_name, suffix = self.suffix) elif self.node == 'chooser': nd.chooser(name=self.composed_name, suffix = self.suffix) elif self.node == 'clamp': nd.clamp(name=self.composed_name, suffix = self.suffix) elif self.node == 'closestPointOnMesh': nd.closestPointOnMesh(name=self.composed_name, suffix = self.suffix) elif self.node == 'closestPointOnSurface': nd.closestPointOnSurface(name=self.composed_name, suffix = self.suffix) elif self.node == 'colorProfile': nd.colorProfile(name=self.composed_name, suffix = self.suffix) elif self.node == 'composeMatrix': nd.composeMatrix(name=self.composed_name, suffix = self.suffix) elif self.node == 'condition': nd.condition(name = self.composed_name, suffix = self.suffix, firstTerm = self.value1, secondTerm = self.value2, operation = self.value3, colorIfTrueR = self.value4, colorIfTrueG = self.value5, colorIfTrueB = self.value6, colorIfFalseR = self.value7, colorIfFalseG = self.value8, colorIfFalseB = self.value9, lockAttr = self.lock) elif self.node == 'contrast': nd.contrast(name=self.composed_name, suffix = self.suffix) elif self.node == 'curveInfo': nd.curveInfo(name=self.composed_name, suffix = self.suffix) elif self.node == 'decomposeMatrix': nd.decomposeMatrix(name=self.composed_name, suffix = self.suffix) elif self.node == 'distanceBetween': nd.distanceBetween(name=self.composed_name, suffix = self.suffix, point1 = self.value1, point2 = self.value2, inMatrix1 = self.value3, inMatrix2 = self.value4, lockAttr = self.lock) elif self.node == 'doubleSwitch': nd.doubleSwitch(name=self.composed_name, suffix = self.suffix) elif self.node == 'eLocator': nd.eLocator(name=self.composed_name, suffix = self.suffix, size = self.value1, color = self.value2, lockAttr = self.lock) elif self.node == 'follicle': nd.follicle(name=self.composed_name, suffix = self.suffix, parameterU = self.value1, parameterV = self.value2, parent = self.value3, show = self.value4, lockAttr = self.lock) elif self.node == 'frameCache': nd.frameCache(name=self.composed_name, suffix = self.suffix) elif self.node == 'gammaCorrect': nd.gammaCorrect(name=self.composed_name, suffix = self.suffix) elif self.node == 'heightField': nd.heightField(name=self.composed_name, suffix = self.suffix) elif self.node == 'hsvToRgb': nd.hsvToRgb(name=self.composed_name, suffix = self.suffix) elif self.node == 'inverseMatrix': nd.inverseMatrix(name=self.composed_name, suffix = self.suffix) elif self.node == 'lightInfo': nd.lightInfo(name=self.composed_name, suffix = self.suffix) elif self.node == 'locator': nd.locator(name=self.composed_name, suffix = self.suffix, position = self.value1, rotation = self.value2, worldSpace = self.value3, parent = self.value4) elif self.node == 'luminance': nd.luminance(name=self.composed_name, suffix = self.suffix) elif self.node == 'mirrorSwitch': nd.mirrorSwitch(name=self.composed_name, suffix = self.suffix, mirror = self.value1, mirrorAxis = self.value2, lockAttr = self.lock) elif self.node == 'multDoubleLinear': nd.multDoubleLinear(name=self.composed_name, suffix = self.suffix, input1 = self.value1, input2 = self.value2, lockAttr = self.lock) elif self.node == 'multiplyDivide': nd.multiplyDivide(name=self.composed_name, suffix = self.suffix, operation = self.value1, input1X = self.value2, input1Y = self.value3, input1Z = self.value4, input2X = self.value5, input2Y = self.value6, input2Z = self.value7, lockAttr = self.lock) elif self.node == 'nearestPointOnCurve': nd.nearestPointOnCurve(name=self.composed_name, suffix = self.suffix) elif self.node == 'orientConstraint': nd.orientConstraint(name=self.composed_name, suffix = self.suffix, objA = self.value1, objB = self.value2, maintainOffset = self.value3) elif self.node == 'parentConstraint': nd.parentConstraint(name=self.composed_name, suffix = self.suffix, objA = self.value1, objB = self.value2, maintainOffset = self.value3, lock = self.value4) elif self.node == 'particleSampler': nd.particleSampler(name=self.composed_name, suffix = self.suffix) elif self.node == 'place2dTexture': nd.place2dTexture(name=self.composed_name, suffix = self.suffix) elif self.node == 'place3dTexture': nd.place3dTexture(name=self.composed_name, suffix = self.suffix) elif self.node == 'plusMinusAverage': nd.plusMinusAverage(name=self.composed_name, suffix = self.suffix, operation = self.value1, lockAttr = self.lock) elif self.node == 'pointConstraint': nd.pointConstraint(name=self.composed_name, suffix = self.suffix, objA = self.value1, objB = self.value2, maintainOffset = self.value3, lock = self.value4) elif self.node == 'pointMatrixMult': nd.pointMatrixMult(name=self.composed_name, suffix = self.suffix) elif self.node == 'pointOnCurveInfo': nd.pointOnCurveInfo(name=self.composed_name, suffix = self.suffix) elif self.node == 'pointOnPolyConstraint': nd.pointOnPolyConstraint(name=self.composed_name, suffix = self.suffix) elif self.node == 'pointOnSurfaceInfo': nd.pointOnSurfaceInfo(name=self.composed_name, suffix = self.suffix) elif self.node == 'poleVectorConstraint': nd.poleVectorConstraint(name=self.composed_name, suffix = self.suffix, objA = self.value1, objB = self.value2) elif self.node == 'projection': nd.projection(name=self.composed_name, suffix = self.suffix) elif self.node == 'quadSwitch': nd.quadSwitch(name=self.composed_name, suffix = self.suffix) elif self.node == 'remapColor': nd.remapColor(name=self.composed_name, suffix = self.suffix) elif self.node == 'remapHsv': nd.remapHsv(name=self.composed_name, suffix = self.suffix) elif self.node == 'remapValue': nd.remapValue(name=self.composed_name, suffix = self.suffix, inputValue = self.value1, inputMin = self.value2, inputMax = self.value3, outputMin = self.value4, outputMax = self.value5, lockAttr = self.lock) elif self.node == 'reverse': nd.reverse(name=self.composed_name, suffix = self.suffix, inputX = self.value2, inputY = self.value2, inputZ = self.value3, lockAttr = self.lock) elif self.node == 'rgbToHsv': nd.rgbToHsv(name=self.composed_name, suffix = self.suffix) elif self.node == 'samplerInfo': nd.samplerInfo(name=self.composed_name, suffix = self.suffix) elif self.node == 'scaleConstraint': nd.scaleConstraint(name=self.composed_name, suffix = self.suffix, objA = self.value1, objB = self.value2, maintainOffset = self.value3) elif self.node == 'setRange': nd.setRange(name=self.composed_name, suffix = self.suffix) elif self.node == 'singleSwitch': nd.singleSwitch(name=self.composed_name, suffix = self.suffix) elif self.node == 'stencil': nd.stencil(name=self.composed_name, suffix = self.suffix) elif self.node == 'surfaceInfo': nd.surfaceInfo(name=self.composed_name, suffix = self.suffix) elif self.node == 'surfaceLuminance': nd.surfaceLuminance(name=self.composed_name, suffix = self.suffix) elif self.node == 'transform': nd.transform(name=self.composed_name, suffix = self.suffix, position = self.value1, parent = self.value2) elif self.node == 'transposeMatrix': nd.transposeMatrix(name=self.composed_name, suffix = self.suffix) elif self.node == 'tripleSwitch': nd.tripleSwitch(name=self.composed_name, suffix = self.suffix) elif self.node == 'unitConversion': nd.unitConversion(name=self.composed_name, suffix = self.suffix) elif self.node == 'vectorProduct': nd.vectorProduct(name=self.composed_name, suffix = self.suffix) #--- save the created node information in code self.save_code_info() #--- clear all fields and checkboxes self.clear_all()
def __setup_flexiplane(self): #--- this method setups the flexiplane properly attr = attribute.Attribute() nd = node.Node() #--- reorient the flexiplane attr.setAttr(node=self.spine_flexiplane.control_main.transform, attribute='rz', value=90) attr.lockAttr(node=self.spine_flexiplane.control_main.group, attribute=['t', 'r', 's'], lock=False, show=True) #--- parent the main control of the flexiplane to the cog control cmds.parent(self.spine_flexiplane.control_main.group, self.pelvis_control.transform) #--- get the position of the mid control mid_pos = cmds.xform(self.spine_flexiplane.control_mid.transform, query=True, rotatePivot=True, worldSpace=True) #--- create mid control self.mid_control = control.Control(side=self.side, name=self.mod + 'MidFK', suffix='CTL', size=self.size + 1, shape=0, color=self.color, position=mid_pos, rotation=[0, 0, 0], orientation=[0, 0, 0], lockAttrs=['t', 's', 'v']) cmds.parent(self.mid_control.group, self.pelvis_control.transform) #--- create another group above the mid_control self.vert_up_grp = cmds.group(self.mid_control.transform, name=self.side + '_' + self.mod + 'MidUpFK_GRP') #--- pointConstraint the flexiPlane mid control to the mid control nd.pointConstraint(objA=self.mid_control.transform, objB=self.spine_flexiplane.control_mid.group, suffix='PCN', maintainOffset=True) #--- reposition the pivot of the ribcage group cmds.xform(self.ribcage_control.group, pivots=mid_pos, worldSpace=True) #--- orientConstraint the ribcage control to vert control nd.orientConstraint(objA=self.mid_control.transform, objB=self.ribcage_control.group, suffix='OCN', maintainOffset=True) #--- create utility nodes mid_ctl_pma = nd.plusMinusAverage(name=self.side + '_' + self.mod + 'MidCtl', operation=3) mid_cls_pma = nd.plusMinusAverage(name=self.side + '_' + self.mod + 'MidCls', operation=3) multi_pma = nd.plusMinusAverage(name=self.side + '_' + self.mod + 'Multi', operation=3) mid_cls_mlt = nd.multiplyDivide(name=self.side + '_' + self.mod + 'MidCls', input2X=2, input2Y=2, lockAttr=['input2X', 'input2Y']) rot_up_pma = nd.plusMinusAverage(name=self.side + '_' + self.mod + 'RotUpFlp', operation=1) #--- connect nodes attr.connectAttr(node=[self.ribcage_control.transform, mid_ctl_pma], attribute=['ty', 'input1D[0]']) attr.connectAttr(node=[self.hip_control.transform, mid_ctl_pma], attribute=['ty', 'input1D[1]']) attr.connectAttr(node=[mid_ctl_pma, self.vert_up_grp], attribute=['output1D', 'ty']) attr.connectAttr(node=[self.vert_up_grp, mid_cls_mlt], attribute=['ty', 'input1X']) attr.connectAttr(node=[self.mid_control.transform, mid_cls_mlt], attribute=['ty', 'input1Y']) attr.connectAttr(node=[self.ribcage_control.transform, multi_pma], attribute=['ty', 'input1D[0]']) attr.connectAttr(node=[self.hip_control.transform, multi_pma], attribute=['ty', 'input1D[1]']) attr.connectAttr(node=[mid_cls_mlt, multi_pma], attribute=['outputX', 'input1D[2]']) attr.connectAttr(node=[mid_cls_mlt, multi_pma], attribute=['outputY', 'input1D[3]']) #--- unlock ty attribute of the mid cluster group attr.lockAttr(node=self.spine_flexiplane.clstr_mid_grp, attribute=['t'], lock=False) attr.connectAttr(node=[multi_pma, self.spine_flexiplane.clstr_mid_grp], attribute=['output1D', 'tx']) attr.connectAttr(node=[ self.spine_flexiplane.control_mid.group, self.spine_flexiplane.clstr_mid_grp ], attribute=['ty', 'ty']) attr.connectAttr(node=[ self.spine_flexiplane.control_mid.group, self.spine_flexiplane.clstr_mid_grp ], attribute=['tz', 'tz']) attr.connectAttr(node=[self.ribcage_control.transform, rot_up_pma], attribute=['ry', 'input1D[0]']) attr.connectAttr(node=[self.mid_control.transform, rot_up_pma], attribute=['ry', 'input1D[1]']) attr.connectAttr( node=[rot_up_pma, self.spine_flexiplane.control_up.transform], attribute=['output1D', 'rx']) attr.connectAttr(node=[ self.hip_control.transform, self.spine_flexiplane.control_down.transform ], attribute=['ry', 'rx'])