Monday, June 27, 2005

processing code dump for today (I just cant be bothered bringing in my laptop). this code kinda works, and kinda dosnt. the aim is to constantly read the text file while it being created and update the processing thingy while Unreal is being played.


void setup() {
size (880,625); //was 625 by 625
background(252,255,255);
stroke(0,0,0);
}


/////////////////////////////////////////////////
//global variables

int count2 = 0;
int starthere = 0;
int endhere = 0;
int dont = 5;
int i = 0;
String intarr [];
String[] matchstart = { "ScriptLog: START MATCH","Log: appRequestExit(0)" }; //when to start reading and when to stop
int counter = 0;
int arrlen =0;
int fixarraygay =0;
int arrnum = 0;
String format;
float thelist[];

///////////////////////////////////////////////
//loop


void draw() {


if(dont<=5) { // read the text file know where it ends
intarr = loadStrings("C:/UT2004/System/UT2004.log"); //will read from correct place
dont=dont+1; //dont read the file again till you told!
}


//////////////////////////////////////////////
//find the relevant lines of the text file (want to speed this process up with a while other wise its stuck in the slow draw loop!)

while(dont == 6) {

if(intarr[i].equals(matchstart[0]) == true) { //check for when to begin
println("we hit start match at");
println(i);
starthere = i+1; //this is where the first x value is situated
println(intarr[starthere]);
i=i+1;
} else {
i=i+1;
} //end start check

if(intarr[i].equals(matchstart[1]) == true) { //check for when to stop
println("we hit the end of the match at");
println(i);
endhere = i-1; //this is where the final z value is situated
println (intarr[endhere]);

counter = starthere;
arrlen = endhere-starthere;
fixarraygay = arrlen-1;
dont=dont+1;
}
}//endwhile

////////////////////////////////////////////////////////////////


if (dont ==7){

String justnumstrings [] = new String[arrlen];
println(justnumstrings.length);

while (counter < endhere){
String temp [] = split(intarr[counter]);

justnumstrings[arrnum] = temp[3];

arrnum = arrnum+1;
counter= counter+1;
}

String format = join(justnumstrings, " ");
thelist = float (split(format));

fixarraygay= fixarraygay-9;
dont=dont+1;
}

/////////////////////////////////////////////////////////////////


float temp1 = thelist[count2];
float temp2 = thelist[count2+1];
float temp3 = thelist[count2+2];

temp1 = temp1+10000;
temp2 = temp2+10000;
temp3 = temp3+10000;
temp1 = temp1/32;
temp2 = temp2/32;
temp3 = temp3/32;

point (temp1, temp2);

if (count2 >= fixarraygay){
noLoop();
println("endof");
}

count2 = count2+3;

}

0 Comments:

Post a Comment

<< Home