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