Example #1
0
    def __init__(self,name, position=( 1,0,0 ) ):
        super(Foot,self).__init__(name)
        self.name = name
        self.position = position

        #call joint classes
        self.ankle = joint.Joint("{0}_ankle_{1}".format(self.getSide(),nameSpace.JOINT))
        self.ball = joint.Joint("{0}_ball_{1}".format(self.getSide(),nameSpace.JOINT))
        self.tipToe = joint.Joint("{0}_tiptoe_{1}".format(self.getSide(),nameSpace.JOINT))
        self.heel = joint.Joint("{0}_heel_{1}".format(self.getSide(),nameSpace.JOINT))
        self.inPivot = joint.Joint("{0}_inPivot_{1}".format(self.getSide(),nameSpace.JOINT))
        self.outPivot = joint.Joint("{0}_outPivot_{1}".format(self.getSide(),nameSpace.JOINT))
        self.jointList = [ self.ankle, self.ball, self.tipToe,  self.heel, self.inPivot, self.outPivot ]
        self.guides = list()

        #self.ankle1
        self.ankle1 = joint.Joint("{0}_topAnkle_{1}".format(self.getSide(),nameSpace.JOINT))
Example #2
0
    def __init__(self,
                 name,
                 jointCount=5,
                 positions=([1, 0, 0], [2, 0, 0], [2.5, 0,
                                                   0], [3, 0, 0], [3.5, 0, 0]),
                 subCtrl=False):
        super(Finger, self).__init__(name)

        self.jointPositions = list()
        self.jointCount = jointCount
        self.fkChainJoints = list()
        self.subCtrl = subCtrl

        for count in range(0, self.jointCount):

            #store class in self.fkChainJoints list
            index = count + 1

            self.fkChainJoints.append(
                joint.Joint("{0}{1}_{2}".format(self.getName(), str(index),
                                                nameSpace.BINDJOINT)))

            self.jointPositions.append(positions[count])
Example #3
0
    def __init__(self, name, jointCount=4, subCtrl=True):
        super(FkChain,self).__init__(name)

        self.jointCount = jointCount
        self.fkChainJoints = list()
        self.jointPositions = list()
        for count in range(0,self.jointCount):

            #store class in self.fkChainJoints list
            index = count+1
            self.fkChainJoints.append(
                joint.Joint("{0}{1}_{2}".format(
                    self.getName(),
                    str(index),
                    nameSpace.BINDJOINT)
                )
            )

            #store positions as well: add 3 to Y for each new joint.
            dist = count*3+2
            self.jointPositions.append( [0,dist,0] )


        self.subCtrl = subCtrl
