Exemplo n.º 1
0
    def setupIKCtrl(self, x, IKHandle):

        ############# MODIFY FOR INHERITANCE  #############
        side = self.prefixList[x]
        thisChain = self.IKChains[x]

        #create a control for the ik
        name = "%s_%s_IK_CTRL"%(side, self.limbName)
        if x==0:
            IKCtrl = rig.createControl(name, "cube", self.jAxis1, "blue")
        if x==1:
            IKCtrl = rig.createControl(name, "cube", self.jAxis1, "red")
        self.IKCtrls.append(IKCtrl)
        #strip to rotate and translate
        rig.stripToRotateTranslate(IKCtrl)

        #G.O. control
        rig.groupOrient(thisChain[2], IKCtrl, self.groupSuffix)

        #orient constraint joint 2 (wrist ankle) to control
        cmds.orientConstraint(IKCtrl, thisChain[2])

        #parent ik handle to control
        cmds.parent(IKHandle, IKCtrl)

        return IKCtrl
Exemplo n.º 2
0
    def setupFK(self, x):
        """sets up the fk portion of this limb"""
        thisChain = self.FKChains[x]
        side = self.prefixList[x]

        ctrlList = []
        grpList = []

        for i in range(len(thisChain)-1):
            #create control for joint (octagon)
            ctrlName = (thisChain[i].rstrip(self.jointSuffix) + self.controlSuffix)

            #create control
            if x==0:
                ctrl = rig.createControl(ctrlName, "sphere", self.jAxis1, "blue")
            if x==1:
                ctrl = rig.createControl(ctrlName, "sphere", self.jAxis1, "red")
            grpName = "%s_%s"%(ctrl,self.groupSuffix)

            rig.groupOrient(thisChain[i], ctrl, self.groupSuffix)

            #connect the joints to the controls
#-----------catch this constraint with variable????
            cmds.parentConstraint(ctrl, thisChain[i])

            #deal with attrs
            rig.stripToRotateTranslate(ctrl)
            rig.lockTranslate(ctrl)
            cmds.addAttr(ctrl, at="short", ln="__EXTRA__", nn="__EXTRA__", k=True)
            cmds.setAttr("%s.__EXTRA__"%ctrl, l=True)
            cmds.addAttr(ctrl, at="float", ln="stretch", dv=1, min=0.3, max=3, k=True)
            cmds.connectAttr("%s.stretch"%ctrl, "%s.s%s"%(thisChain[i], self.jAxis1))

            ctrlList.append(ctrl)
            grpList.append(grpName)

        #parent up the controls to each other
        for j in range((len(grpList)-1), 0, -1):
            cmds.parent(grpList[j], ctrlList[j-1])

        #create lists of controls
        self.FKCtrlChains.append(ctrlList)

        #do the visibilty of the fk chain from the IK switch
        ikS = self.IKSwitches[x]
        rName = ("%s_%s_ikReverse"%(self.prefixList[x], self.limbName))
        grpTop = cmds.listRelatives(self.FKCtrlChains[x][0], p=True)[0]
        cmds.shadingNode("reverse", asUtility=True, n=( rName))
        cmds.connectAttr("%s.FKIK"%ikS, "%s.inputX"%rName)
        cmds.connectAttr("%s.outputX"%rName, "%s.visibility"%grpTop)

        #pass to bind setup
        self.setupBind(x)
Exemplo n.º 3
0
	def setupIKCtrl(self, x, IKHandle):

		############# MODIFY FOR INHERITANCE  #############
		side = self.prefixList[x]
		thisChain = self.IKChains[x]

		#create a control for the ik
		name = "%s_%s_IK_CTRL"%(side, self.limbName)
		if x==0:
			IKCtrl = rig.createControl(name, "cube", self.jAxis1, "blue")
		if x==1:
			IKCtrl = rig.createControl(name, "cube", self.jAxis1, "red")
		self.IKCtrls.append(IKCtrl)
		#strip to rotate and translate
		rig.stripToRotateTranslate(IKCtrl)

		#G.O. control
		group = rig.groupOrient(thisChain[2], IKCtrl, self.groupSuffix)
		##########
		cmds.setAttr("%s.rotateX"%group, (0))
		cmds.setAttr("%s.rotateY"%group, (0))
		cmds.setAttr("%s.rotateZ"%group, (0))

		#orient constraint joint 2 (wrist ankle) to control
		##########
		# cmds.orientConstraint(IKCtrl, thisChain[2], mo=True)

		#parent ik handle to control
		cmds.parent(IKHandle, IKCtrl)

		return IKCtrl
