]> git.jsancho.org Git - lugaru.git/blob - Source/Animation/Animation.h
91205abe0341400bca884f6f0d1f62fc14f96e26
[lugaru.git] / Source / Animation / Animation.h
1 /*
2 Copyright (C) 2010-2016 - 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_H
21 #define ANIMATION_H
22
23 #include <vector>
24 #include "Math/Quaternions.h"
25
26 enum anim_attack_type {
27     neutral, normalattack, reversed, reversal
28 };
29
30 enum anim_height_type {
31     lowheight, middleheight, highheight
32 };
33
34 enum animation_types {
35 #define DECLARE_ANIM(id, ...) id,
36 #include "Animation.def"
37 #undef DECLARE_ANIM
38     animation_count
39 };
40
41 enum animation_bit_offsets {
42 #define DECLARE_ANIM_BIT(bit) o_##bit,
43 #include "Animation.def"
44 #undef DECLARE_ANIM_BIT
45     animation_bit_count
46 };
47
48 enum animation_bits_def {
49 #define DECLARE_ANIM_BIT(bit) bit = 1 << o_##bit,
50 #include "Animation.def"
51 #undef DECLARE_ANIM_BIT
52 };
53
54 static const int animation_bits[animation_count] = {
55 #define DECLARE_ANIM(id, name, height, type, bits) bits,
56 #include "Animation.def"
57 #undef DECLARE_ANIM
58 };
59
60 struct AnimationFrameJointInfo
61 {
62     XYZ  position;
63     float twist;
64     float twist2;
65     bool onground;
66 };
67
68 struct AnimationFrame
69 {
70     void loadBaseInfo(FILE* tfile);
71     void loadTwist2(FILE* tfile);
72     void loadLabel(FILE* tfile);
73     void loadWeaponTarget(FILE* tfile);
74
75     std::vector<AnimationFrameJointInfo> joints;
76     XYZ forward;
77     int label;
78     XYZ weapontarget;
79     float speed;
80 };
81
82 class Animation
83 {
84 public:
85     static std::vector<Animation> animations;
86     static void loadAll();
87
88     anim_height_type height;
89     anim_attack_type attack;
90     int numjoints;
91
92     std::vector<AnimationFrame> frames;
93
94     XYZ offset;
95
96     Animation();
97     Animation(const std::string& fileName, anim_height_type aheight, anim_attack_type aattack);
98 };
99 #endif