当前位置: 首页>>代码示例>>Python>>正文


Python cmds.setKeyframe函数代码示例

本文整理汇总了Python中maya.cmds.setKeyframe函数的典型用法代码示例。如果您正苦于以下问题:Python setKeyframe函数的具体用法?Python setKeyframe怎么用?Python setKeyframe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setKeyframe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: keyFullRotation

def keyFullRotation (pObjectName, pStartTime, pEndTime, pTargetAttribute):
    
     cmds.cutKey (pObjectName, time = (pStartTime, pEndTime), attribute=pTargetAttribute)
     cmds.setKeyframe (pObjectName, time = pStartTime, attribute=pTargetAttribute, value=0)
     cmds.setKeyframe (pObjectName, time = pEndTime, attribute=pTargetAttribute, value=360)
     cmds.selectKey (pObjectName, time = (pStartTime, pEndTime), attribute=pTargetAttribute, keyframe=True)
     cmds.keyTangent (inTangentType='linear', outTangentType='linear')
开发者ID:FranTirado,项目名称:PruebaMaya,代码行数:7,代码来源:#createRotwithUI.py

示例2: buildGhostAnimation

def buildGhostAnimation(*args):
    
    obj = 'ghost_body1'

    # get animation start and end points from ui controls
    animation_start = cmds.intField('animation_start', query=True, value=True)
    animation_end   = cmds.intField('animation_end', query=True, value=True)

    for current_time in range(animation_start, animation_end + 1):
        
        cmds.currentTime(current_time, edit=True)
        locatorPos = cmds.xform('character_locator', q=1, t=True)
        
        x = round(locatorPos[0], 2)
        z = round(locatorPos[2], 2)

        if x % 1 == 0.25 or z % 1 == 0.25:
            cmds.xform(obj, rotation = [0, 11.25, 0])
        elif x % 1 == 0.5 or z % 1 == 0.5:
            cmds.xform(obj, rotation = [0, 22.5, 0])
        elif x % 1 == 0.75 or z % 1 == 0.75:
            cmds.xform(obj, rotation = [0, 33.75, 0])
        elif x % 1 == 0 or z % 1 == 0:
            cmds.xform(obj, rotation = [0, 0, 0])
        else:
            assert False, "Unhandled character position"

        cmds.setKeyframe([obj])
开发者ID:andy-walker,项目名称:pacman-3d,代码行数:28,代码来源:pacTools.py

示例3: insertKeyToAnimLayer

def insertKeyToAnimLayer():
    '''
    inserts key to all animcurves in anim layer, wont key if objects has not been keyed but is in anim layer
    '''
    currentLayer = cmds.treeView ('AnimLayerTabanimLayerEditor', q=True, selectItem=True)
    curves = cmds.animLayer(currentLayer[0], q=True, anc=True)
    cmds.setKeyframe(curves, i=True)
开发者ID:boochos,项目名称:work,代码行数:7,代码来源:characterSet_lib.py

示例4: OnKeyChange

	def OnKeyChange( self, *args ):
		checks  = [ cmds.checkBox( self.cXKey, query = True, value = True ), cmds.checkBox( self.cYKey, query = True, value = True ), cmds.checkBox( self.cZKey, query = True, value = True ) ]
		attribs = [ ".translateX", ".translateY", ".translateZ" ]
		
		# ... se quieren cambios? ...
		sequence  = next( ( seq for seq in self.SequenceInfo if seq.GetNode() == self.ActiveNode ), None )
		frameInfo = sequence.GetFrameInfo( self.ActiveManip.GetFrame() )
		
		# ...
		refreshCurve = False
		frame        = self.ActiveManip.GetFrame() + self.StartFrame
		
		for i in range( 0, 3 ):
			if ( checks[ i ] != frameInfo.HasTranslationKeyAxis( i ) ):
				if ( checks[ i ] ): # ... se crea la key ...
					cmds.setKeyframe( self.ActiveNode + attribs[ i ], insert = True, time = ( frame, frame ) )
					frameInfo.SetTranslationKey( i )
				else: # ... se borra la key ...
					#cmds.selectKey( self.ActiveNode + attribs[ i ], add = True, keyframe = True, time = ( frame, frame ) )
					cmds.cutKey( self.ActiveNode + attribs[ i ], time = ( frame, frame ), option = "keys" )
					frameInfo.RemoveTranslationKey( i )
					
				refreshCurve = True
				
		# ...
		if ( refreshCurve ):
			self.CreateCurve()
开发者ID:malandrin,项目名称:maya-scripts,代码行数:27,代码来源:MTRuntimeKeyTransform.py

示例5: updateRot

