Package mrv :: Package maya :: Package nt :: Module anim
[hide private]
[frames] | no frames]

Source Code for Module mrv.maya.nt.anim

 1  # -*- coding: utf-8 -*- 
 2  """ Contains implementations of animation specific types and utilities """ 
 3  __docformat__ = "restructuredtext" 
 4   
 5  import base 
 6  import maya.OpenMaya as api 
 7  import maya.OpenMayaAnim as apianim 
 8  import util 
 9   
10  __all__ = ( "AnimCurve", ) 
11 12 -class AnimCurve( base.DependNode ):
13 """Type representing a maya animation cuvrve, fixes existing MFnAnimCurve 14 methods and provides new convenience methods as well""" 15 16 @classmethod
17 - def findAnimation( cls, iter_nodes, asNode=True ):
18 """ 19 :return: list-compatible object containing animation curves attached to 20 the nodes in the given object. 21 :param iter_nodes: MSelection list or list of MObjects or Nodes containing 22 whose animation you would like to retrieve. 23 :param asNode: If True, the animation curves will be wrapped, or 24 MObjects otherwise ( to gain performance )""" 25 selection_list = base.toSelectionList(iter_nodes) 26 anim_plugs = api.MPlugArray() 27 apianim.MAnimUtil.findAnimatedPlugs(selection_list, anim_plugs, False) 28 29 # it will append to this array ! 30 objs = api.MObjectArray() 31 for anim_plug in anim_plugs: 32 apianim.MAnimUtil.findAnimation(anim_plug, objs) 33 # END for each animated plug 34 35 if asNode: 36 return map(base.NodeFromObj, objs) 37 else: 38 return objs
39 # END handle return type 40
41 - def getTangent( self, index, isInTangent ):
42 """ 43 :return: tuple(x,y) tuple containing the x and y positions of the 44 tangent at index: 45 46 * x is the x value of the slope of the tangent in seconds 47 * y is the absolute y value of the slope of the tangent 48 49 :param index: Index of the key for which the tangent x,y value is required 50 :param isInTangent: If true, the in-tangent is returned, else, the out-tangent is returned""" 51 return util.in_two_floats_out_tuple(lambda x, y: self._api_getTangent(index, x, y, isInTangent))
52
53 - def getTangentAsAngle(self, index, isInTangent):
54 """ 55 :return: tuple(MAngle, weight) tuple containing the angle and weight of 56 the tangent. 57 :note: See `getTangent` for all other parameters""" 58 sud = api.MScriptUtil() 59 pd = sud.asDoublePtr() 60 a = api.MAngle() 61 62 self._api_getTangent(index, a, pd, isInTangent) 63 return (a, sud.getDouble(pd))
64