]> git.jsancho.org Git - lugaru.git/blob - Source/Skeleton.h
Remove 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
28
29 /**> HEADER FILES <**/
30 #include "gamegl.h"
31 #include "Quaternions.h"
32 #include "Objects.h"
33 #include "Sprite.h"
34 #include "binio.h"
35
36 enum bodyparts {
37   head, neck,
38   leftshoulder,  leftelbow,  leftwrist,  lefthand,
39   rightshoulder, rightelbow, rightwrist, righthand,
40   abdomen, lefthip, righthip, groin,
41   leftknee,  leftankle,  leftfoot,
42   rightknee, rightankle, rightfoot
43 };
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(const char *fileName, int aheight, int aattack);
146         void Move(XYZ how);
147
148 protected:
149         void deallocate();
150 };
151
152
153 const int max_joints = 50;
154
155 class Skeleton
156 {
157 public:
158         int num_joints;
159         //Joint joints[max_joints];
160         //Joint *joints;
161         Joint* joints;
162
163         int num_muscles;
164         //Muscle muscles[max_muscles];
165         //Muscle *muscles;
166         Muscle* muscles;
167
168         int selected;
169
170         int forwardjoints[3];
171         XYZ forward;
172
173         int id;
174
175         int lowforwardjoints[3];
176         XYZ lowforward;
177
178         XYZ specialforward[5];
179         int jointlabels[max_joints];
180
181         Model model[7];
182         Model modellow;
183         Model modelclothes;
184         int num_models;
185
186         Model drawmodel;
187         Model drawmodellow;
188         Model drawmodelclothes;
189
190         bool clothes;
191         bool spinny;
192
193         GLubyte skinText[512*512*3];
194         int skinsize;
195
196         float checkdelay;
197
198         float longdead;
199         bool broken;
200
201         int free;
202         int oldfree;
203         float freetime;
204         bool freefall;
205
206         void FindForwards();
207         void FindForwardsfirst();
208         float DoConstraints(XYZ *coords,float *scale);
209         void DoGravity(float *scale);
210         void DoBalance();
211         void MusclesSet();
212         void Draw(int muscleview);
213         void AddJoint(float x, float y, float z, int which);
214         void SetJoint(float x, float y, float z, int which, int whichjoint);
215         void DeleteJoint(int whichjoint);
216         void AddMuscle(int attach1,int attach2,float maxlength,float minlength,int type);
217         void DeleteMuscle(int whichmuscle);
218         void FindRotationJoint(int which);
219         void FindRotationJointSameTwist(int which);
220         void FindRotationMuscle(int which, int animation);
221         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);
222
223         Skeleton();
224
225         ~Skeleton();
226 };
227
228 #endif