1 //  SuperTuxKart - a fun racing game with go-kart
2 //  Copyright (C) 2014-2015  SuperTuxKart Team
3 //
4 //  This program is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU General Public License
6 //  as published by the Free Software Foundation; either version 3
7 //  of the License, or (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 
18 #ifndef HEADER_PROPERTY_ANIMATOR_HPP
19 #define HEADER_PROPERTY_ANIMATOR_HPP
20 
21 #include "utils/no_copy.hpp"
22 #include "utils/ptr_vector.hpp"
23 
24 enum AnimatablePropery
25 {
26     AP_LIGHT_ENERGY,
27     FOG_RANGE,
28     FOG_MAX,
29     FOG_COLOR
30 };
31 
32 class AnimatedProperty : NoCopy
33 {
34     AnimatablePropery m_property;
35     int m_values_count;
36     double* m_values_from;
37     double* m_values_to;
38     double* m_new_values;
39     double m_total_time;
40     double m_remaining_time;
41     void* m_data;
42 
43 public:
44     AnimatedProperty(AnimatablePropery property, int values_count,
45         double* values_from, double* values_to,
46         double duration, void* data);
47 
~AnimatedProperty()48     ~AnimatedProperty()
49     {
50         delete[] m_values_from;
51         delete[] m_values_to;
52         delete[] m_new_values;
53     }
54 
55     bool update(double dt);
56 };
57 
58 
59 class PropertyAnimator
60 {
61     PtrVector<AnimatedProperty> m_properties;
62     static PropertyAnimator* s_instance;
63 public:
64 
65     static PropertyAnimator* get();
66 
67     void add(AnimatedProperty* prop);
68     void update(double dt);
69     void clear();
70 };
71 
72 
73 #endif
74