Ejemplo n.º 1
0
    def _handleAttack(self):
        cmds.playbackOptions(max=54, aet=54)
        cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=1)
        cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')), t=1)
        cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')), t=1)
        cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')), t=1)
        cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')), t=1)
        cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')), t=1)

        cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=36)
        cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')-3.5), t=36)
        cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')+1.5), t=36)
        cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')+1.5), t=36)
        cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')+45), t=36)
        cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')+45), t=36)

        cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=48)
        cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')-3.5), t=48)
        cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')+1.5), t=48)
        cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')+1.5), t=48)
        cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')+45), t=48)
        cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')+45), t=48)

        cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-7), t=54)
        cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')+5.5), t=54)
        cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')), t=54)
        cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')), t=54)
        cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')), t=54)
        cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')), t=54)
Ejemplo n.º 2
0
def create_bubble():
    cmds.playbackOptions(minTime='0', maxTime='71')  # set playback range

    size = 0.2

    bubble = cmds.polySphere(name='bubble', radius=0.2)  # create a sphere

    #for f in range(72):        # for the first 84 frames (starting from 0 and ending with 83)

    for time in [1, 15, 30, 45, 60, 72]:  # for each frame calculate sub-steps

        #mc.setKeyframe( bubble, attribute='translateX', value=px, t=f )        # set keyframes
        cmds.setKeyframe(bubble,
                         attribute='translateY',
                         value=size + 0.1 * time,
                         t=time)
        cmds.setKeyframe(bubble,
                         attribute='scaleX',
                         value=size + 0.02 * time,
                         t=time)
        cmds.setKeyframe(bubble,
                         attribute='scaleY',
                         value=size + 0.02 * time,
                         t=time)
        cmds.setKeyframe(bubble,
                         attribute='scaleZ',
                         value=size + 0.02 * time,
                         t=time)
Ejemplo n.º 3
0
 def _handleJump(self):
     cmds.playbackOptions(max=30, aet=30)
     cmds.setKeyframe("MoveAll",
                      at="translateY",
                      v=float(cmds.getAttr('MoveAll.translateY')),
                      t=1)
     cmds.setKeyframe("MoveAll",
                      at="translateY",
                      v=float(cmds.getAttr('MoveAll.translateY') - 4),
                      t=12)
     cmds.setKeyframe("MoveAll",
                      at="translateY",
                      v=float(cmds.getAttr('MoveAll.translateY') - 4),
                      t=12)
     cmds.setKeyframe("MoveAll",
                      at="translateY",
                      v=float(cmds.getAttr('MoveAll.translateY') + 18),
                      t=18)
     cmds.setKeyframe("MoveAll",
                      at="translateY",
                      v=float(cmds.getAttr('MoveAll.translateY') - 4),
                      t=24)
     cmds.setKeyframe("MoveAll",
                      at="translateY",
                      v=float(cmds.getAttr('MoveAll.translateY')),
                      t=30)
Ejemplo n.º 4
0
 def _handleJump(self):
     cmds.playbackOptions(max=30, aet=30)
     cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=1)
     cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-4), t=12)
     cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-4), t=12)
     cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')+18), t=18)
     cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-4), t=24)
     cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=30)
Ejemplo n.º 5
0
 def _handlePlayButton(self):
     #time frame
     startTime=cmds.playbackOptions(query=True, minTime=True)
     endTime=cmds.playbackOptions(query=True, maxTime=True)
     #cmds.selectKey( objName, time=(startTime, endTime), attribute=tarAttr, keyframe=True )
     cmds.keyTangent( inTangentType='linear', outTangentType='linear')
     cmds.playblast( s="fight", f="myMovie.mv" )
     cmds.play(forward = True)
Ejemplo n.º 6
0
 def _merge(self):
     startTime=cmds.playbackOptions(query=True, minTime=True)
     endTime=cmds.playbackOptions(query=True, maxTime=True)
     for i in range(0, 100):
         objName='H2O' + str(i+1)
         self._keyTrans(objName, startTime, endTime, 'translateX', 3)
         self._keyTrans(objName, startTime, endTime, 'translateY', 3)
         self._keyTrans(objName, startTime, endTime, 'translateZ', 3)
Ejemplo n.º 7
0
 def _handelPlayButton(self):
     #time frame
     startTime=cmds.playbackOptions(query=True, minTime=True)
     endTime=cmds.playbackOptions(query=True, maxTime=True)
     cmds.setKeyframe( 'ball', time=startTime, attribute='translateX', value=5 )
     cmds.setKeyframe( 'ball', time=endTime, attribute='translateX', value = 1.6 )
     #cmds.selectKey( objName, time=(startTime, endTime), attribute=tarAttr, keyframe=True )
     cmds.keyTangent( inTangentType='linear', outTangentType='linear')
     cmds.play(forward = True)
Ejemplo n.º 8
0
    def _handleSetActionButton(self):
        #time frame
        startTime=cmds.playbackOptions(query=True, minTime=True)
        endTime=cmds.playbackOptions(query=True, maxTime=True)

        for i in range(0, 100 ):
            objName='H2O' + str(i+1);
            if i % 3 == 0:
                self._keyRot(objName, startTime, endTime, 'rotateX')
            elif i % 3 == 1:
                self._keyRot(objName, startTime, endTime, 'rotateY')
            else:
                self._keyRot(objName, startTime, endTime, 'rotateZ')
Ejemplo n.º 9
0
    def _handleMove(self):
        cmds.playbackOptions(max=24, aet=24)
        cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=1)
        cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')+2), t=6)
        cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=12)
        cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')-2), t=18)
        cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=24)

        cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=1)
        cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')-2), t=6)
        cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=12)
        cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')+2), t=18)
        cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=24)

        cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=1)
        cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')+2), t=6)
        cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=12)
        cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')-2), t=18)
        cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=24)

        cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=1)
        cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')-2), t=6)
        cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=12)
        cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')+2), t=18)
        cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=24)

        cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=1)
        cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')-2), t=6)
        cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=12)
        cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')+2), t=18)
        cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=24)

        cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=1)
        cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')+2), t=6)
        cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=12)
        cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')-2), t=18)
        cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=24)

        cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=1)
        cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')-2), t=6)
        cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=12)
        cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')+2), t=18)
        cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=24)

        cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=1)
        cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')+2), t=6)
        cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=12)
        cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')-2), t=18)
        cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=24)
