svn merge -r39781:39792 https://svn.blender.org/svnroot/bf-blender/trunk/blender...
[blender-staging.git] / source / gameengine / Ketsji / BL_ActionManager.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
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 2
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 Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * Contributor(s): Mitchell Stokes.
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 /** \file BL_ActionManager.cpp
26  *  \ingroup ketsji
27  */
28
29 #ifndef __BL_ACTIONMANAGER
30 #define __BL_ACTIONMANAGER
31
32 #include "BL_Action.h"
33
34 #define MAX_ACTION_LAYERS 8
35
36 /**
37  * BL_ActionManager is responsible for handling a KX_GameObject's actions.
38  */
39 class BL_ActionManager
40 {
41 private:
42         BL_Action* m_layers[MAX_ACTION_LAYERS];
43
44 public:
45         BL_ActionManager(class KX_GameObject* obj);
46         ~BL_ActionManager();
47
48         bool PlayAction(const char* name,
49                                         float start,
50                                         float end,
51                                         short layer=0,
52                                         short priority=0,
53                                         float blendin=0.f,
54                                         short play_mode=0,
55                                         float layer_weight=0.f,
56                                         short ipo_flags=0,
57                                         float playback_speed=1.f);
58         /**
59          * Gets the current frame of an action
60          */
61         float GetActionFrame(short layer);
62
63         /**
64          * Sets the current frame of an action
65          */
66         void SetActionFrame(short layer, float frame);
67         
68         /**
69          * Gets the currently running action on the given layer
70          */
71         struct bAction *GetCurrentAction(short layer);
72
73         /**
74          * Sets play mode of the action on the given layer
75          */
76         void SetPlayMode(short layer, short mode);
77
78         /**
79          * Sets the start and end times of the action on the given layer
80          */
81         void SetTimes(short layer, float start, float end);
82
83         /**
84          * Stop playing the action on the given layer
85          */
86         void StopAction(short layer);
87
88         /**
89          * Check if an action has finished playing
90          */
91         bool IsActionDone(short layer);
92
93         /**
94          * Update any running actions
95          */
96         void Update(float);
97
98 #ifdef WITH_CXX_GUARDEDALLOC
99 public:
100         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ActionManager"); }
101         void operator delete( void *mem ) { MEM_freeN(mem); }
102 #endif
103 };
104
105 #endif //BL_ACTIONMANAGER
106