def updateRot(indAnt, vel, curTri, newTri, comPos, nextLeft, extForceFrame):
    """Update the rotation of the character
    
    """
    if np.linalg.norm(extForceFrame) != 0:
        diff = np.average(newTri, axis=0) - np.average(curTri, axis=0)
    else:
        diff = np.average(newTri, axis=0) - comPos
    velNorm = np.linalg.norm(vel)
    diffNorm = np.linalg.norm(diff)
    newVel = velNorm*diff/diffNorm
    # normal is normalised
    triN = triangleNorm(curTri, nextLeft)
    velOnNormal = np.dot(newVel, triN)*triN
    velOnTri = newVel - velOnNormal    
    # scale matrix for the ant model
    scaleMatrix = np.matrix([[0.4, 0, 0, 0], 
                             [0, 0.4, 0, 0], 
                             [0, 0, 0.4, 0], 
                             [0, 0, 0, 1]])    
    rotMat = up.constructRotMat(triN, velOnTri, full=True)
    mat = np.asarray(rotMat*scaleMatrix).flatten()
    cmds.xform("antRig"+str(indAnt), m=mat)
    cmds.setKeyframe('antRig'+str(indAnt), at='rotate')   
    return newVel
开发者ID:shihuiguo,项目名称:pythant,代码行数:25,代码来源:triangleNew.py

