Module IpoCurve
[hide private]
[frames] | no frames]

Source Code for Module IpoCurve

  1  # Blender.IpoCurve module and the IpoCurve PyType object 
  2   
  3  """ 
  4  The Blender.IpoCurve submodule 
  5   
  6  B{New}:  
  7    -  IpoCurves supports the operator [], which accesses the value of  
  8       curves at a given time.  
  9   
 10  This module provides access to the IpoCurve data in Blender.  An Ipo is  
 11  composed of several IpoCurves, and an IpoCurve are composed of several  
 12  BezTriples. 
 13   
 14  @warning: Ipo curves store euler rotations as degrees/10.0 so 180.0 would be 18.0 
 15   
 16  Example:: 
 17    import Blender 
 18    ipo = Blender.Ipo.Get('ObIpo')  # retrieves an Ipo object 
 19    ipo.name = 'ipo1'                 # change the Ipo's name 
 20    icu = ipo[Blender.Ipo.OB_LOCX] # request X Location Ipo curve object 
 21    if icu != None and len(icu.bezierPoints) > 0: # if curve exists and has BezTriple points 
 22       val = icu[2.5]              # get the curve's value at time 2.5 
 23     
 24  @type ExtendTypes: readonly dictionary 
 25  @var ExtendTypes: The available IpoCurve extend types. 
 26      - CONST - curve is constant beyond first and last knots 
 27      - EXTRAP - curve maintains same slope beyond first and last knots 
 28      - CYCLIC - curve values repeat beyond first and last knots 
 29      - CYCLIC_EXTRAP - curve values repeat beyond first and last knots, 
 30      but while retaining continuity 
 31   
 32  @type InterpTypes: readonly dictionary 
 33  @var InterpTypes: The available IpoCurve interpolation types. 
 34      - CONST - curve remains constant from current BezTriple knot 
 35      - LINEAR - curve is linearly interpolated between adjacent knots 
 36      - BEZIER - curve is interpolated by a Bezier curve between adjacent knots 
 37  """ 
 38   
