Ejemplo n.º 1
0
    def _create(self, shapeData):
        point = None
        count = 0
        while True:
            count += 1
            if count > 10000:
                return False

            point = shapeData['box'].getRandomPointInside(padding=self._padding)

            if not cmds.elixirGeneral_PointInsideMesh(mesh=shapeData['name'], point=point):
                continue

            if self._padding > 0:
                cmds.setAttr(self._meshPointNode + '.inPosition', *point, type='double3')
                closestPoint = cmds.getAttr(self._meshPointNode + '.result.position')[0]

                dx = (closestPoint[0] - point[0])
                dy = (closestPoint[1] - point[1])
                dz = (closestPoint[2] - point[2])
                dist = math.sqrt(dx*dx + dy*dy + dz*dz)

                if dist < self._padding:
                    continue
            break

        cube = cmds.polyCube(width=self._size, height=self._size, depth=self._size)
        cmds.move(point[0], point[1], point[2], cube[0], absolute=True)
        return True
Ejemplo n.º 2
0
def doSingle():

    #keyframes a bubble, does NOT use slider
    r = .1
    c = cmds.polySphere(r=r)
    cmds.setAttr(c[0] + ".visibility", 0)
    cmds.setKeyframe(time=60)
    cmds.scale(11, 10, 11)
    cmds.move(0, 20, 0)
    cmds.setKeyframe(time=50)
    cmds.setAttr(c[0] + ".visibility", 1)
    cmds.rotate(100, 0, 0)
    cmds.scale(10, 9, 9.5)
    cmds.setKeyframe(time=40)
    cmds.move(4, 10, 0)
    cmds.rotate(60, 0, 0)
    cmds.setKeyframe(time=30)
    cmds.move(0, 6, 0)
    cmds.rotate(0, 0, 0)
    cmds.setKeyframe(time=20)
    cmds.move(0, 3, 0)
    cmds.scale(3, 3, 3)
    cmds.setKeyframe(time=10)
    cmds.move(0, 0, 0)
    cmds.scale(1, .8, 1)
    cmds.setKeyframe(time=1)
Ejemplo n.º 3
0
    def _makeMolecule(self):
        #H2O
        O = cmds.polySphere(r=1, n='O', ax = [0,0,0]);
        H1 = cmds.polySphere(r=0.8, n='H1', ax=[0,0,0]);
        H2 = cmds.polySphere(r=0.8, n='H2', ax=[0,0,0]);
        cmds.move(0.0,0.0,1,H1, r=True)
        cmds.move(0.0,0.0,-1,H2, r=True)
        cmds.xform(H1, piv=[0,0,0], ws=True)
        cmds.xform(H2, piv=[0,0,0], ws=True)
        cmds.rotate(0,'60',0, H1);

        #group O, H1, H2 as a water molecule
        H2O = cmds.group( empty=True, name='H2O' )
        cmds.parent(H1,H2,O,H2O)

        #paint on colors for the water molecule
        #create red lambert
        cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name='O_WhiteSG' )
        cmds.shadingNode( 'lambert', asShader=True, name='O_White' )
        cmds.setAttr( 'O_White.color', 1, 1, 1, type='double3')
        cmds.connectAttr('O_White.outColor', 'O_WhiteSG.surfaceShader')
        #create red lambert
        cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name='H_RedSG' )
        cmds.shadingNode( 'lambert', asShader=True, name='H_Red' )
        cmds.setAttr( 'H_Red.color', 1, 0, 0, type='double3')
        cmds.connectAttr('H_Red.outColor', 'H_RedSG.surfaceShader')

        #assign the material
        cmds.sets('H1', edit=True, forceElement='H_RedSG')
        cmds.sets('H2', edit=True, forceElement='H_RedSG')
        cmds.sets('O', edit=True, forceElement='O_WhiteSG')
        return H2O
Ejemplo n.º 4
0
    def createShaderFromConfig(cls, shaderConfig):
        """create a shader and engine if not already available"""

        if not cls.shaderExistsInScene(shaderConfig):
            shader = cmds.shadingNode(
                shaderConfig['type'],
                name=shaderConfig['uid'],
                asShader=True)
            cmds.setAttr(shader + '.color', *shaderConfig['color'], type='double3')
            if 'transparency' in shaderConfig:
                cmds.setAttr(
                    shader + '.transparency',
                    *shaderConfig['transparency'], type='double3')

            shaderEngine = cmds.sets(
                renderable=True,
                noSurfaceShader=True,
                empty=True,
                name=shader + '_SG')
            cmds.connectAttr(shader + '.outColor', shaderEngine + '.surfaceShader')
        else:
            shader  = shaderConfig['uid']
            engines = cmds.listConnections(shader + '.outColor')
            if engines:
                shaderEngine = engines[0]
            else:
                shaderEngine = cmds.sets(
                    renderable=True,
                    noSurfaceShader=True,
                    empty=True,
                    name=shader + '_SG')
                cmds.connectAttr(shader + '.outColor', shaderEngine + '.surfaceShader')

        return shader, shaderEngine
Ejemplo n.º 5
0
    def _create(self, shapeData):
        point = None
        count = 0
        while True:
            count += 1
            if count > 10000:
                return False

            point = shapeData['box'].getRandomPointInside(padding=self._padding)

            if not cmds.elixirGeneral_PointInsideMesh(mesh=shapeData['name'], point=point):
                continue

            if self._padding > 0:
                cmds.setAttr(self._meshPointNode + '.inPosition', *point, type='double3')
                closestPoint = cmds.getAttr(self._meshPointNode + '.result.position')[0]

                dx = (closestPoint[0] - point[0])
                dy = (closestPoint[1] - point[1])
                dz = (closestPoint[2] - point[2])
                dist = math.sqrt(dx*dx + dy*dy + dz*dz)

                if dist < self._padding:
                    continue
            break

        cube = cmds.polyCube(width=self._size, height=self._size, depth=self._size)
        cmds.move(point[0], point[1], point[2], cube[0], absolute=True)
        return True
Ejemplo n.º 6
0
def doMulti(time):

    for i in range(0, time / 2):
        #makes time/2 bubbles and sets up a bunch of random stats for them
        initTime = randint(0, time - 30)
        initX = randint(-10, 10)
        initZ = randint(-10, 10)
        xRand = randint(-5, 5)
        zRand = randint(-5, 5)

        #keyframes all the bubbles based on time that user sets in Qt slider
        r = .1
        c = cmds.polySphere(r=r)
        cmds.setAttr(c[0] + ".visibility", 0)
        cmds.setKeyframe(time=initTime + 60)
        cmds.scale(11, 10, 11)
        cmds.move(initX, 20, initZ)
        cmds.setKeyframe(time=initTime + 50)
        cmds.setAttr(c[0] + ".visibility", 1)
        cmds.rotate(100, 0, 0)
        cmds.scale(10, 9, 9.5)
        cmds.setKeyframe(time=initTime + 40)
        cmds.move(initX + xRand, 10, initZ + zRand)
        cmds.rotate(60, 0, 0)
        cmds.setKeyframe(time=initTime + 30)
        cmds.move(initX, 6, initZ)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe(time=initTime + 20)
        cmds.move(initX, 3, initZ)
        cmds.scale(3, 3, 3)
        cmds.setKeyframe(time=initTime + 10)
        cmds.move(initX, 0, initZ)
        cmds.scale(1, .8, 1)
        cmds.setKeyframe(time=initTime)
