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