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