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 __create_chain(self, side=None, name=None, suffix=None, position=[0, 0, 0], orientation=[0, 0, 0], ikSolver='ikRPsolver', ikCurve=None, ikName=None, offset=[0, 0, 0], amount=0, mirror=True, radius=1, parentJoint=None, parentIk=None): #--- this method creates the ikChain cmds.select(clear=True) ik_chain = [] if isinstance(name, list): for i in range(len(name)): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0 + i, 0, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: if not len(orientation) == len(name): jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=position[i], orientation=orientation, parent=True, radius=radius) else: jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=position[i], orientation=orientation[i], parent=True, radius=radius) ik_chain.append(jnt.name) else: for i in range(amount): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [offset[0] + i, 0, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: if not len(orientation) == len(name): jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=position[i], orientation=orientation, parent=True, radius=radius) else: jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=position[i], orientation=orientation[i], parent=True, radius=radius) ik_chain.append(jnt.name) cmds.select(clear=1) self.ik_joint_names = ik_chain #--- reorient the jointChain for i in self.ik_joint_names: cmds.joint(i, edit=True, zeroScaleOrient=True, orientJoint='xyz', secondaryAxisOrient='yup') #--- zero out the jointOrient values of the last joint cmds.setAttr(self.ik_joint_names[-1] + '.jointOrient', 0, 0, 0) #--- create ikHandle self.__create_ik_handle(side=side, name=name, suffix=suffix, ikSolver=ikSolver, ikCurve=ikCurve, ikName=ikName) #--- mirror joints if mirror: self.__mirror_chain(side=side) #--- parent the joints and ikHandles #--- joints if parentJoint: if mirror: if isinstance(parentJoint, list): if len(parentJoint) == 2: cmds.parent(self.ik_joint_names[0], parentJoint[0]) cmds.parent(self.mirrored_ik_joint_names[0], parentJoint[1]) else: raise Exception( 'First element is left and second is right!' 'You have to specify proper parent nodes!') else: cmds.parent(self.ik_joint_names[0], self.mirrored_ik_joint_names[0], parentIk) else: cmds.parent(self.ik_joint_names[0], parentJoint) #-- ikHandles if parentIk: if mirror: if isinstance(parentIk, list): if len(parentIk) == 2: cmds.parent(self.ik_handle_names[0], parentIk[0]) cmds.parent(self.mirrored_ik_handle_names[0], parentIk[1]) else: raise Exception( 'First element is left and second is right!' 'You have to specify proper parent nodes!') else: cmds.parent(self.ik_handle_names[0], self.mirrored_ik_handle_names[0], parentIk) else: cmds.parent(self.ik_handle_names[0], parentIk)
def create_chain(self, side=None, name=[], suffix=None, position=[], orientation=[], offset=[0, 0, 0], amount=3, mirror=False, radius=1): fk_chain = [] if isinstance(name, list): for i in range(len(name)): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [offset[0] + i, 0, 0] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: jnt = joint.Joint(side=side, name=name[i] + 'FK', suffix=suffix, position=position[i], orientation=orientation[i], parent=True, radius=radius) fk_chain.append(jnt.name) else: for i in range(amount): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [offset[0] + i, 0, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=off, parent=True, radius=radius) fk_chain.append(jnt.name) else: jnt = joint.Joint(side=side, name=name + ` i ` + 'FK', suffix=suffix, position=position[i], orientation=orientation[i], parent=True, radius=radius) fk_chain.append(jnt.name) cmds.select(clear=1) self.fk_joint_names = fk_chain #mirror joints if specified if mirror == True: self.mirror_chain(side=side) return fk_chain
def __create_chain(self, side=None, name=None, suffix=None, position=[0, 0, 0], orientation=[0.0, 0.0, 0.0], offset=[0, 0, 0], amount=3, mirror=False, radius=1): #--- this method creates a joint chain by specified flags and values jnt_chain = [] if isinstance(name, list): for i in range(len(name)): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [offset[0] + i, 0, 0] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: jnt = joint.Joint(side=side, name=name[i], suffix=suffix, position=position[i], orientation=orientation[i], parent=True, radius=radius) jnt_chain.append(jnt.name) else: for i in range(amount): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [offset[0] + i, 0, 0] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=off, parent=True, radius=radius) jnt_chain.append(jnt.name) else: jnt = joint.Joint(side=side, name=name + ` i `, suffix=suffix, position=position[i], orientation=orientation[i], parent=True, radius=radius) jnt_chain.append(jnt.name) cmds.select(clear=1) self.joint_names = jnt_chain #--- reorient the jointChain for i in self.joint_names: cmds.joint(i, edit=True, zeroScaleOrient=True, orientJoint='xyz', secondaryAxisOrient='yup') #--- zero out the jointOrient values of the last joint cmds.setAttr(self.joint_names[-1] + '.jointOrient', 0, 0, 0) #--- mirror joints if specified if mirror: self.__mirror_chain(side=side) return jnt_chain
def create_chain(self, side=None, name=[], suffix=None, position=[], ik_solver='ikRPsolver', ikCurve=None, ikName=None, offset=[0, 0, 0], amount=3, mirror=True, radius=1): ik_chain = [] if type(name).__name__ == 'list': for i in range(len(name)): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0 + i, 0, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: jnt = joint.Joint(side=side, name=name[i] + 'IK', suffix=suffix, position=position[i], parent=True, radius=radius) ik_chain.append(jnt.name) else: for i in range(amount): if position == []: if offset == [0, 0, 0]: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) elif offset[0] > 0: if offset[1] > 0: if offset[2] > 0: off = [ offset[0] + i, offset[1] + i, offset[2] + i ] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [offset[0] + i, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [offset[0] + i, 0, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: if offset[1] > 0: if offset[2] > 0: off = [0, offset[1] + i, offset[2] + i] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, offset[1] + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: off = [0, 0 + i, 0] jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=off, parent=True, radius=radius) ik_chain.append(jnt.name) else: jnt = joint.Joint(side=side, name=name + ` i ` + 'IK', suffix=suffix, position=position[i], parent=True, radius=radius) ik_chain.append(jnt.name) cmds.select(clear=1) self.ik_joint_names = ik_chain #create ikHandle self.create_ik_handle(side=side, name=name, suffix=suffix, ik_solver=ik_solver, ikCurve=ikCurve, ikName=ikName) #mirror joints if specified if mirror == True: self.mirror_chain(side=side) return ik_chain