Exemplo n.º 1
0
    def _handleBubbleButton(self):
        """
        This callback creates a polygonal sphere in the Maya scene.
        it then translates it.
        """
        decRange = np.arange(-1,1,.1)
        decRange2 = np.arange(0,1,.1)
        r = 2
        a = 2.0*r
        y = (0, 1, 0) # y up
        c = cmds.polySphere(
            r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0]
        cmds.select(c)
        cmd.setKeyframe()

        cmd.setKeyframe()
        for i in range(1,300,5):
            x = rand.choice(decRange)
            y = 5*rand.choice(decRange2)
            z = rand.choice(decRange)
            cmd.currentTime(i)
            cmd.move(x,y,z,r=True)
            cmd.setKeyframe()
        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
Exemplo n.º 2
0
    def _handleExampleButton(self):
        time = 120
        d = cmds.polyCylinder(r=15,
                              h=20,
                              sx=40,
                              sy=10,
                              sz=1,
                              ax=(0, 0, 0),
                              rcp=0,
                              cuv=2,
                              ch=1,
                              n='CylinderContainer')[0]
        cmds.move(0, 10, 0)

        cmds.select(d)

        response = nimble.createRemoteResponse(globals())
        response.put('name', d)
        num = self.NumBubbles.value()
        bubble = "bubble"
        for i in range(num):

            randomX = random.randrange(-10, 10)
            randomY = random.randrange(1, 2)
            randomZ = random.randrange(-10, 10)
            circleShape(randomX, randomY, randomZ, bubble, 1, None, time)
            bubble = "bubble" + str(i)
 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))
Exemplo n.º 4
0
    def _CreateSphereButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        sphere = cmds.polySphere(r=50.0, name='sphere1')
        cmds.select(sphere)
        response = nimble.createRemoteResponse(globals())
        response.put('name', sphere)
Exemplo n.º 5
0
    def _CreateSphereButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        sphere = cmds.polySphere(r=50.0, name='sphere1')
        cmds.select(sphere)
        response = nimble.createRemoteResponse(globals())
        response.put('name', sphere)
Exemplo n.º 6
0
    def _handleBubblesButton(self):
        """
        This callback creates a polygonal sphere in the Maya scene.
        it then translates it.
        """
        decRange = np.arange(-1,1,.1)
        decRange2 = np.arange(0,1,.1)
        r = 2
        a = 2.0*r
        y = (0, 1, 0) # y up
        #polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1;
        p = cmd.polyPlane(
            w=100, h=100, sx=10, sy=10, ax=y, cuv=3, ch=1,n='HotPlate')[0]
        cmd.select(p)
        cmd.move(0,2,0,r=True)
        cmd.setKeyframe()
        c = cmds.polySphere(
            r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0]
        cmds.select(c)
        cmd.setKeyframe()

        '''
        cmd.setKeyframe()
        for i in range(1,300,5):
            x = rand.choice(decRange)
            y = 5*rand.choice(decRange2)
            z = rand.choice(decRange)
            cmd.currentTime(i)
            cmd.move(x, y, z, r=True)
            cmd.setKeyframe()
        '''
        randBubbleCount = rand.choice(range(10,300)) #this should be set in the interface
        for i in range(0,100,1):
            randX = rand.choice(range(-50,50,1))
            randZ = rand.choice(range(-50,50,1))

            r = 2
            a = 2.0*r
            yUp = (0, 1, 0) # y up
            b = cmds.polySphere(
                r=r, sx=10, sy=10, ax=yUp, cuv=2, ch=1, n='Bubble')[0]
            cmds.select(b)


            startTime = rand.choice(range(1, 600, 1))
            cmd.currentTime(1)
            cmd.move(randX, 0, randZ, a=True)
            cmd.setKeyframe()
            for j in range(startTime, 600, 2):
                x = rand.choice(decRange)
                y = 5*rand.choice(decRange2)
                z = rand.choice(decRange)
                cmd.currentTime(j)
                cmd.move(x, y, z, r=True)
                cmd.setKeyframe()
        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
 def _makeCyl(self):
     r = 50
     a = 2.0*r
     y = (0, 1, 0)
     c = cmds.polyCylinder(
         r=r, h=5, sx=40, sy=1, sz=1, ax=y, rcp=0, cuv=2, ch=1, n='exampleCylinder')[0]
     cmds.select(c)
     response = nimble.createRemoteResponse(globals())
     response.put('name', c)
