Пример #1
0
    def __create_controls(self):
        """ Create the flexiPlane controls """
        #--- create main control
        name = self._mod + self._name[0].upper() + self._name[1:]
        self.control_main = controls.Control(side=self._side,
                                             name=name + 'Main',
                                             size=self._size + 0.75,
                                             shape=5,
                                             color=self._color,
                                             orientation=16,
                                             parent=self.main)
        #--- create up control
        self.control_up = controls.Control(side=self._side,
                                           name=name + 'Up',
                                           size=self._size + 0.25,
                                           shape=1,
                                           color=6,
                                           position=[5, 0, 0],
                                           parent=self.global_move)
        #--- create down control
        self.control_down = controls.Control(side=self._side,
                                             name=name + 'Down',
                                             size=self._size + 0.25,
                                             shape=1,
                                             color=6,
                                             position=[-5, 0, 0],
                                             parent=self.global_move)
        #--- create mid control
        self.control_mid = controls.Control(side=self._side,
                                            name=name + 'Mid',
                                            size=self._size + 0.25,
                                            shape=2,
                                            color=self._color,
                                            parent=self.global_move)
        if self._follow:
            node.pointConstraint(
                objA=[self.control_down.transform, self.control_up.transform],
                objB=self.control_mid.group,
                maintainOffset=False)

        #--- create individual joint controls, parented under the follicle
        for i in range(len(self.follicle)):
            j = i + 1
            #--- create main control
            jnt_ctl = controls.Control(side=self._side,
                                       name=name + "FlexiJnt" + ` j `,
                                       size=self._size / 1.5,
                                       shape=1,
                                       color=13,
                                       rotation=[90, 0, 0],
                                       parent=self.follicle[i])
            goe.setAttr(jnt_ctl.group + '.t', 0, 0, 0)
            attribute.lock_n_hide(jnt_ctl.transform, ['t'])
            self.jnt_ctl.append(jnt_ctl)
Пример #2
0
 def __create_control(self, side, name, index, color, parent):
     ctl = controls.Control(side=side,
                            name=name + 'Guide' + repr(index),
                            shape=self._shape,
                            size=self._size,
                            color=color,
                            position=self.position[index],
                            rotation=self.rotation[index],
                            parent=parent)
     self.__add_control_attributes(ctl.transform, side, name, index)
     return ctl
Пример #3
0
 def __create_controls(self):
     dist = self.__get_boundingbox_distance()
     #--- main control
     self.main_control = controls.Control(side='C',
                                          name='main',
                                          shape=12,
                                          size=dist,
                                          color=4,
                                          offsetGroups=1,
                                          withGimbal=True,
                                          parent=self.main_mod,
                                          exists=True)
     #--- current asset control
     self.current_asset = controls.Control(
         side='C',
         name='currentAsset',
         shape=2,
         size=dist / 4,
         color=4,
         orientation=42,
         position=[0, dist, 0],
         lockAttrs={'transform': ['t', 'r', 's']},
         parent=self.main_control.gimbal,
         exists=True)
Пример #4
0
 def __create_controls(self):
     for num, i in enumerate(self.guides):
         name = None
         pos = i[1]
         rot = i[2]
         name = self._moduleName + repr(num)
         ctl = controls.Control(side=self._side,
                                name=name,
                                shape=self._shape,
                                size=self._size,
                                color=self._color,
                                position=pos,
                                rotation=rot,
                                withGimbal=self._withGimbal,
                                rotateOrder=self._rotateOrder,
                                offsetGroups=self._offsetGroups,
                                parent=self.mod_grp)
         #--- append to a list
         self.controls.append(ctl)