Ejemplo n.º 10
0
 def _handleScene1Button(self):
     self._helpScene1('scene1')
     #make the camera float randomly
     endTime= cmds.playbackOptions(query=True, maxTime=True)
     timeOffset = (endTime - (-30))//7
     currentTime = -30
     tx = 11.595
     ty = 2.125
     tz = -1.627
     rx = -38.988
     ry = 94.883
     rz = -38.782
     i=0
     for i in range(0, 7):
         #get the new key time
         currentTime = currentTime + timeOffset
         #random rotate + random move
         rR = random.uniform(-10, 10)
         rM = random.uniform(-0.5,0.5)
         self._keySingleAttr('scene1', currentTime, 'translateX', tx + rM)
         self._keySingleAttr('scene1', currentTime, 'translateY', ty + rM)
         self._keySingleAttr('scene1', currentTime, 'translateZ', tz + rM)
         self._keySingleAttr('scene1', currentTime, 'rotateX', rx + rR)
         self._keySingleAttr('scene1', currentTime, 'rotateY', ry + rR)
         self._keySingleAttr('scene1', currentTime, 'rotateZ', rz + rR)
     #after set the scene then enable the button
     self.cn1Btn.setEnabled(True)
Ejemplo n.º 11
0
    def _applyButton(self):
        totalTime = float(self.AnimationTime.text()) * 24
        endTime = cmds.playbackOptions(maxTime=totalTime)
        #translateX = float(self.FromXValue.text())
        translateY = float(self.FromYValue.text())
        #translateZ = float(self.FromZValue.text())

        #toTranslateX = float(self.ToXValue.text())
        toTranslateY = float(self.ToYValue.text())
        #toTranslateZ = float(self.ToZValue.text())

        #if translateX=='' or translateY=='' or translateZ=='' or toTranslateX=='' or toTranslateY=='' or toTranslateZ=='':

        cmds.setKeyframe(created + '1',
                         time=0,
                         attribute='translateY',
                         value=translateY)
        cmds.setKeyframe(created + '2',
                         time=0,
                         attribute='translateY',
                         value=-translateY)

        cmds.setKeyframe(created + '1',
                         time=totalTime,
                         attribute='translateY',
                         value=toTranslateY)
        cmds.setKeyframe(created + '2',
                         time=totalTime,
                         attribute='translateY',
                         value=toTranslateY)
Ejemplo n.º 12
0
    def _handleScene2Button(self):
        #show the view
        self._keyObject('scene2', -100, -70, 'translateX', 23.999, 35.094)
        self._keyObject('scene2', -100, -70, 'translateY', 6.42, 5.82)
        self._keyObject('scene2', -100, -70, 'translateZ', 10.714, 10.026)
        self._keyObject('scene2', -100, -70, 'rotateX', -12.338, -12.338)
        self._keyObject('scene2', -100, -70, 'rotateY', -37, 30.6)
        self._keyObject('scene2', -100, -70, 'rotateZ', 0, 0)
        #give more details about the Y character
        self._keySingleAttr('scene2', -40, 'translateX', 40.515)
        self._keySingleAttr('scene2', -40, 'translateY', 5.257)
        self._keySingleAttr('scene2', -40, 'translateZ', -0.283)
        self._keySingleAttr('scene2', -40, 'rotateX', -15.938)
        self._keySingleAttr('scene2', -40, 'rotateY', 90.2)
        self._keySingleAttr('scene2', -40, 'rotateZ', 0)
        #give the view for throw the ball
        self._keySingleAttr('scene2', -30, 'translateX', 30.439)
        self._keySingleAttr('scene2', -30, 'translateY', 7.061)
        self._keySingleAttr('scene2', -30, 'translateZ', -13.223)
        self._keySingleAttr('scene2', -30, 'rotateX', -20.138)
        self._keySingleAttr('scene2', -30, 'rotateY', 179)
        self._keySingleAttr('scene2', -30, 'rotateZ', 0)

        #give the face
        self._keySingleAttr('scene2', 10, 'translateX', 25.00)
        self._keySingleAttr('scene2', 10, 'translateY', 1.944)
        self._keySingleAttr('scene2', 10, 'translateZ', -0.199)
        self._keySingleAttr('scene2', 10, 'rotateX', 0)
        self._keySingleAttr('scene2', 10, 'rotateY', 270)
        self._keySingleAttr('scene2', 10, 'rotateZ', 0)

        #make the camera float randomly
        endTime= cmds.playbackOptions(query=True, maxTime=True)
        timeOffset = (100 - (10))//15
        currentTime = 10
        tx = 19.701
        #flash effect
        for i in range(0, 15):
            #get the new key time
            currentTime = currentTime + timeOffset
            #random rotate + random move
            if i % 2 == 0:
                self._keySingleAttr('scene2', currentTime, 'translateX', tx + 3)
            else:
                self._keySingleAttr('scene2', currentTime, 'translateX', tx - 3)

        #after set the scene then enable the button

        self._keySingleAttr('scene2', endTime, 'translateX', 25.00)
        self._keySingleAttr('scene2', endTime, 'translateY', 1.944)
        self._keySingleAttr('scene2', endTime, 'translateZ', -0.199)
        self._keySingleAttr('scene2', endTime, 'rotateX', 0)
        self._keySingleAttr('scene2', endTime, 'rotateY', 270)
        self._keySingleAttr('scene2', endTime, 'rotateZ', 0)
        self.cn2Btn.setEnabled(True)
Ejemplo n.º 13
0
    def _handleScene4Button(self):
        startTime = cmds.playbackOptions(query=True, minTime=True)
        endTime= cmds.playbackOptions(query=True, maxTime=True)
        #rotate the whole battle for 360
        i = (endTime - startTime)/4
        self._keyObject('scene4', startTime , startTime + i, 'translateX', -58, 15)
        self._keyObject('scene4', startTime , startTime + i, 'translateZ', 0, 71)
        self._keyObject('scene4', startTime , startTime + i, 'rotateY', -90, 0)

        self._keySingleAttr('scene4', startTime + 2 * i, 'translateX', 95)
        self._keySingleAttr('scene4', startTime + 2 * i, 'translateZ', 0)
        self._keySingleAttr('scene4', startTime + 2 * i, 'rotateY', 90)

        self._keySingleAttr('scene4', startTime + 3 * i, 'translateX', 15)
        self._keySingleAttr('scene4', startTime + 3 * i, 'translateZ', -90)
        self._keySingleAttr('scene4', startTime + 3 * i, 'rotateY', 180)

        self._keySingleAttr('scene4', startTime + 4 * i, 'translateX', -58)
        self._keySingleAttr('scene4', startTime + 4 * i, 'translateZ', 15)
        self._keySingleAttr('scene4', startTime + 4 * i, 'rotateY', 270)

        self.cn4Btn.setEnabled(True)