def ctrlSetup():

	cmds.select(hi=True)
	sel = cmds.ls(sl=True)
	ctrlList = []
	groupList = []

	for x in sel:
		if (cmds.listRelatives(x, p=True)):
			cmds.parent(x, w=True)
			#could rename joint here
		ctrl = rig.createControl("%s_CTRL"%x, "cube", "x", "red")
		ctrlList.append(ctrl)
		group = rig.groupOrient(x, ctrl)
		groupList.append(group)
		cmds.parent(x, ctrl)
		
		
	for x in range(len(ctrlList)-1, 0, -1):
		#create a control for the move of the joint
		#snap this to the joint 
		#parent the joint to the control

		#switch this to parenting the new control to the other control . . . 
		cmds.parent(groupList[x], ctrlList[x-1])

		#strip to rotateTranslate, then lock the translate of the old control
		#strip to translate of the new control . . . (lock other channels other than up?2)
		
	#TO-DO----------------put a "local" control onto the joint to do the up/down stuff for each control
def ctrlSetup():

    cmds.select(hi=True)
    sel = cmds.ls(sl=True)
    ctrlList = []
    groupList = []

    for x in sel:
        if (cmds.listRelatives(x, p=True)):
            cmds.parent(x, w=True)
            #could rename joint here
        ctrl = rig.createControl("%s_CTRL" % x, "cube", "x", "red")
        ctrlList.append(ctrl)
        group = rig.groupOrient(x, ctrl)
        groupList.append(group)
        cmds.parent(x, ctrl)

    for x in range(len(ctrlList) - 1, 0, -1):
        #create a control for the move of the joint
        #snap this to the joint
        #parent the joint to the control

        #switch this to parenting the new control to the other control . . .
        cmds.parent(groupList[x], ctrlList[x - 1])

        #strip to rotateTranslate, then lock the translate of the old control
        #strip to translate of the new control . . . (lock other channels other than up?2)

    #TO-DO----------------put a "local" control onto the joint to do the up/down stuff for each control
Exemplo n.º 6
0
    def  setupIK(self, x):
        """sets up the IK portion of the limb rig"""

        #set values for this chain, side
        thisChain = self.IKChains[x]
        side = self.prefixList[x]
        thisBind = self.bindChains[x]

        #create ik control from joint 0 to 2
        mainIK = "%s_%s_IK"%(side, self.limbName)
        IKHandle = cmds.ikHandle(n=mainIK, sj=thisChain[0], ee=thisChain[2], sol="ikRPsolver")[0]
        self.IKHandles.append(IKHandle)

        #create a control for the ik
        IKCtrl = self.setupIKCtrl(x, IKHandle)

        #call pole vector method? - pass IK name, normal or no flip
