//how can I get the e key to actually erase?- ARRAYLIST of boxes //how can I sort x values without losing the attached y,z, and color values?- Make boxes objects //NEED to be able to change vantage point to go over (and maybe to the side). Have to be able to get up. // Bigger boxes and or not as many- tiresome. //What are those lines when draw way out in distance? //NO printy outside of boxy. //Squirtmanager sm; //Squirt test; Vector3D[] v = new Vector3D[10]; //10-slot array of Vector3D values Squirt testerfordansorter; Squirt testerfordansorteraftersort; int pressMode;//start off noting that mouse has never been pressed color curcolor; int eraseMode; int exportMode; int sortMode; int scl=2; float boxsize=10; float curlayer; float floory=199; Vector3D mouseloc; void setup () { size(800, 600, P3D); framerate(100); background(255, 255, 255); noStroke(); pressMode=0; eraseMode=0; exportMode=0; sortMode=0; curcolor= color(50, 200, 50); curlayer= floory-boxsize;//draw first layer right above floor PFont font; font = loadFont("ArialMT-14.vlw"); textFont(font, 14); //sm = new Squirtmanager(); } void draw () { mouseloc= new Vector3D(mouseX/scl-width/2, curlayer, mouseY/scl-height/4); //float curcol=(mouseX/scl)-width/2;// / scl; //float currow=mouseY/scl-height/4;//determined experimentally//+zoff; ambientLight(100, 100, 100); //WAS 0.5 FOR ALL 3 directionalLight(255, 255, 255, 200, 200, 0); //(RVALUE, GVALUE, BVALUE, XPOS, YPOS, ZPOS translate(width/2, height/2, 0);/* Setting 3D origin to center of screen in screen plane.*/ background(0); renderstage(); stringtext(); if (pressMode==1) { fillarray(); } //sm.run(); } void mousePressed() { pressMode = 1; } void mouseReleased() { pressMode = 0; } void keyPressed() { if(key == CODED) { if (keyCode == UP) { nextlayer(); } else if (keyCode == DOWN) { prevlayer(); } else if (keyCode == DELETE) { eraseMode=1; //sm.eraseSquirt(); } else if (keyCode== SHIFT) { sortMode=1; dansorter(); } } if (key == 'r' || key == 'R') { curcolor=color(200, 50, 50); } else if (key == 'g' || key == 'G') {//changes renderbox color to green curcolor=color(50, 200, 50); } else if (key == 'b' || key == 'B') {//changes renderbox color to blue curcolor= color(50, 50, 200); } else if (key == 'x' || key == 'X') { exportMode=1; //have to decide what to do here. Will set squirtmanager to sort and then export sorted arraylist to new manager } } void keyReleased() { if(key == CODED) { if (keyCode == DELETE) { eraseMode=0; } if (keyCode== SHIFT) { sortMode=0; } } } void fillarray() { for (int i = 0; i < v.length; i++) { //fills the array with // if (mouseloc != v[i-1]) { v[i] = mouseloc;// Vector3Ds of the squirt points curcolor= color (50, 50, 200); testerfordansorter= new Squirt(v[i]); testerfordansorter.run(); // } } } void nextlayer() { curlayer -= boxsize; } void prevlayer() { curlayer += boxsize; } void renderstage() { //regardless of whether or not mouse pressed, draw the box in at every frame pushMatrix(); //1 fill(255,255,255);//was just (0.03) translate(0, 200, 0); box(800, 1, 800); popMatrix(); //1 } void stringtext() { String sf = "SNACKFAX"; fill(255, 100, 100); text(sf, 100, -205, 175, 200, 150); String m = "Click & drag to draw"; String s = "UP- next layer up"; String l = "DOWN- prev layer down"; String r = "R- red frosting"; String g = "G- green frosting"; String b = "B- blue frosting"; String x = "DELETE(hold)- erases"; fill(255, 255, 255); text(m, 100, -190, 175, 200, 150); text(s, 100, -175, 175, 200, 150); text(l, 100, -160, 175, 200, 150); text(r, 100, -145, 175, 200, 150); text(g, 100, -130, 175, 200, 150); text(b, 100, -115, 175, 200, 150); text(x, 100, -100, 175, 200, 150); } void dansorter() { println("Unsorted array: "); for (int i = 0; i < v.length; i++) { println(v[i].x + " " + v[i].y + " " + v[i].z); // prints them to show before sorting } for (int i = 0; i < v.length-1; i++) { //goes through the array up to the last slot int smallindex = i; float smallval = v[i].x; //saves the info for current slot for (int j = i+1; j < v.length; j++){ //goes through array again & compares it to all the values that come after it if (v[j].x < v[smallindex].x) {//if a later value is less than current one smallindex = j;//makes the smaller value the current one comparing against smallval = v[j].x; } } Vector3D temp = v[i];//temporary holder for X and y values while being compared v[i] = v[smallindex]; v[smallindex] = temp; } println(""); println("Sorted array by x values: "); curcolor= color (200, 50, 50); for (int i = 0; i < v.length; i++) { testerfordansorteraftersort= new Squirt(v[i]); testerfordansorteraftersort.run(); println(v[i].x + " " + v[i].y + " " + v[i].z); } }