SuperTuxKart
Loading...
Searching...
No Matches
animation_base.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2009-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_ANIMATION_BASE_HPP
20#define HEADER_ANIMATION_BASE_HPP
21
28#include <vector>
29#include <algorithm>
30
31#include "utils/vec3.hpp"
32
33class Ipo;
34class XMLNode;
35
41{
42private:
45 enum AnimTimeType { ATT_CYCLIC, ATT_CYCLIC_ONCE } m_anim_type;
46
49
52
53 void calculateAnimationDuration();
54
55protected:
57 std::vector<Ipo*> m_all_ipos;
58
61
62 float m_animation_duration;
63
66
67public:
68 AnimationBase(const XMLNode &node);
69 AnimationBase(Ipo *ipo);
70 virtual ~AnimationBase();
71 virtual void update(float dt, Vec3 *xyz=NULL, Vec3 *hpr=NULL,
72 Vec3 *scale=NULL);
73 virtual void getAt(float time, Vec3 *xyz = NULL, Vec3 *hpr = NULL,
74 Vec3 *scale = NULL);
75 virtual void getDerivativeAt(float time, Vec3 *xyz);
80 virtual void update(float dt) {assert(false); };
81 void setInitialTransform(const Vec3 &xyz,
82 const Vec3 &hpr);
83 void reset();
84 // ------------------------------------------------------------------------
86 void setPlaying(bool playing) {m_playing = playing; }
87
88 // ------------------------------------------------------------------------
89 float getAnimationDuration() const { return m_animation_duration; }
90
91}; // AnimationBase
92
93#endif
94
A base class for all animations.
Definition: animation_base.hpp:41
virtual void getAt(float time, Vec3 *xyz=NULL, Vec3 *hpr=NULL, Vec3 *scale=NULL)
Return the time, position and rotation at the specified time.
Definition: animation_base.cpp:138
std::vector< Ipo * > m_all_ipos
All IPOs for this animation.
Definition: animation_base.hpp:57
void reset()
Resets all IPOs for this animation.
Definition: animation_base.cpp:100
float m_current_time
The current time used in the IPOs.
Definition: animation_base.hpp:65
void setInitialTransform(const Vec3 &xyz, const Vec3 &hpr)
Stores the initial transform (in the IPOs actually).
Definition: animation_base.cpp:88
AnimTimeType
Two types of animations: cyclic ones that play all the time, and one time only (which might get trigg...
Definition: animation_base.hpp:45
bool m_playing
True if the animation is currently playing.
Definition: animation_base.hpp:60
void setPlaying(bool playing)
Disables or enables an animation.
Definition: animation_base.hpp:86
virtual void update(float dt)
This needs to be implemented by the inheriting classes.
Definition: animation_base.hpp:80
Vec3 m_initial_hpr
The initial rotation of this object.
Definition: animation_base.hpp:51
virtual void getDerivativeAt(float time, Vec3 *xyz)
Returns the derivative at the specified point.
Definition: animation_base.cpp:156
virtual void update(float dt, Vec3 *xyz=NULL, Vec3 *hpr=NULL, Vec3 *scale=NULL)
Updates the time, position and rotation.
Definition: animation_base.cpp:115
Vec3 m_initial_xyz
The inital position of this object.
Definition: animation_base.hpp:48
A class to manage a single blender IPO curve.
Definition: ipo.hpp:38
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48