Exemplo n.º 8
0
    def _CreateCubeButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        cube = cmds.polyCube(w=50, h=50, d=50, name="cube1")
        cmds.select(cube)
        response = nimble.createRemoteResponse(globals())
        response.put('name', cube)
Exemplo n.º 9
0
    def _CreateCubeButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        cube = cmds.polyCube(w=50,h=50,d=50,name="cube1")
        cmds.select(cube)
        response = nimble.createRemoteResponse(globals())
        response.put('name', cube)
Exemplo n.º 10
0
    def runAsNimbleScript(self, **kwargs):
        """ Used to call the remote script as an independent operation outside of a MayaRouter, the
            normal method by which the script is executed. Used primarily for unit testing purposes
            and should not be called during normal operation.

            [kwargs]: Script arguments """

        self.kwargs = kwargs if kwargs else nimble.getRemoteKwargs(globals())
        self.response = nimble.createRemoteResponse(globals())
        self.run()
Exemplo n.º 11
0
    def runAsNimbleScript(self, **kwargs):
        """ Used to call the remote script as an independent operation outside of a MayaRouter, the
            normal method by which the script is executed. Used primarily for unit testing purposes
            and should not be called during normal operation.

            [kwargs]: Script arguments """

        self.kwargs = kwargs if kwargs else nimble.getRemoteKwargs(globals())
        self.response = nimble.createRemoteResponse(globals())
        self.run()
Exemplo n.º 12
0
    def _CreateCubeButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        cube = cmds.polyCube(w=20,h=20,d=20,name="cube1")
        cmds.duplicate('cube1')
        response = nimble.createRemoteResponse(globals())
        response.put('name', cube)
        global created
        created = 'cube'
Exemplo n.º 13
0
    def _CreateCubeButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        cube = cmds.polyCube(w=20, h=20, d=20, name="cube1")
        cmds.duplicate('cube1')
        response = nimble.createRemoteResponse(globals())
        response.put('name', cube)
        global created
        created = 'cube'
Exemplo n.º 14
0
    def _CreateSphereButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        sphere = cmds.polySphere(r=20, name="sphere1")
        cmds.duplicate('sphere1')
        response = nimble.createRemoteResponse(globals())
        response.put('name', sphere)
        global created
        created = 'sphere'
Exemplo n.º 15
0
    def _CreateSphereButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        sphere = cmds.polySphere(r=20, name="sphere1")
        cmds.duplicate('sphere1')
        response = nimble.createRemoteResponse(globals())
        response.put('name', sphere)
        global created
        created = 'sphere'
Exemplo n.º 16
0
def drawBubble(radius, xpoint, ypoint, zpoint, name, time):
    """
    Arguments: radius is the size of the overall shape
    Return: None
    """

    y = (0, 1, 0)
    d = cmds.polyCylinder(r=10,
                          h=20,
                          sx=40,
                          sy=10,
                          sz=1,
                          ax=(0, 0, 0),
                          rcp=0,
                          cuv=2,
                          ch=1,
                          n='CylinderContainer')[0]
    cmds.move(0, 10, 0)
    cmds.select(d)
    response = nimble.createRemoteResponse(globals())
    response.put('name', d)
    c = cmds.polySphere(r=radius, ax=y, cuv=2, ch=1, n=name)[0]

    xpoint = 0
    for i in range(1, time + 1, 3):  # figure out best time step
        cmds.setKeyframe(name, t=i)
        cmds.move(xpoint, ypoint, zpoint, relative=False)
        cmds.select(name)
        response = nimble.createRemoteResponse(globals())
        response.put('name', name)
        xpoint = xpoint + .1  # need to do some physics for theses
        print(ypoint, i)
        if ypoint >= 19.5:
            ypoint = 20
            print("pop")
            break
        else:
            ypoint = (.55 + float(ypoint))
        zpoint = zpoint + .001
    #cmds.setKeyframe( name , at="translateY", t=time, v=xpoint + 3)
    return None
