class light_box{ float x, y, z, yr; int[] switches; int[] messages; int indx; public light_box(float xpos, float ypos, float zpos, float yrot, int i, int[] msgs){ x = xpos; y = ypos; z = zpos; yr = yrot; switches = new int[]{0, 0, 0}; indx = i; messages = msgs; } public void render(){ pushMatrix(); translate(x,y,z); rotateY(radians(yr)); fill(255); emissive(30, 30, 15); box(100, 30, 30); draw_lights(); popMatrix(); } public boolean click(){ if(lit_orb < 0) return false; float sx = screenX(x + 60, y, z); float sy = screenY(x + 60, y, z); float d = dist(mouseX, mouseY, sx, sy); boolean ret = false; if(d < 60){ ret = orbs[lit_orb].grab(x, y, z, switches, indx); if(ret) zeroing = true; } return ret; } public void turnon(int i){ switches[i] = 1; // myPort.write(messages[i]); } public void turnoff(int i){ switches[i] = 0; // myPort.write(messages[i]); } public void draw_lights(){ //can ony create 8 lights, so it's combined into one. int def = 20; int r = switches[0] == 0 ? def : 255; int g = switches[1] == 0 ? def : 150; int b = switches[2] == 0 ? def : 200; //light squares pushMatrix(); rotateX(radians(90)); translate(0,0,16); fill(255); emissive(r, def, def); rect(-50, -15, 30, 30); emissive(def, g, def); rect(-15, -15, 30, 30); emissive(def, def, b); rect(20, -15, 30, 30); //spotLight translate(0, -room_size[0], 0); lightFalloff(1.0, 0.05, 0.0); spotLight(r, g, b, 0, 0, -20, 0, 1, 0, radians(90), 2); popMatrix(); } }