Ejemplo n.º 14
0
def main(fn, scaleFactor, heightFactor):
    startTime = time.time()
    # set up audio for playback in Maya
    # audioNode = cmds.sound( offset=10, file=filename)
    # gPlayBackSlider = maya.mel.eval( '$tmpVar=$gPlayBackSlider' )
    # cmds.timeControl( gPlayBackS lider, edit=True, sound=audioNode )

    # read audio faile into raw data
    filename = '../../resources/' + fn + '.wav'
    print('FILENAME: ' + filename)

    print "Reading file " + filename + "..."
    rate, data = wav.read(filename)
    lastFrame = int(len(data) / float(rate) * 24)
    cmds.playbackOptions(min='1', max=str(lastFrame))

    print "Creating Scenes..."
    scaleFactor = float(scaleFactor)
    heightFactor = float(heightFactor)
    sphere = bouncingBubble(data.T[0], rate, scaleFactor)
    # scene = BoxScene(data.T[0], rate, 0, int(1e4), (-9, .5, 0))
    scene = BoxOnSphereScene(data.T[0], rate, 0, int(1e4), sphere)

    print "Animating Scenes..."
    scene.animate(scaleFactor, heightFactor)

    # normalize data from -1 to 1
    norms = data / (2.**15)
    print "Length of audio:"
    print str(norms.shape[0] / rate) + ' Seconds'

    elapsed = time.time() - startTime
    if elapsed >= 60:
        min = elapsed // 60
        sec = elapsed % 60
    else:
        min = 0
        sec = elapsed
    print('Elapsed time: ' + str(int(min)) + 'm' + str(int(sec)) + 's')
Ejemplo n.º 15
0
    def _applyButton(self):
        totalTime = float(self.AnimationTime.text())*24
        endTime = cmds.playbackOptions( maxTime=totalTime )
        #translateX = float(self.FromXValue.text())
        translateY = float(self.FromYValue.text())
        #translateZ = float(self.FromZValue.text())

        #toTranslateX = float(self.ToXValue.text())
        toTranslateY = float(self.ToYValue.text())
        #toTranslateZ = float(self.ToZValue.text())

        #if translateX=='' or translateY=='' or translateZ=='' or toTranslateX=='' or toTranslateY=='' or toTranslateZ=='':

        cmds.setKeyframe( created+'1', time=0, attribute='translateY', value=translateY )
        cmds.setKeyframe( created+'2', time=0, attribute='translateY', value=-translateY )

        cmds.setKeyframe( created+'1', time=totalTime, attribute='translateY', value=toTranslateY )
        cmds.setKeyframe( created+'2', time=totalTime, attribute='translateY', value=toTranslateY )
Ejemplo n.º 16
0
    def _handleScene3Button(self):
        #set the ball from z view to x view
        self._keyObject('scene3', -100, 60, 'translateX', 29, 29)
        self._keyObject('scene3', -100, 60, 'translateY', 3, 3)
        self._keyObject('scene3', -100, 60, 'translateZ', 10.11, 10.11)
        self._keyObject('scene3', -100, 60, 'rotateX', 0, 0)
        self._keyObject('scene3', -100, 60, 'rotateY', 0, 0)
        self._keyObject('scene3', -100, 60, 'rotateZ', 0, 0)

        self._keySingleAttr('scene3', 80, 'translateX', 39.84)
        self._keySingleAttr('scene3', 80, 'translateY', 4.2)
        self._keySingleAttr('scene3', 80, 'translateZ', -0.2)
        self._keySingleAttr('scene3', 80, 'rotateX', 0)
        self._keySingleAttr('scene3', 80, 'rotateY', 90)
        self._keySingleAttr('scene3', 80, 'rotateZ', 0)

        self._keySingleAttr('scene3', 135, 'translateX', 5)
        self._keySingleAttr('scene3', 135, 'translateY', 1.9)
        self._keySingleAttr('scene3', 135, 'translateZ', -0.2)
        self._keySingleAttr('scene3', 135, 'rotateX', 0)
        self._keySingleAttr('scene3', 135, 'rotateY', 90)
        self._keySingleAttr('scene3', 135, 'rotateZ', 0)

        self._keySingleAttr('scene3', 140, 'translateX', 2.539)
        self._keySingleAttr('scene3', 140, 'translateY', 1.372)
        self._keySingleAttr('scene3', 140, 'translateZ', 3.569)
        self._keySingleAttr('scene3', 140, 'rotateX', -2.4)
        self._keySingleAttr('scene3', 140, 'rotateY', -4)
        self._keySingleAttr('scene3', 140, 'rotateZ', 0)
        #set the keyframe from 140 to the end
        endTime= cmds.playbackOptions(query=True, maxTime=True)
        self._keySingleAttr('scene3', 200, 'translateX', 17)
        self._keySingleAttr('scene3', 270, 'translateX', 25)
        self._keySingleAttr('scene3', endTime, 'translateX', 30)
        #after set the scene then enable the button
        self.cn3Btn.setEnabled(True)