#-----------------get argument from UI about what kind of handles
        thisPv = self.setupPV(IKHandle, "normal", x)

        #create stretchy bits
        cmds.addAttr(IKCtrl, ln="__EXTRA__", nn="__EXTRA__", at="short", k=True)
        cmds.setAttr("%s.__EXTRA__"%IKCtrl, l=True)
        cmds.addAttr(IKCtrl, ln="autoStretch", at="float", min=0, max=1, k=True)
        cmds.addAttr(IKCtrl, ln="scaleMin", at="float", min=0.5, max=3, k=True, dv=1)
        #add "upScale" and "lowScale" (.5-3)
        cmds.addAttr(IKCtrl, ln="upScale", at="float", min=0.3, max=3, k=True, dv=1.0)
        cmds.addAttr(IKCtrl, ln="lowScale", at="float", min=0.3, max=3, k=True, dv=1.0)

        #from measure, get final add node
        add = self.measureAdds[x]

        #orient the IK wrist to the control? do it here or elsewhere (for inheritance?)
        cmds.orientConstraint(IKCtrl, thisChain[2])

        #create distance node from thigh to ctrl
        distance = rig.measureDistance("%s_%s_ikCtrlDistance"%(side, self.limbName), self.measureChains[x][0], IKCtrl)

        ratioMult, defaultMult, defaultBlend, conditional, upScaleMult, loScaleMult = rig.scaleStretchIK(("%s_%s"%(side, self.limbName)), thisChain[0], thisChain[1], thisChain[2], "%s.output"%add, "%s.distance"%distance, IKCtrl, self.jAxis1)

        #create the ik switch (call as "diamond")
        ikSwitchName = "%s_%s_FKIKSwitch"%(side, self.limbName)
        if x == 0:
            thisIKSwitch = rig.createControl(ikSwitchName, "diamond", self.jAxis1, "lightBlue")
        if x == 1:
            thisIKSwitch = rig.createControl(ikSwitchName, "diamond", self.jAxis1, "pink")
        rig.stripTransforms(thisIKSwitch)
        cmds.addAttr(thisIKSwitch, ln="FKIK", k=True, at="float", min=0, max=1, dv=0)
        #create reverse
        thisIKSwitchRev = cmds.shadingNode("reverse", asUtility=True, n="%s_%s_IKSwtchReverse"%(side, self.limbName))
        cmds.connectAttr("%s.FKIK"%thisIKSwitch, "%s.inputX"%thisIKSwitchRev)
        rig.groupOrient(thisBind[2], thisIKSwitch, self.groupSuffix)
        IKSwitchGrp = cmds.listRelatives(thisIKSwitch, p=True)

        #do stuff here to push the IKFK switch in the right direction
        if x== 0:
            offset = -3
        if x==1:
            offset = 3
        cmds.xform(IKSwitchGrp, os=True, r=True, t=(0, 0, offset))
        self.IKSwitches.append(thisIKSwitch)
        self.IKSwitchesRev.append(thisIKSwitchRev)

        #set up visibility switching from this for IK and PV controls
        #get pv parent group
        pvGroup = cmds.listRelatives(thisPv, p=True)[0]
        ikCtrlGroup = cmds.listRelatives(IKCtrl, p=True)[0]
        cmds.connectAttr("%s.FKIK"%thisIKSwitch, "%s.v"%pvGroup)
        cmds.connectAttr("%s.FKIK"%thisIKSwitch, "%s.v"%ikCtrlGroup)

        #pass onto the FK part of the rig
        self.setupFK(x)
Exemplo n.º 7
0
	def  setupIK(self, x):
		"""sets up the IK portion of the limb rig"""

		#set values for this chain, side
		thisChain = self.IKChains[x]
		side = self.prefixList[x]
		thisBind = self.bindChains[x]

		#create ik control from joint 0 to 2
		mainIK = "%s_%s_IK"%(side, self.limbName)
		IKHandle = cmds.ikHandle(n=mainIK, sj=thisChain[0], ee=thisChain[2], sol="ikRPsolver")[0]
		self.IKHandles.append(IKHandle)

		#create a control for the ik
		IKCtrl = self.setupIKCtrl(x, IKHandle)

		#call pole vector method? - pass IK name, normal or no flip
