-
Notifications
You must be signed in to change notification settings - Fork 0
/
Candyman.pde
164 lines (153 loc) · 4.21 KB
/
Candyman.pde
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
Graficos graficos;
Audio audio;
Config config;
Movement move;
Juego game;
Personaje uno;
void setup()
{
size(1024, 768);
graficos = new Graficos();
audio = new Audio();
config = new Config();
move = new Movement();
game = new Juego();
uno = new Personaje(0,0,0);
graficos.CargarGraficos();
}
void draw(){
graficos.Inicio();
move.IniciaKinect();
}
void drawPosition(SkeletonData _s)
{
noStroke();
fill(0, 100, 255);
String s1 = str(_s.dwTrackingID);
text(s1, _s.position.x*width/2, _s.position.y*height/2);
}
void drawSkeleton(SkeletonData _s)
{
// Body
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_HEAD,
Kinect.NUI_SKELETON_POSITION_SHOULDER_CENTER);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_CENTER,
Kinect.NUI_SKELETON_POSITION_SHOULDER_LEFT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_CENTER,
Kinect.NUI_SKELETON_POSITION_SHOULDER_RIGHT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_CENTER,
Kinect.NUI_SKELETON_POSITION_SPINE);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_LEFT,
Kinect.NUI_SKELETON_POSITION_SPINE);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_RIGHT,
Kinect.NUI_SKELETON_POSITION_SPINE);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SPINE,
Kinect.NUI_SKELETON_POSITION_HIP_CENTER);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_HIP_CENTER,
Kinect.NUI_SKELETON_POSITION_HIP_LEFT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_HIP_CENTER,
Kinect.NUI_SKELETON_POSITION_HIP_RIGHT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_HIP_LEFT,
Kinect.NUI_SKELETON_POSITION_HIP_RIGHT);
// Left Arm
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_LEFT,
Kinect.NUI_SKELETON_POSITION_ELBOW_LEFT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_ELBOW_LEFT,
Kinect.NUI_SKELETON_POSITION_WRIST_LEFT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_WRIST_LEFT,
Kinect.NUI_SKELETON_POSITION_HAND_LEFT);
// Right Arm
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_SHOULDER_RIGHT,
Kinect.NUI_SKELETON_POSITION_ELBOW_RIGHT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_ELBOW_RIGHT,
Kinect.NUI_SKELETON_POSITION_WRIST_RIGHT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_WRIST_RIGHT,
Kinect.NUI_SKELETON_POSITION_HAND_RIGHT);
// Left Leg
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_HIP_LEFT,
Kinect.NUI_SKELETON_POSITION_KNEE_LEFT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_KNEE_LEFT,
Kinect.NUI_SKELETON_POSITION_ANKLE_LEFT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_ANKLE_LEFT,
Kinect.NUI_SKELETON_POSITION_FOOT_LEFT);
// Right Leg
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_HIP_RIGHT,
Kinect.NUI_SKELETON_POSITION_KNEE_RIGHT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_KNEE_RIGHT,
Kinect.NUI_SKELETON_POSITION_ANKLE_RIGHT);
DrawBone(_s,
Kinect.NUI_SKELETON_POSITION_ANKLE_RIGHT,
Kinect.NUI_SKELETON_POSITION_FOOT_RIGHT);
}
void DrawBone(SkeletonData _s, int _j1, int _j2)
{
noFill();
stroke(255, 255, 0);
if (_s.skeletonPositionTrackingState[_j1] != Kinect.NUI_SKELETON_POSITION_NOT_TRACKED &&
_s.skeletonPositionTrackingState[_j2] != Kinect.NUI_SKELETON_POSITION_NOT_TRACKED) {
line(_s.skeletonPositions[_j1].x*width/2,
_s.skeletonPositions[_j1].y*height/2,
_s.skeletonPositions[_j2].x*width/2,
_s.skeletonPositions[_j2].y*height/2);
}
}
void appearEvent(SkeletonData _s)
{
if (_s.trackingState == Kinect.NUI_SKELETON_NOT_TRACKED)
{
return;
}
synchronized(bodies) {
bodies.add(_s);
}
}
void disappearEvent(SkeletonData _s)
{
synchronized(bodies) {
for (int i=bodies.size ()-1; i>=0; i--)
{
if (_s.dwTrackingID == bodies.get(i).dwTrackingID)
{
bodies.remove(i);
}
}
}
}
void moveEvent(SkeletonData _b, SkeletonData _a)
{
if (_a.trackingState == Kinect.NUI_SKELETON_NOT_TRACKED)
{
return;
}
synchronized(bodies) {
for (int i=bodies.size ()-1; i>=0; i--)
{
if (_b.dwTrackingID == bodies.get(i).dwTrackingID)
{
bodies.get(i).copy(_a);
break;
}
}
}
}