Example #4
0
    def build(self):
        super(Foot,self).build()
        #get rid of this!
        cmds.delete( self.footJntUpv.getZeroGroup1() )

        #duplicate ball joint
        self.ankle1.create()
        self.ankle1.setPosition ( self.ball.getPosition() )
        #make it a little bigger
        cmds.setAttr("{0}.radius".format(self.ankle1.getName()), 2)
        self.ankle1.setParent( self.heel.getName() )

        #rename and move the bind joints to jointgrp
        self.ankle.setName( self.ankle.getName().replace(nameSpace.JOINT, nameSpace.BINDJOINT) )
        self.ball.setName( self.ball.getName().replace(nameSpace.JOINT, nameSpace.BINDJOINT) )
        self.tipToe.setName( self.tipToe.getName().replace(nameSpace.JOINT, nameSpace.BINDJOINT) )



        #duplicate the bind joints and we'll use them for the ctrl rig
        self.ballJntRig = joint.Joint( self.ball.getName().replace(nameSpace.JOINT, nameSpace.DRVJOINT),
                                           position=self.ball.getPosition(),
                                           parent=self.heel.getName)
        self.toeJntRig = joint.Joint( self.tipToe.getName().replace(nameSpace.JOINT, nameSpace.DRVJOINT),
                                          position=self.tipToe.getPosition(),
                                          parent=self.ballJntRig.getName())
        self.ankleJntRig = joint.Joint( self.ankle.getName().replace(nameSpace.JOINT, nameSpace.DRVJOINT),
                                            position=self.ankle.getPosition(),
                                            parent=self.ankle1.getName())

        self.ballJntRig.create()
        self.toeJntRig.create()
        cmds.select(cl=True)
        self.ankleJntRig.create()
        self.ankleJntRig.setParent( self.ankle1.getName() )

        #parent accordingly


        #first remove parent on pivots
        cmds.parent(self.inPivot.getName() ,w=True)
        cmds.parent(self.outPivot.getName() ,w=True)

        cmds.select(cl=True)


        #ikh names
        self.toeIkh = self.tipToe.getName().replace(nameSpace.BINDJOINT, nameSpace.IK)
        self.ankleIkh = self.ankle1.getName().replace(nameSpace.JOINT, nameSpace.IK)
        #ikh applications
        cmds.ikHandle( sj=self.ballJntRig.getName(), ee=self.toeJntRig.getName(), sol="ikSCsolver", n=self.toeIkh )
        cmds.ikHandle( sj=self.ankle1.getName(), ee=self.ankleJntRig.getName(), sol="ikSCsolver", n=self.ankleIkh )

        #create sdk nodes
        tipToeSdk = cmds.createNode('transform', n=self.tipToe.getName().replace( nameSpace.BINDJOINT, 'sdk' ))
        ankleSdk = cmds.createNode('transform', n=self.ankle.getName().replace( nameSpace.BINDJOINT, 'sdk' ))

        #pointConstraint ball to ankle1jnt
        #cmds.pointConstraint( self.ballJntRig.getName(), self.ankle1.getName())

        #snap
        self.snap( self.ball.getName(), tipToeSdk )
        self.snap( self.ankle1.getName(), ankleSdk)

        #create ikh ctrls
        self.toeCtrl = control.Control( self.tipToe.getName().replace(nameSpace.BINDJOINT, nameSpace.CONTROL),
                                              position=self.tipToe.getPosition(),
                                              parent=tipToeSdk,
                                              shape = "circle" )
        self.ankleCtrl = control.Control( self.ankle.getName().replace(nameSpace.BINDJOINT, nameSpace.CONTROL),
                                              position=self.ankle.getPosition(),
                                              parent=ankleSdk,
                                              shape = "circle" )

        self.ankleCtrl.create()
        self.toeCtrl.create()
        self.toeCtrl.setColor(7)
        self.toeCtrl.setOrientation( 'z' )

        #parent ik handles to ctrls
        cmds.parent( self.toeIkh, self.toeCtrl.getName() )
        cmds.parent( self.ankleIkh, self.ankleCtrl.getName() )


        #replace pivot joints with locators
        self.inPivotLocator = locator.Locator( name="{0}_{1}".format( self.inPivot.getName(), nameSpace.LOCATOR ))
        self.outPivotLocator = locator.Locator( name="{0}_{1}".format( self.outPivot.getName(), nameSpace.LOCATOR ))

        self.inPivotLocator.create()
        self.outPivotLocator.create()

        #snap!
        self.snap( self.inPivot.getName(), self.inPivotLocator.getName())
        self.snap( self.outPivot.getName(), self.outPivotLocator.getName())
        #delete the joints.
        cmds.delete( self.inPivot.getName())
        cmds.delete( self.outPivot.getName())

        #now implement the hierarchy
        cmds.parent( self.outPivotLocator.getName(),self.inPivotLocator.getName())
        cmds.parent( self.heel.getName(), self.outPivotLocator.getName())
        cmds.parent( tipToeSdk, ankleSdk, self.heel.getName() )

        #create foot control
        self.footCtrl = control.Control( name="{0}_{1}".format( self.getName(), nameSpace.CONTROL),
                                             position = self.ankle.getPosition(),
                                             parent = self.controlsGroup,
                                             shape = 'square')
        self.footCtrl.create()
        cmds.parent(self.inPivotLocator.getName(), self.footCtrl.getName())
        self.footCtrl.setColor(7)
        #add attributes
        cmds.select(self.footCtrl.getName())
        cmds.addAttr( ln="footRoll", at="float", max=45, min=-45, k=True)
        cmds.addAttr( ln="toeBend", at="float", max=45, min=-45, k=True)
        cmds.addAttr( ln="tilt", at="float", max=45, min=-45, k=True)

    #set driven keys
        footRoll = ("{0}.footRoll".format( self.footCtrl.getName() ))
        toeBend = ("{0}.toeBend".format( self.footCtrl.getName() ))
        tilt = ("{0}.tilt".format( self.footCtrl.getName() ))
        #foot roll
        
        '''
        #ball footRoll
        animSdk.setDrivenKey(footRoll, 0, "{0}.rx".format(ankleSdk), 0)
        animSdk.setDrivenKey(footRoll, 45, "{0}.rx".format(ankleSdk), 90)
        #heel footRoll
        animSdk.setDrivenKey(footRoll, 0, "{0}.rx".format(self.heel.getName()), 0)
        animSdk.setDrivenKey(footRoll, -45, "{0}.rx".format(self.heel.getName()), -90)
        #toe bend
        animSdk.setDrivenKey(toeBend, 0, "{0}.rx".format(tipToeSdk), 0)
        animSdk.setDrivenKey(toeBend, 45, "{0}.rx".format(tipToeSdk), 90)
        animSdk.setDrivenKey(toeBend, -45, "{0}.rx".format(tipToeSdk), -90)
        #tilt
        if self.getSide() == nameSpace.SIDES["left"]:
            animSdk.setDrivenKey(tilt, 0, "{0}.rz".format(self.inPivotLocator.getName()), 0)
            animSdk.setDrivenKey(tilt, 45, "{0}.rz".format(self.inPivotLocator.getName()), 90)
            animSdk.setDrivenKey(tilt, 0, "{0}.rz".format(self.outPivotLocator.getName()), 0)
            animSdk.setDrivenKey(tilt, -45, "{0}.rz".format(self.outPivotLocator.getName()), -90)
        else:
            animSdk.setDrivenKey(tilt, 0, "{0}.rz".format(self.inPivotLocator.getName()), 0)
            animSdk.setDrivenKey(tilt, 45, "{0}.rz".format(self.inPivotLocator.getName()), -90)
            animSdk.setDrivenKey(tilt, 0, "{0}.rz".format(self.outPivotLocator.getName()), 0)
            animSdk.setDrivenKey(tilt, -45, "{0}.rz".format(self.outPivotLocator.getName()), 90)
        '''
        
        #delete the unessecaries
        cmds.delete( self.noXformGroup, self.hookGroup )
