]> git.jsancho.org Git - lugaru.git/blob - Source/Skeleton.h
Migrate some definitions from Constants.h
[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 const int max_joints = 50;
146
147 class Skeleton
148 {
149 public:
150         int num_joints;
151         //Joint joints[max_joints];
152         //Joint *joints;
153         Joint* joints;
154
155         int num_muscles;
156         //Muscle muscles[max_muscles];
157         //Muscle *muscles;
158         Muscle* muscles;
159
160         int selected;
161
162         int forwardjoints[3];
163         XYZ forward;
164
165         int id;
166
167         int lowforwardjoints[3];
168         XYZ lowforward;
169
170         XYZ specialforward[5];
171         int jointlabels[max_joints];
172
173         Model model[7];
174         Model modellow;
175         Model modelclothes;
176         int num_models;
177
178         Model drawmodel;
179         Model drawmodellow;
180         Model drawmodelclothes;
181
182         bool clothes;
183         bool spinny;
184
185         GLubyte skinText[512*512*3];
186         int skinsize;
187
188         float checkdelay;
189
190         float longdead;
191         bool broken;
192
193         int free;
194         int oldfree;
195         float freetime;
196         bool freefall;
197
198         void FindForwards();
199         void FindForwardsfirst();
200         float DoConstraints(XYZ *coords,float *scale);
201         void DoGravity(float *scale);
202         void DoBalance();
203         void MusclesSet();
204         void Draw(int muscleview);
205         void AddJoint(float x, float y, float z, int which);
206         void SetJoint(float x, float y, float z, int which, int whichjoint);
207         void DeleteJoint(int whichjoint);
208         void AddMuscle(int attach1,int attach2,float maxlength,float minlength,int type);
209         void DeleteMuscle(int whichmuscle);
210         void FindRotationJoint(int which);
211         void FindRotationJointSameTwist(int which);
212         void FindRotationMuscle(int which, int animation);
213         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);
214
215         Skeleton();
216
217         ~Skeleton();
218 };
219
220 #endif