39 -class IpoCurve:
40 """ 41 The IpoCurve object 42 =================== 43 This object gives access to generic data from all Ipo curves objects 44 in Blender. 45 46 Important Notes for Rotation Ipo Curves:\n 47 For the rotation Ipo curves, the y values for points are in units of 10 48 degrees. For example, 45.0 degrees is stored as 4.50 degrees. These are the 49 same numbers you see in the Transform Properties pop-up menu ( NKey ) in 50 the IPO Curve Editor window. Positive rotations are in a counter-clockwise 51 direction, following the standard convention. 52 53 @ivar driver: Status of the driver. 1= object or armature/bone driver, 2= python expression, 0= no driver 54 @type driver: int 55 @ivar driverObject: Object used to drive the Ipo curve. 56 @type driverObject: Blender Object or None 57 @ivar driverBone: Name of the armature bone used to drive the Ipo curve. 58 If empty or None, sets driver type to object, otherwise sets driver type to pose. [0 - 31 chars] 59 @type driverBone: string or None 60 @ivar driverBone2: Name of the second bone used to drive the Ipo curve. 61 Only to be used with ROT_DIFF channel. [0 - 31 chars] 62 @type driverBone2: string or None 63 @ivar driverExpression: Python expression used to drive the Ipo curve. [0 - 127 chars] 64 @type driverExpression: string 65 @ivar sel: The selection state of this curve. 66 @type sel: bool 67 @ivar driverChannel: Object channel used to drive the Ipo curve. 68 Use module constants: IpoCurve.LOC_X, IpoCurve.LOC_Y, IpoCurve.LOC_Z, 69 IpoCurve.ROT_X, IpoCurve.ROT_Y, IpoCurve.ROT_Z, IpoCurve.SIZE_X, 70 IpoCurve.SIZE_Y, IpoCurve.SIZE_Z, IpoCurve.ROT_DIFF (this last one is only for pose type drivers) 71 @type driverChannel: int 72 @ivar name: The IpoCurve data name. 73 @type name: string 74 @ivar bezierPoints: The list of the curve's bezier points. 75 @type bezierPoints: list of BezTriples. 76 @ivar interpolation: The curve's interpolation mode. See L{InterpTypes} for 77 values. 78 @type interpolation: int 79 @ivar extend: The curve's extend mode. See L{ExtendTypes} for values. 80 81 B{Note}: Cyclic Ipo curves never reach the end value. If the first and 82 last bezier points do not have the same y coordinate, the value of the 83 curve when it "cycles" is that of the first point. If a user wants to 84 get the value of the final curve point, read the final point from the 85 curve:: 86 87 ipo = Blender.Object.Get('Cube').ipo 88 icu = ipo['LocX'] 89 endtime,endvalue = icu.bezierPoints[-1].pt 90 @type extend: int 91 """ 92
93 - def __getitem__ (time):
94 """ 95 Returns the value of the curve at a particular time. 96 @type time: float 97 @param time: time (Vertex X) on the curve 98 @rtype: float 99 @return: value (Vertex Y) corresponding to the given time 100 """
101
102 - def __setitem__ (time):
103 """ 104 Sets the value (Vertex Y) of the curve at a particular time. 105 @type time: float 106 @param time: time (Vertex X) on the curve 107 """
108
109 - def setExtrapolation(extendmode):
110 """ 111 Sets the extend mode of the curve (B{deprecated}). B{Note}: new scripts 112 should use the L{extend} attribute instead. 113 @type extendmode: string 114 @param extendmode: the extend mode of the curve. 115 Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation. 116 @rtype: None 117 @return: None 118 """
119
120 - def getExtrapolation():
121 """ 122 Gets the extend mode of the curve (B{deprecated}). B{Note}: new scripts 123 should use the L{extend} attribute instead. 124 @rtype: string 125 @return: the extend mode of the curve. Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation. 126 """
127
128 - def setInterpolation(interpolationtype):
129 """ 130 Sets the interpolation type of the curve (B{deprecated}). B{Note}: 131 new scripts should use the L{interpolation} attribute instead. 132 @type interpolationtype: string 133 @param interpolationtype: the interpolation type of the curve. Can be Constant, Bezier, or Linear. 134 @rtype: None 135 @return: None 136 """
137
138 - def getInterpolation():
139 """ 140 Gets the interpolation type of the curve (B{deprecated}). B{Note}: 141 new scripts should use the L{interpolation} attribute instead. 142 @rtype: string 143 @return: the interpolation type of the curve. Can be Constant, Bezier, or Linear. 144 """
145
146 - def append(point):
147 """ 148 Adds a Bezier point to a IpoCurve. 149 @type point: BezTriple or tuple of 2 floats 150 @param point: Can either be a BezTriple, or the x and y coordinates of 151 the Bezier knot point. 152 @rtype: None 153 @return: None 154 """
155
156 - def addBezier(coordlist):
157 """ 158 Adds a Bezier point to a curve B{deprecated}). B{Note}: new scripts 159 should use L{append} instead. 160 @type coordlist: tuple of (at least) 2 floats 161 @param coordlist: the x and y coordinates of the new Bezier point. 162 @rtype: None 163 @return: None 164 """
165
166 - def delBezier(index):
167 """ 168 Deletes a Bezier point from a curve. 169 @type index: integer 170 @param index: the index of the Bezier point. Negative values index from the end of the list. 171 @rtype: None 172 @return: None 173 """
174
175 - def recalc():
176 """ 177 Recomputes the curve after changes to control points. 178 @rtype: None 179 @return: None 180 """
181
182 - def getName():
183 """ 184 Returns the name of the Ipo curve (B{deprecated}). B{Note}: 185 new scripts should use the L{name} attribute instead. 186 The name can be: 187 1. Camera Ipo: Lens, ClSta, ClEnd, Apert, FDist. 188 2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref, 189 Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu, 190 RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY, 191 OfsZ, SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var, 192 Disp. 193 3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ, 194 dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ, 195 Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFall, Damping, 196 RDamp, Perm. 197 4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaInt. 198 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi, 199 MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ, 200 SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var. 201 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi, 202 MisSta, MisHi, StarR, StarB, StarG, StarDi, StarSi, OfsX, OfsY, OfsZ,i 203 SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var. 204 6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4, 205 MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct, 206 MgOff, MgGain, NBase1, NBase2. 207 7. Curve Ipo: Speed. 208 8. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, QuatX, QuatY, 209 QuatZ, QuatW. 210 9. Sequence Ipo: Fac. 211 10. Constraint Ipo: Inf. 212 213 @rtype: string 214 @return: the name of the Ipo curve. 215 """
216
217 - def getPoints():
218 """ 219 Returns all the points of the IpoCurve (B{deprecated}). 220 B{Note}: new scripts should use the L{bezierPoints} attribute instead. 221 @rtype: list of BezTriples 222 @return: the points of the Ipo curve. 223 """
224
225 - def clean( thresh=0.0000001 ):
226 """ 227 Calls the IPO-curve cleaning function on this IpoCurve. 228 There is no need to recalculate curve manually. 229 @type thresh: float 230 @param thresh: The threshold to used to determine if two values are identical. 231 By default, the IPO-editor tool's value is used. 232 @rtype: None 233 @return: None 234 """
235
236 - def evaluate( time ):
237 """ 238 Compute the value of the Ipo curve at a particular time (B{deprecated}). 239 B{Note}: new scripts should use L{icu[time]<__getitem__>} instead. 240 @type time: float 241 @param time: value along the X axis 242 @rtype: float 243 @return: the Y value of the curve at the given time 244 """
245