2
""" Contains implementations of animation specific types and utilities """
3
__docformat__ = "restructuredtext"
6
import maya.OpenMaya as api
7
import maya.OpenMayaAnim as apianim
10
__all__ = ( "AnimCurve", )
12
class AnimCurve( base.DependNode ):
13
"""Type representing a maya animation cuvrve, fixes existing MFnAnimCurve
14
methods and provides new convenience methods as well"""
17
def findAnimation( cls, iter_nodes, asNode=True ):
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)
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
36
return map(base.NodeFromObj, objs)
39
# END handle return type
41
def getTangent( self, index, isInTangent ):
43
:return: tuple(x,y) tuple containing the x and y positions of the
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
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))
53
def getTangentAsAngle(self, index, isInTangent):
55
:return: tuple(MAngle, weight) tuple containing the angle and weight of
57
:note: See `getTangent` for all other parameters"""
58
sud = api.MScriptUtil()
59
pd = sud.asDoublePtr()
62
self._api_getTangent(index, a, pd, isInTangent)
63
return (a, sud.getDouble(pd))