Ejemplo n.º 7
0
    def _handleArm(self):
        time.sleep(2)

        ctime = cmds.currentTime(query=True)

        cmds.select('arm_L')

        cmds.setAttr('arm_L.rx', 0)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 10)
        cmds.setAttr('arm_L.rx', -90)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 15)
        cmds.setAttr('arm_L.rx', -180)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 25)
        cmds.setAttr('arm_L.rx', -180)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 35)
        cmds.setAttr('arm_L.rx', 0)
        cmds.setKeyframe()
Ejemplo n.º 8
0
    def _handleRun(self):
        def rotate_limbs(angle):

            cmds.select('arm_L')
            cmds.setAttr('arm_L.rx', angle)
            cmds.setKeyframe(at='rotateX')

            cmds.select('arm_R')
            cmds.setAttr('arm_R.rx', -angle)
            cmds.setKeyframe(at='rotateX')

            cmds.select('left_L')
            cmds.setAttr('left_L.rx', -angle)
            cmds.setKeyframe(at='rotateX')

            cmds.select('leg_R')
            cmds.setAttr('leg_R.rx', angle)
            cmds.setKeyframe(at='rotateX')

        def change_height(height):

            cmds.select('Lego_Group')
            cmds.setAttr('Lego_Group.ty', height)
            cmds.setKeyframe(at='translateY')

        ctime = cmds.currentTime(query=True)

        cmds.select('Lego_Group')
        cmds.setAttr('Lego_Group.tz', 0)
        cmds.setKeyframe(at='translateZ')

        for index in range(1, 5):

            rotate_limbs(0)
            change_height(0)

            ctime += 5
            cmds.currentTime(ctime)
            rotate_limbs(90)
            change_height(3)

            ctime += 5
            cmds.currentTime(ctime)
            rotate_limbs(0)
            change_height(0)

            ctime += 5
            cmds.currentTime(ctime)
            rotate_limbs(-90)
            change_height(3)

            ctime += 5
            cmds.currentTime(ctime)

        rotate_limbs(0)
        change_height(0)

        cmds.select('Lego_Group')
        cmds.setAttr('Lego_Group.tz', 65)
        cmds.setKeyframe(at='translateZ')
Ejemplo n.º 9
0
 def _handleEyeHeight(self, value_e):
     response=nimble.createRemoteResponse(globals())
     scaledVal_e = float(value_e)/100
     translateEyeball = (scaledVal_e)*(0.13)+5.941
     response.put('name', cmds.setAttr('blendShape7.pasted__pasted__face2', scaledVal_e))
     #print(translateEyeball)
     response.put('name', cmds.setAttr('pasted__pasted__L_eye1.translateY', translateEyeball))
     response.put('name', cmds.setAttr('pasted__pasted__R_eye1.translateY', translateEyeball))
Ejemplo n.º 10
0
    def setAllLayersVisible(self, visible):
        """ This sets all layers visible, as the name suggests. """

        layers = cmds.ls( type='displayLayer')

        for layer in layers:
            if layer.endswith(self.LAYER_SUFFIX):
                cmds.setAttr('%s.visibility' % layer, visible)
Ejemplo n.º 11
0
    def showTrackway(self, trackwayName, visible =True):
        """ Presuming the track nodes for a specified trackway are already in a
            corresponding layer, this turns on visibility of that layer. """

        layer = trackwayName + self.LAYER_SUFFIX

        # then set that layer either visible or invisible according to the kwarg
        cmds.setAttr('%s.visibility' % layer, visible)
Ejemplo n.º 12
0
 def setTrackProps(cls, node, props):
     for enum in Reflection.getReflectionList(TrackPropEnum):
         if enum.maya and enum.maya in props:
             if enum.type == 'string':
                 cmds.setAttr(
                     node + '.' + enum.maya, props[enum.maya],
                     type=enum.type)
             else:
                 cmds.setAttr(node + '.' + enum.maya, props[enum.maya])
Ejemplo n.º 13
0
def eyeBrow(newVal):
    if newVal < 0:
        nonSuffix = "FaceDeformer.FaceAngry"
        suffix    = "FaceDeformer.FaceSad"
    else:
        suffix    =  "FaceDeformer.FaceAngry"
        nonSuffix = "FaceDeformer.FaceSad"
    newVal = abs(newVal)/100.0
    mc.setAttr(nonSuffix,  0.0)
    mc.setAttr(suffix, newVal)
Ejemplo n.º 14
0
 def handleEyebrowSlider(self):
     topCapAmt = 0.021
     btmCapAmt = -0.014
     value = self.eyebrowSlider.value()
     eyebrowValue = float(value) * float(topCapAmt / 10.0)
     if value < 0:
         lowEyebrowValue = float(value) * float(btmCapAmt / 10.0)
         cmds.setAttr('eyebrowsClusterHandle.translateY', -lowEyebrowValue)
     else:
         cmds.setAttr('eyebrowsClusterHandle.translateY', eyebrowValue)
Ejemplo n.º 15
0
 def handleSmileSlider(self):
     topCapAmt = 0.016
     btmCapAmt = -0.032
     value = self.smileSlider.value()
     smileValue = float(value) * float(topCapAmt / 10.0)
     if value < 0:
         lowSmileValue = float(value) * float(btmCapAmt / 10.0)
         cmds.setAttr("smileClusterHandle.translateY", -lowSmileValue)
     else:
         cmds.setAttr("smileClusterHandle.translateY", smileValue)
Ejemplo n.º 16
0
def head(newVal):
    if newVal < 0:
        nonSuffix = "FaceDeformer.FaceTall"
        suffix    = "FaceDeformer.FaceWide"
    else:
        suffix    =  "FaceDeformer.FaceTall"
        nonSuffix = "FaceDeformer.FaceWide"
    newVal = abs(newVal)/100.0
    mc.setAttr(nonSuffix,  0.0)
    mc.setAttr(suffix, newVal)
Ejemplo n.º 17
0
 def handleSmileSlider(self):
     topCapAmt = 0.016
     btmCapAmt = -0.032
     value = self.smileSlider.value()
     smileValue = float(value) * float(topCapAmt / 10.0)
     if value < 0:
         lowSmileValue = float(value) * float(btmCapAmt / 10.0)
         cmds.setAttr('smileClusterHandle.translateY', -lowSmileValue)
     else:
         cmds.setAttr('smileClusterHandle.translateY', smileValue)
Ejemplo n.º 18
0
 def handleSchnauzSlider(self):
     topCapAmt = 0.028
     btmCapAmt = 0.000
     value = self.schnauzSlider.value()
     schnauzValue = float(value) * float(topCapAmt / 10.0)
     if value < 0:
         lowSchnauzValue = float(value) * float(btmCapAmt / 10.0)
         cmds.setAttr('schnauzClusterHandle.translateY', -lowSchnauzValue)
     else:
         cmds.setAttr('schnauzClusterHandle.translateY', schnauzValue)
Ejemplo n.º 19
0
 def handleSchnauzSlider(self):
     topCapAmt = 0.028
     btmCapAmt = 0.000
     value = self.schnauzSlider.value()
     schnauzValue = float(value) * float(topCapAmt / 10.0)
     if value < 0:
         lowSchnauzValue = float(value) * float(btmCapAmt / 10.0)
         cmds.setAttr("schnauzClusterHandle.translateY", -lowSchnauzValue)
     else:
         cmds.setAttr("schnauzClusterHandle.translateY", schnauzValue)
Ejemplo n.º 20
0
 def handleEyebrowSlider(self):
     topCapAmt = 0.021
     btmCapAmt = -0.014
     value = self.eyebrowSlider.value()
     eyebrowValue = float(value) * float(topCapAmt / 10.0)
     if value < 0:
         lowEyebrowValue = float(value) * float(btmCapAmt / 10.0)
         cmds.setAttr("eyebrowsClusterHandle.translateY", -lowEyebrowValue)
     else:
         cmds.setAttr("eyebrowsClusterHandle.translateY", eyebrowValue)