#-----------------get argument from UI about what kind of handles
		thisPv = self.setupPV(IKHandle, "normal", x)

		#create stretchy bits
		cmds.addAttr(IKCtrl, ln="__EXTRA__", nn="__EXTRA__", at="short", k=True)
		cmds.setAttr("%s.__EXTRA__"%IKCtrl, l=True)
		cmds.addAttr(IKCtrl, ln="autoStretch", at="float", min=0, max=1, k=True)
		cmds.addAttr(IKCtrl, ln="scaleMin", at="float", min=0.5, max=3, k=True, dv=1)
		#add "upScale" and "lowScale" (.5-3)
		cmds.addAttr(IKCtrl, ln="upScale", at="float", min=0.3, max=3, k=True, dv=1.0)
		cmds.addAttr(IKCtrl, ln="lowScale", at="float", min=0.3, max=3, k=True, dv=1.0)
		cmds.addAttr(IKCtrl, ln="__IKFOOT__", nn="__EXTRA__", at="short", k=True)
		cmds.setAttr("%s.__IKFOOT__"%IKCtrl, l=True)
		cmds.addAttr(IKCtrl, ln="ballRoll", at="float", k=True, dv=0)
		cmds.addAttr(IKCtrl, ln="toeRoll", at="float", k=True, dv=0)
		cmds.addAttr(IKCtrl, ln="heelRoll", at="float", k=True, dv=0)
		cmds.addAttr(IKCtrl, ln="toePivot", at="float", k=True, dv=0)
		cmds.addAttr(IKCtrl, ln="heelPivot", at="float", k=True, dv=0)
		cmds.addAttr(IKCtrl, ln="toeFlap", at="float", k=True, dv=0)

		#from measure, get final add node
		add = self.measureAdds[x]

		#orient the IK wrist to the control? do it here or elsewhere (for inheritance?)
		cmds.orientConstraint(IKCtrl, thisChain[2], mo=True)

		#create distance node from thigh to ctrl
		distance = rig.measureDistance("%s_%s_ikCtrlDistance"%(side, self.limbName), self.measureChains[x][0], IKCtrl)

		ratioMult, defaultMult, defaultBlend, conditional, upScaleMult, loScaleMult = rig.scaleStretchIK(("%s_%s"%(side, self.limbName)), thisChain[0], thisChain[1], thisChain[2], "%s.output"%add, "%s.distance"%distance, IKCtrl, self.jAxis1)

		#create the ik switch (call as "diamond")
		ikSwitchName = "%s_%s_FKIKSwitch"%(side, self.limbName)
		if x == 0:
			thisIKSwitch = rig.createControl(ikSwitchName, "diamond", self.jAxis1, "lightBlue")
		if x == 1:
			thisIKSwitch = rig.createControl(ikSwitchName, "diamond", self.jAxis1, "pink")
		rig.stripTransforms(thisIKSwitch)
		cmds.addAttr(thisIKSwitch, ln="FKIK", k=True, at="float", min=0, max=1, dv=0)
		#create reverse
		thisIKSwitchRev = cmds.shadingNode("reverse", asUtility=True, n="%s_%s_IKSwtchReverse"%(side, self.limbName))
		cmds.connectAttr("%s.FKIK"%thisIKSwitch, "%s.inputX"%thisIKSwitchRev)
		rig.groupOrient(thisBind[2], thisIKSwitch, self.groupSuffix)
		IKSwitchGrp = cmds.listRelatives(thisIKSwitch, p=True)

		#do stuff here to push the IKFK switch in the right direction
		if x== 0:
			offset = -3
		if x==1:
			offset = 3
		cmds.xform(IKSwitchGrp, os=True, r=True, t=(0, 0, offset))
		self.IKSwitches.append(thisIKSwitch)
		self.IKSwitchesRev.append(thisIKSwitchRev)

		#set up visibility switching from this for IK and PV controls
		#get pv parent group
		pvGroup = cmds.listRelatives(thisPv, p=True)[0]
		ikCtrlGroup = cmds.listRelatives(IKCtrl, p=True)[0]
		cmds.connectAttr("%s.FKIK"%thisIKSwitch, "%s.v"%pvGroup)
		cmds.connectAttr("%s.FKIK"%thisIKSwitch, "%s.v"%ikCtrlGroup)

		#pass onto the FK part of the rig
		self.setupFK(x)
#to connect a vis attr to the vis of the shape nodes

import maya.cmds as cmds

sel = cmds.ls(sl=True)

for ctrl in sel:
    thisShape = cmds.listRelatives(ctrl, s=True, c=True)
    cmds.connectAttr("COG_CTRL.fineShaperCtrls", "%s.visibility"%thisShape[0])

#to add controls to selected cvs (via cluster, replace weighted node w/control)
import maya.cmds as cmds
import zbw_rig as rig

sel = cmds.ls(sl=True, fl=True)

for i in range(len(sel)):
    #create a cluster
    cluster = cmds.cluster(sel[i], relative=False, n="cluster%02d"%i)
    #print(cluster)
    #for that cluster, create a circle control at that cluster
    ctrl = rig.createControl("control%02d"%i, "sphere", "z", "blue")
    rig.groupOrient(cluster[1], ctrl)
    #replace the weighted node of the cluster with the circle
    clusHandShape = cmds.listRelatives(cluster[1], s=True)
    cmds.cluster(cluster[0], e=True, bs=1, wn=(ctrl, ctrl))

    cmds.setAttr("%s.originX"%clusHandShape[0], 0.0)
    cmds.setAttr("%s.originY"%clusHandShape[0], 0.0)
    cmds.setAttr("%s.originZ"%clusHandShape[0], 0.0)
    cmds.setAttr("%s.visibility"%clusHandShape[0], 0)