Ejemplo n.º 17
0
    def _handleExampleButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """

        random.seed(1234)

        #check
        sphereList = cmds.ls('hydrogen1', 'hydrogen2', 'oxygen', 'H2O')

        if len(sphereList) > 0:
            cmds.delete(sphereList)

        #create 2 hydrogen and oxygen
        h1 = cmds.polySphere(r=12.0, name='hydrogen1')
        h2 = cmds.polySphere(r=12.0, name='hydrogen2')
        oxygen = cmds.polySphere(r=15.0, name='oxygen')

        #move
        cmds.move(-15, 0, 0, h1)
        cmds.move(15, 0, 0, h2)
        cmds.xform(h1, piv=[0, 0, 0], ws=True)
        cmds.xform(h2, piv=[0, 0, 0], ws=True)
        cmds.rotate(0, '75', 0, h1)

        #group hydrogen and oxygen together
        H2O = cmds.group(empty=True, name='H2O#')
        cmds.parent('hydrogen1', 'hydrogen2', 'oxygen', 'H2O1')

        #add color
        def createMaterial(name, color, type):
            cmds.sets(renderable=True,
                      noSurfaceShader=True,
                      empty=True,
                      name=name + 'SG')
            cmds.shadingNode(type, asShader=True, name=name)
            cmds.setAttr(name + '.color',
                         color[0],
                         color[1],
                         color[2],
                         type='double3')
            cmds.connectAttr(name + '.outColor', name + 'SG.surfaceShader')

        def assignMaterial(name, object):
            cmds.sets(object, edit=True, forceElement=name + 'SG')

        def assignNewMaterial(name, color, type, object):
            createMaterial(name, color, type)
            assignMaterial(name, object)

        #H is white and O is red
        assignNewMaterial('Red', (1, 0, 0), 'lambert', 'oxygen')
        assignNewMaterial('White', (1, 1, 1), 'lambert', 'hydrogen1')
        assignMaterial('White', 'hydrogen2')

        #key frame
        def keyFullRotation(pObjectName, pStartTime, pEndTime,
                            pTargetAttribute, pValueStart, pvalueEnd):
            keyt = (pStartTime[0], pStartTime[0])
            cmds.cutKey(pObjectName,
                        time=(keyt, keyt),
                        attribute=pTargetAttribute)
            cmds.setKeyframe(pObjectName,
                             time=pStartTime,
                             attribute=pTargetAttribute,
                             value=pValueStart)
            cmds.setKeyframe(pObjectName,
                             time=pEndTime,
                             attribute=pTargetAttribute,
                             value=pvalueEnd)
            #cmds.selectKey( pObjectName, time=(pStartTime, [pEndTime]), attribute=pTargetAttribute, keyframe=True )

        #duplicate H2O
        for i in range(1, 52):
            cmds.duplicate(H2O)
            #get random coord
            x = random.uniform(-200, 200)
            y = random.uniform(0, 300)
            z = random.uniform(-200, 200)

            cmds.move(x, y, z, H2O)

            xRot = random.uniform(0, 360)
            yRot = random.uniform(0, 360)
            zRot = random.uniform(0, 360)

            cmds.rotate(xRot, yRot, zRot, H2O)

            startTime = cmds.playbackOptions(minTime=1)
            endTime = cmds.playbackOptions(maxTime=30)

            h2o = "H2O" + str(i)

            for y in range(3):
                coordsX = cmds.getAttr(h2o + '.translateX')
                coordsY = cmds.getAttr(h2o + '.translateY')
                coordsZ = cmds.getAttr(h2o + '.translateZ')

                ranStartX = int(random.uniform(0, 15))
                ranStartY = int(random.uniform(0, 15))
                ranStartZ = int(random.uniform(0, 15))

                ranEndX = int(random.uniform(15, 30))
                ranEndY = int(random.uniform(15, 30))
                ranEndZ = int(random.uniform(15, 30))

                x = random.uniform(coordsX - 50, coordsX + 50)
                y = random.uniform(coordsY, coordsY + 50)
                z = random.uniform(coordsZ - 50, coordsZ + 50)
                #print x,y,z

                keyFullRotation(h2o, ranStartZ, 15, 'translateZ', coordsZ, z)
                keyFullRotation(h2o, ranStartX, 15, 'translateX', coordsX, x)
                keyFullRotation(h2o, ranStartY, 15, 'translateY', coordsY, y)

                keyFullRotation(h2o, 15, ranEndZ, 'translateZ', z, coordsZ)
                keyFullRotation(h2o, 15, ranEndX, 'translateX', x, coordsX)
                keyFullRotation(h2o, 15, ranEndY, 'translateY', y, coordsY)

                RcoordsX = cmds.getAttr(h2o + '.rotateX')
                RcoordsY = cmds.getAttr(h2o + '.rotateY')
                RcoordsZ = cmds.getAttr(h2o + '.rotateZ')

                xRot = random.uniform(0, 360)
                yRot = random.uniform(0, 360)
                zRot = random.uniform(0, 360)

                keyFullRotation(h2o, ranStartZ, 15, 'rotateZ', RcoordsZ, zRot)
                keyFullRotation(h2o, ranStartX, 15, 'rotateX', RcoordsX, xRot)
                keyFullRotation(h2o, ranStartY, 15, 'rotateY', RcoordsY, zRot)

                keyFullRotation(h2o, 15, ranEndZ, 'rotateZ', zRot, RcoordsZ)
                keyFullRotation(h2o, 15, ranEndX, 'rotateX', xRot, RcoordsX)
                keyFullRotation(h2o, 15, ranEndY, 'rotateY', zRot, RcoordsY)

        print 'done'
        cmds.delete('H2O52')
Ejemplo n.º 18
0
    def _handleMove(self):
        cmds.playbackOptions(max=24, aet=24)
        cmds.setKeyframe("CTRL_L_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legA.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_L_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legA.translateZ') + 2),
                         t=6)
        cmds.setKeyframe("CTRL_L_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legA.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_L_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legA.translateZ') - 2),
                         t=18)
        cmds.setKeyframe("CTRL_L_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legA.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_L_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legB.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_L_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legB.translateZ') - 2),
                         t=6)
        cmds.setKeyframe("CTRL_L_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legB.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_L_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legB.translateZ') + 2),
                         t=18)
        cmds.setKeyframe("CTRL_L_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legB.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_L_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legC.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_L_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legC.translateZ') + 2),
                         t=6)
        cmds.setKeyframe("CTRL_L_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legC.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_L_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legC.translateZ') - 2),
                         t=18)
        cmds.setKeyframe("CTRL_L_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legC.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_L_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legD.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_L_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legD.translateZ') - 2),
                         t=6)
        cmds.setKeyframe("CTRL_L_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legD.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_L_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legD.translateZ') + 2),
                         t=18)
        cmds.setKeyframe("CTRL_L_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_L_legD.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_R_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legA.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_R_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legA.translateZ') - 2),
                         t=6)
        cmds.setKeyframe("CTRL_R_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legA.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_R_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legA.translateZ') + 2),
                         t=18)
        cmds.setKeyframe("CTRL_R_legA",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legA.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_R_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legB.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_R_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legB.translateZ') + 2),
                         t=6)
        cmds.setKeyframe("CTRL_R_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legB.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_R_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legB.translateZ') - 2),
                         t=18)
        cmds.setKeyframe("CTRL_R_legB",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legB.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_R_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legC.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_R_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legC.translateZ') - 2),
                         t=6)
        cmds.setKeyframe("CTRL_R_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legC.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_R_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legC.translateZ') + 2),
                         t=18)
        cmds.setKeyframe("CTRL_R_legC",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legC.translateZ')),
                         t=24)

        cmds.setKeyframe("CTRL_R_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legD.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_R_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legD.translateZ') + 2),
                         t=6)
        cmds.setKeyframe("CTRL_R_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legD.translateZ')),
                         t=12)
        cmds.setKeyframe("CTRL_R_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legD.translateZ') - 2),
                         t=18)
        cmds.setKeyframe("CTRL_R_legD",
                         at="translateZ",
                         v=float(cmds.getAttr('CTRL_R_legD.translateZ')),
                         t=24)
Ejemplo n.º 19
0
def create_bubbles():
    size = rand(0.01, 0.04)
    cmds.scale(0.1, 0.3, 0.1)
    cmds.move(0, 0.4, 0)
    cube = cmds.polyCube(w=5, d=5, h=4)
    cmds.move(0, 1.5, 0)

    cmds.sets(renderable=True,
              noSurfaceShader=True,
              empty=True,
              name='ph' + 'SG')
    myShader = cmds.shadingNode('phongE', asShader=True, name='ph')

    #cmds.shadingNode('lambert', name= 'ph', asShader= True)
    cmds.setAttr(myShader + '.color', 0, 1, 1, type='double3')
    cmds.setAttr(myShader + '.transparency', 1, 0.6, 0.6, type='double3')
    cmds.select(cube)
    cmds.hyperShade(assign=myShader)

    #cmds.displaySurface(xRay=True)
    #cmds.connectAttr('ph'+'.outColor', 'ph'+'SG.surfaceShader')
    #cmds.sets(cube, edit=True, forceElement='ph'+'SG')
    #cmds.move (0, 2, 0)

    for i in range(20):
        # set playback range

        cmds.playbackOptions(minTime=i + rand(1, 4), maxTime='72')
        bubble = cmds.polySphere(name='bubble' + str(i),
                                 radius=rand(0.2, 0.4))  # create a sphere
        cmds.move(rand(-2, 2), rand(-2, 2), rand(-2, 2))
        cmds.select('bubble' + str(i))
        cmds.lattice(dv=(5, 6, 5), oc=True)
        cmds.select('ffd' + str(i + 1) + 'Lattice.pt[0:3][0:1][2]',
                    'ffd' + str(i + 1) + 'Lattice.pt[4][1][2]',
                    'ffd' + str(i + 1) + 'Lattice.pt[0:4][2:5][2]',
                    r=True)
        cmds.scale(0.33, 0.33, 0.33, relative=True)
        cmds.select('ffd' + str(i + 1) + 'Lattice.pt[0][1][3]',
                    'ffd' + str(i + 1) + 'Lattice.pt[2][3][4]',
                    r=True)
        cmds.move(0, 0, -0.05, relative=True)
        cmds.select('ffd' + str(i + 1) + 'Lattice.pt[2][3][0]')
        cmds.move(0, 0, 0.8, relative=True)
        #cmds.select('bubble'+str(i))

        for time in [1, 15, 30, 45, 60,
                     72]:  # for each frame calculate sub-steps

            #mc.setKeyframe( bubble, attribute='translateX', value=px, t=f )        # set keyframes
            cmds.setKeyframe(bubble,
                             attribute='translateY',
                             value=0.002 * time * i,
                             t=time)
            cmds.setKeyframe(bubble,
                             attribute='scaleX',
                             value=size + 0.001 * time * i,
                             t=time)
            cmds.setKeyframe(bubble,
                             attribute='scaleY',
                             value=size + 0.001 * time * i,
                             t=time)
            cmds.setKeyframe(bubble,
                             attribute='scaleZ',
                             value=size + 0.001 * time * i,
                             t=time)
Ejemplo n.º 20
0
    def _handleExampleButton(self):
        """
        This callback creates a polygonal cylinder in the Maya scene.

        """

        random.seed(1234)

        #check
        sphereList = cmds.ls('hydrogen1','hydrogen2', 'oxygen','H2O')

        if len(sphereList)>0:
            cmds.delete(sphereList)

        #create 2 hydrogen and oxygen
        h1 = cmds.polySphere(r=12.0, name='hydrogen1')
        h2 = cmds.polySphere(r=12.0, name='hydrogen2')
        oxygen = cmds.polySphere(r=15.0, name='oxygen')


        #move
        cmds.move(-15,0,0,h1)
        cmds.move(15,0,0,h2)
        cmds.xform(h1, piv=[0,0,0],ws=True)
        cmds.xform(h2, piv=[0,0,0],ws=True)
        cmds.rotate(0,'75',0,h1)

        #group hydrogen and oxygen together
        H2O = cmds.group(empty=True, name='H2O#')
        cmds.parent('hydrogen1','hydrogen2','oxygen','H2O1')

        #add color
        def createMaterial( name, color, type ):
            cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG' )
            cmds.shadingNode( type, asShader=True, name=name )
            cmds.setAttr( name+'.color', color[0], color[1], color[2], type='double3')
            cmds.connectAttr(name+'.outColor', name+'SG.surfaceShader')

        def assignMaterial (name, object):
            cmds.sets(object, edit=True, forceElement=name+'SG')

        def assignNewMaterial( name, color, type, object):
            createMaterial (name, color, type)
            assignMaterial (name, object)

        #H is white and O is red
        assignNewMaterial('Red', (1,0,0), 'lambert', 'oxygen');
        assignNewMaterial('White',(1,1,1),'lambert', 'hydrogen1');
        assignMaterial('White', 'hydrogen2');

        #key frame
        def keyFullRotation( pObjectName, pStartTime, pEndTime, pTargetAttribute,pValueStart, pvalueEnd ):
            keyt = (pStartTime[0], pStartTime[0])
            cmds.cutKey( pObjectName, time=(keyt, keyt), attribute=pTargetAttribute )
            cmds.setKeyframe( pObjectName, time=pStartTime, attribute=pTargetAttribute, value=pValueStart )
            cmds.setKeyframe( pObjectName, time=pEndTime, attribute=pTargetAttribute, value=pvalueEnd )
            #cmds.selectKey( pObjectName, time=(pStartTime, [pEndTime]), attribute=pTargetAttribute, keyframe=True )

        #duplicate H2O
        for i in range(1,52):
            cmds.duplicate(H2O)
            #get random coord
            x = random.uniform(-200,200)
            y = random.uniform(0,300)
            z = random.uniform(-200,200)

            cmds.move(x,y,z, H2O)


            xRot = random.uniform(0,360)
            yRot = random.uniform(0,360)
            zRot = random.uniform(0,360)

            cmds.rotate(xRot,yRot,zRot,H2O)

            startTime = cmds.playbackOptions(minTime=1 )
            endTime = cmds.playbackOptions( maxTime=30 )

            h2o = "H2O"+str(i)

            for y in range(3):
                coordsX = cmds.getAttr( h2o+'.translateX' )
                coordsY = cmds.getAttr( h2o+'.translateY' )
                coordsZ = cmds.getAttr( h2o+'.translateZ' )

                ranStartX = int(random.uniform(0,15))
                ranStartY = int(random.uniform(0,15))
                ranStartZ = int(random.uniform(0,15))

                ranEndX = int(random.uniform(15,30))
                ranEndY = int(random.uniform(15,30))
                ranEndZ = int(random.uniform(15,30))

                x = random.uniform(coordsX-50,coordsX+50)
                y = random.uniform(coordsY,coordsY+50)
                z = random.uniform(coordsZ-50,coordsZ+50)
                #print x,y,z

                keyFullRotation( h2o, ranStartZ, 15, 'translateZ',coordsZ,z)
                keyFullRotation( h2o, ranStartX, 15, 'translateX', coordsX,x)
                keyFullRotation( h2o, ranStartY, 15, 'translateY', coordsY,y)

                keyFullRotation( h2o, 15, ranEndZ, 'translateZ',z,coordsZ)
                keyFullRotation( h2o, 15, ranEndX, 'translateX', x,coordsX)
                keyFullRotation( h2o, 15, ranEndY, 'translateY', y,coordsY)

                RcoordsX = cmds.getAttr( h2o+'.rotateX' )
                RcoordsY = cmds.getAttr( h2o+'.rotateY' )
                RcoordsZ = cmds.getAttr( h2o+'.rotateZ' )

                xRot = random.uniform(0,360)
                yRot = random.uniform(0,360)
                zRot = random.uniform(0,360)

                keyFullRotation( h2o, ranStartZ, 15, 'rotateZ',RcoordsZ,zRot)
                keyFullRotation( h2o, ranStartX, 15, 'rotateX', RcoordsX,xRot)
                keyFullRotation( h2o, ranStartY, 15, 'rotateY', RcoordsY,zRot)

                keyFullRotation( h2o, 15, ranEndZ, 'rotateZ',zRot,RcoordsZ)
                keyFullRotation( h2o, 15, ranEndX, 'rotateX', xRot,RcoordsX)
                keyFullRotation( h2o, 15, ranEndY, 'rotateY', zRot,RcoordsY)

        print 'done'
        cmds.delete('H2O52')
Ejemplo n.º 21
0
    def _handleCreateH2o(self):
        """

        """
        #Sets the animation end time
        cmds.playbackOptions(max=240, aet=240)

        #this number sets the number of molecules to create
        molecules = 10

        #Creates each atom in the h2o molecule, aligns them properly, then groups them together .
        cmds.polySphere(name="oxygen", r=1.2)
        cmds.polySphere(name="hydrogenA", r=1.06)
        cmds.select("hydrogenA")
        cmds.move(0, -1.3, 0)
        cmds.group('oxygen', 'hydrogenA', n='oxygenHydrogenA')

        cmds.select('hydrogenA')
        cmds.rotate(0, 0, '-52.5', p=(0, 0, 0))

        cmds.polySphere(name="hydrogenB", r=1.06)
        cmds.select("hydrogenB")
        cmds.move(0, -1.3, 0)
        cmds.group('oxygen', 'hydrogenB', n='oxygenHydrogenB')

        cmds.select('hydrogenB')
        cmds.rotate(0, 0, '52.5', p=(0, 0, 0))

        cmds.select('hydrogenA', 'hydrogenB')
        cmds.polyColorPerVertex(rgb=(1, 1, 1), cdo=True)

        cmds.select('oxygen')
        cmds.polyColorPerVertex(rgb=(1, 0, 0), cdo=True)

        cmds.group('oxygenHydrogenB', 'oxygenHydrogenA', n='h2o')

        #duplicates the original molecule
        for i in range(1, molecules):
            cmds.duplicate('h2o')

        #list of planes for movement
        xyz = ['X', 'Y']

        #Sets movement for the original h2o molecule
        cmds.select("h2o")
        plane = random.choice(xyz)
        cmds.setKeyframe('h2o',
                         at='translate' + plane,
                         v=float(cmds.getAttr('h2o.translate' + plane)),
                         t=1)
        cmds.setKeyframe('h2o', at='translate' + plane, v=5, t=240)

        #Iterates through each h2o group and assigns a random position and orientation for each molecule.
        #It also randomly choose a direction for the molecule to move in.
        for i in range(1, molecules):
            #random plane
            plane = random.choice(xyz)
            cmds.select("h2o" + str(i))
            #random position
            cmds.move(random.randrange(-9, 9), random.randrange(-9, 9),
                      random.randrange(-9, 9))
            #random orientation
            cmds.rotate(random.randrange(0, 350), random.randrange(0, 350),
                        random.randrange(0, 350))
            #sets the start and end position for movement
            cmds.setKeyframe(
                'h2o' + str(i),
                at='translate' + plane,
                v=float(cmds.getAttr('h2o' + str(i) + '.translate' + plane)),
                t=1)
            cmds.setKeyframe('h2o' + str(i),
                             at='translate' + plane,
                             v=5,
                             t=240)
            plane = random.choice(xyz)

        #Selects all the h2o molecules
        cmds.select("h2o", add=True)
        for i in range(1, molecules):
            cmds.select("h2o" + str(i))

        #Creates a new animation layer called vibrate and adds all the h2o molecules to it.
        cmds.animLayer('vibrate', aso=True)

        #Sets oscillation for original molecule
        cmds.setKeyframe('h2o',
                         at='translateZ',
                         v=float(cmds.getAttr('h2o.translateZ')),
                         t=1)
        cmds.setKeyframe('h2o',
                         at='translateZ',
                         v=float(cmds.getAttr('h2o.translateZ')) + .2,
                         t=2)
        #cmds.selectKey('h2o', t=(1,2), at="translateZ")
        cmds.selectKey('h2o', at='translateZ')
        cmds.setInfinity(pri='oscillate', poi='oscillate')

        #Sets oscillation for all other molecules
        for i in range(1, molecules):
            cmds.setKeyframe('h2o' + str(i),
                             at='translateZ',
                             v=float(
                                 cmds.getAttr('h2o' + str(i) + '.translateZ')),
                             t=1)
            cmds.setKeyframe(
                'h2o' + str(i),
                at='translateZ',
                v=float(cmds.getAttr('h2o' + str(i) + '.translateZ')) + .2,
                t=2)
            #cmds.selectKey('h2o'+str(i), t=(1,2), at="translateZ")
            cmds.selectKey('h2o' + str(i), at="translateZ")
            cmds.setInfinity(pri='oscillate', poi='oscillate')
Ejemplo n.º 22
0
    def _handleScene5Button(self):
        #from -100 to 40
        self._helpScene1('movieshow')
        self._keySingleAttr('movieshow', 39, 'translateX', 11.595)
        self._keySingleAttr('movieshow', 39, 'translateY', 2.125)
        self._keySingleAttr('movieshow', 39, 'translateZ', -1.627)
        self._keySingleAttr('movieshow', 39, 'rotateX', -38.988)
        self._keySingleAttr('movieshow', 39, 'rotateY', 95.883)
        self._keySingleAttr('movieshow', 39, 'rotateZ', -38.782)
        #make the camera float randomly
        #give the face of Y
        self._keySingleAttr('movieshow', 40, 'translateX', 14.00)
        self._keySingleAttr('movieshow', 40, 'translateY', 1.944)
        self._keySingleAttr('movieshow', 40, 'translateZ', -0.199)
        self._keySingleAttr('movieshow', 40, 'rotateX', 0)
        self._keySingleAttr('movieshow', 40, 'rotateY', 270)
        self._keySingleAttr('movieshow', 40, 'rotateZ', 0)

        timeOffset = (100 - (40))//15
        currentTime = 40
        tx = 14
        #flash
        for i in range(0, 15):
            #get the new key time
            currentTime = currentTime + timeOffset
            #random rotate + random move
            if i % 2 == 0:
                self._keySingleAttr('movieshow', currentTime, 'translateX', tx + 3)
            else:
                self._keySingleAttr('movieshow', currentTime, 'translateX', tx - 3)
            self._keySingleAttr('movieshow', currentTime, 'translateY', 2.5)
            self._keySingleAttr('movieshow', currentTime, 'translateZ', 0.078)
            self._keySingleAttr('movieshow', currentTime, 'rotateX', 0)
            self._keySingleAttr('movieshow', currentTime, 'rotateY', 270)
            self._keySingleAttr('movieshow', currentTime, 'rotateZ', 0)

        self._keySingleAttr('movieshow', 101, 'translateX', 33)
        self._keySingleAttr('movieshow', 101, 'translateY', 5.88)
        self._keySingleAttr('movieshow', 101, 'translateZ', -0.169)
        self._keySingleAttr('movieshow', 101, 'rotateX', -12.6)
        self._keySingleAttr('movieshow', 101, 'rotateY', 450.0)
        self._keySingleAttr('movieshow', 101, 'rotateZ', 0)

        self._keySingleAttr('movieshow', 133, 'translateX', 6.72)
        self._keySingleAttr('movieshow', 133, 'translateY', 2.14)
        self._keySingleAttr('movieshow', 133, 'translateZ', 0.035)
        self._keySingleAttr('movieshow', 133, 'rotateX', -6)
        self._keySingleAttr('movieshow', 133, 'rotateY', 444.0)
        self._keySingleAttr('movieshow', 133, 'rotateZ', 0)

        #body crashed
        self._keyObject('movieshow', 134, 170, 'translateX', -0.416, -1.881)
        self._keyObject('movieshow', 134, 170, 'translateY', 2.094,  2.094)
        self._keyObject('movieshow', 134, 170, 'translateZ', 12.584, 12.584)
        self._keyObject('movieshow', 134, 170, 'rotateX', -0.6, -0.6)
        self._keyObject('movieshow', 134, 170, 'rotateY', 359.0, 359.0)
        self._keyObject('movieshow', 134, 170, 'rotateZ', 0, 0)

        #track the ball
        currentTime = 171
        endTime= cmds.playbackOptions(query=True, maxTime=True)
        self._keyObject('movieshow', currentTime, endTime, 'translateX', 12, 28.183)
        self._keyObject('movieshow', currentTime, endTime, 'translateY', 0.037,  1.36)
        self._keyObject('movieshow', currentTime, endTime, 'translateZ', 14.604, 19.477)
        self._keyObject('movieshow', currentTime, endTime, 'rotateX', 3.6, 3.6)
        self._keyObject('movieshow', currentTime, endTime, 'rotateY', 0, 0)
        self._keyObject('movieshow', currentTime, endTime, 'rotateZ', 0, 0)
        print "go left"
        self.cn5Btn.setEnabled(True)
Ejemplo n.º 23
0
def setUpMolecule():
    #Adjust time slider
    cmds.playbackOptions( minTime='1', maxTime='300', mps=1)

    # Create the oxygen part of the larger bond (cylinder)
    cmds.polyCylinder(n='oxyCylinder', r=1, h=2, sx=20, sy=1, sz=1, ax=(1, 0, 0), rcp=0, cuv=3, ch=1)

    #Set scale for oxyCylinder
    cmds.setAttr("oxyCylinder.translateX", 6)
    cmds.setAttr("oxyCylinder.scaleZ", 2)
    cmds.setAttr("oxyCylinder.scaleX", 2)
    cmds.setAttr("oxyCylinder.scaleY", 2)

    #-------Set up shader and shade cylinder----------
    redShader = cmds.shadingNode('blinn', asShader=True, n='redBlinn')
    cmds.setAttr("redBlinn.color", 0.772, 0, 0, type="double3")

    cmds.select('oxyCylinder')

    cmds.hyperShade(assign=redShader)

    #--------------White Cylinder-------------

    # Create the oxygen part of the larger bond (cylinder)
    cmds.polyCylinder(n='hydroCylinder', r=1, h=2, sx=20, sy=1, sz=1, ax=(1, 0, 0), rcp=0, cuv=3, ch=1)

    #Set scale for oxyCylinder
    cmds.setAttr("hydroCylinder.translateX", 10)
    cmds.setAttr("hydroCylinder.scaleZ", 2)
    cmds.setAttr("hydroCylinder.scaleX", 2)
    cmds.setAttr("hydroCylinder.scaleY", 2)

    #-------Set up shader and shade cylinder----------
    whiteShader = cmds.shadingNode('blinn', asShader=True, n='whiteBlinn')
    cmds.setAttr("whiteBlinn.color", 1, 1, 1, type="double3")

    #Select the cylinder to color
    cmds.select('hydroCylinder')
    # Assign shader
    cmds.hyperShade(assign=whiteShader)

    #----------------------------------------------------------
    #-----------Group two cylinders together as "cylinder"-----
    #----------------------------------------------------------
    cmds.group(em=True, n='cylinder')
    cmds.parent('oxyCylinder', 'cylinder')
    cmds.parent('hydroCylinder', 'cylinder')

    #------------Oxygen-------------

    # Create the Oxygen sphere
    cmds.polySphere(n='oxygen', r=1, sx=20, sy=20, ax=(0, 1, 0), cuv=2, ch=1)

    #Set scale for oxygen
    cmds.setAttr("oxygen.scaleZ", 5)
    cmds.setAttr("oxygen.scaleX", 5)
    cmds.setAttr("oxygen.scaleY", 5)

    #-------Assign shader--------
    cmds.select('oxygen')

    cmds.hyperShade(assign=redShader)

    #------------Hydrogen-------------

    # Create the Hydrogen sphere
    cmds.polySphere(n='hydrogen', r=1, sx=20, sy=20, ax=(0, 1, 0), cuv=2, ch=1)

    #Set scale for oxygen
    cmds.setAttr("hydrogen.translateX", 14)
    cmds.setAttr("hydrogen.scaleZ", 4)
    cmds.setAttr("hydrogen.scaleX", 4)
    cmds.setAttr("hydrogen.scaleY", 4)

    #-------Assign shader--------
    cmds.select('hydrogen')

    cmds.hyperShade(assign=whiteShader)

    #----------------------------------------------------------
    #-----------Group 'cylinder' and hydrogen together as "hydroAssembly"-----
    #----------------------------------------------------------
    cmds.group(em=True, n='hydroAssembly1')
    cmds.parent('cylinder', 'hydroAssembly1')
    cmds.parent('hydrogen', 'hydroAssembly1')

    #----------------------------------------------------------
    #-----------Group into realign group
    #----------------------------------------------------------
    cmds.group(em=True, n='realignGroup1')
    cmds.parent('hydroAssembly1', 'realignGroup1')

    #-------------------------------------------------------------
    #------------Duplicate the assembly--------------------------
    #-------------------------------------------------------------
    cmds.duplicate('realignGroup1', n='realignGroup2')
    cmds.setAttr('realignGroup2.rotateZ', 180)
    cmds.rename('realignGroup2|hydroAssembly1','hydroAssembly2')

    #----------------------------------------------------------
    #-----------Make entire thing a group "molecule"-----
    #----------------------------------------------------------
    cmds.group(em=True, n='molecule')
    cmds.parent('oxygen', 'molecule')
    cmds.parent('realignGroup1', 'molecule')
    cmds.parent('realignGroup2', 'molecule')

    #-------Move entire molecule up-------
    cmds.setAttr("molecule.translateY", 10)
Ejemplo n.º 24
0
 def _handleRotateButton(self):
     dust = cmds.ls("pie_instance*")
     startTime=cmds.playbackOptions(query=True, minTime=True)
     endTime=cmds.playbackOptions(query=True, maxTime=True)
     for obj in dust:
         self._keyRot(obj, startTime, endTime, 'rotateX')
Ejemplo n.º 25
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)
Ejemplo n.º 26
0
    def _handleAttack(self):
        cmds.playbackOptions(max=54, aet=54)
        cmds.setKeyframe("MoveAll",
                         at="translateY",
                         v=float(cmds.getAttr('MoveAll.translateY')),
                         t=1)
        cmds.setKeyframe("MoveAll",
                         at="translateZ",
                         v=float(cmds.getAttr('MoveAll.translateZ')),
                         t=1)
        cmds.setKeyframe("CTRL_innerFangL",
                         at="translateY",
                         v=float(cmds.getAttr('CTRL_innerFangL.translateY')),
                         t=1)
        cmds.setKeyframe("CTRL_innerFangR",
                         at="translateY",
                         v=float(cmds.getAttr('CTRL_innerFangR.translateY')),
                         t=1)
        cmds.setKeyframe("L_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('L_outerFang_JA.rotateZ')),
                         t=1)
        cmds.setKeyframe("R_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('R_outerFang_JA.rotateZ')),
                         t=1)

        cmds.setKeyframe("MoveAll",
                         at="translateY",
                         v=float(cmds.getAttr('MoveAll.translateY')),
                         t=36)
        cmds.setKeyframe("MoveAll",
                         at="translateZ",
                         v=float(cmds.getAttr('MoveAll.translateZ') - 3.5),
                         t=36)
        cmds.setKeyframe(
            "CTRL_innerFangL",
            at="translateY",
            v=float(cmds.getAttr('CTRL_innerFangL.translateY') + 1.5),
            t=36)
        cmds.setKeyframe(
            "CTRL_innerFangR",
            at="translateY",
            v=float(cmds.getAttr('CTRL_innerFangR.translateY') + 1.5),
            t=36)
        cmds.setKeyframe("L_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('L_outerFang_JA.rotateZ') + 45),
                         t=36)
        cmds.setKeyframe("R_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('R_outerFang_JA.rotateZ') + 45),
                         t=36)

        cmds.setKeyframe("MoveAll",
                         at="translateY",
                         v=float(cmds.getAttr('MoveAll.translateY')),
                         t=48)
        cmds.setKeyframe("MoveAll",
                         at="translateZ",
                         v=float(cmds.getAttr('MoveAll.translateZ') - 3.5),
                         t=48)
        cmds.setKeyframe(
            "CTRL_innerFangL",
            at="translateY",
            v=float(cmds.getAttr('CTRL_innerFangL.translateY') + 1.5),
            t=48)
        cmds.setKeyframe(
            "CTRL_innerFangR",
            at="translateY",
            v=float(cmds.getAttr('CTRL_innerFangR.translateY') + 1.5),
            t=48)
        cmds.setKeyframe("L_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('L_outerFang_JA.rotateZ') + 45),
                         t=48)
        cmds.setKeyframe("R_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('R_outerFang_JA.rotateZ') + 45),
                         t=48)

        cmds.setKeyframe("MoveAll",
                         at="translateY",
                         v=float(cmds.getAttr('MoveAll.translateY') - 7),
                         t=54)
        cmds.setKeyframe("MoveAll",
                         at="translateZ",
                         v=float(cmds.getAttr('MoveAll.translateZ') + 5.5),
                         t=54)
        cmds.setKeyframe("CTRL_innerFangL",
                         at="translateY",
                         v=float(cmds.getAttr('CTRL_innerFangL.translateY')),
                         t=54)
        cmds.setKeyframe("CTRL_innerFangR",
                         at="translateY",
                         v=float(cmds.getAttr('CTRL_innerFangR.translateY')),
                         t=54)
        cmds.setKeyframe("L_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('L_outerFang_JA.rotateZ')),
                         t=54)
        cmds.setKeyframe("R_outerFang_JA",
                         at="rotateZ",
                         v=float(cmds.getAttr('R_outerFang_JA.rotateZ')),
                         t=54)