///////////////////////////////////////////////// int dotmapheight = 63; int dotmapwidth = 63; float gridspace = 1.0; float lato = 5.5; float dotmapoffsh, dotmapoffsv; float[][] map; color[][] colormap; int mapwidth, mapheight; bug[] bugs; color bgcol; float ang; ///////////////////////////////////////////////// void setup(){ ang = 0; bgcol = color(0, 0, 0); mouseX = 200; mouseY = 200; size(400, 400); framerate(30); noStroke(); background(bgcol); //noLights(); bugs = new bug[dotmapheight * dotmapwidth]; for (int i = 0; i < bugs.length; i++){ bugs[i] = new bug(); } dotmapoffsh = ((lato + gridspace ) * dotmapheight - gridspace) / 2.0; dotmapoffsv = ((lato + gridspace ) * dotmapwidth - gridspace) / 2.0; initmaps(); calcmapoffs(0, 0); } ///////////////////////////////////////////////// void loop(){ int oh = int((mouseX) * (mapwidth - dotmapwidth) / width); int ov = int((mouseY) * (mapheight - dotmapheight) / height); calcmapoffs(oh, ov); background(bgcol); translate(190, 128, 100); rotateX(PI/180*35.0); rotateZ(PI/180*6.0); rotateZ(ang); ang += PI/180*0.2; for (int i = 0; i < bugs.length; i++){ bugs[i].step(); } } ///////////////////////////////////////////////// void mouseReleased(){ } ///////////////////////////////////////////////// void initmaps(){ BImage pixmap, colmap; pixmap = loadImage("map.jpg"); colmap = loadImage("skin.jpg"); mapwidth = pixmap.width; mapheight = pixmap.height; map = new float[mapwidth][mapheight]; colormap = new color[mapwidth][mapheight]; for (int v = 0; v < mapwidth; v++){ for (int h = 0; h < mapheight; h++){ map[h][v] = brightness(pixmap.get(h,v))/1.8; colormap[h][v] = colmap.get(h,v); } } } ///////////////////////////////////////////////// void calcmapoffs(int mh, int mv){ int n = 0; for (int v = 0; v < dotmapwidth; v++){ for (int h = 0; h < dotmapheight; h++){ bugs[n].x = (lato + gridspace) * h; bugs[n].y = (lato + gridspace) * v; bugs[n].destz = map[h + mh][v + mv]; bugs[n].col = colormap[h + mh][v + mv]; n++; } } } ///////////////////////////////////////////////// class bug{ float x,y,z; float destz; color col = color(255, 255, 255); float damp = 0.08; bug(){ x = 0; y = 0; z = 0; destz = 0; } void step(){ // col = color(bugheight, z, z); fill(col); push(); z = z + (destz - z) * damp; translate(x - dotmapoffsh, y - dotmapoffsv, z); // rect(0, 0, lato, lato); ellipse(0, 0, lato, lato); pop(); } }