def leverBAK(self, ml_handles=None): try: _str_func = 'lever' log_start(_str_func) mBlock = self.mBlock mRigNull = self.mRigNull _offset = self.v_offset _jointOrientation = self.d_orientation['str'] ml_formHandles = self.ml_formHandles #Get our curves... ml_targets = [] for i, mHandle in enumerate(ml_formHandles[:2]): ml_targets.append(mHandle.loftCurve) if i: continue ml_sub = mHandle.msgList_get('subShapers') if ml_sub: for mSub in ml_sub: ml_targets.append(mSub) ml_new = [] for mTar in ml_targets: mDup = mTar.doDuplicate(po=False) DIST.offsetShape_byVector(mDup.mNode, _offset) mDup.p_parent = False ml_new.append(mDup) CURVES.connect([mTar.mNode for mTar in ml_new], mode='even') return ml_new[0] mLeverControlJoint = mRigNull.getMessageAsMeta('leverDirect') mLeverControlFK = mRigNull.getMessageAsMeta('leverFK') if not mLeverControlJoint: mLeverControlJoint = mLeverControlFK else: mLeverControlJoint = mLeverControlJoint log.debug("|{0}| >> mLeverControlJoint: {1}".format( _str_func, mLeverControlJoint)) dist_lever = DIST.get_distance_between_points( ml_prerigHandles[0].p_position, ml_prerigHandles[1].p_position) log.debug("|{0}| >> Lever dist: {1}".format(_str_func, dist_lever)) #Dup our rig joint and move it mDup = mLeverControlJoint.doDuplicate() mDup.p_parent = mLeverControlJoint mDup.resetAttrs() ATTR.set(mDup.mNode, 't{0}'.format(_jointOrientation[0]), dist_lever * .8) mDup2 = mDup.doDuplicate() ATTR.set(mDup2.mNode, 't{0}'.format(_jointOrientation[0]), dist_lever * .25) ml_clavShapes = BUILDUTILS.shapes_fromCast( self, targets=[ mDup2.mNode, #ml_fkJoints[0].mNode], mDup.mNode ], aimVector=self.d_orientation['vectorOut'], offset=_offset, f_factor=0, mode='frameHandle') mHandleFactory.color(ml_clavShapes[0].mNode, controlType='main') CORERIG.shapeParent_in_place(mLeverControlFK.mNode, ml_clavShapes[0].mNode, True, replaceShapes=True) #CORERIG.shapeParent_in_place(mLeverFKJnt.mNode,ml_clavShapes[0].mNode, False, replaceShapes=True) mc.delete([mShape.mNode for mShape in ml_clavShapes] + [mDup.mNode, mDup2.mNode]) except Exception, err: cgmGEN.cgmExceptCB(Exception, err, localDat=vars())
def ik_bankRollShapes(self): try: _str_func = 'bankRollShapes' log.debug(cgmGEN.logString_sub(_str_func)) mBlock = self.mBlock mRigNull = self.mRigNull mHandleFactory = self.mHandleFactory _offset = self.v_offset _jointOrientation = self.d_orientation['str'] ml_formHandles = self.ml_formHandles ml_fkShapes = [] mBallFK = False mToeFK = False mToeIK = False mBallIK = False _minRot = -90, _maxRot = 90 mMesh_tmp = self.mBlock.atUtils('get_castMesh', pivotEnd=1) str_meshShape = mMesh_tmp.getShapes()[0] #if self.mPivotHelper: # size_pivotHelper = POS.get_bb_size(self.mPivotHelper.mNode) #else: # size_pivotHelper = POS.get_bb_size(ml_formHandles[-1].mNode) #reload(SHAPECASTER) _d_cast = { 'vectorOffset': _offset, 'points': 15, #'minRot':-90,'maxRot':90, 'closedCurve': False } _max = None if self.mBall: try: _max = RAYS.get_dist_from_cast_axis( self.mBall.mNode, self.d_orientation['str'][2], shapes=str_meshShape) except: _max = 1 _d_cast['maxDistance'] = _max crvBall = SHAPECASTER.createMeshSliceCurve(str_meshShape, self.mBall.mNode, **_d_cast) if not self.mToe: pos = RAYS.get_cast_pos(self.mBall.mNode, shapes=mMesh_tmp.mNode) pos_me = self.mBall.p_position dist = DIST.get_distance_between_points(pos, pos_me) / 2 pos_end = DIST.get_pos_by_vec_dist(pos_me, [0, 0, 1], dist) mDup = self.mBall.doDuplicate(po=True) mDup.p_position = pos_end crvBall2 = SHAPECASTER.createMeshSliceCurve( str_meshShape, mDup.mNode, **_d_cast) CURVES.connect([crvBall, crvBall2], 7) mDup.delete() mHandleFactory.color(crvBall, controlType='sub') mBallFK = self.mBall.getMessageAsMeta('fkJoint') CORERIG.shapeParent_in_place(mBallFK.mNode, crvBall, True, replaceShapes=True) if self.str_ikRollSetup == 'control': log.debug(cgmGEN.logString_msg(_str_func, "Ball Ik control...")) mBallIK = self.mBall.doCreateAt(setClass=True) CORERIG.shapeParent_in_place(mBallIK.mNode, crvBall, True, replaceShapes=True) mRigNull.connectChildNode(mBallIK, 'controlIKBall', 'rigNull') #Connect mBallIK.doCopyNameTagsFromObject(self.mBall.mNode, ignore=['cgmType']) mBallIK.doStore('cgmTypeModifier', 'ik') mBallIK.doName() mBallIK.connectChildNode(self.mBall.fkJoint.blendJoint.mNode, 'blendJoint') #Connect #Hinge =================================================================== log.debug( cgmGEN.logString_msg(_str_func, "Ball Hinge Ik control...")) #Need to make our cast locs mStart = mBallIK.doCreateAt(setClass=1) mEnd = mBallIK.doCreateAt(setClass=1) pos1_start = self.mBall.getParent(asMeta=1).p_position pos2_start = mEnd.p_position vec_to_end = MATH.get_vector_of_two_points( pos1_start, pos2_start) vec_to_start = MATH.get_vector_of_two_points( pos2_start, pos1_start) mStart.p_position = DIST.get_average_position( [pos1_start, pos2_start]) #DIST.get_pos_by_vec_dist(pos1_start,vec_to_end,_offset)# mEnd.p_position = DIST.get_pos_by_vec_dist( pos2_start, vec_to_start, _offset) crv1 = SHAPECASTER.createMeshSliceCurve( str_meshShape, mStart.mNode, **_d_cast) crv2 = SHAPECASTER.createMeshSliceCurve( str_meshShape, mEnd.mNode, **_d_cast) CURVES.connect([crv1, crv2], 7) mBallHingeIK = self.mBall.doCreateAt(setClass=True) mRigNull.connectChildNode(mBallHingeIK, 'controlIKBallHinge', 'rigNull') #Connect mBallHingeIK.connectChildNode( self.mBall.fkJoint.blendJoint.mNode, 'blendJoint') #Connect mHandleFactory.color(crv1, controlType='sub') CORERIG.shapeParent_in_place(mBallHingeIK.mNode, crv1, True, replaceShapes=True) mBallHingeIK.doCopyNameTagsFromObject(self.mBall.mNode, ignore=['cgmType']) mBallHingeIK.doStore('cgmNameModifier', 'hinge') mBallHingeIK.doStore('cgmTypeModifier', 'ik') mBallHingeIK.doName() for mObj in mStart, mEnd: mObj.delete() ml_fkShapes.append(cgmMeta.asMeta(crv1)) ml_fkShapes.append(cgmMeta.validateObjArg(crvBall, 'cgmObject')) if self.mToe: if not _max: _max = RAYS.get_dist_from_cast_axis( self.mToe.mNode, self.d_orientation['str'][2], shapes=str_meshShape) _d_cast['maxDistance'] = _max crv = SHAPECASTER.createMeshSliceCurve(str_meshShape, self.mToe.mNode, **_d_cast) """ crv = CURVES.create_controlCurve(self.mToe.mNode, shape='circle', direction = _jointOrientation[0]+'+', sizeMode = 'fixed', size = size_pivotHelper[0])""" mHandleFactory.color(crv, controlType='sub') mToeFK = self.mToe.getMessageAsMeta('fkJoint') CORERIG.shapeParent_in_place(mToeFK.mNode, crv, True, replaceShapes=True) ml_fkShapes.append(cgmMeta.validateObjArg(crv, 'cgmObject')) if self.str_ikRollSetup == 'control': log.debug(cgmGEN.logString_msg(_str_func, "Toe Ik control...")) mToeIK = self.mToe.doCreateAt(setClass=True) CORERIG.shapeParent_in_place(mToeIK.mNode, crv, True, replaceShapes=True) mRigNull.connectChildNode(mToeIK, 'controlIKToe', 'rigNull') #Connect mToeIK.doCopyNameTagsFromObject(self.mToe.mNode, ignore=['cgmType']) mToeIK.doStore('cgmTypeModifier', 'ik') mToeIK.doName() mToeIK.connectChildNode(self.mToe.fkJoint.blendJoint.mNode, 'blendJoint') #Connect mMesh_tmp.delete() return ml_fkShapes except Exception, err: cgmGEN.cgmExceptCB(Exception, err, localDat=vars())