Ejemplo n.º 21
0
def mouthEnbiggen(newVal):
    if newVal < 0:
        nonSuffix = "FaceDeformer.FaceBigMouth"
        suffix = "FaceDeformer.FaceSmallMouth"
    else:
        suffix = "FaceDeformer.FaceBigMouth"
        newVal = newVal * .75
        nonSuffix = "FaceDeformer.FaceSmallMouth"
    newVal = abs(newVal) / 100.0
    mc.setAttr(nonSuffix, 0.0)
    mc.setAttr(suffix, newVal)
Ejemplo n.º 22
0
def mouth(newVal):
    if newVal < 0:
        nonSuffix = "FaceDeformer.Face6"
        suffix = "FaceDeformer.FaceFrown"
    else:
        suffix = "FaceDeformer.Face6"
        newVal = newVal * .75
        nonSuffix = "FaceDeformer.FaceFrown"
    newVal = abs(newVal) / 100.0
    mc.setAttr(nonSuffix, 0.0)
    mc.setAttr(suffix, newVal)
Ejemplo n.º 23
0
def mouth(newVal):
    if newVal < 0:
        nonSuffix = "FaceDeformer.Face6"
        suffix    = "FaceDeformer.FaceFrown"
    else:
        suffix    =  "FaceDeformer.Face6"
        newVal = newVal*.75
        nonSuffix = "FaceDeformer.FaceFrown"
    newVal = abs(newVal)/100.0
    mc.setAttr(nonSuffix,  0.0)
    mc.setAttr(suffix,  newVal)
Ejemplo n.º 24
0
def clearPlastic():
    ### clear plastic
    global cPlasticSG
    cPlastic = mc.shadingNode('phong', asShader=True, n='cPlastic')
    cPlasticSG = mc.sets(r=True, nss=True, em=True, n='cPlasticSG')
    mc.connectAttr(cPlastic + '.outColor', cPlasticSG + '.surfaceShader')
    mc.setAttr(cPlastic + '.color', 0.0, 0.0, 0.0, type='double3')
    mc.setAttr(cPlastic + '.cosinePower', 20)
    mc.setAttr(cPlastic + '.specularColor', 2.0, 2.0, 2.0, type='double3')
    mc.setAttr(cPlastic + '.reflectivity', 0.5)
    mc.setAttr(cPlastic + '.transparency', 0.6, 0.6, 0.6, type='double3')
Ejemplo n.º 25
0
def mouthEnbiggen(newVal):
    if newVal < 0:
        nonSuffix = "FaceDeformer.FaceBigMouth"
        suffix    = "FaceDeformer.FaceSmallMouth"
    else:
        suffix    =  "FaceDeformer.FaceBigMouth"
        newVal=newVal*.75
        nonSuffix = "FaceDeformer.FaceSmallMouth"
    newVal = abs(newVal)/100.0
    mc.setAttr(nonSuffix,  0.0)
    mc.setAttr(suffix,  newVal)
Ejemplo n.º 26
0
def bouncingBubble(amp, sampFreq, scaleFactor):
    startRadius = 1.0  #2.865
    spf = sampFreq / 24  # approximate samples per frame
    sphere = cmds.polySphere(
        n='bubble',
        r=startRadius)[0]  # bakes in radius, scale of 1.0 makes radius 2.865
    shader = str(
        cmds.listConnections(cmds.listHistory(sphere, f=1), type='lambert')[0])

    print('Created ' + sphere + ' with shader ' + shader)
    # cmds.xform('column', t = [0,.5,0], sp=[0,-.5,0]) # move scale pivot to bottom of shape

    frameWin = BoxOnSphere.SPHERE_STEP
    print('Calculating average amplitude for every ' + str(frameWin) +
          '-frame (' + str(frameWin / 24.) + ' second) ' + 'window')
    avgs = averageAmplitude(amp, spf * frameWin)
    curProg = 1
    tenPercent = len(avgs) / 10
    # scaleFactor = 10.0
    print('Keyframing size translations')
    for i in range(1, len(avgs)):
        h = normalize(
            avgs, i
        ) * scaleFactor  # take away or add + 1 to allow or disallow the sphere to decay infinitely small
        cmds.setKeyframe(sphere, v=h, at='scaleX', t=(i - 1) * frameWin)
        cmds.setKeyframe(sphere, v=h, at='scaleY', t=(i - 1) * frameWin)
        cmds.setKeyframe(sphere, v=h, at='scaleZ', t=(i - 1) * frameWin)
        if i % tenPercent == 0:
            if not (curProg == 0 or curProg == 10):
                sys.stdout.write(str(curProg) + '0%...')
                curProg += 1
    print('100%')

    frameWin = 10
    print('Calculating average amplitude for every ' + str(frameWin) +
          '-frame (' + str(frameWin / 24.) + ' second) ' + 'window')
    avgs = averageAmplitude(amp, spf * frameWin)
    curProg = 1
    tenPercent = len(avgs) / 10
    print('Keyframing color translations')
    for i in range(1, len(avgs)):
        norm = normalize(avgs, i)
        rgb = colorsys.hsv_to_rgb(norm, 1, min(
            norm + .2, 1))  # hue and value both vary with amplitude
        # listConnections returns a list with unicode strings
        cmds.setAttr(shader + '.color', rgb[0], rgb[1], rgb[2], type='double3')
        cmds.setKeyframe(shader + '.color', at='color', t=i * frameWin)
        if i % tenPercent == 0:
            if not (curProg == 0 or curProg == 10):
                sys.stdout.write(str(curProg) + '0%...')
                curProg += 1
    print('100%')
    return sphere
Ejemplo n.º 27
0
    def setNodeDatum(cls, node, value):
        """ Sets the numeric datum value, creating the attribute if not already
            defined. """

        if not cmds.attributeQuery('datum', node=node, exists=True):
            cmds.addAttr(
                node,
                longName='cadence_datum',
                shortName='datum',
                niceName='Datum')

        cmds.setAttr(node + '.datum', value)
Ejemplo n.º 28
0
    def _handleEccentricity(self):

        value = 0.0
        value = self.eccen_Slider.value()
        value = value / 100.0
        self.eccen_Label.setText("Head Eccentricity: " + str(value))

        if (value >= 0):
            cmds.setAttr('AllFaces.TallFace', value * .6)
        if (value < 0):
            cmds.setAttr('AllFaces.BigFace', value * -.6)

        return
Ejemplo n.º 29
0
    def _handleMouthCurve(self):

        value = 0.0
        value = self.mouth_curve_Slider.value()
        value = value / 100.0
        self.mouth_curve_Label.setText("Mouth Curvature: " + str(value))

        if (value >= 0):
            cmds.setAttr('AllFaces.SmilingFace', value * .7)
        if (value < 0):
            cmds.setAttr('AllFaces.sadFace', value * -1)

        return
Ejemplo n.º 30
0
    def _handleChangeColor(self):
        red = self.redSlider.value()
        green = self.greenSlider.value()
        blue = self.blueSlider.value()

        #---Normalize----
        normRed = (float(red)) * (1.0 / (255.0 - 0))
        normGreen = (float(green)) * (1.0 / (255.0 - 0))
        normBlue = (float(blue)) * (1.0 / (255.0 - 0))

        cmds.setAttr("phong2.color",
                     normRed,
                     normGreen,
                     normBlue,
                     type="double3")
        cmds.setAttr("phong3.color",
                     normRed,
                     normGreen,
                     normBlue,
                     type="double3")
        cmds.setAttr("phong8.color",
                     normRed,
                     normGreen,
                     normBlue,
                     type="double3")
        cmds.setAttr("phong14.color",
                     normRed,
                     normGreen,
                     normBlue,
                     type="double3")