Exemplo n.º 17
0
    def _handleExampleButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        r = 5
        a = 2.0*r
        y = (0, 1, 0)
        c = cmds.polyCylinder(
            r=r, h=5, sx=40, sy=1, sz=1, ax=y, rcp=0, cuv=2, ch=1, n='exampleCylinder')[0]
        cmds.select(c)
        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
Exemplo n.º 18
0
    def _handleExampleButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        r = 50
        a = 2.0*r
        y = (0, 1, 0)
        c = cmds.polyCylinder(
            r=r, h=5, sx=40, sy=1, sz=1, ax=y, rcp=0, cuv=2, ch=1, n='exampleCylinder')[0]
        cmds.select(c)
        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
Exemplo n.º 19
0
 def _handleSphereButton(self):
     """
     This callback creates a polygonal sphere in the Maya scene.
     it then translates it.
     """
     r = 2
     a = 2.0*r
     y = (0, 1, 0) # y up
     c = cmds.polySphere(
         r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0]
     cmds.select(c)
     cmd.move(0, 5, 0, r = True)
     response = nimble.createRemoteResponse(globals())
     response.put('name', c)
Exemplo n.º 20
0
    def _handleSpawnButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        # Grab the names of all molecules in a scene
        allObj = cmds.ls("molecule*", assemblies=True)
        # If there aren't any molecules yet, make them
        if not allObj:
            numMolec = self.numMolecSpin.value()
            MoleculeSpawn.spawnMolecules(numMolec)
            response = nimble.createRemoteResponse(globals())
        # Otherwise, tell user to delete all before making more
        else:
            self.spawnButton.setText("Please delete before making more molecules")
Exemplo n.º 21
0
    def _handleSpawnButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        #Grab the names of all molecules in a scene
        allObj = cmds.ls('molecule*', assemblies=True)
        #If there aren't any molecules yet, make them
        if not allObj:
            numMolec = self.numMolecSpin.value()
            MoleculeSpawn.spawnMolecules(numMolec)
            response = nimble.createRemoteResponse(globals())
        # Otherwise, tell user to delete all before making more
        else:
            self.spawnButton.setText(
                "Please delete before making more molecules")
Exemplo n.º 22
0
 def _handleSmileSlider(self,value_s):
     #print(value)
     response=nimble.createRemoteResponse(globals())
     #response.put('name', cmds.setAttr('polyCylinder1.radius', value))
     scaledVal_s = float(value_s)/100
     response.put('name', cmds.setAttr('blendShape1.pasted__face', scaledVal_s))
