~ubuntu-branches/ubuntu/precise/supertuxkart/precise

« back to all changes in this revision

Viewing changes to src/animations/animation_base.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-24 22:36:25 UTC
  • mfrom: (1.1.9 upstream) (6.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110224223625-ygrjfpg92obovuch
Tags: 0.7+dfsg1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  $Id: animation_base.hpp 1681 2008-04-09 13:52:48Z hikerstk $
 
2
//
 
3
//  SuperTuxKart - a fun racing game with go-kart
 
4
//  Copyright (C) 2009  Joerg Henrichs
 
5
//
 
6
//  This program is free software; you can redistribute it and/or
 
7
//  modify it under the terms of the GNU General Public License
 
8
//  as published by the Free Software Foundation; either version 3
 
9
//  of the License, or (at your option) any later version.
 
10
//
 
11
//  This program is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 
 
20
#ifndef HEADER_ANIMATION_BASE_HPP
 
21
#define HEADER_ANIMATION_BASE_HPP
 
22
 
 
23
/**
 
24
 * \defgroup animations
 
25
 */
 
26
 
 
27
#include <vector>
 
28
 
 
29
#include "irrlicht.h"
 
30
using namespace irr;
 
31
 
 
32
#include "tracks/track_object.hpp"
 
33
#include "utils/no_copy.hpp"
 
34
 
 
35
class XMLNode;
 
36
class Ipo;
 
37
 
 
38
/**
 
39
  * \brief A base class for all animations.
 
40
  * \ingroup animations
 
41
  */
 
42
class AnimationBase : public TrackObject, public NoCopy
 
43
{
 
44
private:
 
45
    /** Two types of animations: cyclic ones that play all the time, and
 
46
    *  one time only (which might get triggered more than once). */
 
47
    enum AnimTimeType { ATT_CYCLIC, ATT_CYCLIC_ONCE } m_anim_type;
 
48
 
 
49
    /** True if the animation is currently playing. */
 
50
    bool  m_playing;
 
51
 
 
52
    /** For one time animations: start time. */
 
53
    float m_start;
 
54
 
 
55
    /** For cyclic animations: duration of the cycle. */
 
56
    float m_cycle_length;
 
57
 
 
58
    /** The current time in the cycle of a cyclic animation. */
 
59
    float m_current_time;
 
60
 
 
61
    /** The inital position of this object. */
 
62
    core::vector3df m_initial_xyz;
 
63
 
 
64
    /** The initial rotation of this object. */
 
65
    core::vector3df m_initial_hpr;
 
66
protected:
 
67
    /** All IPOs for this animation. */
 
68
    std::vector<Ipo*> m_all_ipos;
 
69
 
 
70
public:
 
71
                 AnimationBase(const XMLNode &node);
 
72
    virtual     ~AnimationBase();
 
73
    virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr,
 
74
                        core::vector3df *scale);
 
75
    /** This needs to be implemented by the inheriting classes. It is called
 
76
    *  once per frame from the track. */
 
77
    virtual void update(float dt) = 0;
 
78
    void         setInitialTransform(const core::vector3df &xyz, 
 
79
                                     const core::vector3df &hpr);
 
80
    void         reset();
 
81
 
 
82
};   // AnimationBase
 
83
 
 
84
#endif
 
85