Ejemplo n.º 31
0
def matRedPlastic():
    red = cmds.shadingNode('phongE', asShader=True)
    cmds.setAttr(red + '.color', 0.77, 0, 0.03, type='double3')
    cmds.setAttr(red + '.diffuse', 0.752)
    cmds.setAttr(red + '.reflectivity', 0.684)
    cmds.setAttr(red + '.reflectedColor', 0.68, 0.47, 0.48, type='double3')
    return red
Ejemplo n.º 32
0
 def __init__(self, name, r, g, b):
     AA = mc.shadingNode('phong', asShader=True, n=name + '_AA')
     self.AASG = mc.sets(r=True, nss=True, em=True, n=name + '_AASG')
     mc.connectAttr(AA + '.outColor', self.AASG + '.surfaceShader')
     mc.setAttr(AA + '.color', r, g, b, type='double3')
     mc.setAttr(AA + '.cosinePower', 2)
     mc.setAttr(AA + '.specularColor', r, g, b, type='double3')
     mc.setAttr(AA + '.reflectivity', 0.2)
Ejemplo n.º 33
0
 def __init__(self, name, r, g, b):
     ### blue fine metallic
     FM = mc.shadingNode('phong', asShader=True, n=name + 'FM')
     self.FMSG = mc.sets(r=True, nss=True, em=True, n=name + 'FMSG')
     mc.connectAttr(FM + '.outColor', self.FMSG + '.surfaceShader')
     mc.setAttr(FM + '.color', r, g, b, type='double3')
     mc.setAttr(FM + '.cosinePower', 20)
     mc.setAttr(FM + '.specularColor', r, g, b, type='double3')
     mc.setAttr(FM + '.reflectivity', 0.8)
Ejemplo n.º 34
0
def whiteAnodizedAluminum():
    ### white anodized aluminum
    global whiteAASG
    whiteAA = mc.shadingNode('phong', asShader=True, n='whiteAA')
    whiteAASG = mc.sets(r=True, nss=True, em=True, n='whiteAASG')
    mc.connectAttr(whiteAA + '.outColor', whiteAASG + '.surfaceShader')
    mc.setAttr(whiteAA + '.color', 0.9, 0.9, 0.9, type='double3')
    mc.setAttr(whiteAA + '.cosinePower', 2)
    mc.setAttr(whiteAA + '.specularColor', 0.9, 0.9, 0.9, type='double3')
    mc.setAttr(whiteAA + '.reflectivity', 0.2)
Ejemplo n.º 35
0
def redAnodizedAluminum():
    ### red anodized aluminum
    global redAASG
    redAA = mc.shadingNode('phong', asShader=True, n='redAA')
    redAASG = mc.sets(r=True, nss=True, em=True, n='redAASG')
    mc.connectAttr(redAA + '.outColor', redAASG + '.surfaceShader')
    mc.setAttr(redAA + '.color', 0.5, 0.0395, 0.0395, type='double3')
    mc.setAttr(redAA + '.cosinePower', 2)
    mc.setAttr(redAA + '.specularColor', 0.5, 0.0395, 0.0395, type='double3')
    mc.setAttr(redAA + '.reflectivity', 0.2)
Ejemplo n.º 36
0
def blueAnodizedAluminum():
    ### blue Anodized aluminum
    global blueAASG
    blueAA = mc.shadingNode('phong', asShader=True, n='blueAA')
    blueAASG = mc.sets(r=True, nss=True, em=True, n='blueAASG')
    mc.connectAttr(blueAA + '.outColor', blueAASG + '.surfaceShader')
    mc.setAttr(blueAA + '.color', 0.0, 0.0, 0.3, type='double3')
    mc.setAttr(blueAA + '.cosinePower', 2)
    mc.setAttr(blueAA + '.specularColor', 0.0, 0.0, 0.3, type='double3')
    mc.setAttr(blueAA + '.reflectivity', 0.2)
Ejemplo n.º 37
0
def blueFineMetallic():
    ### blue fine metallic
    global blueFMSG
    blueFM = mc.shadingNode('phong', asShader=True, n='blueFM')
    blueFMSG = mc.sets(r=True, nss=True, em=True, n='blueFMSG')
    mc.connectAttr(blueFM + '.outColor', blueFMSG + '.surfaceShader')
    mc.setAttr(blueFM + '.color', 0.04, 0.04, 0.5, type='double3')
    mc.setAttr(blueFM + '.cosinePower', 20)
    mc.setAttr(blueFM + '.specularColor', 0.04, 0.04, 0.5, type='double3')
    mc.setAttr(blueFM + '.reflectivity', 0.8)
Ejemplo n.º 38
0
def redFineMettalic():
    ### red fine metallic
    global redFMSG
    redFM = mc.shadingNode('phong', asShader=True, n='redFM')
    redFMSG = mc.sets(r=True, nss=True, em=True, n='redFMSG')
    mc.connectAttr(redFM + '.outColor', redFMSG + '.surfaceShader')
    mc.setAttr(redFM + '.color', 0.5, 0.0395, 0.0395, type='double3')
    mc.setAttr(redFM + '.cosinePower', 20)
    mc.setAttr(redFM + '.specularColor', 0.5, 0.0395, 0.0395, type='double3')
    mc.setAttr(redFM + '.reflectivity', 0.8)
Ejemplo n.º 39
0
 def __init__(self, name, r, g, b):
     ### blue clear plastic
     blueCPlastic = mc.shadingNode('phong', asShader=True, n='blueCPlastic')
     self.PlasticSG = mc.sets(r=True, nss=True, em=True, n='blueCPlasticSG')
     mc.connectAttr(blueCPlastic + '.outColor',
                    self.PlasticSG + '.surfaceShader')
     mc.setAttr(blueCPlastic + '.color', r, g, b, type='double3')
     mc.setAttr(blueCPlastic + '.cosinePower', 20)
     mc.setAttr(blueCPlastic + '.specularColor',
                2.0,
                2.0,
                2.0,
                type='double3')
     mc.setAttr(blueCPlastic + '.reflectivity', 0.5)
     mc.setAttr(blueCPlastic + '.transparency',
                0.6,
                0.6,
                0.6,
                type='double3')
Ejemplo n.º 40
0
    def createRenderEnvironment(self):
        lightName = 'scenic_light1'
        if not cmds.objExists(lightName):
            lightName = cmds.directionalLight(name=lightName, intensity=0.5)
            cmds.move(0, 2500, 0, lightName)
            cmds.rotate('-45deg', '-45deg', 0, lightName)

        lightName = 'scenic_light2'
        if not cmds.objExists(lightName):
            lightName = cmds.directionalLight(name=lightName, intensity=0.5)
            cmds.move(0, 2500, 0, lightName)
            cmds.rotate('-45deg', '135deg', 0, lightName)

        floorName = 'floor'
        if not cmds.objExists(floorName):
            floorName = cmds.polyPlane(width=10000, height=10000, name=floorName)[0]
        shader, shaderEngine = self.createShader('Whiteout_Surface', 'surfaceShader')
        cmds.setAttr(shader + '.outColor', 1.0, 1.0, 1.0, type='double3')
        cmds.select([floorName])
        cmds.sets(forceElement=shaderEngine)
