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