// Ira Greenberg // Reading Freedom, ver .01 int chapterCount = 9; int articleCount = 115; int artChapRatio = articleCount/(chapterCount-1); float helixRadius = 300.0; float partRadius = 35.0; Icosahedron[] articles = new Icosahedron[articleCount]; int[] partCount = { 0, 2, 4, 1, 1, 1, 1, 1, 1, 3, 1, 2, 3, 1, 2, 1, 2, 2, 2, 2, 3, 3, 1, 1, 2, 3, 1, 7, 1,5, 1, 2, 2, 2, 1, 5, 4, 6, 1, 2, 2, 4, 1, 2, 2, 13, 3, 1, 3, 4, 1, 5, 2, 1, 2, 2, 3, 1, 1, 2, 8, 2, 1, 1, 13, 2, 3, 1, 2, 5, 2, 1, 1, 2, 3, 1, 1, 2, 2, 1, 3, 2, 1, 3, 1, 3, 3, 3, 18, 2, 3, 1, 2, 1, 2, 2, 2, 2, 3, 2, 1, 3, 4, 2, 1, 3, 1, 4, 2, 1, 1, 1, 1, 3, 1 }; Cube[][] parts = new Cube[articleCount][18]; Vector3D[] articleLoc = new Vector3D[articleCount]; Vector3D[][] partLoc = new Vector3D[articleCount][18]; color[] chapterColors = { #EEEEEE, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #FF0000, #00FFFF, #00FFFF, #00FFFF, #00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF,#00FFFF, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FFFF00, #FF6600, #FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600,#FF6600, #55FF11, #0011FF, #FF00FF, #FF00FF,#FF00FF,#FF00FF,#FF00FF,#FF00FF,#FF00FF, #0000FF, #0000FF,#0000FF,#0000FF,#0000FF,#0000FF,#0000FF,#0000FF}; color[] mainNodeColors = new color[articleCount]; color[] partNodeColors = new color[articleCount]; float nodeCounter=0; float partCounter=0; int colConter = 0; // controls rotating boolean isRotateSafe = false; float rotX, rotY; float posX1, posY1; float posX2, posY2; float damping = .95; // controls dragging boolean isDragSafe = false; float nodePosX1, nodePosY1; float nodePosX2, nodePosY2; int nodeID; Tendril tendril; float buildRate = .1; void setup(){ size(800, 600, P3D); // instantiate main article cubes for (int i=0; iarticleCount-1){ posY1 *= damping; posX1 *= damping; } rotY += posX1; rotX += -posY1; rotateY(radians(rotY)); rotateX(radians(rotX)); // custom rotation //rotate_z(radians(rotY)); // update mx2, my2 to current mouse position posY2 = mouseY; posX2 = mouseX; drawTethers(); // nodeCounter = 0; drawNodes(); // checkMouseEvents(); } void drawTethers(){ // connecting parts fill(175, 175, 235); tendril.create(IGConsts.RENDER_SKIN_DYNAMIC, .1); noFill(); for (int i=0; i screenX(articles[i].x, articles[i].y, articles[i].z)-articles[i].radius && mouseX < screenX(articles[i].x, articles[i].y, articles[i].z)+articles[i].radius && mouseY > screenY(articles[i].x, articles[i].y, articles[i].z)-articles[i].radius && mouseY < screenY(articles[i].x, articles[i].y, articles[i].z)+articles[i].radius){ isRotateSafe = false; // highlight node pushMatrix(); translate(articles[i].x, articles[i].y, articles[i].z); //lights(); fill(255, 190, 190); new Icosahedron(14).create(); popMatrix(); } } } void mouseReleased(){ isRotateSafe = false; isDragSafe = false; } void mousePressed(){ for (int i=0; i screenX(articles[i].x, articles[i].y, articles[i].z)-articles[i].radius && mouseX < screenX(articles[i].x, articles[i].y, articles[i].z)+articles[i].radius && mouseY > screenY(articles[i].x, articles[i].y, articles[i].z)-articles[i].radius && mouseY < screenY(articles[i].x, articles[i].y, articles[i].z)+articles[i].radius){ nodePosX1 = mouseX; nodePosY1 = mouseY; isDragSafe = true; nodeID = i; } } isRotateSafe = true; posX2 = mouseX; posY2 = mouseY; } // custom rotations void rotate_z(float theta){ // println(theta); float tx=0, ty=0, tz=0; for (int i=0; i< articles.length; i++){ // top point tx = cos(theta)*articleLoc[i].x-sin(theta)*articleLoc[i].y; ty = sin(theta)*articleLoc[i].x+cos(theta)*articleLoc[i].y; articleLoc[i].x = tx; articleLoc[i].y = ty; calculateSubNodesLoc(); } } // HERE void setSpring(int id, float delta){ for (int i=0; i