Ejemplo n.º 41
0
    def _handleChangeColor(self):
        red = self.redSlider.value()
        green = self.greenSlider.value()
        blue = self.blueSlider.value()

        #---Normalize----
        normRed = (float(red))*(1.0/(255.0-0))
        normGreen = (float(green))*(1.0/(255.0-0))
        normBlue = (float(blue))*(1.0/(255.0-0))

        cmds.setAttr("phong2.color", normRed, normGreen, normBlue, type="double3")
        cmds.setAttr("phong3.color", normRed, normGreen, normBlue, type="double3")
        cmds.setAttr("phong8.color", normRed, normGreen, normBlue, type="double3")
        cmds.setAttr("phong14.color", normRed, normGreen, normBlue, type="double3")
Ejemplo n.º 42
0
    def initializeCadenceCam(self):
        """ This creates an orthographic camera that looks down the Y axis onto
            the XZ plane, and rotated so that the AI file track labels are
            legible.  This camera is positioned so that the given track nodeName
            is centered in its field by setCameraFocus. """

        if cmds.objExists(self.CADENCE_CAM):
            return

        priorSelection = MayaUtils.getSelectedTransforms()

        c = cmds.camera(
            orthographic=True,
            nearClipPlane=1,
            farClipPlane=100000,
            orthographicWidth=400)
        cmds.setAttr(c[0] + '.visibility', False)
        cmds.rename(c[0], self.CADENCE_CAM)
        cmds.rotate(-90, 180, 0)
        cmds.move(0, 100, 0, self.CADENCE_CAM, absolute=True)

        MayaUtils.setSelection(priorSelection)
Ejemplo n.º 43
0
def eyeDistance(newVal):
    newP=abs(newVal)/100.0 # new percentage
    if newVal < 0:
        nonSuffix = "FaceDeformer.FaceWideEye"
        suffix    = "FaceDeformer.FaceNarrowEye"
        scaleV= newP*-.25 #woo guess what I learned in sciviz class?
    else:
        suffix    =  "FaceDeformer.FaceWideEye"
        nonSuffix = "FaceDeformer.FaceNarrowEye"
        scaleV= newP*.5 #woo guess what I learned in sciviz class?
        
    mc.setAttr(nonSuffix,  0.0)
    mc.setAttr(suffix,  newP)
    mc.setAttr("LeftEye.translateX", scaleV)
    mc.setAttr("RightEye1.translateX", -1*scaleV)
Ejemplo n.º 44
0
    def setNodeLinks(cls, node, prev, next):
        """ Sets up two attributes, prev and next, that directly link the given
            node to its previous and next nodes. """

        if not cmds.attributeQuery('prevNode', node=node, exists=True):
            cmds.addAttr(
                node,
                longName='cadence_prevNode',
                shortName='prevNode',
                dataType='string',
                niceName='PrevNode')

        if not cmds.attributeQuery('nextNode', node=node, exists=True):
            cmds.addAttr(
                node,
                longName='cadence_nextNode',
                shortName='nextNode',
                dataType='string',
                niceName='NextNode')

        if prev:
            cmds.setAttr(node + '.prevNode', prev, type='string')
        if next:
            cmds.setAttr(node + '.nextNode', next, type='string')
Ejemplo n.º 45
0
        def rotate_limbs(angle):

          cmds.select('arm_L')
          cmds.setAttr('arm_L.rx', angle)
          cmds.setKeyframe(at='rotateX')

          cmds.select('arm_R')
          cmds.setAttr('arm_R.rx', -angle)
          cmds.setKeyframe(at='rotateX')

          cmds.select('left_L')
          cmds.setAttr('left_L.rx', -angle)
          cmds.setKeyframe(at='rotateX')

          cmds.select('leg_R')
          cmds.setAttr('leg_R.rx', angle)
          cmds.setKeyframe(at='rotateX')
Ejemplo n.º 46
0
    def _handleArm(self):

        ctime = cmds.currentTime(query=True)

        cmds.select('arm_L')

        cmds.setAttr('arm_L.rx', 0)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 10)
        cmds.setAttr('arm_L.rx', -90)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 15)
        cmds.setAttr('arm_L.rx', -180)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 25)
        cmds.setAttr('arm_L.rx', -180)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 35)
        cmds.setAttr('arm_L.rx', 0)
        cmds.setKeyframe()
Ejemplo n.º 47
0
        def rotate_limbs(angle):

            cmds.select('arm_L')
            cmds.setAttr('arm_L.rx', angle)
            cmds.setKeyframe(at='rotateX')

            cmds.select('arm_R')
            cmds.setAttr('arm_R.rx', -angle)
            cmds.setKeyframe(at='rotateX')

            cmds.select('left_L')
            cmds.setAttr('left_L.rx', -angle)
            cmds.setKeyframe(at='rotateX')

            cmds.select('leg_R')
            cmds.setAttr('leg_R.rx', angle)
            cmds.setKeyframe(at='rotateX')
Ejemplo n.º 48
0
    def _handleKick(self):

        ctime = cmds.currentTime(query=True)
        cmds.select('leg_R')

        cmds.setAttr('leg_R.rx', 0)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 10)
        cmds.setAttr('leg_R.rx', 90)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 20)
        cmds.setAttr('leg_R.rx', -90)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 30)
        cmds.setAttr('leg_R.rx', 0)
        cmds.setKeyframe()

        cmds.currentTime(ctime + 15)
