]> git.jsancho.org Git - lugaru.git/blob - Source/Animation/Animation.hpp
clang-format: Apply to all headers
[lugaru.git] / Source / Animation / Animation.hpp
1 /*
2 Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Lugaru 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 Lugaru.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _ANIMATION_HPP_
21 #define _ANIMATION_HPP_
22
23 #include "Math/XYZ.hpp"
24
25 #include <vector>
26
27 enum anim_attack_type
28 {
29     neutral,
30     normalattack,
31     reversed,
32     reversal
33 };
34
35 enum anim_height_type
36 {
37     lowheight,
38     middleheight,
39     highheight
40 };
41
42 enum animation_type
43 {
44 #define DECLARE_ANIM(id, ...) id,
45 #include "Animation.def"
46 #undef DECLARE_ANIM
47     animation_count
48 };
49
50 enum animation_bit_offsets
51 {
52 #define DECLARE_ANIM_BIT(bit) o_##bit,
53 #include "Animation.def"
54 #undef DECLARE_ANIM_BIT
55     animation_bit_count
56 };
57
58 enum animation_bits_def
59 {
60 #define DECLARE_ANIM_BIT(bit) bit = 1 << o_##bit,
61 #include "Animation.def"
62 #undef DECLARE_ANIM_BIT
63 };
64
65 static const int animation_bits[animation_count] = {
66 #define DECLARE_ANIM(id, name, height, type, bits) bits,
67 #include "Animation.def"
68 #undef DECLARE_ANIM
69 };
70
71 struct AnimationFrameJointInfo
72 {
73     XYZ position;
74     float twist;
75     float twist2;
76     bool onground;
77 };
78
79 struct AnimationFrame
80 {
81     void loadBaseInfo(FILE* tfile);
82     void loadTwist2(FILE* tfile);
83     void loadLabel(FILE* tfile);
84     void loadWeaponTarget(FILE* tfile);
85
86     std::vector<AnimationFrameJointInfo> joints;
87     XYZ forward;
88     int label;
89     XYZ weapontarget;
90     float speed;
91 };
92
93 class Animation
94 {
95 public:
96     static std::vector<Animation> animations;
97     static void loadAll();
98
99     anim_height_type height;
100     anim_attack_type attack;
101     int numjoints;
102
103     std::vector<AnimationFrame> frames;
104
105     XYZ offset;
106
107     Animation();
108     Animation(const std::string& fileName, anim_height_type aheight, anim_attack_type aattack);
109 };
110 #endif