//Camera; float rotX=-.47; float rotY= .8; float transX = 415; float transY = 142; float zoom = 1; // helper for the infinity of the cube and the layers int l0; int l1; int l2; int i0; int i1; int i2; int j0; int j1; int j2; float credits_alpha; float credits_helper; int gridsize = 10; int grid_abs = 300; int max_layers = 30; int nextgen, helper_ac; int current_layer=1; int [] rules = new int [16]; int [] neighbours = new int [4]; int [][]neighbours_gol = new int [26][2]; int [] s_a = new int [2]; int [] h_nextgen = new int [2]; int objects, h_objects = 0; int h_alpha=35; int h2_alpha=65; int ac_motherrule=0; int ac_layer=0; int axis=0; CUBE[][][] cubes; boolean[][][] generation_current; boolean[][][] generation_new; int[][][] generation_new_species; int[][] pixel_block; PImage img; String rules_str=""; boolean b = true, s = true, gol_new = true, orbit = true; boolean p_inactive = false, p = false, show_d = false , vis = false, l = false, gol = false, s_rules = false, s_layers = false, help = false, current_settings = false, remember_current_settings = false, credits = false; boolean show_livetime = false, autokill = true, species_evolution = true; void setup() { size(1200, 600, P3D); frameRate(10); background(0); colorMode(RGB); color black = color(0, 0, 0); int[][] imgPixels; img = loadImage("europe map.jpg"); //image(img, 0, 0, grid_abs, grid_abs); // read all pixel from the img imgPixels = new color[grid_abs][grid_abs]; loadPixels(); for(int j=0; j=6 && self[0]==0) { return_aliveness[0]=1; } if (h_alive == 4 && self[0]==0) { return_aliveness[0]=1; } if (species_evolution) { // 2nd species if (h_alive <= 4 && self[0]==1 && n[4][0] == 1 && n[21][0] == 1 || h_alive <= 4 && self[0]==1 && n[10][0] == 1 && n[15][0] == 1 || h_alive_species1>=4 && h_alive_species1<=6 && self[0]==0) { return_aliveness[0]=1; return_aliveness[1]=1; } // 3rd species if (h_alive_species1>=12 && h_alive_species1<=6 && self[1]==1 || h_alive_species1>=12 && h_alive_species1<=6 && self[0]==0 || h_alive>=19 || self[0]==1 && h_alive_species1==2 || self[0]==0 && h_alive_species2==3) { return_aliveness[0]=1; return_aliveness[1]=2; } } return return_aliveness; } // rules int rules (int a, int b, int c, int d) { if (a == 1 && b == 1 && c == 1 && d == 1) return rules[0]; if (a == 1 && b == 1 && c == 1 && d == 0) return rules[1]; if (a == 1 && b == 1 && c == 0 && d == 1) return rules[2]; if (a == 1 && b == 1 && c == 0 && d == 0) return rules[3]; if (a == 1 && b == 0 && c == 1 && d == 1) return rules[4]; if (a == 1 && b == 0 && c == 1 && d == 0) return rules[5]; if (a == 1 && b == 0 && c == 0 && d == 1) return rules[6]; if (a == 1 && b == 0 && c == 0 && d == 0) return rules[7]; if (a == 0 && b == 1 && c == 1 && d == 1) return rules[8]; if (a == 0 && b == 1 && c == 1 && d == 0) return rules[9]; if (a == 0 && b == 1 && c == 0 && d == 1) return rules[10]; if (a == 0 && b == 1 && c == 0 && d == 0) return rules[11]; if (a == 0 && b == 0 && c == 1 && d == 1) return rules[12]; if (a == 0 && b == 0 && c == 1 && d == 0) return rules[13]; if (a == 0 && b == 0 && c == 0 && d == 1) return rules[14]; if (a == 0 && b == 0 && c == 0 && d == 0) return rules[15]; return 0; } void show_layout() { textMode(SCREEN); PFont font; font = loadFont("HelveticaNeue-10.vlw"); textFont(font, 10); fill(120, 55, 255); textAlign(RIGHT); if (current_settings) { text("current settings |x|", 1125, 27,0); } else { text("current settings", 1125, 27,0); } textAlign(LEFT); if (help) { text("help |x|", 75, 27,0); } else { text("help", 75, 27,0); } textAlign(LEFT); fill(255); text("cellular automaton . developing layer "+current_layer+" of "+max_layers, 75, 15,0); if (current_layer==max_layers) { text("", 280, 15); } else { text("|...working|", 275, 15); } text("|c| . 2.5d CA . developed by . kai franz . eth zŸrich . d_arch . prof l.hovestadt . 02.2007", 75, 585); textAlign(RIGHT); text("rules: "+rules_str, 1125, 15); text("objects: "+objects+" . vertices: "+objects*4, 1125, 585); } void export() { beginRaw(DXF, "CA__3d_output___rules"+rules_str+".dxf"); for (int l=0; l 10) { h_alpha--; } } if (keyCode == RIGHT) { if (h2_alpha < 250) { h2_alpha++; } } if (keyCode == LEFT) { if (h2_alpha > 10) { h2_alpha--; } } if (key == 'd') { if (show_d) { show_d = false; } else { show_d = true; } } if (key == 'a') { if (vis) { vis = false; } else { vis = true; } } if (key == ',') { if (p_inactive) { p_inactive = false; } else { p_inactive = true; } } if (key == '-') { if (l) { l = false; } else { l = true; } } if (key == '.') { if (p) { p = false; } else { p = true; } } if (key == 's') { if (s) { s = false; } else { s = true; } } //show/hide image if (key == 'b') { if (b) { b = false; } else { b = true; } } } void mousePressed() { if (mouseX >= 70 && mouseX <= 120 && mouseY >= 15 && mouseY <= 40) { if (help) { help=false; if (remember_current_settings) { current_settings=true; } } else { remember_current_settings = current_settings; if (remember_current_settings) { current_settings=false; } help=true; } } if (mouseX >= 970 && mouseX <= 1130 && mouseY >= 15 && mouseY <= 40) { if (current_settings) { current_settings=false; } else { if (help) { help=false; } current_settings=true; } } if (mouseX >= 70 && mouseX <= 350 && mouseY >= 575 && mouseY <= 590) { credits_alpha=80; credits_helper=2.5; credits=true; } } void mouseDragged() { if(key == 'p') { orbit=false; transX += (mouseX - pmouseX); transY += (mouseY - pmouseY); println("trans: "+transX+" . "+transY); } else if(key == 'z') { orbit=false; zoom -= (mouseY - pmouseY) * .05; if (zoom <.05) { zoom = .05; } println("zoom: "+zoom); } else if(orbit) { rotX += (mouseY - pmouseY) * 0.01; rotY -= (mouseX - pmouseX) * 0.01; println("rot: "+rotX+" . "+rotY); } }