Пример #5
0
    def __muscle_system(self):
        """ Create a simple muscle system based on sculptDeformers """
        if not self._muscleSystem:
            return
        #--- check if specified mesh is a mesh
        if self._mesh:
            msg = 'Specified mesh: ' + str(self._mesh) + ' does not exist!'
            assert cmds.objExists(self._mesh), msg
            child = cmds.listRelatives(self._mesh, allDescendents=True)
            node_type = cmds.nodeType(child)
            msg = 'Specified mesh: ' + str(self._mesh) + ' is not a mesh!'
            assert node_type == 'mesh', msg
            if not self._muscles < 1:
                #--- create a nurbsPlane
                self.muscle_surface = cmds.nurbsPlane(degree=1,
                                                      width=10,
                                                      lengthRatio=0.2,
                                                      patchesU=self._length,
                                                      patchesV=1,
                                                      axis=(0, 1, 0),
                                                      name=self.name +
                                                      'Muscle_NRB')[0]
                #--- rotate the muscle surface
                goe.setAttr(self.muscle_surface + '.r', self._rotation)
                #--- parent the muscle surface under extra nodes
                cmds.parent(self.muscle_surface, self.extra_nodes)
                #--- create a follicle by the given amount of the muscles flag
                for i in range(self._muscles):
                    i = i + 1
                    if i == 0:
                        continue
                    #--- MUSCLE FOLLICLE SETUP JUST SCULPT DEFORMER
                    #--- create a follicle on the muscle plane
                    mus_follicle = node.follicle(name=self.name + 'Muscle' +
                                                 ` i `,
                                                 suffix='FOL',
                                                 parameterU=0,
                                                 parameterV=0.5,
                                                 parent=self.follicle_grp,
                                                 show=False,
                                                 lockAttr='parameterV')
                    #--- connect the follicle with the muscle surface
                    goe.connectAttr(self.muscle_surface + '.local',
                                    mus_follicle[1] + '.inputSurface')
                    goe.connectAttr(self.muscle_surface + '.worldMatrix[0]',
                                    mus_follicle[1] + '.inputWorldMatrix')
                    #--- connect the main control and the muscle follicle
                    at = '.muscle' + ` i ` + 'Slide'
                    goe.connectAttr(self.control_main.transform + at,
                                    mus_follicle[1] + '.parameterU')

                    #--- NORMAL FOLLICLE SETUP, MUSCLE CTL DRIVES SCULPT
                    #--- create a follicle on the normal surface
                    norm_follicle = node.follicle(name=self.name +
                                                  'MuscleCtl' + ` i `,
                                                  suffix='FOL',
                                                  parameterU=0,
                                                  parameterV=0.5,
                                                  parent=self.follicle_grp,
                                                  show=False,
                                                  lockAttr='parameterV')
                    #--- connect the follicle with the normal surface
                    goe.connectAttr(self.surface + '.local',
                                    norm_follicle[1] + '.inputSurface')
                    goe.connectAttr(self.surface + '.worldMatrix[0]',
                                    norm_follicle[1] + '.inputWorldMatrix')
                    #--- connect the normal follicle scale attributes to the globalMovement group
                    node.scaleConstraint(objA=self.global_move,
                                         objB=norm_follicle[0],
                                         maintainOffset=True)
                    #--- create connections between the main control and the muscle follicle
                    at = '.muscle' + ` i ` + 'Slide'
                    goe.connectAttr(self.control_main.transform + at,
                                    norm_follicle[1] + '.parameterU')

                    #--- SCULPT DEFORMER
                    #--- create a control for the sculpt deformer and set it up
                    nme = self._mod + self._name[0].upper(
                    ) + self._name[1:] + 'Muscle' + ` i `
                    self.mus_ctl = controls.Control(side=self._side,
                                                    name=nme,
                                                    suffix='FPCTL',
                                                    size=self._size + 0.1,
                                                    shape=2,
                                                    color=self._color,
                                                    parent=norm_follicle[0])
                    #--- connect the size attr of the main control with the
                    #--- scale of the muscle controls' group
                    for axis in 'xyz':
                        at = '.muscle' + ` i ` + 'Size'
                        goe.connectAttr(self.control_main.transform + at,
                                        self.mus_ctl.group + '.s' + axis)
                    #--- connect the visiblity of the control with the
                    #--- muscle attr of the main control
                    goe.connectAttr(
                        self.control_main.transform + '.muscle' + ` i `,
                        self.mus_ctl.transform + '.v')
                    #--- create a sculpt deformer and parent it under the muscle follicle
                    sculpt = deformer.sculpt(mod=self._mod,
                                             side=self._side,
                                             name=self._name + 'Muscle',
                                             suffix='DEF',
                                             geometry=self._mesh,
                                             dropoffDistance=0.14,
                                             parent=mus_follicle[0])

                    #--- CONNECTION MUSCLE CONTROL WITH SCULPT DEFORMER
                    #--- connect the muscle size attr with the sculpt radius
                    at = '.muscle' + ` i ` + 'Size'
                    goe.connectAttr(self.control_main.transform + at,
                                    sculpt[1] + '.radius')
                    attribute.lock_attributes(sculpt[0], ['s'], False)
                    #--- connect the muscle controls scale with the sculpt one
                    goe.connectAttr(self.mus_ctl.transform + '.s',
                                    sculpt[0] + '.s')
                    #--- connect the muscle MaxDisplacement attr with the sculpt one
                    at = '.muscle' + ` i ` + 'MaxDisplace'
                    goe.connectAttr(self.control_main.transform + at,
                                    sculpt[2] + '.maximumDisplacement')
                    #--- connect the muscle dropOff attr with the sculpt one
                    at = '.muscle' + ` i ` + 'DropOff'
                    goe.connectAttr(self.control_main.transform,
                                    sculpt[2] + '.dropoffDistance')
                    #--- connect t and r of the sculpt with the muscle ctl
                    goe.connectAttr(self.mus_ctl.transform + '.t',
                                    sculpt[0] + '.t')
                    goe.connectAttr(self.mus_ctl.transform + '.r',
                                    sculpt[0] + '.r')
                    #--- lock tx attribute of the muscle ctl
                    attribute.lock_attributes(self.mus_ctl.transform, ['tx'])
                    #--- set the sculpts' transform values to default
                    goe.setAttr(sculpt[-1] + '.t', 0, 0, 0)
                    goe.setAttr(sculpt[-1] + '.r', 0, 0, 0)
                    attribute.lock_attributes(sculpt[-1], ['t', 'r'])
                    cmds.setAttr(sculpt[0] + '.visibility', 0, lock=True)

                #--- COMPUTE PART
                #--- compute the steps to go to locate the cv's translateX position
                step = (10 / float(self._length))
                off = (10 / float(self._length))
                cv_pos = [[-5.0, 0.0, 0.0]]
                for i in range(self._length):
                    res = -5 + step
                    pos = [res, 0.0, 0.0]
                    cv_pos.append(pos)
                    step = +step + off
                #--- create the curves based on the computed position
                #--- and create clusters for each cv
                crv = cmds.curve(degree=2, point=cv_pos)
                mus_crv = cmds.rename(crv, self.name + 'Muscle_CRV')
                mus_cvs = cmds.ls(mus_crv + '.cv[*]', flatten=True)
                cmds.parent(mus_crv, self.extra_nodes)
                #--- create a matrix setup to connect the cvs with the control
                for i in range(len(mus_cvs)):
                    dcm = node.decomposeMatrix(name=self.name + 'Muscle' +
                                               ` i `)
                    if i == 0:
                        goe.connectAttr(
                            self.control_down.transform + '.worldMatrix[0]',
                            dcm + '.inputMatrix')
                        goe.connectAttr(dcm + '.outputTranslate',
                                        mus_crv + '.controlPoints[0]')
                    elif i == (len(mus_cvs) - 1):
                        goe.connectAttr(
                            self.control_up.transform + '.worldMatrix[0]',
                            dcm + '.inputMatrix')
                        at = 'controlPoints[' + str(len(mus_cvs) - 1) + ']'
                        goe.connectAttr(dcm + '.outputTranslate', mus_crv + at)
                    else:
                        goe.connectAttr(
                            self.jnt_ctl[i - 1].transform + '.worldMatrix[0]',
                            dcm + '.inputMatrix')
                        at = '.controlPoints[' + ` i ` + ']'
                        goe.connectAttr(dcm + '.outputTranslate', mus_crv + at)