-
Notifications
You must be signed in to change notification settings - Fork 20
/
Xmlplayer.pde
76 lines (70 loc) · 1.91 KB
/
Xmlplayer.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
void xmlPlayerInit(int mfc){
MotionCapture = new XMLElement("MotionCapture");
xmlIO = new XMLInOut(this);
try {
xmlIO.loadElement(xmlFilePath + "/" + xmlFileName + (mfc) + "." + xmlFileType); //loads the XML
delay(saveDelayInterval);
}
catch(Exception e) {
//if loading failed
println("XML file loading failed");
}
}
//~~~
void xmlPlayerUpdate() {
background(0);
if(loaded){
parseXML();
fill(255,200);
stroke(0);
strokeWeight(5);
for(int i=0;i<osceletonNames.length;i++) {
pushMatrix();
translate(width*x[i],height*y[i],(-sD*z[i])+abs(sD/2));
ellipse(0,0,circleSize,circleSize);
popMatrix();
}
if(sendOsc) oscSend(1);
if(counter<counterMax&&!modeStop) {
counter++;
}
else {
counter=0;
if(dialogueFile!="none") countdown.dialogue.play(0);
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void xmlEvent(XMLElement element) {
//this function is ccalled by default when an XML object is loaded
MotionCapture = element;
loaded = true;
xmlFirstRun();
}
void xmlFirstRun(){
counterMax = int(MotionCapture.getAttribute("numFrames"));
}
void parseXML(){
if(counter<counterMax){
for(int i=0;i<oscXmlTags.length;i++) {
String posXs, posYs, posZs;
float posX, posY, posZ;
oscXmlTags[i] = MotionCapture.getChild(counter).getChild(0).getChild(0).getChild(i); //gets to the child we need
//loops through all the children that interest us
posXs = oscXmlTags[i].getAttribute("x"); //gets the title
posYs = oscXmlTags[i].getAttribute("y"); //gets the URL link
posZs = oscXmlTags[i].getAttribute("z"); //gets the description
posX = float(posXs);
posY = float(posYs);
posZ = float(posZs);
//add the data to the 2D array
x[i] = posX;
y[i] = posY;
z[i] = posZ;
if(i==0){
//println("~~~~~~~~~~~~~~~~");
}
//println(osceletonNames[i] + " x: " + posX + " y: " + posY + " z: " + posZ);
}
}
}