Ejemplo n.º 49
0
    def createTrackNode(cls, uid, trackSetNode =None, props =None):
        """ A track node consists of a triangular pointer (left = red, right =
            green) which is selectable but only allows rotateY, translateX, and
            translateZ. The node has a child, a transform called inverter, which
            serves to counteract the scaling in x and z that is applied to the
            triangular node.  There are two orthogonal rulers (width and
            length).  Width and length uncertainty is represented by rectangular
            bars at the ends of the rulers.  In Maya one can directly adjust
            track position (translateX and translateZ) and orientation
            (rotationY); other attributes are adjusted only through the UI. """

        if not trackSetNode:
            trackSetNode = TrackSceneUtils.getTrackSetNode()

        if not trackSetNode:
            return None

        node = cls.getTrackNode(uid, trackSetNode=trackSetNode)
        if node:
            return node

        # Set up dimensional constants for the track node
        nodeThickness  = 1.0
        thetaBreadth   = 0.1
        thetaThickness = 0.5
        barBreadth     = 2.0
        barThickness   = 0.5
        rulerBreadth   = 1.0
        rulerThickness = 0.25
        epsilon        = 1.0

        # Create an isoceles triangle pointer, with base aligned with X, and
        # scaled by node.width.  The midpoint of the base is centered on the
        # 'track center' and the altitude extends from that center of the track
        # 'anteriorly' to the perimeter of the track's profile (if present, else
        # estimated).  The node is scaled longitudinally (in z) based on the
        # distance zN (the 'anterior' length of the track, in cm).  The triangle
        # is initially 1 cm on a side.
        sideLength = 1.0
        node = cmds.polyPrism(
            length=nodeThickness,
            sideLength=sideLength,
            numberOfSides=3,
            subdivisionsHeight=1,
            subdivisionsCaps=0,
            axis=(0, 1, 0),
            createUVs=0,
            constructionHistory=0,
            name='Track0')[0]

        # Point the triangle down the +Z axis
        cmds.rotate(0.0, -90.0, 0.0)

        # push it down below ground level so that the two rulers are just
        # submerged, and scale the triangle in Z to match its width (1 cm) so it
        # is ready to be scaled
        cmds.move(0, -(nodeThickness/2.0 + rulerThickness), math.sqrt(3.0)/6.0)

        # move the node's pivot to the 'base' of the triangle so it scales
        # outward from that point
        cmds.move(
            0, 0, 0, node + ".scalePivot", node + ".rotatePivot", absolute=True)
        cmds.scale(2.0/math.sqrt(3.0), 1.0, 100.0)
        cmds.makeIdentity(
            apply=True,
            translate=True,
            rotate=True,
            scale=True,
            normal=False)

        # Set up the cadence attributes
        cmds.addAttr(
             longName='cadence_width',
             shortName=TrackPropEnum.WIDTH.maya,
             niceName='Width')
        cmds.addAttr(
             longName='cadence_widthUncertainty',
             shortName=TrackPropEnum.WIDTH_UNCERTAINTY.maya,
             niceName='Width Uncertainty')
        cmds.addAttr(
             longName='cadence_length',
             shortName=TrackPropEnum.LENGTH.maya,
             niceName='Length')
        cmds.addAttr(
             longName='cadence_lengthUncertainty',
             shortName=TrackPropEnum.LENGTH_UNCERTAINTY.maya,
             niceName='Length Uncertainty')
        cmds.addAttr(
             longName='cadence_lengthRatio',
             shortName=TrackPropEnum.LENGTH_RATIO.maya,
             niceName='Length Ratio')
        cmds.addAttr(
             longName='cadence_rotationUncertainty',
             shortName=TrackPropEnum.ROTATION_UNCERTAINTY.maya,
             niceName='Rotation Uncertainty')
        cmds.addAttr(
             longName='cadence_uniqueId',
             shortName=TrackPropEnum.UID.maya,
             dataType='string',
             niceName='Unique ID')

        # Construct a ruler representing track width, then push it down just
        # below ground level, and ake it non-selectable.  Drive its scale by the
        # node's width attribute.
        widthRuler = cmds.polyCube(
            axis=(0, 1, 0),
            width=100.0,
            height=rulerThickness,
            depth=rulerBreadth,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='WidthRuler')[0]

        # Push it down to just rest on the triangular node (which is already
        # submerged by the thickness of the ruler and half the node thickness.
        cmds.move(0.0, -rulerThickness/2.0, 0.0)
        cmds.setAttr(widthRuler + '.overrideEnabled', 1)
        cmds.setAttr(widthRuler + '.overrideDisplayType', 2)

        # Construct a ruler representing track length and push it down the same
        # as the width ruler, and make it non-selectable.  Its length will be
        # driven by the node's length attribute.
        lengthRuler = cmds.polyCube(
            axis=(0, 1, 0),
            width=rulerBreadth,
            height=rulerThickness,
            depth=100.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='LengthRuler')[0]
        cmds.move(0.0, -rulerThickness/2.0, 0.0)
        cmds.setAttr(lengthRuler + '.overrideEnabled', 1)
        cmds.setAttr(lengthRuler + '.overrideDisplayType', 2)

        # Now construct 'error bars' to the North, South, West, and East of the
        # node, to visualize uncertainty in width (West and East bars) and
        # length (North and South bars), and push them just below ground level,
        # and make them non-selectable.
        barN = cmds.polyCube(
            axis=(0,1,0),
            width=barBreadth,
            height=barThickness,
            depth=100.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarN')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barN + '.overrideEnabled', 1)
        cmds.setAttr(barN + '.overrideDisplayType', 2)

        barS = cmds.polyCube(
            axis=(0, 1, 0),
            width=barBreadth,
            height=barThickness,
            depth=100.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarS')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barS + '.overrideEnabled', 1)
        cmds.setAttr(barS + '.overrideDisplayType', 2)

        barW = cmds.polyCube(
            axis=(0, 1, 0),
            width=100.0,
            height=barThickness,
            depth=barBreadth,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarW')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barW + '.overrideEnabled', 1)
        cmds.setAttr(barW + '.overrideDisplayType', 2)

        barE = cmds.polyCube(
            axis=(0, 1, 0),
            width=100.0,
            height=barThickness,
            depth=barBreadth,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='BarE')[0]
        cmds.move(0, -(barThickness/2 + rulerThickness), 0)
        cmds.setAttr(barE + '.overrideEnabled', 1)
        cmds.setAttr(barE + '.overrideDisplayType', 2)

        # Create two diverging lines that indicate rotation uncertainty (plus
        # and minus), with their pivots placed so they extend from the node
        # center, and each is made non-selectable.  First make the indicator of
        # maximum (counterclockwise) estimated track rotation
        thetaPlus = cmds.polyCube(
            axis=(0, 1, 0),
            width=thetaBreadth,
            height=thetaThickness,
            depth=1.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='ThetaPlus')[0]
        cmds.setAttr(thetaPlus + '.overrideEnabled',     1)
        cmds.setAttr(thetaPlus + '.overrideDisplayType', 2)

        # Next, construct the indicator of the minimum (clockwise) estimate of
        # track rotation
        thetaMinus = cmds.polyCube(
            axis=(0, 1, 0),
            width=thetaBreadth,
            height=thetaThickness,
            depth=1.0,
            subdivisionsX=1,
            subdivisionsY=1,
            createUVs=0,
            constructionHistory=0,
            name='ThetaMinus')[0]
        cmds.setAttr(thetaMinus + '.overrideEnabled',     1)
        cmds.setAttr(thetaMinus + '.overrideDisplayType', 2)

        # The two width 'error bars' will be translated outward from the node
        # center.  First, the width attribute is converted from meters (as it
        # comes from the database) to centimeters; the computation is available
        # in the output of the node 'width'.
        width = cmds.createNode('multiplyDivide', name='width')
        cmds.setAttr(width + '.operation', 1)
        cmds.setAttr(width + '.input1X', 100.0)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.WIDTH.maya, width + '.input2X')

        # Translate barW in x by width/2.0; output is in xW.outputX
        xW = cmds.createNode('multiplyDivide', name = 'xW')
        cmds.setAttr(xW + '.operation', 2)
        cmds.connectAttr(width + '.outputX', xW + '.input1X')
        cmds.setAttr(xW + '.input2X', 2.0)
        cmds.connectAttr(xW + '.outputX', barW + '.translateX')

        # Translate barE in x by -width/2.0; output is in xE.outputX
        xE = cmds.createNode('multiplyDivide', name = 'xE')
        cmds.setAttr(xE + '.operation', 2) # division operation
        cmds.connectAttr(width + '.outputX', xE + '.input1X')
        cmds.setAttr(xE + '.input2X', -2.0)
        cmds.connectAttr(xE + '.outputX', barE + '.translateX')

        # Now regarding length, first convert the node.length attribute from
        # meters to centimeters. This computation is available in the output of
        # the node 'length'
        length = cmds.createNode('multiplyDivide', name='length')
        cmds.setAttr(length + '.operation', 1)
        cmds.setAttr(length + '.input1X', 100.0)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.LENGTH.maya, length + '.input2X')

        # scale thetaPlus and thetaMinus by length (since they are 1 cm,
        # multiply by length in cm)
        cmds.connectAttr(length + '.outputX', thetaPlus  + '.scaleZ')
        cmds.connectAttr(length + '.outputX', thetaMinus + '.scaleZ')

        # Then barN is translated forward in z by zN = lengthRatio*length
        # (centimeters)
        zN = cmds.createNode('multiplyDivide', name='zN')
        cmds.setAttr(zN + '.operation', 1)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.LENGTH_RATIO.maya, zN + '.input1X')
        cmds.connectAttr(length + '.outputX',  zN + '.input2X')
        cmds.connectAttr(zN + '.outputX', barN + '.translateZ')

        # Next, translate barS backward in z by (zN - length); output is in
        # zS.output1D
        zS = cmds.createNode('plusMinusAverage', name='sZ')
        cmds.setAttr(zS + '.operation', 2)
        cmds.connectAttr(zN + '.outputX',     zS + '.input1D[0]')
        cmds.connectAttr(length + '.outputX', zS + '.input1D[1]')
        cmds.connectAttr(zS + '.output1D',    barS + '.translateZ')

        # Next, compute the half length, hl = length/2.0 (centimeters)
        hl = cmds.createNode('multiplyDivide', name='hl')
        cmds.setAttr(hl + '.operation', 2)
        cmds.connectAttr(length + '.outputX', hl + '.input1X')
        cmds.setAttr(hl + '.input2X', 2.0)

        # Translate lengthRuler along z by zL = (zN - hl) (centimeters)
        zL = cmds.createNode('plusMinusAverage', name='zL')
        cmds.setAttr(zL + '.operation', 2)
        cmds.connectAttr(zN + '.outputX',  zL + '.input1D[0]')
        cmds.connectAttr(hl + '.outputX',  zL + '.input1D[1]')
        cmds.connectAttr(zL + '.output1D', lengthRuler + '.translateZ')

        # Scale the four 'error bars' to represent the width and length
        # uncertainties (centimeters)
        cmds.connectAttr(
            node + "." + TrackPropEnum.WIDTH_UNCERTAINTY.maya,
            barW + '.scaleX')
        cmds.connectAttr(
            node + "." + TrackPropEnum.WIDTH_UNCERTAINTY.maya,
            barE + '.scaleX')
        cmds.connectAttr(
            node + "." + TrackPropEnum.LENGTH_UNCERTAINTY.maya,
            barN + '.scaleZ')
        cmds.connectAttr(
            node + "." + TrackPropEnum.LENGTH_UNCERTAINTY.maya,
            barS + '.scaleZ')

        # Create an 'inverter' transform under which all the other parts are
        # hung as children, which counteracts scaling applied to its parent
        # triangular node.
        inverter = cmds.createNode('transform', name='inverter')

        # drive the inverter's .scaleX and .scaleZ as the inverse of the parent
        # node's scale values
        sx = cmds.createNode('multiplyDivide', name='sx')
        cmds.setAttr(sx + '.operation', 2)
        cmds.setAttr(sx + '.input1X', 1.0)
        cmds.connectAttr(node + '.scaleX', sx + '.input2X')
        cmds.connectAttr(sx + '.outputX', inverter + '.scaleX')

        sz = cmds.createNode('multiplyDivide', name='sz')
        cmds.setAttr(sz + '.operation', 2)
        cmds.setAttr(sz + '.input1X', 1.0)
        cmds.connectAttr(node + '.scaleZ', sz + '.input2X')
        cmds.connectAttr(sz + '.outputX', inverter + '.scaleZ')

        # Assemble the parts as children under the scale inverter node
        cmds.parent(lengthRuler, inverter)
        cmds.parent(widthRuler,  inverter)
        cmds.parent(barN,        inverter)
        cmds.parent(barS,        inverter)
        cmds.parent(barW,        inverter)
        cmds.parent(barE,        inverter)
        cmds.parent(thetaPlus,   inverter)
        cmds.parent(thetaMinus,  inverter)
        cmds.parent(inverter,    node)

        # Rotate thetaPlus and thetaMinus about the Y axis to indicate
        # rotational uncertainty
        cmds.connectAttr(
            node + '.' + TrackPropEnum.ROTATION_UNCERTAINTY.maya,
            node + '|' + inverter + '|' + thetaPlus + '.rotateY')

        neg = cmds.createNode('multiplyDivide', name='negative')
        cmds.setAttr(neg + '.operation', 1)
        cmds.setAttr(neg + '.input1X',  -1.0)
        cmds.connectAttr(
            node + '.' + TrackPropEnum.ROTATION_UNCERTAINTY.maya,
            neg + '.input2X')
        cmds.connectAttr(
            neg + '.outputX',
            node + '|' + inverter + '|' + thetaMinus + '.rotateY')

        # Disable some transforms of the node
        cmds.setAttr(node + '.rotateX',    lock=True)
        cmds.setAttr(node + '.rotateZ',    lock=True)
        cmds.setAttr(node + '.scaleY',     lock=True)
        cmds.setAttr(node + '.translateY', lock=True)

        # Now, the width of the triangle will be driven by its width attribute
        # (driving .scaleX)
        cmds.connectAttr(node + '.width',  node + '.scaleX')

        # The quantity zN is used to scale length of the triangle
        cmds.connectAttr(zN + '.outputX',  node + '.scaleZ')

        # Scale the 'length' (in x) of the width ruler
        cmds.connectAttr(
            node + '.width',  node + '|' + inverter + '|WidthRuler.scaleX')

        # Scale the length of the length ruler
        cmds.connectAttr(
            node + '.length', node + '|' + inverter + '|LengthRuler.scaleZ')

        # Translate the track node epsilon below ground level (to reveal the
        # overlaid track siteMap)
        cmds.move(0, -epsilon, 0, node)

        # Initialize all the properties from the dictionary
        if props:
            cls.setTrackProps(node, props)
        else:
            print('in createTrackNode:  properties not provided')
            return node

        # Add the new nodeName to the Cadence track scene set, color it, and
        # we're done
        cmds.sets(node, add=trackSetNode)
        cls.colorTrackNode(node, props)
        return node
