]> git.jsancho.org Git - lugaru.git/blob - Source/Skeleton.h
Cleanup animation loading
[lugaru.git] / Source / Skeleton.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program 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.  
14
15 See the GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21
22 #ifndef _SKELETON_H_
23 #define _SKELETON_H_
24
25 #include "Models.h"
26 #include "Quaternions.h"
27 #include "Constants.h"
28
29
30 /**> HEADER FILES <**/
31 #include "gamegl.h"
32 #include "Quaternions.h"
33 #include "Objects.h"
34 #include "Sprite.h"
35 #include "binio.h"
36
37 class Joint
38 {
39 public:
40         XYZ position;
41         XYZ oldposition;
42         XYZ realoldposition;
43         XYZ velocity;
44         XYZ oldvelocity;
45         XYZ startpos;
46         float blurred;
47         float length;
48         float mass;
49         bool lower;
50         bool hasparent;
51         bool locked;
52         int modelnum;
53         bool visible;
54         Joint* parent;
55         bool sametwist;
56         int label;
57         int hasgun;
58         float delay;
59         XYZ velchange;
60
61         Joint()
62         {
63                 blurred = 0;
64                 length = 0;
65                 mass = 0;
66                 lower = 0;
67                 hasparent = 0;
68                 locked = 0;
69                 modelnum = 0;
70                 visible = 0;
71                 parent = 0;
72                 sametwist = 0;
73                 label = 0;
74                 hasgun = 0;
75                 delay = 0;
76         }
77
78         void DoConstraint();
79 };
80
81 class Muscle
82 {
83 public:
84         int numvertices;
85         int* vertices;
86         int numverticeslow;
87         int* verticeslow;
88         int numverticesclothes;
89         int* verticesclothes;
90         float length;
91         float targetlength;
92         Joint* parent1;
93         Joint* parent2;
94         float maxlength;
95         float minlength;
96         int type;
97         bool visible;
98         void DoConstraint(bool spinny);
99         float rotate1,rotate2,rotate3;
100         float lastrotate1,lastrotate2,lastrotate3;
101         float oldrotate1,oldrotate2,oldrotate3;
102         float newrotate1,newrotate2,newrotate3;
103
104         float strength;
105
106         ~Muscle();
107         Muscle();
108 };
109
110 class Animation
111 {
112 public:
113         int numframes;
114         int height;
115         int attack;
116         int joints;
117         int weapontargetnum;
118
119         XYZ**  position;
120         float** twist;
121         float** twist2;
122         float* speed;
123         bool** onground;
124         XYZ* forward;
125         int* label;
126         XYZ* weapontarget;
127
128
129         XYZ offset;
130
131         Animation();
132
133         ~Animation();
134
135         Animation & operator = (const Animation & ani);
136
137         void Load(const char *fileName, int aheight, int aattack);
138         void Move(XYZ how);
139
140 protected:
141         void deallocate();
142 };
143
144
145 class Skeleton
146 {
147 public:
148         int num_joints;
149         //Joint joints[max_joints];
150         //Joint *joints;
151         Joint* joints;
152
153         int num_muscles;
154         //Muscle muscles[max_muscles];
155         //Muscle *muscles;
156         Muscle* muscles;
157
158         int selected;
159
160         int forwardjoints[3];
161         XYZ forward;
162
163         int id;
164
165         int lowforwardjoints[3];
166         XYZ lowforward;
167
168         XYZ specialforward[5];
169         int jointlabels[max_joints];
170
171         Model model[7];
172         Model modellow;
173         Model modelclothes;
174         int num_models;
175
176         Model drawmodel;
177         Model drawmodellow;
178         Model drawmodelclothes;
179
180         bool clothes;
181         bool spinny;
182
183         GLubyte skinText[512*512*3];
184         int skinsize;
185
186         float checkdelay;
187
188         float longdead;
189         bool broken;
190
191         int free;
192         int oldfree;
193         float freetime;
194         bool freefall;
195
196         void FindForwards();
197         void FindForwardsfirst();
198         float DoConstraints(XYZ *coords,float *scale);
199         void DoGravity(float *scale);
200         void DoBalance();
201         void MusclesSet();
202         void Draw(int muscleview);
203         void AddJoint(float x, float y, float z, int which);
204         void SetJoint(float x, float y, float z, int which, int whichjoint);
205         void DeleteJoint(int whichjoint);
206         void AddMuscle(int attach1,int attach2,float maxlength,float minlength,int type);
207         void DeleteMuscle(int whichmuscle);
208         void FindRotationJoint(int which);
209         void FindRotationJointSameTwist(int which);
210         void FindRotationMuscle(int which, int animation);
211         void Load(const char *fileName,const char *lowfileName,const char *clothesfileName,const char *modelfileName,const char *model2fileName,const char *model3fileName,const char *model4fileName,const char *model5fileNamee,const char *model6fileName,const char *model7fileName,const char *modellowfileName,const char *modelclothesfileName, bool aclothes);
212
213         Skeleton();
214
215         ~Skeleton();
216 };
217
218 #endif