Example #5
0
    def setup(self):

        #handle which direction UPV will be in
        x = 5
        y = 0
        z = 0
        #control and grp frz creation

        #organize and place into groups
        #ctrlGroup
        self.ctrlGrp = cmds.createNode("transform",
                                       n="{0}_ctrl_grp".format(self.getName()))
        #Master Group
        self.masterGrp = cmds.createNode("transform",
                                         n="{0}_rbn_grp".format(
                                             self.getName()))

        for i in range(int(self.jointAmmount)):

            inc = i + 1
            #check if it's the MID!!!
            if i == self.middleList:
                #ctrl creation
                midCtrl = control.Control("{0}_ctrl{1}".format(
                    self.nameSpace, inc), (0, i, 0),
                                          shape="star")
                midCtrl.create()
                midCtrl.setColor(17)
                self.ribbonCtrls.append(midCtrl.getName())
                #joint creation
                midJnt = joint.Joint("{0}_{1}{2}".format(
                    self.nameSpace, nameSpace.JOINT, inc), (0, i, 0),
                                     parent=midCtrl.getName())
                midJnt.create()
                self.ribbonJnts.append(midJnt.getName())
                #midJnt.setPosition([0,i,0])
                #upv creation
                upvCtrl = control.Control("{0}_{1}{2}".format(
                    self.nameSpace, nameSpace.UPV, inc), (0, i, 0),
                                          shape="cross")
                upvCtrl.create()
                self.ribbonUpvs.append(upvCtrl.getName())
                cmds.select(upvCtrl.getZeroGroup1())
                cmds.move(x, y, z, r=True)
                cmds.parent(upvCtrl.getZeroGroup1(), self.masterGrp)
                #hide upvector. Animators don't need to see it!
                cmds.setAttr("{0}.visibility".format(upvCtrl.getName()), 0)

                self.ribbonZeros.append(midCtrl.getZeroGroup1())
                self.getMidCtrl = midCtrl.getName()
                self.getMidZeroGroup = midCtrl.getZeroGroup1()

                cmds.parent(midCtrl.getZeroGroup1(), self.ctrlGrp)

                #midLocator
                self.midLoc = control.Control("{0}_midpoint".format(
                    self.nameSpace), (0, i, 0),
                                              shape="cross")
                self.midLoc.create()
                #hide it
                cmds.setAttr("{0}.visibility".format(self.midLoc.getName()), 0)

            else:
                #ctrl creation
                ribbonCtrl = control.Control("{0}_ctrl{1}".format(
                    self.nameSpace, inc), (0, i, 0),
                                             shape="square")
                ribbonCtrl.create()
                self.ribbonCtrls.append(ribbonCtrl.getName())
                #loc creation
                ribbonLoc = cmds.spaceLocator(
                    n="{0}_loc{1}".format(self.nameSpace, inc))
                cmds.parent(ribbonLoc[0], ribbonCtrl.getName())
                self.ribbonLocs.append(ribbonLoc[0])
                cmds.setAttr("{0}.ty".format(ribbonLoc[0]), 0)
                #hide it
                cmds.setAttr("{0}.visibility".format(ribbonLoc[0]), 0)
                #joint creation
                ribbonJnt = joint.Joint("{0}_{1}{2}".format(
                    self.nameSpace, nameSpace.JOINT, inc), (0, i, 0),
                                        parent=ribbonCtrl.getName())
                ribbonJnt.create()
                self.ribbonJnts.append(ribbonJnt.getName())
                #upv creation
                upvCtrl = control.Control("{0}_{1}{2}".format(
                    self.nameSpace, nameSpace.UPV, inc), (0, i, 0),
                                          shape="cross")
                upvCtrl.create()
                self.ribbonUpvs.append(upvCtrl.getName())
                cmds.parent(upvCtrl.getZeroGroup1(), ribbonCtrl.getName())
                cmds.select(upvCtrl.getZeroGroup1())
                cmds.move(x, y, z, r=True)

                #hide upvector. Animators don't need to see it!
                cmds.setAttr("{0}.visibility".format(upvCtrl.getName()), 0)

                self.ribbonZeros.append(ribbonCtrl.getZeroGroup1())

                cmds.parent(ribbonCtrl.getZeroGroup1(), self.ctrlGrp)

                #orientControls. ribbons are default set to z-downaxis
                ribbonCtrl.setOrientation('z')
                #make them a little smaller too
                cmds.select("{0}.cv[*]".format(ribbonCtrl.getName()))
                cmds.scale(0.6, 0.6, 0.6, r=True)

        #aim contraint startLoc to midCtrl
        cmds.aimConstraint(self.ribbonCtrls[1],
                           self.ribbonLocs[0],
                           mo=True,
                           wut="object",
                           wuo=self.ribbonUpvs[0])

        #aim constraint endLoc to midCtrl
        cmds.aimConstraint(self.ribbonCtrls[1],
                           self.ribbonLocs[-1],
                           mo=True,
                           wut="object",
                           wuo=self.ribbonUpvs[-1])

        #parentConstraint start and end ctrls to midloc
        cmds.parentConstraint(self.ribbonCtrls[0], self.ribbonCtrls[-1],
                              self.midLoc.getName())

        #pointConstraint midZeroGrp to midLoc
        cmds.pointConstraint(self.midLoc.getName(), self.ribbonZeros[1])

        #aim midZero to startCtrl
        cmds.aimConstraint(self.ribbonCtrls[-1],
                           self.ribbonZeros[1],
                           wut="object",
                           wuo=self.ribbonUpvs[1],
                           mo=True)
        #parentConstraint startUpv and endUpv to midUpv
        cmds.parentConstraint(self.ribbonUpvs[-1], self.ribbonUpvs[0],
                              self.ribbonUpvs[1])