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