Beispiel #1
0
    def buildRibbonPlane(self):
        # Create Nurbs surface
        flexiPlane = cmds.nurbsPlane(w=self.width,
                                     lr=self.lengthRatio,
                                     u=self.numJnts,
                                     v=1,
                                     ax=[0, 1, 0])
        flexiPlane = cmds.rename(flexiPlane[0], '%s_surface01' % self.name)
        cmds.delete(flexiPlane, constructionHistory=1)

        # Create plane follicles
        mel.eval('createHair %s 1 2 0 0 0 0 1 0 1 1 1;' % str(self.numJnts))
        for obj in ['hairSystem1', 'pfxHair1', 'nucleus1']:
            cmds.delete(obj)
        folChildren = cmds.listRelatives('hairSystem1Follicles', ad=1)
        cmds.delete([i for i in folChildren if 'curve' in i])
        folGrp = cmds.rename('hairSystem1Follicles', '%s_flcs01' % self.name)

        alphabetList = map(chr, range(97, 123))
        folChildren = cmds.listRelatives(str(folGrp), c=1)
        folJnts = []

        for obj, letter in zip(folChildren, alphabetList):
            folJnt = cmds.joint(p=cmds.xform(obj, t=1, q=1),
                                n='%s_bind_%s01' % (self.name, letter))
            folJnts.append(folJnt)
            cmds.parent(folJnt, obj)
            cmds.rename(obj, '%s_flc_%s01' % (self.name, letter))

        utils.lockAttrs(flexiPlane, 1, 1, 1, 0)

        cmds.parent(folGrp, self.extrasGrp)
        cmds.parent(flexiPlane, self.moveGrp)

        return flexiPlane, folGrp
Beispiel #2
0
    def buildRibbonPlane(self):
        # Create Nurbs surface
        flexiPlane = cmds.nurbsPlane(w=self.width, lr=self.lengthRatio,
                                     u=self.numJnts, v=1, ax=[0, 1, 0])
        flexiPlane = cmds.rename(flexiPlane[0], '%s_surface01' % self.name)
        cmds.delete(flexiPlane, constructionHistory=1)

        # Create plane follicles
        mel.eval('createHair %s 1 2 0 0 0 0 1 0 1 1 1;' % str(self.numJnts))
        for obj in ['hairSystem1', 'pfxHair1', 'nucleus1']:
            cmds.delete(obj)
        folChildren = cmds.listRelatives('hairSystem1Follicles', ad=1)
        cmds.delete([i for i in folChildren if 'curve' in i])
        folGrp = cmds.rename('hairSystem1Follicles', '%s_flcs01' % self.name)

        alphabetList = map(chr, range(97, 123))
        folChildren = cmds.listRelatives(str(folGrp), c=1)
        folJnts = []

        for obj, letter in zip(folChildren, alphabetList):
            folJnt = cmds.joint(p=cmds.xform(obj, t=1, q=1), n='%s_bind_%s01' % (self.name, letter))
            folJnts.append(folJnt)
            cmds.parent(folJnt, obj)
            cmds.rename(obj, '%s_flc_%s01' % (self.name, letter))

        utils.lockAttrs(flexiPlane, 1, 1, 1, 0)

        cmds.parent(folGrp, self.extrasGrp)
        cmds.parent(flexiPlane, self.moveGrp)

        return flexiPlane, folGrp
