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)
def bAlter(bName, timeFrame, changeVal, chStr):
    mc.select(bName)    
    startTime = mc.currentTime(query=True)
    endTime = startTime + timeFrame
    rotBy = mc.getAttr(bName+ "." + chStr) + changeVal
    mc.setKeyframe(attribute=chStr)
    mc.currentTime(endTime)
    mc.setKeyframe(attribute=chStr, v=rotBy)
Exemplo n.º 3
0
    def _handleRaiseBtn(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        cmds.currentTime(self.timeBox.value(), edit=True)
        arm_l = findName("arm_L")
        limbRotate(arm_l, 20, -140)
        self.frameDisplay.display(self.timeBox.value() + 20)
Exemplo n.º 4
0
    def _handleRaiseBtn(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """
        cmds.currentTime(self.timeBox.value(), edit=True)
        arm_l = findName("arm_L")
        limbRotate(arm_l, 20, -140) 
        self.frameDisplay.display(self.timeBox.value() + 20)
def bAlter(bName, timeFrame, changeVal, chStr):
    mc.select(bName)    
    startTime = mc.currentTime(query=True)
    endTime = startTime + timeFrame
    rotBy = mc.getAttr(bName+ "." + chStr) + changeVal
    mc.setKeyframe(attribute=chStr)
    mc.currentTime(endTime)
    mc.setKeyframe(attribute=chStr, v=rotBy)	
    mc.currentTime(startTimeTime)
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)
Exemplo n.º 7
0
 def calculateRadii(self):
     print('Calculating radii...')
     for frame in range(self.boxes[0].getNumberOfFrames()):
         actualFrame = frame * BoxOnSphere.SPHERE_STEP
         cmds.currentTime(
             actualFrame,
             update=True)  # try to replace with query at a particular frame
         self.radii[frame] = cmds.xform(
             self.sphere, q=True, s=True, relative=True)[
                 0]  # get radius of sphere from x scale attribute
Exemplo 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')
Exemplo n.º 9
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()
Exemplo n.º 10
0
 def _handleRotBtn(self):
     """
     This callback creates a polygonal cylinder in the Maya scene.
     
     """
     cmds.currentTime(self.timeBox.value(), edit=True)
     currAngle = self.rotDial.value()
     changeTime = currAngle * (20.0 / 90.0)
     bod = findName("body")
     bAlter(bod, changeTime, currAngle, "rotateY")
     self.frameDisplay.display(self.timeBox.value() + changeTime)
Exemplo n.º 11
0
 def _handleKickBtn(self):
     """
     This callback creates a polygonal cylinder in the Maya scene.
     
     """
     cmds.currentTime(self.timeBox.value(), edit=True)
     limb = findName("leg_R")
     limbRotate(limb, 10, 35)
     cmds.currentTime(self.timeBox.value() + 10, edit=True)
     limbRotate(limb, 15, -100) 
     self.frameDisplay.display(self.timeBox.value() + 35)
Exemplo n.º 12
0
 def _handleRotBtn(self):
     """
     This callback creates a polygonal cylinder in the Maya scene.
     
     """
     cmds.currentTime(self.timeBox.value(), edit=True)
     currAngle = self.rotDial.value()
     changeTime = currAngle * (20.0/90.0)
     bod = findName("body")
     bAlter(bod, changeTime, currAngle, "rotateY")
     self.frameDisplay.display(self.timeBox.value() + changeTime)
Exemplo n.º 13
0
 def _handleKickBtn(self):
     """
     This callback creates a polygonal cylinder in the Maya scene.
     
     """
     cmds.currentTime(self.timeBox.value(), edit=True)
     limb = findName("leg_R")
     limbRotate(limb, 10, 35)
     cmds.currentTime(self.timeBox.value() + 10, edit=True)
     limbRotate(limb, 15, -100)
     self.frameDisplay.display(self.timeBox.value() + 35)
Exemplo n.º 14
0
    def _handleDropClaw(self):

        #Get the current time
        lastKeyTime = cmds.currentTime(query=True)
        print lastKeyTime

        #-------------------------
        #------Drop the claw------
        #-------------------------
        #Set initial status keyframe
        cmds.setKeyframe('claw', attribute='translateY', t=lastKeyTime, v=345)
        #----set keyframe for dropped claw
        cmds.setKeyframe('claw', attribute='translateY', t=lastKeyTime+72, v=20)

        #---change curTime to be time at last keyframe
        lastKeyTime = lastKeyTime+72

        #---Keyframe claw closing----
        #---Loop over the 3 claw fingers
        for i in range (1,4):
            #---current finger we are looking at
            fingerName = 'clawFinger'+str(i)
            #---initial keyframe
            cmds.setKeyframe(fingerName+"Group|"+fingerName+"Joint", attribute='rotateZ', t=lastKeyTime)
            #----After 1.5 seconds, rotate finger to -70 Z
            cmds.setKeyframe(fingerName+"Group|"+fingerName+"Joint", attribute='rotateZ', t=lastKeyTime+36, v=40)

        #--last keyframe was at lastKey+36
        lastKeyTime = lastKeyTime+36

        #-----Raise the claw----------
        #Set initial status keyframe
        cmds.setKeyframe('claw', attribute='translateY', t=lastKeyTime, v=20)
        #--raise it back to the start position of Y
        cmds.setKeyframe('claw', attribute='translateY', t=lastKeyTime+72, v=345)
Exemplo n.º 15
0
    def _handleRun(self):

        # This callback causes the lego man to run a short distance, along the Z axis.

        time = cmds.currentTime(q=1)
        loc = cmds.getAttr('Lego_Man.tz')

        cmds.setKeyframe('leg_R', v=0.0, at='rotateX')
        cmds.setKeyframe('leg_L', v=0.0, at='rotateX')
        cmds.setKeyframe('arm_R', v=0.0, at='rotateX')
        cmds.setKeyframe('arm_L', v=0.0, at='rotateX')
        cmds.setKeyframe('Lego_Man', v=loc, at='translateZ')

        cmds.setKeyframe('leg_R', v=-90.0, at='rotateX', t=time+20)
        cmds.setKeyframe('leg_L', v=90.0, at='rotateX', t=time+20)
        cmds.setKeyframe('arm_R', v=90.0, at='rotateX', t=time+20)
        cmds.setKeyframe('arm_L', v=-90.0, at='rotateX', t=time+20)
        cmds.setKeyframe('Lego_Man', v=loc+6.0, at='translateZ', t=time+20)

        cmds.setKeyframe('leg_R', v=90.0, at='rotateX', t=time+40)
        cmds.setKeyframe('leg_L', v=-90.0, at='rotateX', t=time+40)
        cmds.setKeyframe('arm_R', v=-90.0, at='rotateX', t=time+40)
        cmds.setKeyframe('arm_L', v=90.0, at='rotateX', t=time+40)
        cmds.setKeyframe('Lego_Man', v=loc+12.0, at='translateZ', t=time+40)

        cmds.setKeyframe('leg_R', v=-90.0, at='rotateX', t=time+60)
        cmds.setKeyframe('leg_L', v=90.0, at='rotateX', t=time+60)
        cmds.setKeyframe('arm_R', v=90.0, at='rotateX', t=time+60)
        cmds.setKeyframe('arm_L', v=-90.0, at='rotateX', t=time+60)
        cmds.setKeyframe('Lego_Man', v=loc+18.0, at='translateZ', t=time+60)
Exemplo n.º 16
0
    def _handleRaiseRight(self):

        # This callback raises the lego man's right hand.

        time = cmds.currentTime(q=1)

        cmds.setKeyframe('arm_R', v=0.0, at='rotateX')
        cmds.setKeyframe('arm_R', v=-120.0, at='rotateX', t=time+15)
        cmds.setKeyframe('arm_R', v=0.0, at='rotateX', t=time+30)
Exemplo n.º 17
0
 def _time_check(self):
     i = 0
     try:
         while (1):
             time.sleep(.5)
             print(i)
             i += 1
             new_time = cmds.currentTime(query=True)
             self.timeLabel.setText("Current time: " + str(new_time))
     except:
         print "Caught it!"
Exemplo n.º 18
0
    def _handleReleaseClaw(self):
        #Get the current time
        lastKeyTime = cmds.currentTime(query=True)

        #---Keyframe claw closing----
        #---Loop over the 3 claw fingers
        for i in range (1,4):
            #---current finger we are looking at
            fingerName = 'clawFinger'+str(i)
            #---initial keyframe
            cmds.setKeyframe(fingerName+"Group|"+fingerName+"Joint", attribute='rotateZ', t=lastKeyTime)
            #----After 1.5 seconds, rotate finger to -70 Z
            cmds.setKeyframe(fingerName+"Group|"+fingerName+"Joint", attribute='rotateZ', t=lastKeyTime+36, v=0)
Exemplo n.º 19
0
    def handleScriptBtn(self):
        cmds.select('arm_R')
        cmds.currentTime(1)
        cmds.setKeyframe('arm_R', at='rotateX')

        cmds.currentTime(20)
        cmds.rotate(-142.85, 0, 0)
        cmds.setKeyframe('arm_R', at='rotateX')

        cmds.currentTime(32)
        cmds.rotate(-142.85, 0, 0)
        cmds.setKeyframe('arm_R', at='rotateX')

        cmds.currentTime(48)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe('arm_R', at='rotateX')
Exemplo n.º 20
0
    def handleScriptBtn(self):
        cmds.select('arm_R')
        cmds.currentTime(1)
        cmds.setKeyframe('arm_R', at='rotateX')

        cmds.currentTime(20)
        cmds.rotate(-142.85, 0, 0)
        cmds.setKeyframe('arm_R', at='rotateX')

        cmds.currentTime(32)
        cmds.rotate(-142.85, 0, 0)
        cmds.setKeyframe('arm_R', at='rotateX')

        cmds.currentTime(48)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe('arm_R', at='rotateX')
Exemplo n.º 21
0
    def on_click_object_flight(self, height=30):
        ball = get_ball_from_current_selection()
        if ball is '':
            return """Was unable to find a "ball" in the current selection!"""
        starting_ball_height = cmds.getAttr(ball + ".translateY")
        final_slide = height/10
        ball_rotation = 360*random.randint(height/20, height/10)
        final_slide_time = height/10

        # Set initial key frame
        current_time = cmds.currentTime(query=True)
        cmds.setKeyframe(ball, at="translateZ", t=current_time, ott="linear")
        cmds.setKeyframe(ball, at="translateY", t=current_time, ott="linear")
        cmds.setKeyframe(ball, at="rotate", t=current_time)

        # Set all remaining key frames programatically in the below loop
        bounce_height = height
        bounce_time = bounce_height
        bounce_distance = 0
        while bounce_height > 1:
            # peak of flight
            current_time += bounce_time/2
            cmds.setKeyframe(ball, v=bounce_height, at="translateY", t=current_time, itt="spline", ott="spline")

            # touch down to earth
            current_time += bounce_time/2
            cmds.setKeyframe(ball, v=starting_ball_height, at="translateY", t=current_time, itt="linear", ott="linear")

            bounce_distance += bounce_height*3
            bounce_time *= 0.5
            bounce_height *= 0.5

        # Set final key frame
        current_time += final_slide_time
        cmds.setKeyframe(ball, v=bounce_distance + final_slide, at="translateZ", t=current_time, itt="spline")
        cmds.setKeyframe(ball, v=ball_rotation, at="rotate", t=current_time)
        cmds.currentTime(current_time)
Exemplo n.º 22
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)
Exemplo n.º 23
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)
Exemplo n.º 24
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()
Exemplo n.º 25
0
    def handleBallBtn(self):
        cmds.select('ball')
        cmds.currentTime(74)
        cmds.setKeyframe('ball')

        cmds.currentTime(112)
        cmds.move(-0.757, 6.434, 15.831)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')

        cmds.currentTime(144)
        cmds.move(-0.772, 0.637, 22.462)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')
Exemplo n.º 26
0
    def handleBallBtn(self):
        cmds.select('ball')
        cmds.currentTime(74)
        cmds.setKeyframe('ball')

        cmds.currentTime(112)
        cmds.move(-0.757, 6.434, 15.831)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')

        cmds.currentTime(144)
        cmds.move(-0.772, 0.637, 22.462)
        cmds.rotate(9.208, 17.386, -368.887)
        cmds.setKeyframe('ball')
Exemplo n.º 27
0
def main(bubbleQuantity, allAtts):
    for i in range(bubbleQuantity): # create 50 bubbles
        name = 'bubble' + str(i) # name them sequentially

        """
        first -- a random integer between 1 and 50
        which represents the keyframe in which a
        bubble is generated
        """
        first = random.randint(1,300)

        last = first + 66 # all bubbles take 66 keyframes to rise
        x = 10 - random.random()*20 # this makes x values in the range [-10.0,10.0]
        z = 10 - random.random()*20 # this makes z values in the range [-10.0,10.0]
        createBubble(x,z,name)
        cmds.currentTime(first)

        cmds.setKeyframe( name, v=1, at='visibility' )
        cmds.setKeyframe(name)
        cmds.currentTime(last)

        ############ keyframe all attributes ############
        if allAtts:
            cmds.scale(10,10,10, name)
            cmds.move(0, 20, 0, name, relative=True)
            cmds.setKeyframe()
        #################################################

        ####### keyframe only necessary attributes ######
        else:
            cmds.setKeyframe( name, v=10, at='scaleX' )
            cmds.setKeyframe( name, v=10, at='scaleY' )
            cmds.setKeyframe( name, v=10, at='scaleZ' )
            cmds.setKeyframe( name, v=10, at='translateY' )
        #################################################

        cmds.currentTime(last + 1)
        cmds.setKeyframe( name, v=0, at='visibility' )
    cmds.currentTime(1)
Exemplo n.º 28
0
    def _handleKick(self):

        # This callback causes the lego man to kick with his right leg.

        # actions at frame 0
        time = cmds.currentTime(q=1)
        cmds.setKeyframe('body', v=0.0, at='rotateX')
        cmds.setKeyframe('leg_R', v=0.0, at='rotateX')
        cmds.setKeyframe('leg_L', v=0.0, at='rotateX')
        cmds.setKeyframe('arm_R', v=0.0, at='rotateX')
        cmds.setKeyframe('arm_L', v=0.0, at='rotateX')

        # actions at frame 40
        cmds.setKeyframe('body', v=15, at='rotateX', t=time+40)
        cmds.setKeyframe('leg_R', v=70, at='rotateX', t=time+40)
        cmds.setKeyframe('leg_L', v=-15, at='rotateX', t=time+40)
        cmds.setKeyframe('arm_R', v=40, at='rotateX', t=time+40)
        cmds.setKeyframe('arm_L', v=-40, at='rotateX', t=time+40)

        # actions at frame 60
        cmds.setKeyframe('leg_R', v=-90, at='rotateX', t=time+60)
        cmds.setKeyframe('body', v=-15, at='rotateX', t=time+60)
        cmds.setKeyframe('arm_R', v=-40, at='rotateX', t=time+60)
        cmds.setKeyframe('arm_L', v=40, at='rotateX', t=time+60)
def runFrom(bodyName, startTime, endTime):        
    mc.select(bodyName)
    #first we start 
    mc.currentTime(startTime+24)
    mc.setKeyframe(attribute='translateZ', v=-60)
    mc.currentTime(endTime)
    mc.setKeyframe(attribute='translateZ', v=0)

    mc.currentTime(startTime)
    mc.setKeyframe(attribute='rotateX', v=0)
    mc.currentTime(startTime+24)
    mc.setKeyframe(attribute='rotateX', v=385)    
    mc.currentTime(endTime-24)
    mc.setKeyframe(attribute='rotateX', v=385)     
    mc.currentTime(endTime)
    mc.setKeyframe(attribute='rotateX', v=360)
     
    left_leg = findName('leg_R')
    right_leg = findName('left_L')
    rTime = startTime
    lTime = startTime + 6 
    startVal = 0
    while (lTime+12) < endTime:
        rTime = rTime + 12
        lTime = lTime + 12
        legRotate(right_leg, rTime, rTime+12, startVal, startVal + 360)
        legRotate(left_leg, lTime, lTime+12, startVal, startVal+360)
        startVal = startVal + 360
    mc.select(right_leg)
    mc.currentTime(endTime+1)
    mc.rotate(0,0,0)
    mc.currentTime(startTime)
Exemplo n.º 30
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()
def runFrom(bodyName, startTime, endTime):        
    mc.select(bodyName)
    #first we start 
    mc.currentTime(startTime+24)
    mc.setKeyframe(attribute='translateZ', v=-60)
    mc.currentTime(endTime)
    mc.setKeyframe(attribute='translateZ', v=0)

    mc.currentTime(startTime)
    mc.setKeyframe(attribute='rotateX', v=0)
    mc.currentTime(startTime+24)
    mc.setKeyframe(attribute='rotateX', v=385)    
    mc.currentTime(endTime-24)
    mc.setKeyframe(attribute='rotateX', v=385)     
    mc.currentTime(endTime)
    mc.setKeyframe(attribute='rotateX', v=360)
     
    left_leg = findName('leg_R')
    right_leg = findName('left_L')
    rTime = startTime
    lTime = startTime + 6 
    startVal = 0
    while (lTime+12) < endTime:
        rTime = rTime + 12
        lTime = lTime + 12
        legRotate(right_leg, rTime, rTime+12, startVal, startVal + 360)
        legRotate(left_leg, lTime, lTime+12, startVal, startVal+360)
        startVal = startVal + 360
    mc.select(right_leg)
    mc.currentTime(endTime+1)
    mc.rotate(0,0,0)
    mc.currentTime(startTime)
Exemplo n.º 32
0
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, 1000))
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()
Exemplo n.º 33
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.º 34
0
    def handleLegsBtn(self):
        cmds.select('leg_R')
        cmds.currentTime(48)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(64)
        cmds.rotate(70.63, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(80)
        cmds.rotate(-64.254, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(96)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(104)
        cmds.rotate(12.526, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(107)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')
Exemplo n.º 35
0
    def _handleRunBtn(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.
        
        """
        #first we raise the leg, then halfway through the leg raise, we start jumping a bit, and raise the back leg in reverse
        currTime = self.timeBox.value()
        changeTime = (self.distBox.value()*10)
        endTime = currTime + changeTime
        cmds.currentTime(currTime, edit=True)
        RArm = findName("arm_R")
        LArm = findName("arm_L")
        arm = ""
        leg = ""
        R = findName("leg_R")
        L = findName("left_L")
        bod = findName("body")
        
        
        #we start by beginning the X/Z translation keys at the same time
        cmds.currentTime(currTime, edit=True)
        bAlter(bod, changeTime, self._getX(), "translateX")
        cmds.currentTime(currTime, edit=True)
        bAlter(bod, changeTime, self._getZ(), "translateZ")
        #then, while currTime < endTime, move the legs, hop up and down.
        while (currTime < endTime):
            #move the right leg up
            limbRotate(R, 10, -60) 
            #while doing so, move the left arm up
            cmds.currentTime(currTime, edit=True)
            limbRotate(LArm, 10, -60)   
            #while doing so, move the right arm slightly back
            cmds.currentTime(currTime, edit=True)
            limbRotate(RArm, 10, 30)
            #while doings so, move the left leg slightly back
            cmds.currentTime(currTime, edit=True)
            limbRotate(L, 10, 30)        
            #meanwhile, we also need to start hopping.
            cmds.currentTime(currTime, edit=True)
            bAlter(bod, 10, 1, "translateY")
            currTime += 10            
            #move the right leg down
            limbRotate(R, 10, 60) 
            #while doing so, move the left arm down
            cmds.currentTime(currTime, edit=True)
            limbRotate(LArm, 10, 60)   
            #while doing so, move the right arm back forward
            cmds.currentTime(currTime, edit=True)
            limbRotate(RArm, 10, -30)
            #while doings so, move the left leg back forward
            cmds.currentTime(currTime, edit=True)
            limbRotate(L, 10, -30)    
            #no we're at the peak, everything back to neutral
            cmds.currentTime(currTime, edit=True)
            bAlter(bod, 10, -1, "translateY")
            currTime += 10
            arm = RArm
            RArm = LArm
            LArm = arm

            leg = R
            R = L
            L = leg
        self.frameDisplay.display(endTime)
Exemplo n.º 36
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()
Exemplo n.º 37
0
def simulate(numFlockers, numFrames, alignmentWeight, cohesionWeight,
             separationWeight, speed, distance, in3D):

    # Create the flock
    flock = Flock(alignmentWeight, cohesionWeight, separationWeight, speed,
                  distance)

    cmds.shadingNode('phong', asShader=True, name='Redwax')
    cmds.select('Redwax')
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='RedwaxSG')
    cmds.connectAttr('Redwax.outColor', 'RedwaxSG.surfaceShader', f=True)
    cmds.setAttr('Redwax.color', 1, 0, 0, type='double3')
    cmds.setAttr('Redwax.cosinePower', 5)
    cmds.setAttr('Redwax.reflectivity', 0)
    cmds.setAttr('Redwax.specularColor', 1, 1, 1, type='double3')

    cmds.shadingNode('blinn', asShader=True, name='Plastic')
    cmds.select('Plastic')
    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='PlasticSG')
    cmds.connectAttr('Plastic.outColor', 'PlasticSG.surfaceShader', f=True)
    cmds.setAttr('Plastic.color', 0.9, 0.9, 0.9, type='double3')
    cmds.setAttr('Plastic.eccentricity', 0.55)
    cmds.setAttr('Plastic.specularRollOff', 1)
    cmds.setAttr('Plastic.diffuse', 0.9)

    cmds.directionalLight(rotation=(-90, 0, 0))

    cmds.polyPlane(name='base')
    cmds.setAttr('base.scaleX', 25)
    cmds.setAttr('base.scaleZ', 25)
    cmds.setAttr('base.translateY', -15)
    cmds.select('base')
    cmds.sets(e=True, forceElement='PlasticSG')

    for i in range(numFlockers):
        xVel = random.randint(-9, 9)
        yVel = random.randint(-9, 9)
        zVel = random.randint(-9, 9)
        xPos = random.randint(-100, 100)
        yPos = random.randint(-100, 100)
        zPos = random.randint(-100, 100)
        fname = 'f' + str(i)
        if (in3D):
            flock.addFlocker(xVel, yVel, zVel, xPos, yPos, zPos, fname)
        else:
            flock.addFlocker(xVel, 0, zVel, xPos, 0, zPos, fname)

        cmds.polySphere(name=fname, radius=0.2)
        cmds.select(fname)
        cmds.sets(e=True, forceElement='RedwaxSG')

    # Initialize time
    time = 0
    endTime = numFrames
    cmds.currentTime(time)

    # Initialize flock member positions
    for flocker in flock.flockers:
        cmds.select(flocker.name)
        cmds.move(flocker.xPos, flocker.yPos, flocker.zPos)
        cmds.setKeyframe(flocker.name)

    while time < endTime:

        time += 12

        for flocker in flock.flockers:
            flocker.updateVelocity(flock)

        for flocker in flock.flockers:
            flocker.updatePostion()

        cmds.currentTime(time)
        for flocker in flock.flockers:
            fx = flocker.name + '.translateX'
            fy = flocker.name + '.translateY'
            fz = flocker.name + '.translateZ'
            cmds.setAttr(fx, flocker.xPos)
            cmds.setAttr(fy, flocker.yPos)
            cmds.setAttr(fz, flocker.zPos)
            cmds.setKeyframe(flocker.name)
