-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnimationController.h
More file actions
86 lines (74 loc) · 6.25 KB
/
Copy pathAnimationController.h
File metadata and controls
86 lines (74 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
Copyright (C) 2011-2012 Alican Sekerefe
TeamTwo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TeamTwo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact: projectteamtwo@gmail.com
*/
#ifndef ANIMATIONCONTROLLER_H
#define ANIMATIONCONTROLLER_H
#include "stdafx.h"
//a struct that is used by the AnimationController
//in order to hold details about the animation
typedef struct AnimationInfo
{
AnimationState* state;
AnimationState* idleState;
bool enabled;
double speed;
bool loop;
bool playTillEnd;
bool oneFrame;
bool autoDisable;
}AnimationInfo_t;
/* Animation Controller
*
* This class is responsible for providing a high
* level animation interface using Ogre3D's own
* animation handlers. Updating an animation till
* the last frame and reseting the animation to
* the starting time are the main features of this
* class.
*/
class AnimationController
{
Entity* entity;
std::map<std::string,AnimationInfo_t*> animationMap;
//initializes the animations of given Ogre::Entity object
void initialize();
public:
//takes the given entity and initializes the controller
AnimationController(Entity* entity);
//updates the animation only one frame by considering its speed.
//loop is defined as "true" by default so that if the animation reaches
//to the end, it starts over.
void updateOneFrame(std::string animationName,double speed,bool loop=true);
//enables the given animation on the entity object
void enableAnimation(std::string animationName);
//disables the given animation on the entity object
void disableAnimation(std::string animationName);
//updates all of the specified animations per one frame
//this method must be called at the each frame of the game
void updateAnimations(double updateTime);
//returns the current time position of the animation
double getAnimationTime(std::string animationName);
//returns the max. time position of the animation
double getAnimationLength(std::string animationName);
//plays the animation to the end of the animation length.
//this should be used for continious animations like
//"death" or "jump".
void playTillEnd(std::string animationName,double speed,bool autoDisable=false);
//returns the animation state
AnimationState* getAnimationState(std::string animationName);
//adds an idle animation which going to be used when there are no other
//active animations running
void addIdleAnimation(std::string sourceAnimation,std::string subAnimation);
};
#endif