Exemplo n.º 9
0
import maya.cmds as cmds
import zbw_rig as rig

crv = cmds.ls(sl=True)[0]

cvs = cmds.ls("%s.cv[*]"%crv, fl=True)
orList = []

for x in range(0, len(cvs)):
    cv = cvs[x]
    
    pos = cmds.pointPosition(cv)
    
    clsName = "%s_%s"%(crv, x)
    cls = cmds.cluster(cv, n=clsName)[1]
    ctrl = rig.createControl(name="%sCtrl"%clsName, type="sphere", color="red")
    grpOrient = rig.groupOrient(cls, ctrl)
    orList.append(grpOrient)
    cmds.parent(cls, ctrl)
    cmds.setAttr("%s.v"%cls, 0)

cmds.group(orList, n="crvCtrlsGrp")
Exemplo n.º 10
0
#to connect a vis attr to the vis of the shape nodes

import maya.cmds as cmds

sel = cmds.ls(sl=True)

for ctrl in sel:
    thisShape = cmds.listRelatives(ctrl, s=True, c=True)
    cmds.connectAttr("COG_CTRL.fineShaperCtrls", "%s.visibility"%thisShape[0])

#to add controls to selected cvs (via cluster, replace weighted node w/control)
import maya.cmds as cmds
import zbw_rig as rig

sel = cmds.ls(sl=True, fl=True)

for i in range(len(sel)):
    #create a cluster
    cluster = cmds.cluster(sel[i], relative=False, n="cluster%02d"%i)
    #print(cluster)
    #for that cluster, create a circle control at that cluster
    ctrl = rig.createControl("control%02d"%i, "sphere", "z", "blue")
    rig.groupOrient(cluster[1], ctrl)
    #replace the weighted node of the cluster with the circle
    clusHandShape = cmds.listRelatives(cluster[1], s=True)
    cmds.cluster(cluster[0], e=True, bs=1, wn=(ctrl, ctrl))

    cmds.setAttr("%s.originX"%clusHandShape[0], 0.0)
    cmds.setAttr("%s.originY"%clusHandShape[0], 0.0)
    cmds.setAttr("%s.originZ"%clusHandShape[0], 0.0)
    cmds.setAttr("%s.visibility"%clusHandShape[0], 0)
