-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommunication.pde
148 lines (119 loc) · 6.39 KB
/
Communication.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
import oscP5.*;
import netP5.*;
public class Communication{
private OscP5 oscP5;
private NetAddress pdAddress;
public Communication(String pdIp, int pdPort, int myPort){
this.oscP5 = new OscP5(this, myPort);
this.pdAddress = new NetAddress(pdIp, pdPort); //localhost: "127.0.0.1" "192.168.15.16" // "192.168.15.1"
}
public void sendScene(Scene scene){
if(!scene.activeSkeletons.isEmpty()){
for(Skeleton skeleton:scene.activeSkeletons.values()){
this.sendMessageToElenaProject(skeleton);
/*
this.sendKinectSkeleton(skeleton);
this.sendGrainParameters(skeleton);
this.sendVideoParameter(skeleton);
this.sendSteeringWheel(skeleton);
*/
}
}
}
private void sendMessageToElenaProject(Skeleton skeleton){
OscMessage messageToElenaProject;
messageToElenaProject = new OscMessage("/SaturaRight");
messageToElenaProject.add(skeleton.joints[HAND_RIGHT].saturation);
this.oscP5.send(messageToElenaProject, pdAddress);
messageToElenaProject = new OscMessage("/SaturaLeft");
messageToElenaProject.add(skeleton.joints[HAND_LEFT].saturation);
this.oscP5.send(messageToElenaProject, pdAddress);
messageToElenaProject = new OscMessage("/JerkNormRight");
messageToElenaProject.add(skeleton.joints[HAND_RIGHT].standartDeviationNorm);
this.oscP5.send(messageToElenaProject, pdAddress);
messageToElenaProject = new OscMessage("/JerkNormLeft");
messageToElenaProject.add(skeleton.joints[HAND_LEFT].standartDeviationNorm);
this.oscP5.send(messageToElenaProject, pdAddress);
//messageToElenaProject = new OscMessage("/centerOfMassHeightAdjusted:");
//messageToElenaProject.add(skeleton.centerOfMassHeightAdjusted);
//this.oscP5.send(messageToElenaProject, pdAddress);
//messageToElenaProject = new OscMessage("/dispersion:");
//messageToElenaProject.add(skeleton.dispersion);
//this.oscP5.send(messageToElenaProject, pdAddress);
//messageToElenaProject = new OscMessage("/leftHandPollock.activationDirectionCode:");
//messageToElenaProject.add(skeleton.leftHandPollock.activationDirectionCode);
//this.oscP5.send(messageToElenaProject, pdAddress);
//messageToElenaProject = new OscMessage("/rightHandPollock.activationDirectionCode:");
//messageToElenaProject.add(skeleton.rightHandPollock.activationDirectionCode);
//this.oscP5.send(messageToElenaProject, pdAddress);
messageToElenaProject = new OscMessage("/leftHandRondDuBras");
messageToElenaProject.add(skeleton.leftHandRondDuBras.activatedDirectionCode);
this.oscP5.send(messageToElenaProject, pdAddress);
messageToElenaProject = new OscMessage("/rightHandRondDuBras");
messageToElenaProject.add(skeleton.rightHandRondDuBras.activatedDirectionCode);
this.oscP5.send(messageToElenaProject, pdAddress);
//messageToElenaProject = new OscMessage("/momentum.averageFluid:");
//messageToElenaProject.add(skeleton.momentum.averageFluid);
//this.oscP5.send(messageToElenaProject, pdAddress);
//messageToElenaProject = new OscMessage("/momentum.averageHarsh:");
//messageToElenaProject.add(skeleton.momentum.averageHarsh);
//this.oscP5.send(messageToElenaProject, pdAddress);
messageToElenaProject = new OscMessage("/momentum.averageTotal:");
messageToElenaProject.add(skeleton.momentum.averageTotal);
this.oscP5.send(messageToElenaProject, pdAddress);
}
/*private void sendSteeringWheel(Skeleton skeleton){
OscMessage messageToVideoSphere = new OscMessage("/steeringWheelRollStep:");
messageToVideoSphere.add(skeleton.steeringWheel.rollStep);
this.oscP5.send(messageToVideoSphere, pdAddress);
messageToVideoSphere = new OscMessage("/steeringWheelPitchStep:");
messageToVideoSphere.add(skeleton.steeringWheel.pitchStep);
this.oscP5.send(messageToVideoSphere, pdAddress);
}*/
private void sendKinectSkeleton(Skeleton skeleton){
OscMessage messageToPd = new OscMessage("/indexColor:");
messageToPd.add(skeleton.indexColor);
this.oscP5.send(messageToPd, pdAddress);
messageToPd = new OscMessage("/handStates:");
messageToPd.add(skeleton.estimatedHandRadius[0]);
messageToPd.add(skeleton.estimatedHandRadius[1]);
this.oscP5.send(messageToPd, pdAddress);
for (int jointType = 0; jointType<25 ; jointType++){
messageToPd = new OscMessage("/joint" + Integer.toString(jointType) + ":");
messageToPd.add(skeleton.joints[jointType].trackingState);
messageToPd.add(skeleton.joints[jointType].estimatedPosition.x);
messageToPd.add(skeleton.joints[jointType].estimatedPosition.y);
messageToPd.add(skeleton.joints[jointType].estimatedPosition.z);
messageToPd.add(skeleton.joints[jointType].estimatedOrientation.real);
messageToPd.add(skeleton.joints[jointType].estimatedOrientation.vector.x);
messageToPd.add(skeleton.joints[jointType].estimatedOrientation.vector.y);
messageToPd.add(skeleton.joints[jointType].estimatedOrientation.vector.z);
this.oscP5.send(messageToPd, pdAddress);
}
}
private void sendGrainParameters(Skeleton skeleton){
OscMessage messageToPd = new OscMessage("/Ready");
messageToPd = new OscMessage("/mid_z");
messageToPd.add(map((skeleton.joints[SPINE_BASE].estimatedPosition.z),0.4,3.5,0,1));
this.oscP5.send(messageToPd, pdAddress);
messageToPd = new OscMessage("/hand_left_x");
messageToPd.add(map((skeleton.joints[HAND_LEFT].estimatedPosition.x),-1.5,1,0,1));
this.oscP5.send(messageToPd, pdAddress);
messageToPd = new OscMessage("/hand_left_y");
messageToPd.add(map((skeleton.joints[HAND_LEFT].estimatedPosition.y),-1.5,1,0,1));
this.oscP5.send(messageToPd, pdAddress);
messageToPd = new OscMessage("/hand_right_x");
messageToPd.add(map((skeleton.joints[HAND_RIGHT].estimatedPosition.x),-1.5,1,0,1));
this.oscP5.send(messageToPd, pdAddress);
messageToPd = new OscMessage("/hand_right_y");
messageToPd.add(map((skeleton.joints[HAND_RIGHT].estimatedPosition.y),-1.5,1,0,1));
this.oscP5.send(messageToPd, pdAddress);
}
private void sendVideoParameter(Skeleton skeleton){
OscMessage messageToPd = new OscMessage("/Ready");
this.oscP5.send(messageToPd, pdAddress);
messageToPd = new OscMessage("/Elastic");
messageToPd.add((skeleton.distanceBetweenHands));
this.oscP5.send(messageToPd,pdAddress);
}
}