示例6: constructNode

	def constructNode( self, timeOffset=0 ):
		'''
		constructs an animCurve node using the data stored on the instance

		returns the node created
		'''
		animCurveNode = createNode( self[ self.CURVE_TYPE ] )

		#massage the time values
		times = [ t+timeOffset for t in self[ self.TIME ] ]
		values = self[ self.VALUE ]
		maxIdxVal = len( values ) - 1

		setKeyframe = cmd.setKeyframe
		for time, value in zip( times, values ):
			setKeyframe( animCurveNode, t=time, v=value )

		#set key data
		setAttr( '%s.wgt' % animCurveNode, self[ self.WEIGHTED ] )
		setAttr( '%s.pre' % animCurveNode, self[ self.PRE_INF ] )
		setAttr( '%s.pst' % animCurveNode, self[ self.POST_INF ] )

		setAttr( '%s.keyBreakdown[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.BREAKDOWN ] )
		setAttr( '%s.keyTanLocked[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.TAN_LOCK ] )
		setAttr( '%s.keyWeightLocked[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.WEIGHT_LOCK ] )

		setAttr( '%s.kix[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.ITX ] )
		setAttr( '%s.kiy[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.ITY ] )
		setAttr( '%s.kox[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.OTX ] )
		setAttr( '%s.koy[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.OTY ] )

		setAttr( '%s.kit[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.ITT ] )
		setAttr( '%s.kot[0:%d]' % (animCurveNode, maxIdxVal), *self[ self.OTT ] )

		return animCurveNode
开发者ID:zethwillie,项目名称:zbw_python_tools,代码行数:35,代码来源:animClip.py

示例7: BezierInterpolate

def BezierInterpolate(curveName):
    rawKeyCount = mc.keyframe(curveName, query=True, keyframeCount=True)
    keyframes = mc.keyframe(curveName, query=True, timeChange=True, valueChange=True)
    
    if rawKeyCount < 4:
        print "Not enough control points, key count = " + str(rawKeyCount) + ", must have at least 4"
        return;
    
    keyCount = ((rawKeyCount - 4) // 3) * 3 + 4;
    curveCount = 1 + ((keyCount - 4) // 3);
    
    basisMatrix = matrix4x4([-1, 3, -3, 1, 3, -6, 3, 0, -3, 3, 0, 0, 1, 0, 0, 0])
    
    for index in range(curveCount):
        p1KeyArrayIndex = 2 * (index * 3);
        p2KeyArrayIndex = 2 * (index * 3 + 1);
        p3KeyArrayIndex = 2 * (index * 3 + 2);
        p4KeyArrayIndex = 2 * (index * 3 + 3);
        p1 = vector2(keyframes[p1KeyArrayIndex], keyframes[p1KeyArrayIndex + 1]);
        p2 = vector2(keyframes[p2KeyArrayIndex], keyframes[p2KeyArrayIndex + 1]);
        p3 = vector2(keyframes[p3KeyArrayIndex], keyframes[p3KeyArrayIndex + 1]);
        p4 = vector2(keyframes[p4KeyArrayIndex], keyframes[p4KeyArrayIndex + 1]);

        startTime = int(keyframes[p1KeyArrayIndex])
        endTime = int(keyframes[p4KeyArrayIndex])
        timeSteps = abs(endTime - startTime)
        
        for t in range(timeSteps + 1):
            time = float(t) / timeSteps
            timeVector = matrix1x4([time ** 3, time ** 2, time, 1]);
            inputPointsVector = matrix4x1([p1, p2, p3, p4]);
            
            output = timeVector * basisMatrix * inputPointsVector;
            mc.setKeyframe(curveName, time=output.x, value=output.y)
开发者ID:ddias3,项目名称:ddias3ComputerAnimationProjects,代码行数:34,代码来源:InterpolationCurves.py

示例8: setKeyByData

def setKeyByData(namespace, data):
    #- data format not right..
    if not isinstance(data, dict):
        return
    
    #- data is empty..
    if len(data) == 0:
        return
    
    #- object not exists..
    obj = getObjectReferencedName(namespace, data.get('object', '"'))
    if not mc.objExists(obj):
        return
    
    #- reading data..
    for attr, keydata in data.get('keyData', dict()).iteritems():
        #- testing attribute..
        
        #- key it
        for tm_V, va_V, ia_V, iw_V, oa_V, ow_V in keydata:
            #- set key
            mc.setKeyframe(obj, at=attr, t=tm_V, v=va_V)
            #- fix curve
            mc.keyTangent('%s.%s'%(obj, attr), l=False)
            mc.keyTangent(obj, e=True, at=attr, a=True, t=(tm_V, tm_V), ia=ia_V, iw=iw_V, oa=oa_V, ow=ow_V)
            mc.keyTangent('%s.%s'%(obj, attr), l=True)
开发者ID:auqeyjf,项目名称:poseLibrary,代码行数:26,代码来源:KeyData.py

示例9: apply

    def apply(self, attr):
        obj = attr.node()
        obj_mel = obj.__melobject__()
        attr_longName = attr.longName()
        attrMel = attr.__melobject__()
        if len(self.times) > 0:
            for time, value in zip(self.times, self.values):
                cmds.setKeyframe(obj_mel, time=time, attribute=attr_longName, value=value,
                     breakdown=False,  # TODO: Approve
                     hierarchy='none',  # TODO: Approve
                     controlPoints=False,  # TODO: Approve
                     shape=False)  # TODO: Approve

            # set tangents
            cmds.keyTangent(attrMel, edit=True, wt=int(self.weightedTangent))  # todo: approve int cast
            for time, inAngle, outAngle, inWeight, outWeight, inTangentType, outTangentType, lock in zip(
                self.times, self.inAngles, self.outAngles, self.inWeights, self.outWeights, self.inTangentTypes, self.outTangentTypes, self.locks):
                fn_keyTangent = functools.partial(cmds.keyTangent, attrMel, edit=True, time=(time, time))
                fn_keyTangent(inAngle=inAngle,
                    outAngle=outAngle,
                    inWeight=inWeight,
                    outWeight=outWeight)
                fn_keyTangent(inTangentType=inTangentType,outTangentType=outTangentType)
                fn_keyTangent(lock=lock) # TODO: Optimise

            # set infinity
            if self.preInfinity != "constant":
                cmds.setInfinity(obj, attribute=attr_longName, preInfinity=self.preInfinity)
            if self.postInfinity != "constant":
                cmds.setInfinity(obj, attribute=attr_longName, postInfinity=self.postInfinity)
        else:
            attr.set(self.value)
开发者ID:Leopardob,项目名称:omtk,代码行数:32,代码来源:cpAnim.py

示例10: cutEarlier

def cutEarlier(selectionOption=1, setKey=True):
    
    keySel = _getKeySelection(selectionOption)
    keySel.fromBeginning()
    if setKey and keySel.findKeyframe('previous', time=(keySel._timeRangeEnd,)) < keySel._timeRangeEnd :
        mc.setKeyframe(keySel.curves, time=keySel._timeRangeEnd)
    keySel.cutKey()
开发者ID:Italic-,项目名称:maya-prefs,代码行数:7,代码来源:ml_animCurveEditor.py

示例11: findSpeeds

def findSpeeds(arg):
    frameRates = {"game": 15, "film": 24, "pal": 25, "ntsc": 30, "show": 48, "palf": 50, "ntscf": 60}

    first_user_frame = cmds.intField(window_UI["first_frame"], query=True, value=True)
    last_user_frame = cmds.intField(window_UI["last_frame"], query=True, value=True)

    start_frame = cmds.playbackOptions(query=True, minTime=True)
    end_frame = cmds.playbackOptions(query=True, maxTime=True)

    if first_user_frame < start_frame or last_user_frame > end_frame:
        return

    current_frame = first_user_frame

    fps = frameRates[cmds.currentUnit(query=True, time=True)]
    timeInterval = 1.0 / fps

    selectedObjects = cmds.ls(selection=True)
    attr = "speed"
    addAttributeToObjects(selectedObjects, attr)

    prevPos = []
    for obj in selectedObjects:
        prevPos.append(cmds.getAttr(obj + ".translate")[0])

    while current_frame < last_user_frame:
        current_frame += 1
        for k in xrange(0, len(selectedObjects)):
            obj = selectedObjects[k]
            currentPos = cmds.getAttr(obj + ".translate", time=current_frame)[0]

            speed = getSpeed(prevPos[k], currentPos, timeInterval)

            cmds.setKeyframe(obj, at="speed", v=speed, t=current_frame)
            prevPos[k] = currentPos
开发者ID:juansc,项目名称:maya_speedometer,代码行数:35,代码来源:speedometer.py

示例12: PasteMirrorPose

def PasteMirrorPose():
    # создаю функцию, которая проверяет значение на '-'
    # и заменяет его на противоположное
    def MirrorChange(value):
        if '-' in value:
            value = value[1:]
        else:
            value = '-' + value
        return value
    
    # задаю префиксы, по которым ориентируюсь, правая или левая сторона
    lPref = 'l_'
    rPref = 'r_'
    
    # paste copied and mirrored keys
    for setAttrib in setAttribList:
        splitKey = setAttrib.split()
        object = splitKey[0]
        attribute = splitKey[1]
        value = splitKey[2]
        # извлекаю префикс из имени объекта
        objPref = object[0:2]
        # задаю условия для зеркального отображения объектов
        if 'rotateY' in attribute:
            value = MirrorChange(value)
        if 'rotateZ' in attribute:
            value = MirrorChange(value)    
        if 'translateX' in attribute:
            value = MirrorChange(value)
        if rPref in objPref:
            object = lPref + object[2:]
        if lPref in objPref:
            object = rPref + object[2:]    
        cmds.setAttr(object + '.' + attribute, float(value))
    cmds.setKeyframe(locList)
开发者ID:AndreySibiryakov,项目名称:coding,代码行数:35,代码来源:face_animation_tools.py

示例13: createBurnin

    def createBurnin(self,*args):
        """
        Create the burn-in image plane for the playblast
        """
        #Get play blast camera shape node
        temp = cmds.listRelatives(self.classScopeData['camera'],shapes=True)
        camShape = temp[0]
        
        #Create image plane
        mel.eval('createImportedImagePlane { "%s" }  "%s" "image";'%(camShape,self.classScopeData['image']))
        temp = cmds.listConnections(camShape)
        
        #If other image planes exist, select the last one
        if len(temp) > 1:
            self.imagePlane = temp[len(temp)-1]
        else:
            self.imagePlane = temp[0]
        
        cmds.setAttr('%s.depth'%self.imagePlane,1)

        #Key the burn-ins visibility
        cmds.setKeyframe( self.imagePlane, attribute='alphaGain', 
                          t=( self.classScopeData['startTime'] - 1 ),v=0 )
        cmds.setKeyframe( self.imagePlane, attribute='alphaGain', 
                          t=( self.classScopeData['startTime'] ),v=1 )
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:25,代码来源:BlastMaster.py

示例14: createSlate

 def createSlate(self,*args):
     """
     Create the slate image plane for the playblast
     """
     #Setup image plane
     #Get play blast camera shape node
     temp = cmds.listRelatives(self.classScopeData['camera'],shapes=True)
     camShape = temp[0]
     
     #Create image plane
     mel.eval('createImportedImagePlane { "%s" }  "%s" "image";'%(camShape,self.classScopeData['slate']))
                             
     temp = cmds.listConnections(camShape)
     
     #If other image planes exist, select the last one
     if len(temp) > 1:
         self.slatePlane = temp[len(temp)-1]
     else:
         self.slatePlane = temp[0]
     
     #Key the slates visibility. On for 1 frame.
     cmds.setKeyframe( self.slatePlane, attribute='alphaGain', 
                       t=( self.classScopeData['startTime'] - 1 ),v=1 )
     cmds.setKeyframe( self.slatePlane, attribute='alphaGain', 
                       t=( self.classScopeData['startTime'] ),v=0 )
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:25,代码来源:BlastMaster.py

示例15: animateLegs

def animateLegs(indAnt, feetPos):
    """Animate the legs via Maya keyframe commands
    
    """
    for leg, footPos in zip(legArray, feetPos):                    
        cmds.xform(leg+"IK"+str(indAnt), t=footPos)        
        cmds.setKeyframe(leg+"IK"+str(indAnt),at="translate")
开发者ID:shihuiguo,项目名称:pythant,代码行数:7,代码来源:utils_pythant.py


注:本文中的maya.cmds.setKeyframe函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。