Exemplo n.º 23
0
    def _handleExampleButton(self):
        """
        This callback creates a polygonal container and fills it with bubbles.
        """

        sx = 0.1  # original scale size x
        sy = 0.1  # original scale size y
        sz = 0.1  # original scale size z
        so = 0.1  # scale original for exp growth form

        maxY = 10  # highest bound
        maxX = 5  # max horizon bound
        maxZ = 5  # max horzon bound

        # Create container material
        containerShader = mayaShader('container_mat', (0.6, 0.6, 0.6),
                                     (0.9, 0.9, 0.9), (0.8, 0.8, 0.8), 'blinn')
        containerShader.create()

        # Create Container
        cHeight = 12
        c = cmds.polyCylinder(r=11,
                              h=cHeight,
                              sx=40,
                              sy=10,
                              sz=0,
                              ax=(0, 1, 0),
                              rcp=0,
                              cuv=3,
                              ch=1,
                              n='container1')[0]
        cmds.select(c)
        cmds.setAttr("container1.translateY", cHeight / 2 - 0.5)

        # create another mesh smaller
        cHeight = 12
        c = cmds.polyCylinder(r=10.5,
                              h=cHeight,
                              sx=40,
                              sy=10,
                              sz=0,
                              ax=(0, 1, 0),
                              rcp=0,
                              cuv=3,
                              ch=1,
                              n='container2')[0]
        cmds.select(c)
        cmds.setAttr("container2.translateY", cHeight / 2)

        # Boolean difference for making container
        cmds.polyCBoolOp('container1', 'container2', op=2, n='container')

        # Assign container_mat
        cmds.hyperShade(a="container_mat")

        keyStep = 3  #  3 * 10 = 30 fps
        totalTime = 10  # number of seconds of animation

        maxKey = totalTime * keyStep * 10  # max num of keys for the time
        minHdev = -2.0  # max movement between horizon space
        maxHdev = 2.0  # max movement beteen horiz space

        numBubbles = 50  # make 20 bubbles

        scaleRate = 0.2  # for growth of bubble exponentially as a decimal

        bubbleToTop = 1  # seconds for life of bubble

        # Create Material
        # Start bubble_mat
        bubbleShader = mayaShader('bubble_mat', (0.0, 0.8, 1.0),
                                  (0.9, 0.9, 0.9), (0.8, 0.8, 0.8), 'blinn')
        bubbleShader.create()
        #end bubble_mat

        for i in xrange(0, numBubbles):
            x = 0
            y = 0
            z = 0

            time = 0  # amount of time since bubble creation

            # Create Spehere nurb, the [0] selects first node of object
            randX = uniform(-maxX, maxX)
            randZ = uniform(-maxZ, maxZ)
            r = 1
            yUp = (0, 1, 0)  # start creation at y-up
            p = (randX, 0, randZ)  # object pivot point
            d = 3  # degree
            bNum = 1  # bNum is the bubble number

            c = cmds.sphere(p=p,
                            ax=yUp,
                            ssw=0,
                            esw=360,
                            r=r,
                            d=d,
                            ut=0,
                            tol=0.01,
                            s=8,
                            nsp=4,
                            ch=1,
                            n='bubble' + str(bNum))[0]
            cmds.select(c)

            # Assign bubble_mat
            cmds.hyperShade(a="bubble_mat")

            randFrameStart = randint(1, maxKey)  # Start randomly in time

            for j in xrange(randFrameStart, maxKey, keyStep):
                cmds.currentTime(j)
                cmds.setKeyframe(v=y, at='translateY')
                cmds.setKeyframe(v=x, at='translateX')
                cmds.setKeyframe(v=z, at='translateZ')

                x = x + uniform(minHdev, maxHdev)
                z = z + uniform(minHdev, maxHdev)
                y = y + (keyStep / bubbleToTop)
                print(y)
                if x >= maxX:
                    x = maxX

                if z >= maxZ:
                    z = maxZ

                sx = so * ((1 + scaleRate)**time)
                sz = so * ((1 + scaleRate)**time)
                sy = so * ((1 + scaleRate)**time)

                cmds.setKeyframe(v=sy, at='scaleY')
                cmds.setKeyframe(v=sx, at='scaleX')
                cmds.setKeyframe(v=sz, at='scaleZ')

                time = time + 1

                if y > maxY:
                    break  # terminate movement which can explode bubble later

        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
