-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathSettings.pde
176 lines (163 loc) · 6.48 KB
/
Settings.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
165
166
167
168
169
170
171
172
173
174
175
176
class Settings {
Data settings;
Settings(String _s) {
try {
settings = new Data();
settings.load(_s);
for (int i=0;i<settings.data.length;i++) {
if (settings.data[i].equals("Mirror Joints")) mirror = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Send OSC Active")) sendOsc = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("OSC Send IP Number")) ipNumber = setString(settings.data[i+1]);
if (settings.data[i].equals("OSC Send Port")) sendPort = setInt(settings.data[i+1]);
if (settings.data[i].equals("OSC Receive Port")) receivePort = setInt(settings.data[i+1]);
if (settings.data[i].equals("OSC Local Echo")) oscLocalEcho = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("OSC Channel Format (Isadora, OSCeleton, Animata)")) oscChannelFormat = setString(settings.data[i+1]);
if (settings.data[i].equals("Export AE Puppet Pin Data (.txt)")) savePins = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Export AE Point Control Data (.txt)")) savePoints = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Export AE Point Control 3D Data (.txt)")) savePoints3D = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Export JSON Data (.json)")) saveJson = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Export AE Template Script (.jsx)")) saveJsx = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Export Maya Script (.py)")) saveMaya = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Export Pointcloud (.obj)")) saveObj = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Original Capture Image Width")) sW = setInt(settings.data[i+1]);
if (settings.data[i].equals("Original Capture Image Height")) sH = setInt(settings.data[i+1]);
if (settings.data[i].equals("Original Capture Depth")) sD = setFloat(settings.data[i+1]);
if (settings.data[i].equals("Destination AE Comp Width")) dW = setInt(settings.data[i+1]);
if (settings.data[i].equals("Destination AE Comp Height")) dH = setInt(settings.data[i+1]);
if (settings.data[i].equals("Framerate (max 30)")) fps = setInt(settings.data[i+1]);
if (settings.data[i].equals("Camera Display Quality (1 = best)")) previewLevel = setInt(settings.data[i+1]);
if (settings.data[i].equals("Enable Multithreading")) multiThread = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Load SimpleOpenNI at Startup")) loadSimpleOpenNIatStart = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("SimpleOpenNI Autocalibration (no \"cactus pose\")")) autoCalibrate = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Delay Between Saving Files")) saveDelayInterval = setInt(settings.data[i+1]);
if (settings.data[i].equals("BVH Names List")) bvhJointNames = setStringArray(settings.data[i+1]);
if (settings.data[i].equals("BVH Scale Factor")) bvhScaleFactor = setPVector(settings.data[i+1]);
if (settings.data[i].equals("BVH Offset")) bvhOffset = setPVector(settings.data[i+1]);
}
}
catch(Exception e) {
println("Couldn't load settings file. Using defaults.");
}
}
int setInt(String _s) {
return int(_s);
}
float setFloat(String _s) {
return float(_s);
}
boolean setBoolean(String _s) {
return boolean(_s);
}
String setString(String _s) {
return ""+(_s);
}
String[] setStringArray(String _s) {
int commaCounter=0;
for(int j=0;j<_s.length();j++){
if (_s.charAt(j)==char(',')){
commaCounter++;
}
}
//println(commaCounter);
String[] buildArray = new String[commaCounter+1];
commaCounter=0;
for(int k=0;k<buildArray.length;k++){
buildArray[k] = "";
}
for (int i=0;i<_s.length();i++) {
if (_s.charAt(i)!=char(' ') && _s.charAt(i)!=char('(') && _s.charAt(i)!=char(')') && _s.charAt(i)!=char('{') && _s.charAt(i)!=char('}') && _s.charAt(i)!=char('[') && _s.charAt(i)!=char(']')) {
if (_s.charAt(i)==char(',')){
commaCounter++;
}else{
buildArray[commaCounter] += _s.charAt(i);
}
}
}
println(buildArray);
return buildArray;
}
color setColor(String _s) {
color endColor = color(0);
int commaCounter=0;
String sr = "";
String sg = "";
String sb = "";
String sa = "";
int r = 0;
int g = 0;
int b = 0;
int a = 0;
for (int i=0;i<_s.length();i++) {
if (_s.charAt(i)!=char(' ') && _s.charAt(i)!=char('(') && _s.charAt(i)!=char(')')) {
if (_s.charAt(i)==char(',')){
commaCounter++;
}else{
if (commaCounter==0) sr += _s.charAt(i);
if (commaCounter==1) sg += _s.charAt(i);
if (commaCounter==2) sb += _s.charAt(i);
if (commaCounter==3) sa += _s.charAt(i);
}
}
}
if (sr!="" && sg=="" && sb=="" && sa=="") {
r = int(sr);
endColor = color(r);
}
if (sr!="" && sg!="" && sb=="" && sa=="") {
r = int(sr);
g = int(sg);
endColor = color(r, g);
}
if (sr!="" && sg!="" && sb!="" && sa=="") {
r = int(sr);
g = int(sg);
b = int(sb);
endColor = color(r, g, b);
}
if (sr!="" && sg!="" && sb!="" && sa!="") {
r = int(sr);
g = int(sg);
b = int(sb);
a = int(sa);
endColor = color(r, g, b, a);
}
return endColor;
}
PVector setPVector(String _s){
PVector endPVector = new PVector(0,0,0);
int commaCounter=0;
String sx = "";
String sy = "";
String sz = "";
float x = 0;
float y = 0;
float z = 0;
for (int i=0;i<_s.length();i++) {
if (_s.charAt(i)!=char(' ') && _s.charAt(i)!=char('(') && _s.charAt(i)!=char(')')) {
if (_s.charAt(i)==char(',')){
commaCounter++;
}else{
if (commaCounter==0) sx += _s.charAt(i);
if (commaCounter==1) sy += _s.charAt(i);
if (commaCounter==2) sz += _s.charAt(i);
}
}
}
if (sx!="" && sy=="" && sz=="") {
x = float(sx);
endPVector = new PVector(x,0);
}
if (sx!="" && sy!="" && sz=="") {
x = float(sx);
y = float(sy);
endPVector = new PVector(x,y);
}
if (sx!="" && sy!="" && sz!="") {
x = float(sx);
y = float(sy);
z = float(sz);
endPVector = new PVector(x,y,z);
}
return endPVector;
}
}