Ejemplo n.º 50
0
def eyeEnbiggen(newVal):
    newP=abs(newVal)/100.0 # new percentage
    if newVal < 0:
        nonSuffix = "FaceDeformer.FaceBigEye"
        suffix    = "FaceDeformer.FaceSmallEye"
        scaleV = 1 - newP*.4 #woo guess what I learned in sciviz class?
    else:
        suffix    =  "FaceDeformer.FaceBigEye"
        nonSuffix = "FaceDeformer.FaceSmallEye"
        scaleV = 1 + newP*.5 #woo guess what I learned in sciviz class?
    mc.setAttr(nonSuffix,  0.0)
    mc.setAttr(suffix,  newP)
    mc.setAttr("LeftEye.scaleZ", scaleV)
    mc.setAttr("LeftEye.scaleX", scaleV)
    mc.setAttr("LeftEye.scaleY", scaleV)
    mc.setAttr("RightEye1.scaleZ", scaleV)
    mc.setAttr("RightEye1.scaleX", scaleV)
    mc.setAttr("RightEye1.scaleY", scaleV)
Ejemplo n.º 51
0
        def change_height(height):

          cmds.select('Lego_Group')
          cmds.setAttr('Lego_Group.ty', height);
          cmds.setKeyframe(at='translateY')