Exemplo n.º 24
0
def drawBubble(radius, xpoint, ypoint, zpoint, name, time):
    """
    Arguments: radius is the size of the overall shape
    Return: None
    """

    y = (0, 1, 0)

    c = cmds.polySphere(r=radius, ax=y, cuv=2, ch=1, n=name)[0]
    cmds.setAttr("lambert1.transparency",
                 0.470085,
                 0.470085,
                 0.470085,
                 type="double3")
    cmds.setAttr("lambert1.color", 0.01, 0.1, 0.470085, type="double3")
    rate = float(random.randrange(1, 8)) / 16
    print rate

    i = 1
    positive = True
    positivez = True
    if (xpoint < 0):
        positive = False
    if (zpoint < 0):
        positivez = False
    radius_long = radius
    while ypoint <= 19.9:
        # figure out best time step
        cmds.setKeyframe(name, t=i)
        radius_long = radius * (1 + rate)
        cmds.scale(1, 1, radius_long)
        cmds.move(xpoint, ypoint, zpoint, relative=False)
        cmds.select(name)

        response = nimble.createRemoteResponse(globals())
        response.put('name', name)

        if (xpoint - rate < -13):
            xpoint += rate
            positive = True
        elif (xpoint + rate > 13):
            xpoint -= rate
            positive = False
        else:

            if (positive == True):
                xpoint += rate
            else:
                xpoint -= rate
        if (zpoint - rate < -13):
            zpoint += rate
            positivez = True
        elif (zpoint + rate > 13):
            zpoint -= rate
            positivez = False
        else:

            if (positivez == True):
                zpoint += rate
            else:
                zpoint -= rate

        if ypoint > 20 - radius:
            #ypoint = 20

            print("pop")
            break
        else:
            ypoint = (rate + float(ypoint))

        i += 3
    #cmds.setKeyframe( name , at="translateY", t=time, v=xpoint + 3)

    return None