Beispiel #3
0
    def buildControls(self, createControls=True):
        # Create a global move control
        globalCon = self.utils.createStarControl(name='%s_con_global01' % self.name, radius=1.5)
        cmds.setAttr('%s.overrideEnabled' % globalCon, 1)
        cmds.setAttr('%s.overrideColor' % globalCon, 17)

        cmds.addAttr(globalCon, at='enum', ln='maintainVolume', en='---', k=1)
        cmds.setAttr('%s.maintainVolume' % globalCon, k=0, l=1, cb=1)
        cmds.addAttr(globalCon, at='bool', ln='volEnable', k=1)

        cmds.parent(globalCon, self.rootGrp)
        cmds.parent(self.moveGrp, globalCon)

        # Create FK controls if option selected
        if createControls:

            transCons = ['%s_con_a01' % self.name, '%s_con_b01' % self.name, '%s_midBend01' % self.name]

            for squareCon in transCons:
                squareCon = cmds.curve(n=squareCon, d=1, p=[(-1, 0, -1), (1, 0, -1), (1, 0, 1), (-1, 0, 1), (-1, 0, -1)])
                cmds.scale(.75, .75, .75, squareCon, r=1)
                cmds.setAttr('%s.overrideEnabled' % squareCon, 1)
                cmds.setAttr('%s.overrideColor' % squareCon, 17)
                cmds.xform(squareCon, roo='xzy')
                squareShape = cmds.listRelatives(squareCon, type='shape')
                cmds.rename(squareShape, '%sShape' % squareCon)

            topCon = transCons[0]
            botCon = transCons[1]
            midCon = transCons[2]

            cmds.xform(topCon, t=(-self.width / 2, 0, 0), ws=1)
            cmds.xform(botCon, t=(self.width / 2, 0, 0), ws=1)
            cmds.xform(midCon, t=(0, 0, 0), ws=1)
            cmds.makeIdentity(transCons, a=1)

            squareConGrp = cmds.group(topCon, botCon, n='%s_cons01' % self.name)
            midConGrp = cmds.group(midCon, n='%s_midCon01' % self.name)
            cmds.parent(midConGrp, squareConGrp)
            cmds.pointConstraint(botCon, topCon, midConGrp, mo=0)

            # Lock and hide controller attrs
            utils.lockAttrs(topCon, 0, 0, 1, 1)
            utils.lockAttrs(botCon, 0, 0, 1, 1)
            utils.lockAttrs(midCon, 0, 1, 1, 1)

            for con in transCons:
                cmds.setAttr('%s.rotateY' % con, l=1, k=0, cb=0)
                cmds.setAttr('%s.rotateZ' % con, l=1, k=0, cb=0)

            cmds.parent(squareConGrp, self.moveGrp)

            return transCons, globalCon

        else:
            return [globalCon]
Beispiel #4
0
    def buildControls(self, createControls=True):
        # Create a global move control
        globalCon = self.utils.createStarControl(name='%s_con_global01' %
                                                 self.name,
                                                 radius=1.5)
        cmds.setAttr('%s.overrideEnabled' % globalCon, 1)
        cmds.setAttr('%s.overrideColor' % globalCon, 17)

        cmds.addAttr(globalCon, at='enum', ln='maintainVolume', en='---', k=1)
        cmds.setAttr('%s.maintainVolume' % globalCon, k=0, l=1, cb=1)
        cmds.addAttr(globalCon, at='bool', ln='volEnable', k=1)

        cmds.parent(globalCon, self.rootGrp)
        cmds.parent(self.moveGrp, globalCon)

        # Create FK controls if option selected
        if createControls:

            transCons = [
                '%s_con_a01' % self.name,
                '%s_con_b01' % self.name,
                '%s_midBend01' % self.name
            ]

            for squareCon in transCons:
                squareCon = cmds.curve(n=squareCon,
                                       d=1,
                                       p=[(-1, 0, -1), (1, 0, -1), (1, 0, 1),
                                          (-1, 0, 1), (-1, 0, -1)])
                cmds.scale(.75, .75, .75, squareCon, r=1)
                cmds.setAttr('%s.overrideEnabled' % squareCon, 1)
                cmds.setAttr('%s.overrideColor' % squareCon, 17)
                cmds.xform(squareCon, roo='xzy')
                squareShape = cmds.listRelatives(squareCon, type='shape')
                cmds.rename(squareShape, '%sShape' % squareCon)

            topCon = transCons[0]
            botCon = transCons[1]
            midCon = transCons[2]

            cmds.xform(topCon, t=(-self.width / 2, 0, 0), ws=1)
            cmds.xform(botCon, t=(self.width / 2, 0, 0), ws=1)
            cmds.xform(midCon, t=(0, 0, 0), ws=1)
            cmds.makeIdentity(transCons, a=1)

            squareConGrp = cmds.group(topCon,
                                      botCon,
                                      n='%s_cons01' % self.name)
            midConGrp = cmds.group(midCon, n='%s_midCon01' % self.name)
            cmds.parent(midConGrp, squareConGrp)
            cmds.pointConstraint(botCon, topCon, midConGrp, mo=0)

            # Lock and hide controller attrs
            utils.lockAttrs(topCon, 0, 0, 1, 1)
            utils.lockAttrs(botCon, 0, 0, 1, 1)
            utils.lockAttrs(midCon, 0, 1, 1, 1)

            for con in transCons:
                cmds.setAttr('%s.rotateY' % con, l=1, k=0, cb=0)
                cmds.setAttr('%s.rotateZ' % con, l=1, k=0, cb=0)

            cmds.parent(squareConGrp, self.moveGrp)

            return transCons, globalCon

        else:
            return [globalCon]