//~ Ping Genius Loci processing interaction engine //~ Adam Somlai-Fischer //~ aether architecture // @ todo // for showing available power, sensor reading, etc //~ pixelGrid.xy(12,2).rotateMe(120); //~ [22:12] Bengt Sjölén: i think you should put fieldLength and fieldWidth in PixelGrid is width and height though //~ [22:13] Bengt Sjölén: no no, just have PixelGrid() be PixelGrid(w,h) and make it assign pinPixels as w*h array //~ [22:14] Bengt Sjölén: and you could have PingPixel(id) become PingPixel(id,x,y) as well //~ [22:15] Bengt Sjölén: PingPixel[] pingPixels; direct in class instead of assigning //~ there and then in PixelGrid() you just have pingPixels=new PingPixel[w*h]; // buid a simulated user/human, that can /in multiply instances/ be interacted with. // this model should be contorlled by sensor reading, and for testing purpose, with mouse drag or movement keys // basic interaction examples, like water ripples, mirror man // The Obsessive Camera Direction // find link at http://www.processing.org/reference/libraries/index.html import damkjer.ocd.*; // global vairables int fieldWidth = 20; int fieldLength = 20; int pixelAmount = fieldWidth * fieldLength; float pixelSpacing = 5.0; //~ float rotationSpeed = 255 / 30; // for 1 rotation / second, with 30 fps float rotationSpeed = 140 / 30; // for 1 rotation / second, with 30 fps // create all PingPixels PixelGrid pixelGrid = new PixelGrid(); // set up views Camera cameraTop; Camera cameraBird; Camera cameraHuman; int selectedView = 1; int selectedContent = 2; void setup() { size(800, 600, P3D); colorMode(HSB, 255); framerate(30); noStroke(); // set up views cameraTop = new Camera(this, (fieldWidth * pixelSpacing) / 2, -3000, (fieldLength * pixelSpacing) / 2, (fieldWidth * pixelSpacing) / 2, 0, (fieldLength * pixelSpacing) / 2); cameraTop.zoom(radians(-57.5)); cameraBird = new Camera(this, (fieldWidth * pixelSpacing), -50, (fieldLength * pixelSpacing), (fieldWidth * pixelSpacing) / 2, 0, (fieldLength * pixelSpacing) / 2); cameraHuman = new Camera(this, (fieldWidth * pixelSpacing), -10, (fieldLength * pixelSpacing), (fieldWidth * pixelSpacing) / 2, 0, (fieldLength * pixelSpacing) / 2); } void draw() { background(37,31,142); // color of the shaded wooden stage lights(); drawPixels(); switch (selectedContent){ case 1: displayPerlinNoise(); break; case 2: displayWaves(); break; case 3 : displayID(); break; case 4 : displayRadiatingman(); break; } switch (selectedView){ case 1: cameraTop.feed(); break; case 2: cameraBird.feed(); cameraBirdNavigation(); break; case 3: cameraHuman.feed(); cameraHumanNavigation(); break; } } class PixelGrid { // array of PingPixels to contain all PingPixels PingPixel[] pingPixels = new PingPixel[pixelAmount]; // create all PingPixels upon initilization PixelGrid(){ //~ int gLength = gWidth * gHeigth; int row = 0; int x = 0; int y = 0; for (int id = 0; id < pixelAmount; id++) { pingPixels[id] = new PingPixel(id); if (row >= fieldWidth) { row = 0; x = 0; y += pixelSpacing; } pingPixels[id].x = x; pingPixels[id].y = y; row++; x += pixelSpacing; } } // function for returning PingPixel at x-y PingPixel xy (int x, int y){ int id = x + (y * fieldWidth); return pingPixels[id]; } // function for returning PingPixel at ID PingPixel id (int id){ return pingPixels[id]; } // wrap around // when you step outside in one axis it enters // on the other side, wraps coordinates in x and y PingPixel xy_wrap(int x, int y){ return xy(x%fieldWidth,y%fieldLength); } // ping // ping pong in both axis so if you step outside it bounces backs, // mirrors coordinate system in x and y and wraps PingPixel xy_pingPong(int x, int y){ return xy(abs(x%(fieldWidth*2)-fieldWidth),abs(y%(fieldLength*2)-fieldLength)); } } class PingPixel { //~ int pixelID; int angle, sensor; float speed, speaker, temperature, sunligth, power; int x, y; PingPixel(int pixelID){ angle = 0; sensor = 0; } void rotateMe(int targetAngle){ targetAngle = targetAngle % 360; if (targetAngle < angle){ angle -= rotationSpeed; } if (targetAngle > angle){ angle += rotationSpeed; } } } // visualization ******************************************************** void drawPixels(){ for (int id=0; id