/
animgroups.h
143 lines (120 loc) · 3.72 KB
/
animgroups.h
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/** @file animgroups.h Material animation group.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program 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 2 of the License, or (at your
* option) any later version. This program 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, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef DENG_RESOURCE_ANIMATIONGROUP_H
#define DENG_RESOURCE_ANIMATIONGROUP_H
#include "dd_types.h"
#include "TextureManifest"
#include <QList>
namespace de {
/**
* Material Animation group.
*
* @ingroup resource
*/
class AnimGroup
{
public:
/**
* A single frame in the animation.
*/
struct Frame
{
public:
/**
* Returns the texture manifest for the frame.
*/
TextureManifest &textureManifest() const;
/**
* Returns the duration of the frame in tics.
*/
ushort tics() const;
/**
* Returns the additional duration of the frame in tics.
*/
ushort randomTics() const;
friend class AnimGroup;
private:
Frame(TextureManifest &textureManifest, ushort tics, ushort randomTics);
TextureManifest *_textureManifest;
ushort _tics;
ushort _randomTics;
};
typedef QList<Frame *> Frames;
public:
/**
* Construct a new animation group.
*
* @param uniqueId Unique identifier to associate with the group.
* @param flags @ref animationGroupFlags
*/
AnimGroup(int uniqueId, int flags = 0);
/**
* Returns the unique identifier associated with the animation.
*/
int id() const;
/**
* @return @ref animationGroupFlags
*/
int flags() const;
/**
* Returns @c true iff at least one frame in the animation uses the specified
* @a textureManifest
*
* @see frames()
*/
bool hasFrameFor(TextureManifest const &textureManifest) const;
/**
* Append a new frame to the animation.
*
* @param texture Manifest for the texture to use during the frame.
* @param tics Duration of the frame in tics.
* @param randomTics Additional random duration of the frame in tics.
*
* @return The new frame.
*/
Frame &newFrame(TextureManifest &textureManifest, ushort tics,
ushort randomTics = 0);
/**
* Clear all frames in the animation.
*/
void clearAllFrames();
/**
* Returns the total number of frames in the animation.
*/
inline int frameCount() const { return allFrames().count(); }
/**
* Convenient method of returning a frame in the animation by @a index.
* It is assumed that the index is within valid [0..frameCount) range.
*
* @see frameCount()
*/
inline Frame &frame(int index) const { return *allFrames().at(index); }
/**
* Provides access to the frame list for efficient traversal.
*
* @see frame()
*/
Frames const &allFrames() const;
private:
DENG2_PRIVATE(d)
};
typedef AnimGroup::Frame AnimGroupFrame;
} // namespace de
#endif // DENG_RESOURCE_ANIMATIONGROUP_H