Exemplo n.º 38
0
    def handleLegsBtn(self):
        cmds.select('leg_R')
        cmds.currentTime(48)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(64)
        cmds.rotate(70.63, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(80)
        cmds.rotate(-64.254, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(96)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(104)
        cmds.rotate(12.526, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')

        cmds.currentTime(107)
        cmds.rotate(0, 0, 0)
        cmds.setKeyframe('leg_R', at='rotateX')
Exemplo n.º 39
0
    def buildScene(self):
        """Doc..."""

        groupItems = []
        hinds      = []
        fores      = []

        for c in self._data.getChannelsByKind(ChannelsEnum.POSITION):
            isHind = c.target in [TargetsEnum.LEFT_HIND, TargetsEnum.RIGHT_HIND]
            radius = 20 if isHind else 15
            res    = cmds.polySphere(radius=radius, name=c.target)
            groupItems.append(res[0])
            if isHind:
                hinds.append(res[0])
            else:
                fores.append(res[0])

            if c.target == TargetsEnum.LEFT_HIND:
                self._leftHind = res[0]
            elif c.target == TargetsEnum.RIGHT_HIND:
                self._rightHind = res[0]
            elif c.target == TargetsEnum.RIGHT_FORE:
                self._rightFore = res[0]
            elif c.target == TargetsEnum.LEFT_FORE:
                self._leftFore = res[0]

            for k in c.keys:
                frames = [
                    ['translateX', k.value.x, k.inTangentMaya[0], k.outTangentMaya[0]],
                    ['translateY', k.value.y, k.inTangentMaya[1], k.outTangentMaya[1]],
                    ['translateZ', k.value.z, k.inTangentMaya[2], k.outTangentMaya[2]]
                ]
                for f in frames:
                    cmds.setKeyframe(
                        res[0],
                        attribute=f[0],
                        time=k.time,
                        value=f[1],
                        inTangentType=f[2],
                        outTangentType=f[3]
                    )

                if k.event == 'land':
                    printResult = cmds.polyCylinder(
                        name=c.target + '_print1',
                        radius=radius,
                        height=(1.0 if isHind else 5.0)
                    )
                    cmds.move(k.value.x, k.value.y, k.value.z, printResult[0])
                    groupItems.append(printResult[0])

        cfg = self._data.configs
        name = 'cyc' + str(int(cfg.get(GaitConfigEnum.CYCLES))) + \
               '_ph' + str(int(cfg.get(GaitConfigEnum.PHASE))) + \
               '_gad' + str(int(cfg.get(SkeletonConfigEnum.FORE_OFFSET).z)) + \
               '_step' + str(int(cfg.get(SkeletonConfigEnum.STRIDE_LENGTH)))

        cube        = cmds.polyCube(name='pelvic_reference', width=20, height=20, depth=20)
        self._hips  = cube[0]
        groupItems.append(cube[0])
        cmds.move(0, 100, 0, cube[0])

        backLength = self._data.configs.get(SkeletonConfigEnum.FORE_OFFSET).z - \
                     self._data.configs.get(SkeletonConfigEnum.HIND_OFFSET).z

        cube2 = cmds.polyCube(name='pectoral_comparator', width=15, height=15, depth=15)
        cmds.move(0, 115, backLength, cube2[0])
        cmds.parent(cube2[0], cube[0], absolute=True)

        cmds.expression(
            string="%s.translateZ = 0.5*abs(%s.translateZ - %s.translateZ) + min(%s.translateZ, %s.translateZ)" %
            (cube[0], hinds[0], hinds[1], hinds[0], hinds[1])
        )

        cube = cmds.polyCube(name='pectoral_reference', width=15, height=15, depth=15)
        self._pecs = cube[0]
        groupItems.append(cube[0])
        cmds.move(0, 100, 0, cube[0])
        cmds.expression(
            string="%s.translateZ = 0.5*abs(%s.translateZ - %s.translateZ) + min(%s.translateZ, %s.translateZ)" %
            (cube[0], fores[0], fores[1], fores[0], fores[1])
        )

        self._group = cmds.group(*groupItems, world=True, name=name)

        cfg = self._data.configs
        info = 'Gait Phase: ' + \
                str(cfg.get(GaitConfigEnum.PHASE)) + \
                '\nGleno-Acetabular Distance (GAD): ' + \
                str(cfg.get(SkeletonConfigEnum.FORE_OFFSET).z) + \
                '\nStep Length: ' + \
                str(cfg.get(SkeletonConfigEnum.STRIDE_LENGTH)) + \
                '\nHind Duty Factor: ' + \
                str(cfg.get(GaitConfigEnum.DUTY_FACTOR_HIND)) + \
                '\nFore Duty Factor: ' + \
                str(cfg.get(GaitConfigEnum.DUTY_FACTOR_FORE)) + \
                '\nCycles: ' + \
                str(cfg.get(GaitConfigEnum.CYCLES))

        cmds.select(self._group)
        if not cmds.attributeQuery('notes', node=self._group, exists=True):
            cmds.addAttr(longName='notes', dataType='string')
            cmds.setAttr(self._group + '.notes', info, type='string')

        self.createShaders()
        self.createRenderEnvironment()

        minTime = min(0, int(cmds.playbackOptions(query=True, minTime=True)))

        deltaTime = cfg.get(GeneralConfigEnum.STOP_TIME) - cfg.get(GeneralConfigEnum.START_TIME)
        maxTime = max(
            int(float(cfg.get(GaitConfigEnum.CYCLES))*float(deltaTime)),
            int(cmds.playbackOptions(query=True, maxTime=True))
        )

        cmds.playbackOptions(
            minTime=minTime, animationStartTime=minTime, maxTime= maxTime, animationEndTime=maxTime
        )

        cmds.currentTime(0, update=True)

        cmds.select(self._group)
Exemplo n.º 40
0
    def _handleTime(self):

        new_time = self.timeEdit.displayText()
        self.timeLabel.setText("Current time: " + new_time)

        cmds.currentTime(int(new_time))
Exemplo n.º 41
0
    def _handleRunBtn(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.
        
        """
        #first we raise the leg, then halfway through the leg raise, we start jumping a bit, and raise the back leg in reverse
        currTime = self.timeBox.value()
        changeTime = (self.distBox.value() * 10)
        endTime = currTime + changeTime
        cmds.currentTime(currTime, edit=True)
        RArm = findName("arm_R")
        LArm = findName("arm_L")
        arm = ""
        leg = ""
        R = findName("leg_R")
        L = findName("left_L")
        bod = findName("body")

        #we start by beginning the X/Z translation keys at the same time
        cmds.currentTime(currTime, edit=True)
        bAlter(bod, changeTime, self._getX(), "translateX")
        cmds.currentTime(currTime, edit=True)
        bAlter(bod, changeTime, self._getZ(), "translateZ")
        #then, while currTime < endTime, move the legs, hop up and down.
        while (currTime < endTime):
            #move the right leg up
            limbRotate(R, 10, -60)
            #while doing so, move the left arm up
            cmds.currentTime(currTime, edit=True)
            limbRotate(LArm, 10, -60)
            #while doing so, move the right arm slightly back
            cmds.currentTime(currTime, edit=True)
            limbRotate(RArm, 10, 30)
            #while doings so, move the left leg slightly back
            cmds.currentTime(currTime, edit=True)
            limbRotate(L, 10, 30)
            #meanwhile, we also need to start hopping.
            cmds.currentTime(currTime, edit=True)
            bAlter(bod, 10, 1, "translateY")
            currTime += 10
            #move the right leg down
            limbRotate(R, 10, 60)
            #while doing so, move the left arm down
            cmds.currentTime(currTime, edit=True)
            limbRotate(LArm, 10, 60)
            #while doing so, move the right arm back forward
            cmds.currentTime(currTime, edit=True)
            limbRotate(RArm, 10, -30)
            #while doings so, move the left leg back forward
            cmds.currentTime(currTime, edit=True)
            limbRotate(L, 10, -30)
            #no we're at the peak, everything back to neutral
            cmds.currentTime(currTime, edit=True)
            bAlter(bod, 10, -1, "translateY")
            currTime += 10
            arm = RArm
            RArm = LArm
            LArm = arm

            leg = R
            R = L
            L = leg
        self.frameDisplay.display(endTime)
Exemplo n.º 42
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')
Exemplo n.º 43
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.º 44
0
    def _handleTime(self):

        new_time = self.timeEdit.displayText()
        self.timeLabel.setText("Current time: " + new_time)

        cmds.currentTime(int(new_time))
Exemplo n.º 45
0
 def _handleReset(self):
     cmds.currentTime(1)
     cmds.cutKey('MoveAll', 'CTRL_R_legD', 'CTRL_R_legC', 'CTRL_R_legB', 'CTRL_R_legA', 'CTRL_L_legD', 'CTRL_L_legC',
                 'CTRL_L_legB', 'CTRL_L_legA', 'CTRL_innerFangL', 'CTRL_innerFangR', 'R_outerFang_JA', 'L_outerFang_JA')
Exemplo n.º 46
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.º 47
0
 def _handleReset(self):
     cmds.currentTime(1)
     cmds.cutKey('MoveAll', 'CTRL_R_legD', 'CTRL_R_legC', 'CTRL_R_legB',
                 'CTRL_R_legA', 'CTRL_L_legD', 'CTRL_L_legC', 'CTRL_L_legB',
                 'CTRL_L_legA', 'CTRL_innerFangL', 'CTRL_innerFangR',
                 'R_outerFang_JA', 'L_outerFang_JA')