Exemplo n.º 11
0
    def createRibbon(self, *args):
        self.name = cmds.textFieldGrp(self.widgets["ribbonNameTFG"], q=True, tx=True)
        self.numDiv = (cmds.intFieldGrp(self.widgets["jointsIFG"], q=True, v=True)[0]) - 1
        # self.fk = cmds.checkBox(self.widgets["fkSetupCB"], q=True, v=True)
        self.height = cmds.floatFieldGrp(self.widgets["heightFFG"], q=True, v1=True)
        self.ratio = cmds.floatFieldGrp(self.widgets["ratioFFG"], q=True, v1=True)
        # self.axis = cmds.radioButtonGrp(self.widgets["axis"] , q=True, sl=True)

        # print("axis = :%s"%self.axis)
        self.ribbonName = "%s_ribbonGeo" % self.name
        self.numJoints = self.numDiv
        self.follicleList = []
        self.follicleJntList = []
        # self.own = cmds.checkBox(self.widgets["existingGeoCB"], q=True, v=True)
        # self.myGeo = cmds.textFieldButtonGrp(self.widgets["geoTFBG"], q=True, tx=True)
        # self.dir = cmds.radioButtonGrp(self.widgets["directionRBG"], q=True, sl=True )
        # print("dir: %s"%self.dir)
        # self.centerPos = cmds.floatSliderGrp(self.widgets["centerPosFSG"], q=True, v=True )
        self.follicleGrpList = []

        # -----------make sure the num of divisions is at least 1
        # -----------create the nurbs plane in the correct axis (just make the plane in the axis and figure out how to rotate joint local rotational axes to match it) DON'T WORRY ABOUT THIS SO MUCH (IT'S HIDDEN), WORRY ABOUT THE CONTROLS BEING ORIENTED CORRECTLY!!!

        # if self.own == 0:
        # 	self.dir = 2
        # if self.dir == 1:
        # 	dir = "u"
        # 	uDiv = self.numDiv
        # 	vDiv = 1
        # else:
        # 	dir = "v'"
        # 	uDiv = 1
        # 	vDiv = self.numDiv

        # if self.axis  == 1:
        axis = [0, 0, 1]
        # elif self.axis  == 2:
        # 	axis = [0, 1, 0]
        # elif self.axis  == 3:
        # 	axis = [0, 0, 1]

        # if self.own == 0:
        width = self.height / self.ratio

        # create the nurbsPlane
        cmds.nurbsPlane(ax=axis, w=width, lr=self.ratio, d=3, u=1, v=4, ch=0, n=self.ribbonName)
        cmds.rebuildSurface(
            self.ribbonName, ch=0, rpo=1, rt=0, end=1, kr=0, kcp=0, kc=0, su=1, du=1, sv=4, dv=3, tol=0.1, fr=0, dir=2
        )
        cmds.move(0, self.height / 2, 0, self.ribbonName)

        cmds.xform(self.ribbonName, ws=True, rp=[0, 0, 0])

        # else:
        # 	self.ribbonName = self.myGeo

        # find the ratio for the uv's (one dir will be .5, the other a result of the num joints)
        factor = 1.0 / self.numJoints

        # -------keep follicle joints separate, not parente under each follicle, separate group for those
        # -------follicle jnts each go under a ctrl (star) that is under a group. That group gets parent constrained to the follicles
        # -------these joints should be aligned with the follicles??? does that make a difference?

        # create the follicles on the surface, joints on the follicles
        for x in range(self.numJoints + 1):
            val = x * factor
            folName = "%s_follicle%s" % (self.name, x)
            # create a follicle in the right direction
            # if self.dir ==1:
            # 	follicle = rig.follicle(self.ribbonName, folName, val, 0.5)[0]
            # else:
            follicle = rig.follicle(self.ribbonName, folName, 0.5, val)[0]

            self.follicleList.append(follicle)

            # create joint and parent to follicle
            jointName = "%s_fol%s_JNT" % (self.name, x)
            # ---------have to figure out how to orient this correctly (just translate and rotate the joints (or the controls they're under))
            # create joint control? then move the control and the joint under it to the correct rot and pos
            folPos = cmds.xform(follicle, q=True, ws=True, t=True)
            folRot = cmds.xform(follicle, q=True, ws=True, ro=True)
            cmds.select(cl=True)
            folJoint = cmds.joint(n=jointName, p=(0, 0, 0))
            folGroup = cmds.group(folJoint, n="%s_GRP" % folJoint)  # this could become control for the joint
            cmds.xform(folGroup, a=True, ws=True, t=folPos)
            cmds.xform(folGroup, a=True, ws=True, ro=folRot)
            self.follicleJntList.append(folJoint)
            self.follicleGrpList.append(folGroup)
            cmds.parent(folGroup, follicle)

            # create controls here:
            # create a loop that runs through the cvs in v, 0 to 6
        origClusterList = [
            "top_CLS",
            "topBez_CLS",
            "centerTop_CLS",
            "center_CLS",
            "centerEnd_CLS",
            "endBez_CLS",
            "end_CLS",
        ]
        origControlList = [
            "top_CTRL",
            "topBez_CTRL",
            "centerTop_CTRL",
            "center_CTRL",
            "centerEnd_CTRL",
            "endBez_CTRL",
            "end_CTRL",
        ]

        clusterList = []
        controlList = []
        constrGrpList = []
        attachGrpList = []

        for v in range(0, 7):
            cmds.select(clear=True)
            clusNodeName = self.name + "_" + origClusterList[v] + "Base"
            # select u (0 and 1) for each v and cluster them
            fullCls = cmds.cluster("%s.cv[0:1][%d]" % (self.ribbonName, v), relative=False, n=clusNodeName)[0]
            clusHandle = clusNodeName + "Handle"
            clusName = clusHandle.rstrip("BaseHandle")
            cmds.rename(clusHandle, clusName)
            clusterList.append(clusName)
            # now setup the controls and groups for the clusters
            # goes control,group (const), group(attach)
            control = self.name + "_" + origControlList[v]
            constrGrp = self.name + "_" + origControlList[v] + "_const_GRP"
            attachGrp = self.name + "_" + origControlList[v] + "_attach_GRP"

            rig.createControl(name=control, type="circle", axis="y", color="darkGreen", *args)
            oldGrp = rig.groupOrient(clusName, control)
            cmds.rename(oldGrp, constrGrp)

            # parent clus to control
            cmds.parent(clusName, control)

            # get cluster position
            clusPos = cmds.pointPosition(clusName + ".rotatePivot")
            cmds.xform(constrGrp, ws=True, piv=(clusPos[0], clusPos[1], clusPos[2]))

            cmds.group(constrGrp, n=attachGrp)
            cmds.xform(attachGrp, ws=True, piv=(clusPos[0], clusPos[1], clusPos[2]))

            controlList.append(control)
            constrGrpList.append(constrGrp)
            attachGrpList.append(attachGrp)
