Skip to content

Instantly share code, notes, and snippets.

@timini
Created May 22, 2010 13:03
Show Gist options
  • Save timini/410063 to your computer and use it in GitHub Desktop.
Save timini/410063 to your computer and use it in GitHub Desktop.
float[][] verticies = {{ 0 , 0 , 12 },
{ 0.931306 , -2.86627 , 11.6154 },
{ 3.01377 , 0 , 11.6154 },
{ 1.94952 , -6 , 10.2078 },
{ 4.34164 , -3.15439 , 10.7331 },
{ 6.30877 , 0 , 10.2078 },
{ 2.79392 , -8.5988 , 7.89016 },
{ 5.36656 , -6.30877 , 8.68328 },
{ 7.65836 , -3.15439 , 8.68328 },
{ 9.04131 , 0 , 7.89016 },
{ 3.31672 , -10.2078 , 5.36657 },
{ 5.80769 , -8.5988 , 6.02755 },
{ 8.25829 , -6 , 6.30878 },
{ 9.97262 , -2.86627 , 6.02755 },
{ 10.7331 , 0 , 5.36657 },
{ -2.43819 , -1.77145 , 11.6154 },
{ -5.1039 , -3.7082 , 10.2078 },
{ -1.65836 , -5.1039 , 10.7331 },
{ -7.31458 , -5.31435 , 7.89016 },
{ -4.34164 , -7.05342 , 8.68328 },
{ -0.633439 , -8.25829 , 8.68328 },
{ -8.68328 , -6.30877 , 5.36657 },
{ -6.38327 , -8.18062 , 6.02755 },
{ -3.15439 , -9.7082 , 6.30878 },
{ 0.355725 , -10.3703 , 6.02755 },
{ -2.43819 , 1.77145 , 11.6154 },
{ -5.1039 , 3.7082 , 10.2078 },
{ -5.36656 , 0 , 10.7331 },
{ -7.31458 , 5.31435 , 7.89016 },
{ -8.04984 , 1.94952 , 8.68328 },
{ -8.04984 , -1.94952 , 8.68328 },
{ -8.68328 , 6.30877 , 5.36657 },
{ -9.75277 , 3.5429 , 6.02755 },
{ -10.2078 , -2.10208e-07 , 6.30878 },
{ -9.75277 , -3.5429 , 6.02755 },
{ 0.931306 , 2.86627 , 11.6154 },
{ 1.94952 , 6 , 10.2078 },
{ -1.65836 , 5.1039 , 10.7331 },
{ 2.79392 , 8.5988 , 7.89016 },
{ -0.633439 , 8.25829 , 8.68328 },
{ -4.34164 , 7.05342 , 8.68328 },
{ 3.31672 , 10.2078 , 5.36657 },
{ 0.355725 , 10.3703 , 6.02755 },
{ -3.15439 , 9.7082 , 6.30878 },
{ -6.38327 , 8.18062 , 6.02755 },
{ 4.34164 , 3.15439 , 10.7331 },
{ 7.65836 , 3.15439 , 8.68328 },
{ 5.36656 , 6.30877 , 8.68328 },
{ 9.97262 , 2.86627 , 6.02755 },
{ 8.25829 , 6 , 6.30878 },
{ 5.80769 , 8.5988 , 6.02755 },
{ 11.4795 , -1.77145 , 3.01378 },
{ 10.3416 , -5.10391 , 3.31672 },
{ 11.4127 , -3.7082 , 0 },
{ 8.04984 , -8.25829 , 3.31672 },
{ 9.7082 , -7.05342 , 0 },
{ 5.23211 , -10.3703 , 3.01377 },
{ 7.05342 , -9.7082 , 0 },
{ 1.86261 , -11.4651 , 3.01377 },
{ 0 , -12 , 0 },
{ 3.7082 , -11.4127 , 0 },
{ -1.65836 , -11.4127 , 3.31672 },
{ -5.36656 , -10.2078 , 3.31672 },
{ -3.7082 , -11.4127 , 0 },
{ -8.24589 , -8.18062 , 3.01377 },
{ -7.05342 , -9.7082 , 0 },
{ -10.3284 , -5.31435 , 3.01377 },
{ -11.4127 , -3.7082 , 0 },
{ -9.7082 , -7.05342 , 0 },
{ -11.3666 , -1.94952 , 3.31672 },
{ -11.3666 , 1.94952 , 3.31672 },
{ -12 , 0 , 0 },
{ -10.3284 , 5.31435 , 3.01377 },
{ -11.4127 , 3.7082 , 0 },
{ -8.24589 , 8.18062 , 3.01377 },
{ -7.05342 , 9.7082 , 0 },
{ -9.7082 , 7.05342 , 0 },
{ -5.36656 , 10.2078 , 3.31672 },
{ -1.65836 , 11.4127 , 3.31672 },
{ -3.7082 , 11.4127 , 0 },
{ 1.86261 , 11.4651 , 3.01377 },
{ 0 , 12 , 0 },
{ 5.23211 , 10.3703 , 3.01377 },
{ 7.05342 , 9.7082 , 0 },
{ 3.7082 , 11.4127 , 0 },
{ 8.04984 , 8.25829 , 3.31672 },
{ 10.3416 , 5.10391 , 3.31672 },
{ 9.7082 , 7.05342 , 0 },
{ 11.4795 , 1.77145 , 3.01378 },
{ 11.4127 , 3.7082 , 0 },
{ 12 , 0 , 0 },};
int[][] edges = {{ 0 , 1 },
{ 1 , 2 },
{ 2 , 0 },
{ 1 , 3 },
{ 3 , 4 },
{ 4 , 1 },
{ 4 , 2 },
{ 4 , 5 },
{ 5 , 2 },
{ 3 , 6 },
{ 6 , 7 },
{ 7 , 3 },
{ 7 , 4 },
{ 7 , 8 },
{ 8 , 4 },
{ 8 , 5 },
{ 8 , 9 },
{ 9 , 5 },
{ 6 , 10 },
{ 10 , 11 },
{ 11 , 6 },
{ 11 , 7 },
{ 11 , 12 },
{ 12 , 7 },
{ 12 , 8 },
{ 12 , 13 },
{ 13 , 8 },
{ 13 , 9 },
{ 13 , 14 },
{ 14 , 9 },
{ 0 , 15 },
{ 15 , 1 },
{ 15 , 16 },
{ 16 , 17 },
{ 17 , 15 },
{ 17 , 1 },
{ 17 , 3 },
{ 16 , 18 },
{ 18 , 19 },
{ 19 , 16 },
{ 19 , 17 },
{ 19 , 20 },
{ 20 , 17 },
{ 20 , 3 },
{ 20 , 6 },
{ 18 , 21 },
{ 21 , 22 },
{ 22 , 18 },
{ 22 , 19 },
{ 22 , 23 },
{ 23 , 19 },
{ 23 , 20 },
{ 23 , 24 },
{ 24 , 20 },
{ 24 , 6 },
{ 24 , 10 },
{ 0 , 25 },
{ 25 , 15 },
{ 25 , 26 },
{ 26 , 27 },
{ 27 , 25 },
{ 27 , 15 },
{ 27 , 16 },
{ 26 , 28 },
{ 28 , 29 },
{ 29 , 26 },
{ 29 , 27 },
{ 29 , 30 },
{ 30 , 27 },
{ 30 , 16 },
{ 30 , 18 },
{ 28 , 31 },
{ 31 , 32 },
{ 32 , 28 },
{ 32 , 29 },
{ 32 , 33 },
{ 33 , 29 },
{ 33 , 30 },
{ 33 , 34 },
{ 34 , 30 },
{ 34 , 18 },
{ 34 , 21 },
{ 0 , 35 },
{ 35 , 25 },
{ 35 , 36 },
{ 36 , 37 },
{ 37 , 35 },
{ 37 , 25 },
{ 37 , 26 },
{ 36 , 38 },
{ 38 , 39 },
{ 39 , 36 },
{ 39 , 37 },
{ 39 , 40 },
{ 40 , 37 },
{ 40 , 26 },
{ 40 , 28 },
{ 38 , 41 },
{ 41 , 42 },
{ 42 , 38 },
{ 42 , 39 },
{ 42 , 43 },
{ 43 , 39 },
{ 43 , 40 },
{ 43 , 44 },
{ 44 , 40 },
{ 44 , 28 },
{ 44 , 31 },
{ 2 , 35 },
{ 5 , 45 },
{ 45 , 2 },
{ 45 , 35 },
{ 45 , 36 },
{ 9 , 46 },
{ 46 , 5 },
{ 46 , 45 },
{ 46 , 47 },
{ 47 , 45 },
{ 47 , 36 },
{ 47 , 38 },
{ 14 , 48 },
{ 48 , 9 },
{ 48 , 46 },
{ 48 , 49 },
{ 49 , 46 },
{ 49 , 47 },
{ 49 , 50 },
{ 50 , 47 },
{ 50 , 38 },
{ 50 , 41 },
{ 13 , 51 },
{ 51 , 14 },
{ 12 , 52 },
{ 52 , 13 },
{ 52 , 51 },
{ 52 , 53 },
{ 53 , 51 },
{ 11 , 54 },
{ 54 , 12 },
{ 54 , 52 },
{ 54 , 55 },
{ 55 , 52 },
{ 55 , 53 },
{ 10 , 56 },
{ 56 , 11 },
{ 56 , 54 },
{ 56 , 57 },
{ 57 , 54 },
{ 57 , 55 },
{ 10 , 58 },
{ 58 , 56 },
{ 58 , 59 },
{ 59 , 60 },
{ 60 , 58 },
{ 60 , 56 },
{ 60 , 57 },
{ 24 , 58 },
{ 23 , 61 },
{ 61 , 24 },
{ 61 , 58 },
{ 61 , 59 },
{ 22 , 62 },
{ 62 , 23 },
{ 62 , 61 },
{ 62 , 63 },
{ 63 , 61 },
{ 63 , 59 },
{ 21 , 64 },
{ 64 , 22 },
{ 64 , 62 },
{ 64 , 65 },
{ 65 , 62 },
{ 65 , 63 },
{ 21 , 66 },
{ 66 , 64 },
{ 66 , 67 },
{ 67 , 68 },
{ 68 , 66 },
{ 68 , 64 },
{ 68 , 65 },
{ 34 , 66 },
{ 33 , 69 },
{ 69 , 34 },
{ 69 , 66 },
{ 69 , 67 },
{ 32 , 70 },
{ 70 , 33 },
{ 70 , 69 },
{ 70 , 71 },
{ 71 , 69 },
{ 71 , 67 },
{ 31 , 72 },
{ 72 , 32 },
{ 72 , 70 },
{ 72 , 73 },
{ 73 , 70 },
{ 73 , 71 },
{ 31 , 74 },
{ 74 , 72 },
{ 74 , 75 },
{ 75 , 76 },
{ 76 , 74 },
{ 76 , 72 },
{ 76 , 73 },
{ 44 , 74 },
{ 43 , 77 },
{ 77 , 44 },
{ 77 , 74 },
{ 77 , 75 },
{ 42 , 78 },
{ 78 , 43 },
{ 78 , 77 },
{ 78 , 79 },
{ 79 , 77 },
{ 79 , 75 },
{ 41 , 80 },
{ 80 , 42 },
{ 80 , 78 },
{ 80 , 81 },
{ 81 , 78 },
{ 81 , 79 },
{ 41 , 82 },
{ 82 , 80 },
{ 82 , 83 },
{ 83 , 84 },
{ 84 , 82 },
{ 84 , 80 },
{ 84 , 81 },
{ 50 , 82 },
{ 49 , 85 },
{ 85 , 50 },
{ 85 , 82 },
{ 85 , 83 },
{ 48 , 86 },
{ 86 , 49 },
{ 86 , 85 },
{ 86 , 87 },
{ 87 , 85 },
{ 87 , 83 },
{ 14 , 88 },
{ 88 , 48 },
{ 88 , 86 },
{ 88 , 89 },
{ 89 , 86 },
{ 89 , 87 },
{ 51 , 88 },
{ 53 , 90 },
{ 90 , 51 },
{ 90 , 88 },
{ 90 , 89 },};
color[] colours = new color[edges.length]; // array with colour value of every edge
int redLevel = 0;
int greenLevel = 0;
int blueLevel = 0;
// CHANGE WINDOW SIZE HERE //
int x = 640; // width of window
int y = 340; // height of window
////////////////////////////////
float scaleFactor = 11; // inital SF
int transX = x/2; // middle
int transY = y/2;
int transZ = 0;
color bgColour = color(200);
float xmag, ymag = 0;
float newXmag, newYmag = 0;
PFont ISOfont;
/*
TODO:
make arrays of edges that represent things like:
- arcs
- rings
- triangles
- hexigans
e.g
int[] bottomRing = {1,7,12,144,134,16,2,8,9,10,17,18,99,155,200,201,210,250,245,243}; //there are 20 edges on the bottom row of the dome
you can change the whole ring with:
setColour(bottomRing, green);
MORE TODO:
-make keys to jump to different views.
-lots of lovely functions that do cool shit
*/
void setup(){
size(x, y, P3D);
dome();
}
color red = color(255, 0, 0);
color green = color(0, 255, 0);
color blue = color(0, 0, 255);
void draw(){
setColour(1, red);
setColour(2, green);
setColour(3, blue);
if(mousePressed) {
newXmag = mouseX/float(width) * TWO_PI;
newYmag = mouseY/float(height) * TWO_PI;
float diff = xmag-newXmag;
if (abs(diff) > 0.01) { xmag -= diff/4.0; }
diff = ymag-newYmag;
if (abs(diff) > 0.01) { ymag -= diff/4.0; }
dome();
}
}
void setColour(int selected, color colour){ // set colour of one edge
colours[selected] = colour;
}
void setColour(int[] selected, color colour){ // set colour of a set of edges
for (int i=0;i<selected.length;i++){
colours[selected[i]] = colour;
}
}
void points(float scaleFactoror,int transX,int transY,int transZ){
for (int i=0;i<verticies.length;i++){
point( (verticies[i][0]*scaleFactoror)+transX , (verticies[i][1]*scaleFactoror)+transY , (verticies[i][2]*scaleFactoror)+transZ );
}
}
void dome(){ // draw the dome
background(bgColour);
translate(transX, transY, transZ);
rotateX(-ymag);
rotateY(-xmag);
scale(scaleFactor, scaleFactor, scaleFactor);
beginShape(LINES);
for (int i=0;i<edges.length;i++){
stroke(colours[i]);
vertex( verticies[edges[i][0]][0] , verticies[edges[i][0]][1] , verticies[edges[i][0]][2]);
vertex( verticies[edges[i][1]][0] , verticies[edges[i][1]][1] , verticies[edges[i][1]][2]);
}
endShape();
}
void keyPressed(){
if(key == '='){ //zoom in
scaleFactor += 0.2;
dome();
}
if(key == '-'){ //zoom out
scaleFactor -= 0.2;
dome();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment