• Immutable Page
  • Info
  • Attachments

TransformAnim

TransformAnim is a simple base class on top of Animation which is esepically created for modifying window matrix transformations on each step

Class Definition

class TransformAnim :
virtual public Animation
{
public:
    TransformAnim (CompWindow *w,
                   WindowEvent curWindowEvent,
                   float duration,
                   const AnimEffect info,
                   const CompRect &icon);
    void init ();
    void step ();
    void updateTransform (GLMatrix &wTransform);
    void updateBB (CompOutput &output);
    bool updateBBUsed () { return true; }
    
protected:
    GLMatrix mTransform;
    
    float mTransformStartProgress;
    float mTransformProgress;
    
    void perspectiveDistortAndResetZ (GLMatrix &transform);
    void applyPerspectiveSkew (CompOutput &output,
                               GLMatrix &transform,
                               Point &center);
    virtual void adjustDuration () {}
    virtual void applyTransform () {}
    virtual Point getCenter ();
    
};

Functions already provided

TransformAnim already overloads updateBB for you, and will calculate screen update regions based on your window's transformation matrix. It also overloads updateTransform and multiplies it by mTransform

Setting up the transformation

When updateTransform is called, it will first call the virtual method applyTransform in your animation. This allows you to modify the mTransform variable in TransformAnim before it is applied, which is a GLMatrix. Note that even though mTransform is saved, it is essentially reset to an identity matrix on each update, so you will need to modify the matrix by the full amount that should be displayed during this animation.

Adjusting the duration of the animation

In some cases you will need to make the animation longer or shorter, in order that your transformation looks good. On ::init () of TransformAnim a virtual method called ::adjustDuration ()} is called, which is a hook to modify the mTotalTime of the animation.

Setting the center of the window

Most animations need to translate to the center of a window in order to do even scaling and rotation. If you need to get this center point, your animation can call ::getCenter (). However your animation can also overload this function to set another center point, to account for existing transformation.

Accounting for full-screen transformation

If you are rotating the window at all, you need to apply screen level perspective to that rotation, otherwise it will look incorrect in the case that the whole screen is transformed while your animation is running. Just call ::perspectiveDistortAndResetZ (&mTransform) on your ::applyTransform

Development/zero-nine/PluginsClasses/Animation/CreatingNewEffects/TransformAnim (last edited 2010-10-17 01:36:05 by 58-7-165-35)