Exemplo n.º 12
0
    def createRibbon(self, *args):
        self.name = cmds.textFieldGrp(self.widgets["ribbonNameTFG"],
                                      q=True,
                                      tx=True)
        self.numDiv = (cmds.intFieldGrp(
            self.widgets["jointsIFG"], q=True, v=True)[0]) - 1
        #self.fk = cmds.checkBox(self.widgets["fkSetupCB"], q=True, v=True)
        self.height = cmds.floatFieldGrp(self.widgets["heightFFG"],
                                         q=True,
                                         v1=True)
        self.ratio = cmds.floatFieldGrp(self.widgets["ratioFFG"],
                                        q=True,
                                        v1=True)
        #self.axis = cmds.radioButtonGrp(self.widgets["axis"] , q=True, sl=True)

        #print("axis = :%s"%self.axis)
        self.ribbonName = "%s_ribbonGeo" % self.name
        self.numJoints = self.numDiv
        self.follicleList = []
        self.follicleJntList = []
        #self.own = cmds.checkBox(self.widgets["existingGeoCB"], q=True, v=True)
        #self.myGeo = cmds.textFieldButtonGrp(self.widgets["geoTFBG"], q=True, tx=True)
        #self.dir = cmds.radioButtonGrp(self.widgets["directionRBG"], q=True, sl=True )
        #print("dir: %s"%self.dir)
        #self.centerPos = cmds.floatSliderGrp(self.widgets["centerPosFSG"], q=True, v=True )
        self.follicleGrpList = []

        #-----------make sure the num of divisions is at least 1
        #-----------create the nurbs plane in the correct axis (just make the plane in the axis and figure out how to rotate joint local rotational axes to match it) DON'T WORRY ABOUT THIS SO MUCH (IT'S HIDDEN), WORRY ABOUT THE CONTROLS BEING ORIENTED CORRECTLY!!!

        # if self.own == 0:
        # 	self.dir = 2
        # if self.dir == 1:
        # 	dir = "u"
        # 	uDiv = self.numDiv
        # 	vDiv = 1
        # else:
        # 	dir = "v'"
        # 	uDiv = 1
        # 	vDiv = self.numDiv

        # if self.axis  == 1:
        axis = [0, 0, 1]
        # elif self.axis  == 2:
        # 	axis = [0, 1, 0]
        # elif self.axis  == 3:
        # 	axis = [0, 0, 1]

        #if self.own == 0:
        width = self.height / self.ratio

        #create the nurbsPlane
        cmds.nurbsPlane(ax=axis,
                        w=width,
                        lr=self.ratio,
                        d=3,
                        u=1,
                        v=4,
                        ch=0,
                        n=self.ribbonName)
        cmds.rebuildSurface(self.ribbonName,
                            ch=0,
                            rpo=1,
                            rt=0,
                            end=1,
                            kr=0,
                            kcp=0,
                            kc=0,
                            su=1,
                            du=1,
                            sv=4,
                            dv=3,
                            tol=0.1,
                            fr=0,
                            dir=2)
        cmds.move(0, self.height / 2, 0, self.ribbonName)

        cmds.xform(self.ribbonName, ws=True, rp=[0, 0, 0])

        # else:
        # 	self.ribbonName = self.myGeo

        #find the ratio for the uv's (one dir will be .5, the other a result of the num joints)
        factor = 1.0 / self.numJoints

        #-------keep follicle joints separate, not parente under each follicle, separate group for those
        #-------follicle jnts each go under a ctrl (star) that is under a group. That group gets parent constrained to the follicles
        #-------these joints should be aligned with the follicles??? does that make a difference?

        #create the follicles on the surface, joints on the follicles
        for x in range(self.numJoints + 1):
            val = x * factor
            folName = "%s_follicle%s" % (self.name, x)
            #create a follicle in the right direction
            # if self.dir ==1:
            # 	follicle = rig.follicle(self.ribbonName, folName, val, 0.5)[0]
            # else:
            follicle = rig.follicle(self.ribbonName, folName, 0.5, val)[0]

            self.follicleList.append(follicle)

            #create joint and parent to follicle
            jointName = "%s_fol%s_JNT" % (self.name, x)
            #---------have to figure out how to orient this correctly (just translate and rotate the joints (or the controls they're under))
            #create joint control? then move the control and the joint under it to the correct rot and pos
            folPos = cmds.xform(follicle, q=True, ws=True, t=True)
            folRot = cmds.xform(follicle, q=True, ws=True, ro=True)
            cmds.select(cl=True)
            folJoint = cmds.joint(n=jointName, p=(0, 0, 0))
            folGroup = cmds.group(
                folJoint, n="%s_GRP" %
                folJoint)  #this could become control for the joint
            cmds.xform(folGroup, a=True, ws=True, t=folPos)
            cmds.xform(folGroup, a=True, ws=True, ro=folRot)
            self.follicleJntList.append(folJoint)
            self.follicleGrpList.append(folGroup)
            cmds.parent(folGroup, follicle)

        #create controls here:
        #create a loop that runs through the cvs in v, 0 to 6
        origClusterList = [
            "top_CLS", "topBez_CLS", "centerTop_CLS", "center_CLS",
            "centerEnd_CLS", "endBez_CLS", "end_CLS"
        ]
        origControlList = [
            "top_CTRL", "topBez_CTRL", "centerTop_CTRL", "center_CTRL",
            "centerEnd_CTRL", "endBez_CTRL", "end_CTRL"
        ]

        clusterList = []
        controlList = []
        constrGrpList = []
        attachGrpList = []

        for v in range(0, 7):
            cmds.select(clear=True)
            clusNodeName = self.name + "_" + origClusterList[v] + "Base"
            #select u (0 and 1) for each v and cluster them
            fullCls = cmds.cluster("%s.cv[0:1][%d]" % (self.ribbonName, v),
                                   relative=False,
                                   n=clusNodeName)[0]
            clusHandle = clusNodeName + "Handle"
            clusName = clusHandle.rstrip("BaseHandle")
            cmds.rename(clusHandle, clusName)
            clusterList.append(clusName)
            #now setup the controls and groups for the clusters
            #goes control,group (const), group(attach)
            control = self.name + "_" + origControlList[v]
            constrGrp = self.name + "_" + origControlList[v] + "_const_GRP"
            attachGrp = self.name + "_" + origControlList[v] + "_attach_GRP"

            rig.createControl(name=control,
                              type="circle",
                              axis="y",
                              color="darkGreen",
                              *args)
            oldGrp = rig.groupOrient(clusName, control)
            cmds.rename(oldGrp, constrGrp)

            #parent clus to control
            cmds.parent(clusName, control)

            #get cluster position
            clusPos = cmds.pointPosition(clusName + ".rotatePivot")
            cmds.xform(constrGrp,
                       ws=True,
                       piv=(clusPos[0], clusPos[1], clusPos[2]))

            cmds.group(constrGrp, n=attachGrp)
            cmds.xform(attachGrp,
                       ws=True,
                       piv=(clusPos[0], clusPos[1], clusPos[2]))

            controlList.append(control)
            constrGrpList.append(constrGrp)
            attachGrpList.append(attachGrp)