def render(self): if (self.name == "unnamed"): self.name = cmds.polyCube(n='visBox')[0] cmds.xform(sp=[self.posX, -.5, self.posZ], ro=[0, 0, self.theta]) for i in range(len(self.heights)): cmds.setKeyframe(self.name, v=self.heights[i], at='scaleY', t=i * BoxOnSphere.SPHERE_STEP) cmds.setKeyframe(self.name, v=self.positions[i][0], at='translateX', t=i * BoxOnSphere.SPHERE_STEP) cmds.setKeyframe(self.name, v=self.positions[i][1], at='translateY', t=i * BoxOnSphere.SPHERE_STEP) cmds.setKeyframe(self.name, v=self.widths[i], at='scaleX', t=i * BoxOnSphere.SPHERE_STEP) cmds.setKeyframe(self.name, v=self.widths[i], at='scaleZ', t=i * BoxOnSphere.SPHERE_STEP)
def _cameraHandle(self): if self.Front.isChecked(): camera = 'Front' attr = 'translateZ' value1 = 100 value2 = 220 if self.Back.isChecked(): camera = 'Back' attr = 'translateZ' value1 = -100 value2 = -220 if self.Left.isChecked(): camera = 'Left' attr = 'translateX' value1 = 100 value2 = 220 if self.Right.isChecked(): camera = 'Right' attr = 'translateX' value1 = -100 value2 = -220 cmds.lookThru(camera) cmds.setKeyframe(camera, time=0, attribute=attr, value=value1) cmds.setKeyframe(camera, time=24, attribute=attr, value=value2)
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')
def _cameraHandle(self): if self.Front.isChecked(): camera = "Front" attr = "translateZ" value1 = 100 value2 = 220 if self.Back.isChecked(): camera = "Back" attr = "translateZ" value1 = -100 value2 = -220 if self.Left.isChecked(): camera = "Left" attr = "translateX" value1 = 100 value2 = 220 if self.Right.isChecked(): camera = "Right" attr = "translateX" value1 = -100 value2 = -220 cmds.lookThru(camera) cmds.setKeyframe(camera, time=0, attribute=attr, value=value1) cmds.setKeyframe(camera, time=24, attribute=attr, value=value2)
def plieHalf(self, start, end): if (self.gundamIns.currentFeet != "first"): moveFeetFirst(self.gundamIns) self.gundamIns.currentFeet = "first" mc.setKeyframe(self.gundamIns.torso.h_hips, self.gundamIns.leftLeg.h_foot, self.gundamIns.rightLeg.h_foot, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand, t=self.start) mc.select(self.gundamIns.torso.h_hips, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand) currentY = mc.getAttr(".translateY") print((self.start)) mc.move(0, -31, 0, r=True) mc.select(cl=True) #mc.currentTime((end-start)*2/2) mc.setKeyframe(self.gundamIns.torso.h_hips, self.gundamIns.leftLeg.h_foot, self.gundamIns.rightLeg.h_foot, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand, t=self.end) mc.select(self.gundamIns.torso.h_hips, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand) mc.select(cl=True) print(self.end)
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()
def moveFemur(self, xrotate, yrotate, zrotate): femur = self.getGundamFemur() mc.select(femur[0]) mc.rotate(xrotate, yrotate, zrotate) mc.setKeyframe(femur[0], t=self.timel) mc.select(femur[1]) mc.rotate(xrotate, yrotate, zrotate) mc.setKeyframe(femur[1], t=self.timel)
def moveHip(self, xrotate, yrotate, zrotate): hips = self.getGundamHip() mc.select(hips[0]) mc.rotate(-xrotate, yrotate, zrotate) mc.setKeyframe(hips[0], t=self.timel) mc.select(hips[1]) mc.rotate(-xrotate, -yrotate, zrotate) mc.setKeyframe(hips[1], t=self.timel)
def moveFeet(self, xrotate, yrotate, zrotate): feets = self.getGundamFeet() mc.select(feets[0]) mc.rotate(xrotate, yrotate, zrotate) mc.setKeyframe(feets[0], t=self.timel) mc.select(feets[1]) mc.rotate(xrotate, yrotate, zrotate) mc.setKeyframe(feets[1], t=self.timel)
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)
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)
def render(self): if (self.name == "unnamed"): self.name = cmds.polyCube(n='VisBox')[0] cmds.xform(t=(self.posX, self.posY, self.posZ)) for i in range(len(self.heights)): cmds.setKeyframe(self.name, v=self.heights[i], at='scaleY', t=i * Box.FRAME_STEP)
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)
def doSecond(): filePath = "C:/Users/Kyle/Downloads/x_wing/x_wing.mb" cmds.file(filePath, type='mayaBinary', ra=True, mergeNamespacesOnClash=False, namespace='x_wing', i=True ) cmds.select('x_wing:polySurface3') cmds.scale(.1,.1,.1) cmds.move(0,10,10) cmds.setKeyframe(time=1) cmds.move(0,10,-10) cmds.setKeyframe(time=120)
def render(self): if (self.name == "unnamed"): self.name = cmds.polyCube(n='VisBox')[0] cmds.xform(sp=[self.posX, -.5, self.posZ]) cmds.xform(t=[self.posX, self.posY, self.posZ]) for i in range(0, len(self.heights), Box.AVG_WIN): cmds.setKeyframe(self.name, v=self.avg( [x for x in self.heights[i:i + Box.AVG_WIN]]), at='scaleY', t=i)
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)
def jump(self): PlieIk("half", self.start, (self.end - self.start) / 5.0, self.gundamIns) mc.select(self.gundamIns.torso.h_hips) mc.move(0, 120, 0, r=True) mc.select(self.gundamIns.rightArm.h_hand) mc.move(0, 120, 0, r=True) mc.select(self.gundamIns.leftArm.h_hand) mc.move(0, 120, 0, r=True) mc.select(self.gundamIns.torso.h_shoulders) mc.move(0, 120, 0, r=True) mc.select(cl=True) #exit(0) mc.select(self.gundamIns.leftLeg.h_foot) mc.move(0, 0, 0, r=True) mc.select(cl=True) mc.select(self.gundamIns.rightLeg.h_foot) mc.move(0, 0, -80, r=True) mc.move(0, 50, 0, r=True) mc.move(10, 0, 0, r=True) mc.move(0, 50, 0, r=True) mc.rotate(70, -160, 70) #mc.rotate(0,70,0,r=True) #mc.rotate(0,0,-60,r=True) mc.select(cl=True) mc.setKeyframe(self.gundamIns.torso.h_hips, self.gundamIns.leftLeg.h_foot, self.gundamIns.rightLeg.h_foot, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand, t=(self.end - self.start) / 5.0 + (self.end - self.start) / 2 + 2) mc.select(self.gundamIns.rightLeg.h_foot) mc.rotate(0, -70, 0) mc.move(-8, -100, 90, r=True) mc.select(cl=True) mc.select(self.gundamIns.torso.h_hips, self.gundamIns.leftArm.h_hand, self.gundamIns.rightArm.h_hand, self.gundamIns.torso.h_shoulders) mc.move(0, -124, 0, r=True) mc.setKeyframe(self.gundamIns.torso.h_hips, self.gundamIns.leftLeg.h_foot, self.gundamIns.rightLeg.h_foot, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand, t=(self.end - self.start))
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)
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)
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)
def render(self): if (self.name == "unnamed"): self.name = cmds.polyCube(n='VisDrop')[0] frameStart = max(0, self.frameHit - 3) cmds.xform(t=(self.offset, self.posY + 10, self.posZ)) cmds.setKeyframe(self.name, v=self.posY + 10, at='translateY', t=frameStart * Drop.FRAME_STEP) cmds.setKeyframe(self.name, v=self.posY, at='translateY', t=self.frameHit * Drop.FRAME_STEP)
def _handleBubblesButton(self): """ This callback creates a polygonal sphere in the Maya scene. it then translates it. """ decRange = np.arange(-1,1,.1) decRange2 = np.arange(0,1,.1) r = 2 a = 2.0*r y = (0, 1, 0) # y up #polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1; p = cmd.polyPlane( w=100, h=100, sx=10, sy=10, ax=y, cuv=3, ch=1,n='HotPlate')[0] cmd.select(p) cmd.move(0,2,0,r=True) cmd.setKeyframe() c = cmds.polySphere( r=r, sx=10, sy=10, ax=y, cuv=2, ch=1, n='Bubble')[0] cmds.select(c) cmd.setKeyframe() ''' cmd.setKeyframe() for i in range(1,300,5): x = rand.choice(decRange) y = 5*rand.choice(decRange2) z = rand.choice(decRange) cmd.currentTime(i) cmd.move(x, y, z, r=True) cmd.setKeyframe() ''' randBubbleCount = rand.choice(range(10,300)) #this should be set in the interface for i in range(0,100,1): randX = rand.choice(range(-50,50,1)) randZ = rand.choice(range(-50,50,1)) r = 2 a = 2.0*r yUp = (0, 1, 0) # y up b = cmds.polySphere( r=r, sx=10, sy=10, ax=yUp, cuv=2, ch=1, n='Bubble')[0] cmds.select(b) startTime = rand.choice(range(1, 600, 1)) cmd.currentTime(1) cmd.move(randX, 0, randZ, a=True) cmd.setKeyframe() for j in range(startTime, 600, 2): x = rand.choice(decRange) y = 5*rand.choice(decRange2) z = rand.choice(decRange) cmd.currentTime(j) cmd.move(x, y, z, r=True) cmd.setKeyframe() response = nimble.createRemoteResponse(globals()) response.put('name', c)
def bouncingBubble(amp, sampFreq, scaleFactor): startRadius = 1.0 #2.865 spf = sampFreq / 24 # approximate samples per frame sphere = cmds.polySphere( n='bubble', r=startRadius)[0] # bakes in radius, scale of 1.0 makes radius 2.865 shader = str( cmds.listConnections(cmds.listHistory(sphere, f=1), type='lambert')[0]) print('Created ' + sphere + ' with shader ' + shader) # cmds.xform('column', t = [0,.5,0], sp=[0,-.5,0]) # move scale pivot to bottom of shape frameWin = BoxOnSphere.SPHERE_STEP print('Calculating average amplitude for every ' + str(frameWin) + '-frame (' + str(frameWin / 24.) + ' second) ' + 'window') avgs = averageAmplitude(amp, spf * frameWin) curProg = 1 tenPercent = len(avgs) / 10 # scaleFactor = 10.0 print('Keyframing size translations') for i in range(1, len(avgs)): h = normalize( avgs, i ) * scaleFactor # take away or add + 1 to allow or disallow the sphere to decay infinitely small cmds.setKeyframe(sphere, v=h, at='scaleX', t=(i - 1) * frameWin) cmds.setKeyframe(sphere, v=h, at='scaleY', t=(i - 1) * frameWin) cmds.setKeyframe(sphere, v=h, at='scaleZ', t=(i - 1) * frameWin) if i % tenPercent == 0: if not (curProg == 0 or curProg == 10): sys.stdout.write(str(curProg) + '0%...') curProg += 1 print('100%') frameWin = 10 print('Calculating average amplitude for every ' + str(frameWin) + '-frame (' + str(frameWin / 24.) + ' second) ' + 'window') avgs = averageAmplitude(amp, spf * frameWin) curProg = 1 tenPercent = len(avgs) / 10 print('Keyframing color translations') for i in range(1, len(avgs)): norm = normalize(avgs, i) rgb = colorsys.hsv_to_rgb(norm, 1, min( norm + .2, 1)) # hue and value both vary with amplitude # listConnections returns a list with unicode strings cmds.setAttr(shader + '.color', rgb[0], rgb[1], rgb[2], type='double3') cmds.setKeyframe(shader + '.color', at='color', t=i * frameWin) if i % tenPercent == 0: if not (curProg == 0 or curProg == 10): sys.stdout.write(str(curProg) + '0%...') curProg += 1 print('100%') return sphere
def drawBubble(radius, xpoint, ypoint, zpoint, name, time): """ Arguments: radius is the size of the overall shape Return: None """ y = (0, 1, 0) d = cmds.polyCylinder(r=10, h=20, sx=40, sy=10, sz=1, ax=(0, 0, 0), rcp=0, cuv=2, ch=1, n='CylinderContainer')[0] cmds.move(0, 10, 0) cmds.select(d) response = nimble.createRemoteResponse(globals()) response.put('name', d) c = cmds.polySphere(r=radius, ax=y, cuv=2, ch=1, n=name)[0] xpoint = 0 for i in range(1, time + 1, 3): # figure out best time step cmds.setKeyframe(name, t=i) cmds.move(xpoint, ypoint, zpoint, relative=False) cmds.select(name) response = nimble.createRemoteResponse(globals()) response.put('name', name) xpoint = xpoint + .1 # need to do some physics for theses print(ypoint, i) if ypoint >= 19.5: ypoint = 20 print("pop") break else: ypoint = (.55 + float(ypoint)) zpoint = zpoint + .001 #cmds.setKeyframe( name , at="translateY", t=time, v=xpoint + 3) return None
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 _walkHandle(self): cmds.setKeyframe('Left_leg', time=0, attribute='rotateX', value=47.732) cmds.setKeyframe('Right_leg', time=0, attribute='rotateX', value=-32.235) cmds.setKeyframe('Right_leg', time=12, attribute='rotateX', value=47.732) cmds.setKeyframe('Left_leg', time=12, attribute='rotateX', value=-32.235)
def spawnMolecules(num_molecules): #----------------------Generate X-amount of molecules------------------- setUpMolecule() for i in range(0, num_molecules): #Give each a unique name curName = "molecule" curName = curName+str(i) cmds.duplicate('molecule', n=curName) #---Place in random location cmds.setAttr(curName+".translateX", random.randrange(MAX_DIST)) cmds.setAttr(curName+".translateY", random.randrange(MAX_DIST)) cmds.setAttr(curName+".translateZ", random.randrange(MAX_DIST)) #Random orientation cmds.setAttr(curName+".rotateX", random.randrange(360)) cmds.setAttr(curName+".rotateY", random.randrange(360)) cmds.setAttr(curName+".rotateZ", random.randrange(360)) #Set rotation of legs #These set numbers are arbitrary, but these locations looked good. cmds.setAttr(curName+"|realignGroup1.rotateZ", -39.4)#random.randrange(360)) cmds.setAttr(curName+"|realignGroup2.rotateZ", 217.6)#cmds.getAttr(curName+"|hydroAssembly1.rotateZ")+104) #Get number from 0 to 1. 0=symmetrical 1= asymmetrical stretchType = random.randrange(0,2) #Set up stretching anims based on our assigned type if stretchType == 0: symStretch(curName) else: asymStretch(curName) #Set up bending motion (oscillating animation) bend(curName) #Set some random movement for i in range(1, ANIM_LENGTH): #--------Assign a random animation state---------- #---Move molecule to new location every five frames if i % 5 == 0: curPosX = cmds.getAttr(curName+".translateX") curPosY = cmds.getAttr(curName+".translateY") curPosZ = cmds.getAttr(curName+".translateZ") #Move to random position and keyframe cmds.setKeyframe(curName, at="translateX", t=i, v=curPosX + random.randrange(BROWNIAN_OFFSET)) cmds.setKeyframe(curName, at="translateY", t=i, v=curPosY + random.randrange(BROWNIAN_OFFSET)) cmds.setKeyframe(curName, at="translateZ", t=i, v=curPosZ + random.randrange(BROWNIAN_OFFSET)) #Every five frames, randomly rotate if i % 5 == 0 and i != 0: #Random rotation randNum = random.randrange(3,6) animations[randNum](curName, i, random.randrange(MAX_ROT)) #--_Delete first molecule that we used to duplicate the rest cmds.delete('molecule')
def bend(stringName): keyt = (0, OSC_RATE_ASSEMBLY) curRotation = cmds.getAttr(stringName+"|realignGroup1|hydroAssembly1.rotateZ") cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ", t=0, v=-curRotation) cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ", t=OSC_RATE_ASSEMBLY, v=BEND_SWING) cmds.selectKey(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ") cmds.setInfinity(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup1|hydroAssembly1", itt='plateau') #time=(0, OSC_RATE_ASSEMBLY)) curRotation = cmds.getAttr(stringName+"|realignGroup2|hydroAssembly2.rotateZ") cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ", t=0, v=-curRotation) cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ", t=OSC_RATE_ASSEMBLY, v=-BEND_SWING) cmds.selectKey(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ") cmds.setInfinity(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup2|hydroAssembly2", itt='plateau') #time=(0, OSC_RATE_ASSEMBLY))
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')
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)
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()
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 _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 )
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)
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')
def _handleKeyScream(self): cmds.setKeyframe('blendShape2', attribute='screamHead')
def turns(self,start,end): mc.select(self.gundamIns.rightLeg.h_foot) mc.move(0,44,0,r=True) mc.rotate(137,-70,0,) mc.select(cl=True) mc.select(self.gundamIns.torso.h_hips) mc.move(20,5,0,r=True) mc.select(self.gundamIns.rightArm.h_hand) mc.move(20,5,0,r=True) mc.select(self.gundamIns.leftArm.h_hand) mc.move(20,5,0,r=True) mc.select(self.gundamIns.torso.h_shoulders) mc.move(20,5,0,r=True) mc.select(cl=True) mc.select(self.gundamIns.rightLeg.h_foot) mc.move(0,5,0,r=True) mc.select(cl=True) mc.setKeyframe(self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand, t = (self.start)) mc.select(self.gundamIns.j_root) mc.rotate(0,-45 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*1.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-90 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*2.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-135 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*3.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-180 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*4.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-225 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*5.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-270 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*6.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-315 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*7.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.j_root) mc.rotate(0,-360 ,0) mc.setKeyframe(self.gundamIns.j_root,self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand,t=(self.end - self.start)*8.0/9.0) mc.select(cl=True) mc.select(self.gundamIns.rightLeg.h_foot) mc.move(-20,-44,0,r=True) mc.rotate(0,-70,0,) mc.select(cl=True) mc.select(self.gundamIns.torso.h_hips) mc.move(-20,-5,0,r=True) mc.select(self.gundamIns.rightArm.h_hand) mc.move(-20,-5,0,r=True) mc.select(self.gundamIns.leftArm.h_hand) mc.move(-20,-5,0,r=True) mc.select(self.gundamIns.torso.h_shoulders) mc.move(-20,-5,0,r=True) mc.select(cl=True) mc.select(self.gundamIns.rightLeg.h_foot) mc.move(16,-5,0,r=True) mc.setKeyframe(self.gundamIns.torso.h_hips,self.gundamIns.leftLeg.h_foot,self.gundamIns.rightLeg.h_foot,self.gundamIns.torso.h_shoulders,self.gundamIns.rightArm.h_hand,self.gundamIns.leftArm.h_hand, t = (self.end-self.start)*9.0/9.0) mc.select(cl=True)
def doThird(): filePath3 = "C:/Users/Kyle/Downloads/hangar2.mb" filePath4 = "C:/Users/Kyle/Downloads/tie fighter.mb" cmds.file(filePath3, type='mayaBinary', ra=True, mergeNamespacesOnClash=False, namespace='hangar2', i=True) cmds.select('hangar2:pCube2') cmds.move(0, 2.872, 0) cmds.setKeyframe(time=1) cmds.file(filePath4, type='mayaBinary', ra=True, mergeNamespacesOnClash=False, namespace='tie fighter', i=True) cmds.select('tie_fighter:Tie_Droid:polySurface9') cmds.scale(.25, .25, .25) cmds.move(.8, 5.6, 0) cmds.setKeyframe(time=1) cmds.move(.8, 5.6, 0) cmds.setKeyframe(time=15) cmds.move(.8, 5.6, 0) cmds.setKeyframe(time=30) cmds.move(.8, 3.759, 0) cmds.setKeyframe(time=45) cmds.rotate(0, 40, 0) cmds.setKeyframe(time=65) cmds.move(4.765, 3.759, 3.545) cmds.setKeyframe(time=90) cmds.move(13.514, 3.759, 12.571) cmds.setKeyframe(time=120) cmds.file(filePath4, type='mayaBinary', ra=True, mergeNamespacesOnClash=False, namespace='tie fighter1', i=True) cmds.select('tie_fighter1:Tie_Droid:polySurface9') cmds.scale(.25, .25, .25) cmds.move(-.2, 5.6, 0) cmds.setKeyframe(time=1) cmds.setKeyframe(time=15) cmds.move(-.2, 4.377, 0) cmds.setKeyframe(time=30) cmds.setKeyframe(time=45) time.sleep(1) cmds.rotate(0, 40, 0) time.sleep(1) cmds.setKeyframe(time=65) cmds.move(3.765, 4.377, 3.545) cmds.setKeyframe(time=90) cmds.move(12.514, 4.377, 12.571) cmds.setKeyframe(time=120) time.sleep(1) cmds.file(filePath4, type='mayaBinary', ra=True, mergeNamespacesOnClash=False, namespace='tie fighter2', i=True) cmds.select('tie_fighter2:Tie_Droid:polySurface9') cmds.scale(.25, .25, .25) cmds.move(-1.2, 5.6, 0) cmds.setKeyframe(time=1) cmds.move(-1.2, 3.729, 0) cmds.setKeyframe(time=15) cmds.setKeyframe(time=30) cmds.setKeyframe(time=45) time.sleep(1) cmds.rotate(0, 40, 0) time.sleep(1) cmds.setKeyframe(time=65) cmds.move(2.765, 3.729, 3.545) cmds.setKeyframe(time=90) cmds.move(11.514, 3.729, 12.571) cmds.setKeyframe(time=120) time.sleep(1)
def _handleKeySmile(self): cmds.setKeyframe('blendShape3', attribute='smile')
def asymStretch(stringName): #Keyframe Hydrogen on assembly 2 cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2|hydrogen", at="translateX", t=0, v=HYDRO_OSC_START_POS) cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2|hydrogen", at="translateX", t=OSC_RATE, v=HYDRO_OSC_END_POS) cmds.selectKey(stringName+"|realignGroup2|hydroAssembly2|hydrogen", at="translateX")#, t=['0sec', OSC_RATE+'sec']) cmds.setInfinity(stringName+"|realignGroup2|hydroAssembly2|hydrogen", at="translateX", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup2|hydroAssembly2|hydrogen", itt='plateau')#, time=(0, OSC_RATE)) #Keyframe the cylinder movement on assembly 2 cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2", at="translateX", t=0, v=0) cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2", at="translateX", t=OSC_RATE_ASSEMBLY, v=-1) cmds.selectKey(stringName+"|realignGroup2|hydroAssembly2", at="translateX")#, t=['0sec', OSC_RATE_ASSEMBLY+'sec']) cmds.setInfinity(stringName+"|realignGroup2|hydroAssembly2", at="translateX", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup2|hydroAssembly2", itt='plateau')#, time=(0, OSC_RATE_ASSEMBLY)) #Keyframe the hydrogen on assembly 1 cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1|hydrogen", at="translateX", t=0, v=HYDRO_OSC_END_POS) cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1|hydrogen", at="translateX", t=OSC_RATE, v=HYDRO_OSC_START_POS) cmds.selectKey(stringName+"|realignGroup1|hydroAssembly1|hydrogen", at="translateX")#, t=['0sec', OSC_RATE+'sec']) cmds.setInfinity(stringName+"|realignGroup1|hydroAssembly1|hydrogen", at="translateX", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup1|hydroAssembly1|hydrogen", itt='plateau')#, time=(0, OSC_RATE)) #Keyframe the cylinder movement on assembly 2 cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1", at="translateX", t=0, v=-1) cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1", at="translateX", t=OSC_RATE_ASSEMBLY, v=0) cmds.selectKey(stringName+"|realignGroup1|hydroAssembly1", at="translateX")#, t=['0sec', OSC_RATE_ASSEMBLY+'sec']) cmds.setInfinity(stringName+"|realignGroup1|hydroAssembly1", at="translateX", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup1|hydroAssembly1", itt='plateau')#, time=(0, OSC_RATE_ASSEMBLY))
def _handleKeyEyesUD(self): cmds.setKeyframe('eyeTargets', attribute='translateY')
def _handleKeyCameraPan(self): cmds.setKeyframe("camera1", attribute='translateX')
def _keyRot(self, objName, startTime, endTime, tarAttr): #cmds.cutKey(objName, time=(startTime, endTime), attribute= tarAttr) cmds.setKeyframe(objName, time=startTime, attribute=tarAttr, value=0) cmds.setKeyframe(objName, time=endTime, attribute=tarAttr, value=360) #cmds.selectKey(objName, time=(startTime, endTime), attribute=tarAttr, keyframe=True) cmds.keyTangent(inTangentType='linear', outTangentType='linear')
def _handleKeyCameraDolly(self): cmds.setKeyframe("camera1", attribute='translateX') cmds.setKeyframe("camera1", attribute='translateY') cmds.setKeyframe("camera1", attribute='translateZ')
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)
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)
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)
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')
def _walkHandle(self): cmds.setKeyframe("Left_leg", time=0, attribute="rotateX", value=47.732) cmds.setKeyframe("Right_leg", time=0, attribute="rotateX", value=-32.235) cmds.setKeyframe("Right_leg", time=12, attribute="rotateX", value=47.732) cmds.setKeyframe("Left_leg", time=12, attribute="rotateX", value=-32.235)
def change_height(height): cmds.select('Lego_Group') cmds.setAttr('Lego_Group.ty', height); cmds.setKeyframe(at='translateY')
def _handleKeyBlink(self): cmds.setKeyframe('eyeTargets', attribute='blinkLeft') cmds.setKeyframe('eyeTargets', attribute='blinkRight') cmds.setKeyframe('eyeTargets', attribute='blinkMiddle')
def rotZ(stringName, timeEnd, valEnd): curRotation = cmds.getAttr(stringName+"|realignGroup1|hydroAssembly1.rotateZ") #cmds.setKeyframe(stringName, at="rotateZ", t=timeStart, v=curRotation) cmds.setKeyframe(stringName, at="rotateZ", t=timeEnd, v=valEnd)
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 )