Ejemplo n.º 52
0
    def createToken(cls, uid, props, trackSetNode =None):
        """ A token is created, provided with some additional Maya attributes,
            and placed in the scene. Tokens are functtionally similar to
            TrackNodes, but with different shapes and attributes. """

        cylinderHeight = 5.0
        coneHeight     = 10.0

        if not trackSetNode:
            trackSetNode = TrackSceneUtils.getTrackSetNode()

        if not trackSetNode:
            return None

        node = cls.getTrackNode(uid, trackSetNode=trackSetNode)

        if node:
            return node

        # determine whether left or right, and manus or pes, from name
        name = props['name'] if props else None
        if not name:
            print('createToken:  No properties specified')
            return
        # remove '_proxy' or '_token' if present (as in S6_LP3_proxy)
        nameFields = cls.decomposeName(name.split('_')[0])
        isLeft     = nameFields['left']
        isPes      = nameFields['pes']

        # make a cone for the token of an proxy else a cylinder
        if uid.endswith('_proxy'):
            node = cmds.polyCone(
                radius=0.5,
                height=coneHeight,
                subdivisionsX=10,
                subdivisionsY=1,
                subdivisionsZ=1,
                axis=(0, 1, 0),
                createUVs=0,
                constructionHistory=0,
                name='Token_0')[0]
            cmds.move(0, 0.5 * coneHeight, 0)
        else:
            node = cmds.polyCylinder(
                radius=0.5,
                height=cylinderHeight,
                subdivisionsX=10,
                subdivisionsY=1,
                subdivisionsZ=1,
                subdivisionsCaps=0,
                axis=(0, 1, 0),
                createUVs=0,
                constructionHistory=0,
                name='Token_0')[0]
            cmds.move(0, 0.5 * cylinderHeight, 0)

        # Set up the basic cadence attributes
        cmds.addAttr(longName='cadence_dx', shortName='dx', niceName='DX')
        cmds.addAttr(longName='cadence_dy', shortName='dy', niceName='DY')

        cmds.addAttr(
             longName='cadence_uniqueId',
             shortName='track_uid',
             dataType='string',
             niceName='UID')

        cmds.addAttr(
             longName='cadence_name',
             shortName='token_name',
             dataType='string',
             niceName='Name')

        # Disable some transform attributes
        cmds.setAttr(node + '.rotateX',    lock=True)
        cmds.setAttr(node + '.rotateZ',    lock=True)
        cmds.setAttr(node + '.scaleY',     lock=True)
        cmds.setAttr(node + '.translateY', lock=True)

        # Scale the cylinder/cone in x and z to represent 'dy' and 'dx' in
        # centimeters. There is a change of coordinates between Maya (X, Z) and
        # the simulator (X, Y) space. For example, for the right manus:
        #    x = int(100*float(entry['rm_y']))
        #    z = int(100*float(entry['rm_x']))
        # and likewise for dx and dy.

        # the DX and DY attributes affect scaleZ and scaleX in the node
        cmds.connectAttr(node + '.dx', node + '.scaleZ')
        cmds.connectAttr(node + '.dy', node + '.scaleX')

        # add a short annotation based on the name
        annotation = cmds.annotate(node, text=cls.shortName(props['name']))
        cmds.select(annotation)
        aTransform = cmds.pickWalk(direction='up')[0]

        # control it's position by that of the node, so that it stays 15 cm
        # above the pes and 10 cm above the manus
        if isPes:
            cmds.move(0.0, 15.0, 0.0, aTransform)
        else:
            cmds.move(0.0, 10.0, 0.0, aTransform)

        cmds.connectAttr(node + '.translateX', aTransform + '.translateX')
        cmds.connectAttr(node + '.translateZ', aTransform + '.translateZ')

        # and make it non-selectable
        cmds.setAttr(aTransform + '.overrideEnabled', 1)
        cmds.setAttr(aTransform + '.overrideDisplayType', 2)
        cmds.rename(aTransform, "TokenAnnotation_0")

        if isPes:
            if isLeft:
                color = TrackwayShaderConfig.LEFT_PES_TOKEN_COLOR
            else:
                color = TrackwayShaderConfig.RIGHT_PES_TOKEN_COLOR
        else:
            if isLeft:
                color = TrackwayShaderConfig.LEFT_MANUS_TOKEN_COLOR
            else:
                color = TrackwayShaderConfig.RIGHT_MANUS_TOKEN_COLOR
        ShadingUtils.applyShader(color, node)

        cmds.select(node)
        # add the new node to the Cadence track set
        cmds.sets(node, add=trackSetNode)

        # finally, initialize all the properties from the dictionary props
        cls.setTokenProps(node, props)

        return node
Ejemplo n.º 53
0
    def _handleRun(self):

        def rotate_limbs(angle):

          cmds.select('arm_L')
          cmds.setAttr('arm_L.rx', angle)
          cmds.setKeyframe(at='rotateX')

          cmds.select('arm_R')
          cmds.setAttr('arm_R.rx', -angle)
          cmds.setKeyframe(at='rotateX')

          cmds.select('left_L')
          cmds.setAttr('left_L.rx', -angle)
          cmds.setKeyframe(at='rotateX')

          cmds.select('leg_R')
          cmds.setAttr('leg_R.rx', angle)
          cmds.setKeyframe(at='rotateX')

        def change_height(height):

          cmds.select('Lego_Group')
          cmds.setAttr('Lego_Group.ty', height);
          cmds.setKeyframe(at='translateY')


        ctime = cmds.currentTime(query=True)

        cmds.select('Lego_Group')
        cmds.setAttr('Lego_Group.tz', 0)
        cmds.setKeyframe(at='translateZ')

        for index in range(1, 5):

          rotate_limbs(0)
          change_height(0)

          ctime += 5
          cmds.currentTime(ctime)
          rotate_limbs(90)
          change_height(3)

          ctime += 5
          cmds.currentTime(ctime)
          rotate_limbs(0)
          change_height(0)

          ctime += 5
          cmds.currentTime(ctime)
          rotate_limbs(-90)
          change_height(3)

          ctime += 5
          cmds.currentTime(ctime)

        rotate_limbs(0)
        change_height(0)

        cmds.select('Lego_Group')
        cmds.setAttr('Lego_Group.tz', 65)
        cmds.setKeyframe(at='translateZ')
Ejemplo n.º 54
0
    def _handleBall(self):

        power = self.powerBox.value()

        ctime = cmds.currentTime(query=True)

        cmds.select('ball')

        cmds.setAttr('ball.ty', 0)
        cmds.setAttr('ball.tz', 0)
        cmds.setAttr('ball.rx', 0)
        cmds.setAttr('ball.ry', 0)
        cmds.setAttr('ball.rz', 0)
        cmds.setKeyframe()
        cmds.keyTangent('ball', inTangentType='linear', outTangentType='linear',
                       time=(ctime,ctime))

        ctime += 5*power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.ty', 2*power)
        cmds.setKeyframe(at='translateY')

        ctime += 5*power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.ty', 0)
        cmds.setKeyframe(at='translateY')
        #cmds.keyTangent('ball', inTangentType='linear', outTangentType='linear', time=(ctime,ctime))

        ctime += 3*power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.ty', 1.5*power)
        cmds.setKeyframe(at='translateY')

        ctime += 3*power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.ty', 0)
        cmds.setKeyframe(at='translateY')
        #cmds.keyTangent('ball', inTangentType='linear', outTangentType='linear', time=(ctime,ctime))

        ctime += power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.ty', 0.5*power)
        cmds.setKeyframe(at='translateY')

        ctime += power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.ty', 0)
        cmds.setKeyframe(at='translateY')
        #cmds.keyTangent('ball', inTangentType='linear', outTangentType='linear', time=(ctime,ctime))

        ctime += power
        cmds.currentTime(ctime)
        cmds.setAttr('ball.tz', 16*power)
        cmds.setAttr('ball.ty', 0)
        cmds.setAttr('ball.rx', 300*power)
        cmds.setAttr('ball.ry', 240*power)
        cmds.setAttr('ball.rz', 240*power)
        cmds.setKeyframe()
Ejemplo n.º 55
0
    def setTokenProps(cls, node, props):
        """ This sets the attributes of a token:  uid, x, dx, y, dy.  It
            accounts for the change of coordinates right inside Maya."""

        cmds.setAttr(node + '.token_name',  props['name'], type='string')
        cmds.setAttr(node + '.track_uid',   props['uid'], type='string')
        cmds.setAttr(node + '.translateZ',  100.0*props['x'])
        cmds.setAttr(node + '.dx',          100.0*props['dx'])
        cmds.setAttr(node + '.translateX',  100.0*props['y'])
        cmds.setAttr(node + '.dy',          100.0*props['dy'])