Exemplo n.º 25
0
    def _handleBubbles2Button(self):
        """
        This callback creates a polygonal sphere in the Maya scene.
        it then translates it.
        """
        decRange = np.arange(-1,1,.1)
        decRange2 = np.arange(0,1,.1)
        r = 2
        a = 2.0*r
        y = (0, 1, 0) # y up
        '''
        c = cmds.polySphere(
            r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0]
        cmds.select(c)
        cmd.setKeyframe()

        cmd.setKeyframe()
        '''

        '''
        i have a problem of select not adding
        '''

        sphereDefault = cmd.polySphere(n='sphereDefault')[0]
        cmds.select(sphereDefault)
        cmd.setKeyframe()

        cmd.setKeyframe()
        #print sphereDefault

        sphereXPlus = cmd.polySphere(n='sphereXPlus')[0]
        cmd.move(0, 0, 5, r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[2][2][2]', r=True)
        cmd.move(3, 0, 0, r=True)
        cmd.select(lattice[1]+'.pt[2][2][1]', r=True, add=True)
        cmd.move(3, 0, 0, r=True)
        cmd.select(lattice[1]+'.pt[2][2][0]', r=True, add=True)
        cmd.move(3, 0, 0, r=True)
        cmd.hide()
        cmd.select(sphereXPlus)
        cmd.hide()

        sphereXMinus = cmd.polySphere(n='sphereXMinus')[0]
        cmd.move(0, 0, 10, r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[0][2][2]', r=True)
        cmd.move(-3, 0, 0, r=True)
        cmd.select(lattice[1]+'.pt[0][2][1]', r=True, add=True)
        cmd.move(-3, 0, 0, r=True)
        cmd.select(lattice[1]+'.pt[0][2][0]', r=True, add=True)
        cmd.move(-3, 0, 0, r=True)
        cmd.hide()
        cmd.select(sphereXMinus)
        cmd.hide()

        sphereZPlus = cmd.polySphere(n='sphereZPlus')[0]
        cmd.move(0,0,15,r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[0][2][2]', r=True)
        cmd.move(0, 0, 3, r=True)
        cmd.select(lattice[1]+'.pt[1][2][2]', r=True)
        cmd.move(0, 0, 3, r=True)
        cmd.select(lattice[1]+'.pt[2][2][2]', r=True)
        cmd.move(0, 0, 3, r=True)
        cmd.hide()
        cmd.select(sphereZPlus)
        cmd.hide()

        sphereZMinus = cmd.polySphere(n='sphereZMinus')[0]
        cmd.move(0,0,20,r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[0][2][0]', r=True)
        cmd.move(0, 0, -3, r=True)
        cmd.select(lattice[1]+'.pt[1][2][0]', r=True)
        cmd.move(0, 0, -3, r=True)
        cmd.select(lattice[1]+'.pt[2][2][0]', r=True)
        cmd.move(0, 0, -3, r=True)
        cmd.hide()
        cmd.select(sphereZMinus)
        cmd.hide()

        sphereXPlusZPlus = cmd.polySphere(n='sphereXPlusZPlus')[0]
        cmd.move(0,0,25,r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[2][2][2]', r=True)
        cmd.move(3, 0, 3, r=True)
        cmd.select(lattice[1]+'.pt[2][2][1]', r=True)
        cmd.move(3, 0, 3, r=True)
        cmd.select(lattice[1]+'.pt[1][2][2]', r=True)
        cmd.move(3, 0, 3, r=True)
        cmd.hide()
        cmd.select(sphereXPlusZPlus)
        cmd.hide()

        sphereXPlusZMinus = cmd.polySphere(n='sphereXPlusZMinus')[0]
        cmd.move(0,0,30,r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[2][2][0]', r=True)
        cmd.move(3, 0, -3, r=True)
        cmd.select(lattice[1]+'.pt[2][2][1]', r=True)
        cmd.move(3, 0, -3, r=True)
        cmd.select(lattice[1]+'.pt[1][2][0]', r=True)
        cmd.move(3, 0, -3, r=True)
        cmd.hide()
        cmd.select(sphereXPlusZMinus)
        cmd.hide()

        sphereXMinusZMinus = cmd.polySphere(n='sphereXPMinusZMinus')[0]
        cmd.move(0,0,35,r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[1][2][0]', r=True)
        cmd.move(-3, 0, -3, r=True)
        cmd.select(lattice[1]+'.pt[0][2][1]', r=True)
        cmd.move(-3, 0, -3, r=True)
        cmd.select(lattice[1]+'.pt[0][2][0]', r=True)
        cmd.move(-3, 0, -3, r=True)
        cmd.hide()
        cmd.select(sphereXMinusZMinus)
        cmd.hide()

        sphereXMinusZPlus = cmd.polySphere(n='sphereXPMinusZPlus')[0]
        cmd.move(0,0,40,r=True)
        lattice = cmd.lattice(dv=(3, 3, 3), oc=True)
        cmd.select(lattice[1]+'.pt[1][2][2]', r=True)
        cmd.move(-3, 0, 3, r=True)
        cmd.select(lattice[1]+'.pt[0][2][1]', r=True)
        cmd.move(-3, 0, 3, r=True)
        cmd.select(lattice[1]+'.pt[0][2][2]', r=True)
        cmd.move(-3, 0, 3, r=True)
        cmd.hide()
        cmd.select(sphereXMinusZPlus)
        cmd.hide()

        ####
        #i need to make more blendShapes
        ####

        ####
        #blend shape setup
        ####
        bubbleBlend = cmd.blendShape(sphereXPlus, sphereXMinus, sphereZPlus, sphereZMinus, sphereXPlusZPlus, sphereXPlusZMinus,
                       sphereXMinusZPlus, sphereXMinusZMinus, sphereDefault, n='bubbleBlend' )

        #cmd.blendShape(bubbleBlend, edit=True, w=[(0,1),(1,.3)])

        for i in range(0,100,1):
            randX = rand.choice(range(-50,50,1))
            randZ = rand.choice(range(-50,50,1))

            sphereDefault = cmd.polySphere(n='sphereDefault')[0]
            bubbleBlend = cmd.blendShape(sphereXPlus, sphereXMinus, sphereZPlus, sphereZMinus, sphereXPlusZPlus, sphereXPlusZMinus,
                            sphereXMinusZPlus, sphereXMinusZMinus, sphereDefault, n='bubbleBlend' )
            cmds.select(sphereDefault)



            startTime = rand.choice(range(1, 600, 1))
            cmd.currentTime(1)
            cmd.move(randX, 0, randZ, a=True)
            cmd.setKeyframe()
            for j in range(startTime, 600, 2):
                x = rand.choice(decRange)
                y = 5*rand.choice(decRange2)
                z = rand.choice(decRange)
                cmd.currentTime(i)
                cmd.select(sphereDefault)
                cmd.move(x,y,z,r=True)
                cmd.setKeyframe()
                cmd.blendShape(bubbleBlend, edit=True,
                                   w=[(0,rand.choice(decRange)),
                                      (1,rand.choice(decRange)),
                                      (2,rand.choice(decRange)),
                                      (3,rand.choice(decRange)),
                                      (4,rand.choice(decRange)),
                                      (5,rand.choice(decRange)),
                                      (6,rand.choice(decRange)),
                                      (7,rand.choice(decRange))])
                cmd.setKeyframeBlendshapeTargetWts()
            response = nimble.createRemoteResponse(globals())
Exemplo n.º 26
0
    def _handleExampleButton(self):
        """ makes the bubble """
        x = 0
        y = 0
        z = 0

        sx = 0.1  # original scale size x
        sy = 0.1  # original scale size y
        sz = 0.1  # original scale size z
        so = 0.1  # scale original for exp growth form

        maxY = 30  # highest bound
        maxX = 5  # max horizon bound
        maxZ = 5  # max horzon bound

        keyStep = 3  #  3 * 10 = 30 fps
        totalTime = 10  # number of seconds of animation

        maxKey = totalTime * keyStep * 10  # max num of keys for the time

        minHdev = -2.0  # max movement between horizon space
        maxHdev = 2.0  # max movement beteen horiz space

        scaleRate = 0.2  # for growth of bubble exponentially as a decimal
        time = 0  # amount of time since bubble creation

        bubbleToTop = 1  # seconds for life of bubble

        # Create Material
        # Start bubble_mat
        bubbleShader = mayaShader('bubble_mat', (0.0, 0.8, 1.0),
                                  (0.9, 0.9, 0.9), (0.8, 0.8, 0.8), 'blinn')
        bubbleShader.create()
        #end bubble_mat

        # Create Spehere nurb, the [0] selects first node of object
        r = 1
        yUp = (0, 1, 0)  # start creation at y-up
        p = (0, 0, 0)  # object pivot point
        d = 3  # degree
        bNum = 1  # bNum is the bubble number

        c = cmds.sphere(p=p,
                        ax=yUp,
                        ssw=0,
                        esw=360,
                        r=r,
                        d=d,
                        ut=0,
                        tol=0.01,
                        s=8,
                        nsp=4,
                        ch=1,
                        n='bubble' + str(bNum))[0]
        cmds.select(c)

        # Assign bubble_mat
        cmds.hyperShade(a="bubble_mat")

        for i in xrange(1, maxKey, keyStep):
            cmds.currentTime(i)
            cmds.setKeyframe(v=y, at='translateY')
            cmds.setKeyframe(v=x, at='translateX')
            cmds.setKeyframe(v=z, at='translateZ')

            x = x + uniform(minHdev, maxHdev)
            z = z + uniform(minHdev, maxHdev)
            y = y + (keyStep / bubbleToTop)

            if x >= maxX:
                x = maxX

            if z >= maxZ:
                z = maxZ

            sx = so * ((1 + scaleRate)**time)
            sz = so * ((1 + scaleRate)**time)
            sy = so * ((1 + scaleRate)**time)

            cmds.setKeyframe(v=sy, at='scaleY')
            cmds.setKeyframe(v=sx, at='scaleX')
            cmds.setKeyframe(v=sz, at='scaleZ')

            time = time + 1

            if y > maxY:
                break  # terminate movement which can explode bubble later

        response = nimble.createRemoteResponse(globals())
        response.put('name', c)
Exemplo n.º 27
0
    def _handleExampleButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.
        #Assignment2.py
        import random

        #set the grid
        cmds.grid(s=40)

        #set the random seed
        random.seed(1024)



        cmds.addAttr(longName="expansion", shortName="exp", attributeType='double', min=0,
                        max=100, defaultValue=100, keyable=True)

        #set the move along center of each two atoms
        locatorGrpName=cmds.group(empty=True, name='expansion_locator_grp#')
        cords=cmds.getAttr('H1.translate')[0]
        locatorName=cmds.spaceLocator(position=cords, name='H1_loc')[0]
        cmds.xform( locatorName, centerPivots=True)
        cmds.parent(locatorName, locatorGrpName)
        #pointConstraintName=cmds.pointConstraint(['O',locatorName],H1, name='H1_pointConstraint')[0]
        cmds.xform( locatorGrpName, centerPivots=True)
        #group for all H2O copies
        H2OS1 = cmds.group(empty=True, name='H2OS1')
        H2OS2 = cmds.group(empty=True, name='H2OS2')
        H2OS3 = cmds.group(empty=True, name='H2OS3')

        #time frame
        startTime=cmds.playbackOptions(query=True, minTime=True)
        endTime=cmds.playbackOptions(query=True, maxTime=True)

        #create instance for a group number of water molecules
        for i in range (0, 100):

        cmds.duplicate('H2O')
        #let the instances rotate
        objName='H2O' + str(i+1);
        #random place
        x = random.uniform(-30,30)
        y = random.uniform(0, 40)
        z = random.uniform(-30, 30)
        cmds.move(x, y, z, objName)
        #random rotate
        xRot=random.uniform(0, 360)
        yRot=random.uniform(0, 360)
        zRot=random.uniform(0, 360)
        cmds.rotate(xRot, yRot, zRot, objName)

        #rotation random format
        selection = random.randint(1,3)
        if selection == 1:
            keyRot(objName, startTime, endTime, 'rotateX');
            keyTrans(objName, startTime, endTime, 'translateZ', random.randint(0,2));
        elif selection == 2:
            keyRot(objName, startTime, endTime, 'rotateY');
            keyTrans(objName, startTime, endTime, 'translateX', random.randint(0,2));
        else:
            keyRot(objName, startTime, endTime, 'rotateZ');
            keyTrans(objName, startTime, endTime, 'translateY', random.randint(0,2));
        #add each object into parent H2OS
        cmds.parent(objName, 'H2OS' + str(selection));

        #center the whole group

        cmds.xform(H2OS1, cp=True)
        keyRot(H2OS1, startTime, endTime, 'rotateX')
        cmds.xform(H2OS2, cp=True)
        keyRot(H2OS1, startTime, endTime, 'rotateY')
        cmds.xform(H2OS3, cp=True)
        keyRot(H2OS1, startTime, endTime, 'rotateZ')
        """
        H2O=self._makeMolecule()
        response = nimble.createRemoteResponse(globals())
        response.put('name', H2O)
Exemplo n.º 28
0
import math

import nimble
from nimble import cmds

#cmds.doSomethingHere

response = nimble.createRemoteResponse(globals())
response.put('name', c)
Exemplo n.º 29
0
 def _handleFrownSlider(self, value_f):
     response=nimble.createRemoteResponse(globals())
     scaledVal_f = float(value_f)/100
     response.put('name', cmds.setAttr('blendShape1.pasted__face1', scaledVal_f))