xoreos  0.0.5
animation.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_AURORA_ANIMATION_H
26 #define GRAPHICS_AURORA_ANIMATION_H
27 
28 #include <list>
29 #include <map>
30 
31 #include "src/common/ustring.h"
32 #include "src/common/boundingbox.h"
33 
34 #include "src/graphics/types.h"
37 
39 
40 namespace Common {
41  class SeekableReadStream;
42 }
43 
44 namespace Graphics {
45 
46 namespace Aurora {
47 
48 class AnimNode;
49 
50 class Animation {
51 public:
52  Animation();
53  ~Animation();
54 
56  const Common::UString &getName() const;
57  void setName(Common::UString &name);
58 
60  float getLength() const;
61  void setLength(float length);
62 
63  void setTransTime(float transtime);
64 
66  void update(Model *model, float lastFrame, float nextFrame, const std::vector<ModelNode *> &modelNodeMap);
67 
68  // Nodes
69 
70  void addAnimNode(AnimNode *node);
71 
73  bool hasNode(const Common::UString &node) const;
74 
76  ModelNode *getNode(const Common::UString &node);
78  const ModelNode *getNode(const Common::UString &node) const;
80  const std::list<AnimNode *> &getNodes() const;
81 
82 protected:
83  typedef std::list<AnimNode *> NodeList;
84  typedef std::map<Common::UString, AnimNode *, Common::UString::iless> NodeMap;
85 
88 
90 
92  float _length;
93  float _transtime;
94 
95 private:
96  void interpolatePosition(ModelNode *animNode, ModelNode *target, float time, float scale,
97  bool relative) const;
98  void interpolateOrientation(ModelNode *animNode, ModelNode *target, float time) const;
99 
101  void updateSkinnedModel(Model *model);
102 };
103 
104 } // End of namespace Aurora
105 
106 } // End of namespace Graphics
107 
108 #endif // GRAPHICS_AURORA_ANIMATION_H
Common::UString _name
The model&#39;s name.
Definition: animation.h:91
const Common::UString & getName() const
Get the animation&#39;s name.
Definition: animation.cpp:54
void updateSkinnedModel(Model *model)
Transform vertices for each node of the specified model based on current animation.
Definition: animation.cpp:251
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
void update(Model *model, float lastFrame, float nextFrame, const std::vector< ModelNode *> &modelNodeMap)
Update the model position and orientation.
Definition: animation.cpp:74
void setLength(float length)
Definition: animation.cpp:62
NodeList rootNodes
The nodes in the state without a parent.
Definition: animation.h:89
Basic graphics types.
A container of OpenGL elements.
Basic Aurora graphics types.
void setTransTime(float transtime)
Definition: animation.cpp:70
void interpolatePosition(ModelNode *animNode, ModelNode *target, float time, float scale, bool relative) const
Definition: animation.cpp:148
const std::list< AnimNode * > & getNodes() const
Get all animation nodes.
Definition: animation.cpp:125
ModelNode * getNode(const Common::UString &node)
Get the specified node.
Definition: animation.cpp:109
std::map< Common::UString, AnimNode *, Common::UString::iless > NodeMap
Definition: animation.h:84
A bounding box.
void interpolateOrientation(ModelNode *animNode, ModelNode *target, float time) const
Definition: animation.cpp:198
Unicode string handling.
NodeMap nodeMap
The nodes within the state, indexed by name.
Definition: animation.h:87
float getLength() const
Get the animations length.
Definition: animation.cpp:66
void setName(Common::UString &name)
Definition: animation.cpp:58
bool hasNode(const Common::UString &node) const
Does the specified node exist?
Definition: animation.cpp:105
void addAnimNode(AnimNode *node)
Definition: animation.cpp:100
std::list< AnimNode * > NodeList
Definition: animation.h:83
An object that can be displayed by the graphics manager.
NodeList nodeList
The nodes within the state.
Definition: animation.h:86