about summary refs log tree commit diff
path: root/src/Skeleton.h
blob: fbd1d8bf13ac1dbbb39a28b4b68e53f9636d8d12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef _SKELETON_H_
#define _SKELETON_H_

/**> HEADER FILES <**/
#include <GL/gl.h>
#include <AL/al.h>

#include "Quaternions.h"
#include "Constants.h"
#include "Models.h"

#define boneconnect 0
#define constraint 1
#define muscle 2

#define head 0
#define neck 1
#define leftshoulder 2
#define leftelbow 3
#define leftwrist 4
#define lefthand 5
#define rightshoulder 6
#define rightelbow 7
#define rightwrist 8
#define righthand 9
#define abdomen 10
#define lefthip 11
#define righthip 12
#define groin 13
#define leftknee 14
#define leftankle 15
#define leftfoot 16
#define rightknee 17
#define rightankle 18
#define rightfoot 19

class Joint
{
	public:
		XYZ position;
		XYZ oldposition;
		XYZ realoldposition;
		XYZ velocity;
		XYZ offset;
		float length;
		bool lower;
		bool hasparent;
		bool locked;
		int modelnum;
		bool visible;
		bool existing;
		Joint* parent;
		int label;
		float rotate1,rotate2,rotate3;

		void DoConstraint();
};

class Muscle
{
	public:
		float length;
		float targetlength;
		Joint* parent1;
		Joint* parent2;
		float maxlength;
		float minlength;
		int type;
		bool visible;
		void DoConstraint(int broken);
		float rotate1,rotate2,rotate3;

		float strength;
};

class Animation
{
	public:
		int numframes;
		bool canbeoverridden;
		bool ismodified[max_joints][max_frames];
		XYZ position[max_joints][max_frames];
		float speed[max_frames];
		XYZ forward[max_frames];
		float rotate1[max_joints][max_frames];
		float rotate2[max_joints][max_frames];
		float rotate3[max_joints][max_frames];
		float mrotate1[max_joints][max_frames];
		float mrotate2[max_joints][max_frames];
		float mrotate3[max_joints][max_frames];
		void load(const char* name);
};

class Skeleton
{
	public:
		Joint joints[max_joints];
		Muscle muscles[max_muscles];
		int num_muscles;

		int selected;

		int forwardjoints[3];
		XYZ forward;

		int lowforwardjoints[3];
		XYZ lowforward;

		int broken;
		bool offset;

		XYZ specialforward[5];

		bool free;

		void DoConstraints();
		void DoConstraints(Model *collide, XYZ *move, float rotation);
		void DoGravity();
		void DoBalance();
		void Draw(int muscleview);
		void DeleteJoint(int whichjoint);
		void DeleteMuscle(int whichmuscle);
		void FindRotationJoint(int which);
		void FindRotationMuscle(int which);
		void reload();
};

#endif