Skip to content
Snippets Groups Projects
Ipo.py 12.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jacques Guignot's avatar
    Jacques Guignot committed
    # Blender.Ipo module and the Ipo PyType object
    
    """
    The Blender.Ipo submodule
    
    
    Willian Padovani Germano's avatar
    Willian Padovani Germano committed
    B{New}: Ipo updates to both the program and bpython acess.
    
    
    This module provides access to the Ipo Data in Blender. An Ipo is composed of
    several Ipocurves.
    
    A datatype is defined : IpoCurve type. The member functions of this data type
    are given below.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
    
    
    Example::
      import Blender
    
      ob = Blender.Ipo.Get('ipo')    # retrieves an ipo object
    
    Willian Padovani Germano's avatar
     
    Willian Padovani Germano committed
      ob.setName('ipo1')
      print ob.name
      print ipo.getRctf()
      ipo.setRctf(1,2,3,4)
    
    Jacques Guignot's avatar
    Jacques Guignot committed
    """
    
    
    Stephen Swaney's avatar
     
    Stephen Swaney committed
    def New (type, name):
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      """
      Creates a new Ipo.
    
    Stephen Swaney's avatar
     
    Stephen Swaney committed
      @type type: string
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      @type name: string
    
      @param type: The Ipo's blocktype. Depends on the object the ipo will be
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          linked to. Currently supported types are Object, Camera, World,
          Material, Texture, Lamp, Curve, Key.
    
    Stephen Swaney's avatar
     
    Stephen Swaney committed
      @param name: The name for this Ipo.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      @rtype: Blender Ipo
      @return: The created Ipo.
      """
    
    def Get (name = None):
      """
      Get the Ipo from Blender.
      @type name: string
      @param name: The name of the requested Ipo, or nothing.
      @rtype: Blender Ipo or a list of Blender Ipos
      @return: It depends on the 'name' parameter:
          - (name): The Ipo with the given name;
          - ():     A list with all Ipos in the current scene.
      """
    
    class Ipo:
      """
      The Ipo object
      ==============
      This object gives access to generic data from all objects in Blender.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      """
    
      def getName():
        """
    
        Gets the name of the Ipo.
        @rtype: string
        @return: the name of the Ipo.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
        Gets all the IpoCurves of the Ipo.
        @rtype: list of IpoCurves
        @return: A list (possibly void) containing all the IpoCurves associated to the Ipo object.
    
        Return the IpoCurve with the given name. The possible values for
        'curvename' are:
    
          1. Camera Ipo:  Lens, ClSta, ClEnd.
          2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
    
          Alpha, Emit, Amb, Spec, Hard, SpTra, Ang, Mode, HaSize, Translu,
          RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY,
          OfsZ, SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var.
    
          3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
    
          dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
          Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFOff, Damping,
          RDamp, Perm.
          4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaIntl.
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
    
          MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ,
          SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var.
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4,
    
          MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
          MgOff, MgGan, NBase1, NBase2.
          7. Curve Ipo: Speed.
          8. Key Ipo: Speed, 'Key 1' - 'Key 31'.
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ,
    
          QuatX, QuatY, QuatZ, QuatW.
    
    Willian Padovani Germano's avatar
    Willian Padovani Germano committed
          10. Sequence Ipo: Fac.
          11. Constraint Ipo: Inf.
    
        @type curvename : string
        @rtype: IpoCurve object
        @return: the corresponding IpoCurve, or None.
    
        Add a new curve to the IPO object. The possible values for 'curvename' are:
          1. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
             dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
             Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFOff, Damping, RDamp,
             Perm;
          2. Camera Ipo: Lens, ClSta, ClEnd;
          3. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaIntl
          4. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4,
             MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
             MgOff, MgGan, NBase1, NBase2;
          5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
             MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ,
             SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var;
          6. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
             Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
             RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow;
          7. Curve Ipo: Speed;
          8. Key Ipo: Speed, 'Key 1' - 'Key 31'
    
        @type curvename : string
        @rtype: IpoCurve object
        @return: the corresponding IpoCurve, or None.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      def setName(newname):
        """
    
        Sets the name of the Ipo.
        @type newname: string
        @rtype: None
        @return: None
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
      def getBlocktype():
        """
    
        Gets the blocktype of the Ipo.
        @rtype: int
        @return: the blocktype of the Ipo.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      def setBlocktype(newblocktype):
        """
    
        Sets the blocktype of the Ipo.
        @type newblocktype: int 
        @rtype: None
        @return: None
        @warn: 'newblocktype' should not be changed unless you really know what
           you are doing ...
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
      def getRctf():
        """
    
        Gets the rctf of the Ipo.
        Kind of bounding box...
        @rtype: list of floats
        @return: the rctf of the Ipo.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      def setRctf(newrctf):
        """
    
        Sets the rctf of the Ipo.
        @type newrctf: four floats.
        @rtype: None
        @return: None
        @warn: rctf should not be changed unless you really know what you are
           doing ...
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
      def getNcurves():
        """
    
        Gets the number of curves of the Ipo.
        @rtype: int 
        @return: the number of curve of the Ipo.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      def getCurveBP(curvepos):
        """
    
        This method is unsupported.  BPoint Ipo curves are not implemented.
        Calling this method throws a NotImplementedError exception.
        @raise NotImplementedError: this method B{always} raises an exception
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      def getBeztriple(curvepos,pointpos):
        """
    
        Gets a beztriple of the Ipo.
        @type curvepos: int
        @param curvepos: the position of the curve in the ipo
        @type pointpos: int
        @param pointpos: the position of the point in the curve.
        @rtype: list of 9 floats
        @return: the beztriple of the Ipo, or an error is raised.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
    Jacques Guignot's avatar
    Jacques Guignot committed
      def setBeztriple(curvepos,pointpos,newbeztriple):
        """
    
        Sets the beztriple of the Ipo.
        @type curvepos: int
        @param curvepos: the position of the curve in the ipo
        @type pointpos: int
        @param pointpos: the position of the point in the curve.
        @type newbeztriple: list of 9 floats
        @param newbeztriple: the new value for the point
        @rtype: None
        @return: None
        """
        
    
      def getCurveCurval(curvepos):
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
        Gets the current value of a curve of the Ipo.
        @type curvepos: int or string
        @param curvepos: the position of the curve in the ipo or the name of the
            curve
        @rtype: float
        @return: the current value of the selected curve of the Ipo.
    
    Jacques Guignot's avatar
    Jacques Guignot committed
        """
    
        Gets the current value of a curve of the Ipo.
        @type curvepos: int
        @param curvepos: the position of the curve in the ipo
        @type time: float
        @param time: the position of the curve in the ipo
        @rtype: float
        @return: the current value of the selected curve of the Ipo at the given
            time.
    
    
    class IpoCurve:
      """
      The IpoCurve object
      ===================
      This object gives access to generic data from all ipocurves objects in Blender.
    
    
      Important Notes for Rotation Curves:\n
      For the rotation IpoCurves, the y values for points are in units of 10 degrees.  example:  45.0 degrees is stored as 4.50 degrees.  These are the same numbers you see in the Transform Properties pupmenu ( NKey ) in the IPO Curve Editor window.  Positive rotations are in a counter-clockwise direction, just like in math class.
      
    
      @cvar name: The Curve Data name.
      @cvar bezierPoints : The list of the Bezier points.
      """
    
      def setExtrapolation(extrapolationtype):
        """
    
        Sets the extrapolation type  of the curve.
        @type extrapolationtype: string
        @param extrapolationtype: the extrapolatrion type of the curve.
            Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation.
        @rtype: None
        @return: None
    
      def getExtrapolation():
        """
    
        Gets the extrapolation type  of the curve.
        @rtype: string
        @return: the extrapolation type  of the curve.Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation.
    
    
      def setInterpolation(interpolationtype):
        """
    
        Sets the interpolation type  of the curve.
        @type interpolationtype: string
        @param interpolationtype: the interpolatrion type of the curve. Can be Constant, Bezier, or Linear.
        @rtype: None
        @return: None
    
        """
      def getInterpolation():
        """
    
        Gets the interpolation type  of the curve.
        @rtype: string
        @return: the interpolation type  of the curve.Can be Constant, Bezier, or Linear.
    
      def addBezier(coordlist):
        """
    
        Adds a Bezier point to a curve.
        @type coordlist: tuple of (at least) 2 floats
        @param coordlist: the x and y coordinates of the new Bezier point.
        @rtype: None
        @return: None
    
        Recomputes the curent value of the curve.
        @rtype: None
        @return: None
    
        Returns the name of the ipo curve. This name can be:
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          1. Camera Ipo:  Lens, ClSta, ClEnd.
          2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
    
          Alpha, Emit, Amb, Spec, Hard, SpTra, Ang, Mode, HaSize, Translu,
          RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY,
          OfsZ, SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var;
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
    
          dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
          Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFOff, Damping,
          RDamp, Perm;
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaIntl;
          5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
    
          MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ,
          SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var;
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4,
    
          MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
          MgOff, MgGan, NBase1, NBase2;
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          7. Curve Ipo: Speed;
          8. Key Ipo: Speed, 'Key 1' - 'Key 31';
          9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ,
    
          QuatX, QuatY, QuatZ, QuatW;
    
    Ton Roosendaal's avatar
    Ton Roosendaal committed
          10.Sequence Ipo: Fac;
          11.Constraint Ipo: Inf.
    
        Returns all the points of the ipo curve.
        @rtype: list of BezTriples
        @return: the points of the ipo curve.
    
    Stephen Swaney's avatar
    Stephen Swaney committed
      def evaluate( time ):
        """
    
        Compute the value of the IpoCurve at a particular time.
        @type time: float
        @param time: value along the X axis
        @rtype: float
        @return: the Y value of the curve at the given time
    
    Stephen Swaney's avatar
    Stephen Swaney committed
        """
    
    
    
    class BezTriple:
      """
      The BezTriple object
      ====================
    
    Stephen Swaney's avatar
    Stephen Swaney committed
      This object gives access to generic data from all beztriple objects in Blender.  If an attribute is listed as being 'read-only' that means you cannot write to it.  Use the set*() methods instead.
      @cvar pt : a list of the [x,y] coordinates for knot point of this BezTriple.  read-only.
      @cvar vec : a list of the 3 points [ handle, knot, handle ] that comprise a BezTriple.  See the getTriple() method for an example of the format.  read-only.
    
        Returns the xy coordinates of the Bezier knot point.
        @rtype: list of floats
        @return: list of the x and y coordinates of the Bezier point.
    
        Sets the point xy coordinates of the Bezier knot point.
        @type newval: tuple of 2 floats
        @param newval: the x and y coordinates of the new Bezier point.
        @rtype: None
        @return: None
    
    Stephen Swaney's avatar
    Stephen Swaney committed
    
      def getTriple():
    
        """
        Returns the x,y,z coordinates for each of the three points that make up
        a BezierTriple.
    
        The return list looks like this [ [H1x, H1y, H1z], [Px, Py, Pz],
        [H2x, H2y, H2z] ] .
    
        Example::
          # where bt is of type BezierTriple
          #  and h1, p, and h2 are lists of 3 floats
          h1, p, h2 = bt.getTriple()
        
        @rtype: list consisting of 3 lists of 3 floats
        @return: handle1, knot, handle2
        """