def __init__(self, name_, *args, **kwargs): self.base_name = name_ self.sel = ls(sl=1, fl=1, r=1) prefixList = ['attach', 'attach'] suffixList = ['CTL', 'JNT'] attachGRPs = self.attach_structure(self.base_name) ordict_ = OrderedDict() nulls = _curve.curve_at_null(self.sel[0]) ordict_['CTLs'] = _control.control_(nulls, 'octah') ordict_['JNTs'] = _joint.object_at_joint(nulls) delete(nulls) for i, value in enumerate(ordict_.values()): _name.renamer(value, name_=self.base_name, prefix_=prefixList[i], suffix_=suffixList[i]) CTL_off = [_node.offset_(CTL, num_=2) for CTL in ordict_['CTLs']] JNT_off = [_node.offset_(JNT, num_=2) for JNT in ordict_['JNTs']] JNT_spc = [JNT.getParent() for JNT in ordict_['JNTs']] _connect.subtract(ordict_['CTLs']) self.connect_attrs(ls(ordict_['CTLs'], JNT_spc), 't', 't') self.connect_attrs(ls(ordict_['CTLs'], JNT_spc), 'r', 'r') self.connect_attrs(ls(ordict_['CTLs'], JNT_spc), 's', 's') self.poci_connect(ls(self.sel[0], CTL_off)) [parent(CTL, attachGRPs['CTL']) for CTL in CTL_off] [parent(JNT, attachGRPs['JNT']) for JNT in JNT_off]
def fourDirectionsCtrl(object_): spc_ = _node.space_(object_.name()) values = [0, 90, 180, -90] name = object_.name().split('Ctrl')[0] for i, value in enumerate(values): name_ = '{0}{1}Ctrl'.format(name, i + 1) ctrl_ = _control.control_([object_], 'triangle') ctrl_[0].rename(name_) grp_ = _node.offset_(ctrl_[0], num_=2) chd_ = grp_.getChildren()[0] chd_.attr('rx').set(value) parent(grp_, spc_)
def __init__(self, name_, up_=None, *args, **kwargs): self.base_name = name_ self.sel = ls(sl=1, r=1, fl=1) hybridGRPs = self.hybrid_structure(self.base_name) ordict_ = OrderedDict() prefixList = ['FK', 'IK', 'FK', 'IK', 'IK_space', 'IK_upVec', 'IK_bind', 'IK', 'IK_upVec'] suffixList = ['JNT', 'JNT', 'CTL', 'CRV', 'LOC', 'LOC', 'JNT', 'CTL', 'CRV'] ordict_['FKJNTs'] = _joint.duplicate_joint(self.sel[0]) ordict_['IKJNTs'] = _joint.duplicate_joint(self.sel[0]) ordict_['FKCTLs'] = _control.control_(ordict_['FKJNTs'], 'cube') _connect.chain_structure(ordict_['FKCTLs']) ordict_['IKCRV'] = [_curve.object_cv_curve(ordict_['IKJNTs'], dgree_=1)] _curve.rebuild_curve(ordict_['IKCRV'], ch=1, rpo=1, rt=0, end=1, kr=2, kcp=0, kep=1, kt=0, s=2, d=3, tol=0.01 ) ordict_['IKLOC'] = [_node.locator_(JNT) for JNT in ordict_['IKJNTs']] ordict_['IKupVec'] = [_node.locator_(JNT) for JNT in ordict_['IKJNTs']] [parent(LOC,ordict_['IKLOC'][i]) for i,LOC in enumerate(ordict_['IKupVec'])] IKGuideCRV = [_curve.object_cv_curve(ordict_['IKupVec'], dgree_=1)] _curve.rebuild_curve(IKGuideCRV, ch=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=2, d=1, tol=0.01 ) ordict_['IKBindJNT'] = _curve.curve_at_joint(IKGuideCRV[0]) _joint.joint_orient(ordict_['IKBindJNT'], e=True, oj='xzy', sao='zup', zso=True ) [parent(JNT, w=1) for JNT in ordict_['IKBindJNT']] ordict_['IKCTLs'] = _control.control_(ordict_['IKBindJNT'], 'circle') upTrans = 'tz' if up_: if up_ == 'x': upTrans = 'tx' elif up_ == 'y': upTrans = 'ty' elif up_ == 'z': upTrans = 'tz' [LOC.setAttr(upTrans, 3) for LOC in ordict_['IKupVec']] [parent(LOC, w=1)for LOC in ordict_['IKupVec']] delete(IKGuideCRV) ordict_['IKupVecCRV'] = [_curve.object_cv_curve(ordict_['IKupVec'], dgree_=1)] _curve.rebuild_curve(ordict_['IKupVecCRV'], ch=1, rpo=1, rt=0, end=1, kr=2, kcp=0, kep=1, kt=0, s=2, d=3, tol=0.01 ) for i,value in enumerate(ordict_.values()): _name.renamer(value, name_=self.base_name, prefix_=prefixList[i], suffix_=suffixList[i] ) # FK Setting FK_off_space = [_node.offset_(i, num_=2) for i in ordict_['FKCTLs']] FK_cnt_space = [_node.insert_space(CTL,'cnt') for CTL in ordict_['FKCTLs']] FK_spc_space = [CTL.getParent(2) for CTL in ordict_['FKCTLs']] ordict_['FKJNTs'][0].setAttr('jointOrient', (0,0,0)) _matrix.matrixConsts(ls(ordict_['FKCTLs'], ordict_['FKJNTs']), 'local', t='t', r='r', s='s') self.connect_attrs(ls(ordict_['IKJNTs'], FK_off_space), 't', 't' ) self.connect_attrs(ls(ordict_['IKJNTs'], FK_off_space), 'r', 'r' ) # IK Setting IK_off_space = [_node.offset_(CTL, num_=2) for CTL in ordict_['IKCTLs']] IK_loc_offset = [_node.offset_(LOC, num_=2) for LOC in ordict_['IKLOC']] upVec_offset = [_node.offset_(LOC, num_=2) for LOC in ordict_['IKupVec']] IK_bind_offset = [_node.offset_(LOC, num_=2) for LOC in ordict_['IKBindJNT']] _curve.param_at_objectPositions(ls(ordict_['IKCRV'], IK_loc_offset)) _curve.param_at_objectPositions(ls(ordict_['IKupVecCRV'], upVec_offset)) self.IK_Axis(ordict_['IKCTLs'], IK_loc_offset, ordict_['IKLOC'], ordict_['IKupVec']) _matrix.matrixConsts(ls(ordict_['IKLOC'], ordict_['IKJNTs']), 'local', t='t', r='r', s='s') [JNT.setAttr('jointOrient', (0,0,0)) for JNT in ordict_['IKJNTs']] _matrix.matrixConsts(ls(ordict_['IKCTLs'], IK_bind_offset), 'local', t='t', r='r', s='s') JNTs = ls(ordict_['FKJNTs'][0], ordict_['IKJNTs'][0]) CRVs = ls(ordict_['IKCRV'], ordict_['IKupVecCRV']) [parent(JNT, hybridGRPs['bind_JNT']) for JNT in IK_bind_offset] [parent(JNT, hybridGRPs['JNT']) for JNT in JNTs] [parent(CRV, hybridGRPs['CRV']) for CRV in CRVs] parent(FK_off_space[0], hybridGRPs['FK_CTL']) [parent(CTL, hybridGRPs['IK_CTL']) for CTL in IK_off_space] [parent(LOC, hybridGRPs['IK_space']) for LOC in IK_loc_offset] [parent(LOC, hybridGRPs['IK_upVec']) for LOC in upVec_offset] bindList = ls(ordict_['IKCRV'], ordict_['IKupVecCRV']) for bind in bindList: _joint.bindSkin_(ls(ordict_['IKBindJNT'],bind), n='{}_skinCluster'.format(self.base_name), tsb=False, bm=0, sm=0, nw=1, mi=1, dr=4.0, )
def __init__(self, name_, *args, **kwargs): self.base_name = name_ self.sel = ls(sl=1, r=1, fl=1) _joint.linear_spacing_joint(self.sel[0], 3, e=True, axis='x' ) mainGRPs = self.main_structure(name_) ordict_ = OrderedDict() prefixList = ['main', 'main_FK', 'main_IK', 'main_FK', 'main_IK', 'FK_IK', 'FK_IK', 'FK_IK'] suffixList = ['JNT', 'JNT', 'JNT', 'CTL', 'CTL', 'PRBL', 'BLCL', 'RVS'] ordict_['baseJNTs'] = _joint.duplicate_joint(self.sel[0]) ordict_['FKJNTs'] = _joint.duplicate_joint(self.sel[0]) ordict_['IKJNTs'] = _joint.duplicate_joint(self.sel[0]) ordict_['FKCTLs'] = _control.control_(ordict_['FKJNTs'], 'circle') ordict_['IKCTLs'] = _control.control_(ordict_['IKJNTs'], 'circle') PRBLs, BLCLs = self.IK_FK_Blend(ls(ordict_['IKJNTs'], ordict_['FKJNTs']), ordict_['baseJNTs']) ordict_['PRBLs'] = PRBLs ordict_['BLCLs'] = BLCLs ordict_['RVS'] = ls(_node.reverse_()) for i,value in enumerate(ordict_.values()): _name.renamer(value, name_=self.base_name, prefix_=prefixList[i], suffix_=suffixList[i]) # FK Setting _connect.chain_structure(ordict_['FKCTLs']) FKCTLoffset = [_node.offset_(i, num_=2) for i in ordict_['FKCTLs']] # self.connect_attrs(ls(ordict_['FKCTLs'], ordict_['FKJNTs']), 'r', 'r') _matrix.matrixConsts(ls(ordict_['FKCTLs'], ordict_['FKJNTs']), 'local', t='t', r='r', s='s') # IK Setting IKCTLoffset = [_node.offset_(i, num_=2) for i in ordict_['IKCTLs']] _matrix.matrixConsts(ls(ordict_['IKCTLs'], ordict_['IKJNTs']), 'local', t='t', r='r', s='s') IKConstList = {0:[ordict_['IKCTLs'][0], ordict_['IKCTLs'][-1], ordict_['IKCTLs'][2].getParent(2)], 1:[ordict_['IKCTLs'][0], ordict_['IKCTLs'][2], ordict_['IKCTLs'][1].getParent(2)], 2:[ordict_['IKCTLs'][-1], ordict_['IKCTLs'][2], ordict_['IKCTLs'][3].getParent(2)]} IKConsts = [_connect.n_to_one_constrain(i,'parent',mo_=1) for i in IKConstList.values()] [i[0].setAttr('interpType', 2) for i in IKConsts] [parent(JNTs_[0], mainGRPs['JNT']) for JNTs_ in ordict_.values()[:3]] parent(ordict_['FKCTLs'][0].getParent(2), mainGRPs['FK_CTL']) [parent(CTLs_.getParent(2), mainGRPs['IK_CTL']) for CTLs_ in ordict_['IKCTLs']] _connect.one_to_n_connect(ls(mainGRPs['main'], ordict_['PRBLs']), 'FK_IK', 'weight') _connect.one_to_n_connect(ls(mainGRPs['main'], ordict_['BLCLs']), 'FK_IK', 'blender') self.connect_attrs(ls(mainGRPs['main'], ordict_['RVS']), 'FK_IK', 'ix') self.connect_attrs(ls(mainGRPs['main'], mainGRPs['FK_CTL']), 'FK_IK', 'v') self.connect_attrs(ls(ordict_['RVS'], mainGRPs['IK_CTL']), 'ox', 'v')