def cardAttach(): sel = cmds.ls(sl=True) #get all the cards (could be groups) cards = sel[1:] #get the proxy geo shell = sel[0] #for each card (or group) get the nearest point on surface of proxy for card in cards: #use closest point on surface to get the uv cardPos = cmds.xform(card, ws=True, q=True, rp=True) cpom = cmds.shadingNode("closestPointOnMesh", asUtility=True, n="tempCPOM") cmds.connectAttr("%s.outMesh"%shell, "%s.inMesh"%cpom) cmds.setAttr("%s.inPosition"%cpom, cardPos[0], cardPos[1], cardPos[2]) cmds.connectAttr("%s.worldMatrix"%shell, "%s.inputMatrix"%cpom) u = cmds.getAttr("%s.u"%cpom) v = cmds.getAttr("%s.v"%cpom) #from that uv, create a follicle on the proxy follicle = rig.follicle(shell, "%s_fol"%card, u=u, v=v) #constrain or parent the card to the follicle cmds.makeIdentity(apply=True, s=True) #cmds.parentConstraint(follicle[0], card, mo=True) cmds.parent(card, follicle[0]) #delete the closestPoint on mesh cmds.delete(cpom)
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=uDiv, v=vDiv, 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=self.numDiv, dv=3, tol=0.1, fr=0, dir=0) 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) #now create the control structure for the ribbon # basePosRaw = cmds.xform(self.follicleJntList[0], ws=True, q=True, t=True) # topPosRaw = cmds.xform(self.follicleJntList[self.numJoints], ws=True, q=True, t=True) # baseVec = om.MVector(basePosRaw[0], basePosRaw[1], basePosRaw[2]) # topVec = om.MVector(topPosRaw[0], topPosRaw[1], topPosRaw[2]) #find the center position ratio = self.centerPos #number 0-1, .5 is the middle #---------------- now just need to feed adjusted uv pos of mid into "alignToUV" #---------------- here i should align each top, mid, end to the UV pos I want. . . midUV = 0.5 * 2 * ratio #create ctrl structure prefixList = ["base", "mid", "top"] uvList = [0.0, midUV, 1.0] groupList = [] # vecList = [baseVec, midVec, topVec] locList = [] upLocList = [] ctrlList = [] ctrlJntList = [] #-----------create some options with switches for how things aim, etc at each other #--------deal with axis stuff below #-------then down below we need to use object space to move the locators #--------below must figure out how to parent the up locs to controls? ??? #for each of "base", "mid", "top" create the control structure for i in range(3): groupName = "%s_%s_GRP"%(self.name, prefixList[i]) groupList.append(groupName) # vecName = "%sVec"%prefixList[i] # vecList.append(vecName) #----------------create the whole setup at 000, then align the top group #create group cmds.group(empty=True, n=groupName) thisPos = cmds.xform(groupName, ws=True, q=True, t=True) #create and parent constraint locator locName = "%s_%s_constr_LOC"%(self.name, prefixList[i]) locList.append(locName) cmds.spaceLocator(n=locName) cmds.xform(locName, ws=True, t=(thisPos[0], thisPos[1], thisPos[2])) cmds.parent(locName, groupName) #create a parent constraint locator under the aim locator #create up locator upLocName = "%s_%s_up_LOC"%(self.name, prefixList[i]) upLocList.append(upLocName) cmds.spaceLocator(n=upLocName) #create option for what direction the up vec is? #----------------axis here cmds.xform(upLocName, ws=True, t=[0,0,-1]) cmds.parent(upLocName, groupName) #create controls ctrlName = "%s_%s_CTRL"%(self.name, prefixList[i]) ctrlList.append(ctrlName) #----------------axis here cmds.circle(nr=(0, 1, 0), r=(self.height/10*3), n=ctrlName) cmds.parent(ctrlName, locName) #create control joints (will already be parented to ctrl) jntName = "%s_%s_ctrl_JNT"%(self.name, prefixList[i]) ctrlJntList.append(jntName) ctrlJoint = cmds.joint(n=jntName, p=(0,0,0)) #----------------axis here #align group to surface rig.alignToUV(targetObj=groupName, sourceObj=self.ribbonName, sourceU=0.5, sourceV=uvList[i], mainAxis="+z", secAxis="+y", UorV="v") #now bind the nurbs geo cmds.select(cl=True) for jnt in ctrlJntList: cmds.select(jnt, add=True) cmds.select(self.ribbonName, add=True) cmds.skinCluster(mi=3, sw=0.5, omi=True, tsb=True, nw=1) #-------here add in the constraints to make this work properly. . . on each control have it tell what to aim at? lock these or not (depends on whether it's FK or not?) #-------also add in the FK option here, too. . . #base aim constrain to look at center #top aim constrain to look at center #mid parent constrain to either?, aim to either, point to either? #start packaging stuff up #-------hide the locators folGroup = cmds.group(empty=True, n="%s_follicles_GRP"%self.name) for fol in self.follicleList: cmds.parent(fol, folGroup) cmds.setAttr("%s.inheritsTransform"%folGroup, 0) ctrlsGroup = cmds.group(empty=True, n="%s_ctrls_GRP"%self.name) for grp in groupList: cmds.parent(grp, ctrlsGroup) geoGroup = cmds.group(empty=True, n="%s_geo_GRP"%self.name) cmds.parent(self.ribbonName, geoGroup) cmds.setAttr("%s.inheritsTransform"%geoGroup, 0) ribbonGroup = cmds.group(empty=True, n="%s_ribbon_GRP"%self.name) cmds.parent(folGroup, ribbonGroup) cmds.parent(ctrlsGroup, ribbonGroup) cmds.parent(geoGroup, ribbonGroup) cmds.select(ribbonGroup)
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=uDiv, v=vDiv, 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=self.numDiv, dv=3, tol=0.1, fr=0, dir=0) 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) #now create the control structure for the ribbon # basePosRaw = cmds.xform(self.follicleJntList[0], ws=True, q=True, t=True) # topPosRaw = cmds.xform(self.follicleJntList[self.numJoints], ws=True, q=True, t=True) # baseVec = om.MVector(basePosRaw[0], basePosRaw[1], basePosRaw[2]) # topVec = om.MVector(topPosRaw[0], topPosRaw[1], topPosRaw[2]) #find the center position ratio = self.centerPos #number 0-1, .5 is the middle #---------------- now just need to feed adjusted uv pos of mid into "alignToUV" #---------------- here i should align each top, mid, end to the UV pos I want. . . midUV = 0.5 * 2 * ratio #create ctrl structure prefixList = ["base", "mid", "top"] uvList = [0.0, midUV, 1.0] groupList = [] # vecList = [baseVec, midVec, topVec] locList = [] upLocList = [] ctrlList = [] ctrlJntList = [] #-----------create some options with switches for how things aim, etc at each other #--------deal with axis stuff below #-------then down below we need to use object space to move the locators #--------below must figure out how to parent the up locs to controls? ??? #for each of "base", "mid", "top" create the control structure for i in range(3): groupName = "%s_%s_GRP" % (self.name, prefixList[i]) groupList.append(groupName) # vecName = "%sVec"%prefixList[i] # vecList.append(vecName) #----------------create the whole setup at 000, then align the top group #create group cmds.group(empty=True, n=groupName) thisPos = cmds.xform(groupName, ws=True, q=True, t=True) #create and parent constraint locator locName = "%s_%s_constr_LOC" % (self.name, prefixList[i]) locList.append(locName) cmds.spaceLocator(n=locName) cmds.xform(locName, ws=True, t=(thisPos[0], thisPos[1], thisPos[2])) cmds.parent(locName, groupName) #create a parent constraint locator under the aim locator #create up locator upLocName = "%s_%s_up_LOC" % (self.name, prefixList[i]) upLocList.append(upLocName) cmds.spaceLocator(n=upLocName) #create option for what direction the up vec is? #----------------axis here cmds.xform(upLocName, ws=True, t=[0, 0, -1]) cmds.parent(upLocName, groupName) #create controls ctrlName = "%s_%s_CTRL" % (self.name, prefixList[i]) ctrlList.append(ctrlName) #----------------axis here cmds.circle(nr=(0, 1, 0), r=(self.height / 10 * 3), n=ctrlName) cmds.parent(ctrlName, locName) #create control joints (will already be parented to ctrl) jntName = "%s_%s_ctrl_JNT" % (self.name, prefixList[i]) ctrlJntList.append(jntName) ctrlJoint = cmds.joint(n=jntName, p=(0, 0, 0)) #----------------axis here #align group to surface rig.alignToUV(targetObj=groupName, sourceObj=self.ribbonName, sourceU=0.5, sourceV=uvList[i], mainAxis="+z", secAxis="+y", UorV="v") #now bind the nurbs geo cmds.select(cl=True) for jnt in ctrlJntList: cmds.select(jnt, add=True) cmds.select(self.ribbonName, add=True) cmds.skinCluster(mi=3, sw=0.5, omi=True, tsb=True, nw=1) #-------here add in the constraints to make this work properly. . . on each control have it tell what to aim at? lock these or not (depends on whether it's FK or not?) #-------also add in the FK option here, too. . . #base aim constrain to look at center #top aim constrain to look at center #mid parent constrain to either?, aim to either, point to either? #start packaging stuff up #-------hide the locators folGroup = cmds.group(empty=True, n="%s_follicles_GRP" % self.name) for fol in self.follicleList: cmds.parent(fol, folGroup) cmds.setAttr("%s.inheritsTransform" % folGroup, 0) ctrlsGroup = cmds.group(empty=True, n="%s_ctrls_GRP" % self.name) for grp in groupList: cmds.parent(grp, ctrlsGroup) geoGroup = cmds.group(empty=True, n="%s_geo_GRP" % self.name) cmds.parent(self.ribbonName, geoGroup) cmds.setAttr("%s.inheritsTransform" % geoGroup, 0) ribbonGroup = cmds.group(empty=True, n="%s_ribbon_GRP" % self.name) cmds.parent(folGroup, ribbonGroup) cmds.parent(ctrlsGroup, ribbonGroup) cmds.parent(geoGroup, ribbonGroup) cmds.select(ribbonGroup)
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)
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)