fix config loading
This commit is contained in:
parent
c70575547f
commit
7a0becfba5
1 changed files with 20 additions and 13 deletions
|
@ -26,13 +26,14 @@ boolean enable_IRImage=false;
|
||||||
boolean enable_colordepth=false;
|
boolean enable_colordepth=false;
|
||||||
|
|
||||||
// Which pixels do we care about?
|
// Which pixels do we care about?
|
||||||
int minDepth = 200;
|
int minDepth = 0;
|
||||||
int maxDepth = 1000;
|
int maxDepth = 910;
|
||||||
|
|
||||||
// What is the kinect's angle
|
// What is the kinect's angle
|
||||||
float angle;
|
float angle;
|
||||||
|
|
||||||
static int boxnum=19;
|
static int boxnum=50; //maximum boxes
|
||||||
|
int boxnumloaded=boxnum; //can be changes if less boxes are loaded from config
|
||||||
color box[] = new color[boxnum];
|
color box[] = new color[boxnum];
|
||||||
int boxid[] = new int[boxnum];
|
int boxid[] = new int[boxnum];
|
||||||
PVector boxpos[] = new PVector[boxnum]; //center position of box
|
PVector boxpos[] = new PVector[boxnum]; //center position of box
|
||||||
|
@ -73,18 +74,21 @@ void setup() {
|
||||||
|
|
||||||
for (int i=0;i<boxnum;i++) { //initialize boxpositions PVector
|
for (int i=0;i<boxnum;i++) { //initialize boxpositions PVector
|
||||||
boxpos[i]=new PVector();
|
boxpos[i]=new PVector();
|
||||||
|
boxsize[i]=new PVector();
|
||||||
boxenabled[i]=false;
|
boxenabled[i]=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//default config
|
//default config
|
||||||
|
/*
|
||||||
for (int i=0;i<boxnum;i++) { //initialize boxsizes
|
for (int i=0;i<boxnum;i++) { //initialize boxsizes
|
||||||
boxsize[i]=new PVector();
|
boxsize[i]=new PVector();
|
||||||
//boxsize[i].x=kinect.width/(boxnum+1);
|
//boxsize[i].x=kinect.width/(boxnum+1);
|
||||||
//boxsize[i].y=kinect.width/(boxnum+1);
|
//boxsize[i].y=kinect.width/(boxnum+1);
|
||||||
boxsize[i].x=kinect.width/(10+1);
|
boxsize[i].x=kinect.width/(10+1);
|
||||||
boxsize[i].y=kinect.width/(10+1);
|
boxsize[i].y=kinect.width/(10+1);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
/* for testing
|
||||||
int _boxesperrow=10;
|
int _boxesperrow=10;
|
||||||
for (int j=0;j<=int(boxnum/_boxesperrow);j++) {
|
for (int j=0;j<=int(boxnum/_boxesperrow);j++) {
|
||||||
int _boxesthisrow=min(_boxesperrow,boxnum-j*_boxesperrow);
|
int _boxesthisrow=min(_boxesperrow,boxnum-j*_boxesperrow);
|
||||||
|
@ -94,6 +98,7 @@ void setup() {
|
||||||
boxenabled[i+j*10]=true;
|
boxenabled[i+j*10]=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
boxid[0]=15;
|
boxid[0]=15;
|
||||||
boxid[1]=11;
|
boxid[1]=11;
|
||||||
|
@ -163,7 +168,7 @@ void draw() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i=0;i<boxnum;i++) {
|
for (int i=0;i<boxnumloaded;i++) {
|
||||||
float cpmean=0;
|
float cpmean=0;
|
||||||
int cpmeancounter=0;
|
int cpmeancounter=0;
|
||||||
float cpmax=0;
|
float cpmax=0;
|
||||||
|
@ -359,7 +364,7 @@ void keyPressed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendToWuerfels() {
|
void sendToWuerfels() {
|
||||||
for (int i=0;i<boxnum;i++) {
|
for (int i=0;i<boxnumloaded;i++) {
|
||||||
if (boxenabled[i]) {
|
if (boxenabled[i]) {
|
||||||
//print(str(i)+"="+str(brightness(box[i]))+", ");
|
//print(str(i)+"="+str(brightness(box[i]))+", ");
|
||||||
sPort.write("B,"+str(boxid[i])+","+str(fadetime)+","+int(red(box[i]))+","+int(green(box[i]))+","+int(blue(box[i]))+"\n");
|
sPort.write("B,"+str(boxid[i])+","+str(fadetime)+","+int(red(box[i]))+","+int(green(box[i]))+","+int(blue(box[i]))+"\n");
|
||||||
|
@ -382,9 +387,9 @@ void mouseClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveBoxConfig(){
|
void saveBoxConfig(){
|
||||||
String[] boxconfig=new String[boxnum];
|
String[] boxconfig=new String[boxnumloaded];
|
||||||
for (int i=0;i<boxnum;i++) {
|
for (int i=0;i<boxnumloaded;i++) {
|
||||||
boxconfig[i]=boxid[i]+";"+float(1.0*boxpos[i].x/kinect.width)+";"+float(1.0*boxpos[i].y/kinect.height)+";"+float(1.0*boxsize[i].x/kinect.width)+";"+float(1.0*boxsize[i].y/kinect.height);
|
boxconfig[i]=boxid[i]+";"+(1.0*boxpos[i].x/kinect.width)+";"+(1.0*boxpos[i].y/kinect.height)+";"+(1.0*boxsize[i].x/kinect.width)+";"+(1.0*boxsize[i].y/kinect.height);
|
||||||
}
|
}
|
||||||
saveStrings("boxconfig.txt", boxconfig);
|
saveStrings("boxconfig.txt", boxconfig);
|
||||||
println("saved");
|
println("saved");
|
||||||
|
@ -392,18 +397,20 @@ void saveBoxConfig(){
|
||||||
infomessage="saved";
|
infomessage="saved";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loadBoxConfig(){
|
void loadBoxConfig(){
|
||||||
String[] boxconfig = loadStrings("boxconfig.txt");
|
String[] boxconfig = loadStrings("boxconfig.txt");
|
||||||
for (int i=0;i<boxnum;i++) { //disable boxes
|
for (int i=0;i<boxnum;i++) { //disable boxes
|
||||||
boxenabled[i]=false;
|
boxenabled[i]=false;
|
||||||
}
|
}
|
||||||
|
boxnumloaded = boxconfig.length;
|
||||||
for (int i=0;i<min(boxconfig.length,boxnum);i++) {
|
for (int i=0;i<min(boxconfig.length,boxnum);i++) {
|
||||||
String[] _boxconfsplit=split(boxconfig[i], ';');
|
String[] _boxconfsplit=split(boxconfig[i], ';');
|
||||||
boxid[i]=int(_boxconfsplit[0]);
|
boxid[i]=int(_boxconfsplit[0]);
|
||||||
boxpos[i].x=int(_boxconfsplit[1]*kinect.width);
|
boxpos[i].x=int(float(_boxconfsplit[1])*kinect.width);
|
||||||
boxpos[i].y=int(_boxconfsplit[2]*kinect.height);
|
boxpos[i].y=int(float(_boxconfsplit[2])*kinect.height);
|
||||||
boxsize[i].x=int(_boxconfsplit[3]*kinect.width);
|
boxsize[i].x=int(float(_boxconfsplit[3])*kinect.width);
|
||||||
boxsize[i].y=int(_boxconfsplit[4]*kinect.height);
|
boxsize[i].y=int(float(_boxconfsplit[4])*kinect.height);
|
||||||
boxenabled[i]=true;
|
boxenabled[i]=true;
|
||||||
}
|
}
|
||||||
println("loaded");
|
println("loaded");
|
||||||
|
|
Loading…
Reference in a new issue