import processing.opengl.*; // // viewport float eyeX; float eyeY; float eyeZ = -100.0; float eyeDragX; float eyeDragY; float eyeDragZ; float eyeDragRotation; float eyeRotation; int mouseDragX; int mouseDragY; int cycle = 10; boolean dragFlag = false; int nodeAmount = 600; // nodes array: x,y,z,force float[][] nodes = new float[nodeAmount][4]; // nodesFixed array: x,y,z float[][] nodesFixed = new float[nodeAmount][3]; // nodesTarget array: xtaret,ytarget,ztarget float[][] nodesTarget = new float[nodeAmount][3]; // connections array: node1, node2, orginaldistance float[][] connections = new float[nodeAmount*5][4]; void setup() { size(600, 400, OPENGL); colorMode(HSB, 100); framerate(30); eyeRotation = PI/3; eyeX = sin(eyeRotation)*100; eyeY = cos(eyeRotation)*100; generateNodes(); generateConnections(); //noFill(); setCamera(); } void draw() { background(0,0,50); calcForces(); drawNodes(); drawConnections(); if(keyPressed) { if(key == 'r' || key == 'R') { randomForces(); } if(key == 's' || key == 'S') { resetForces(); } if(key == 'c' || key == 'C') { cycleForces(); } } } // generate data *********************************************************************************** void generateNodes() { float x = -60; float y = -70; float z = 0; for (int i=0; i0) && (x%2==0) ) { x = -63; y += sqrt(27); } else if (x>0){ x = -60; y += sqrt(27); } if ((y > -20) && ((z/sqrt(27))%2==0) ){ y = -73; z -= sqrt(27); } if ((y > -20) && ((z/sqrt(27))%2!=0) ){ y = -70; z -= sqrt(27); } //z = 0; nodes[i][0] = x; nodes[i][1] = y; nodes[i][2] = z; // and force nodes[i][3] = 0; //nodes[i][3] = random(200)-100; // store initial position nodesFixed[i][0] = x; nodesFixed[i][1] = y; nodesFixed[i][2] = z; // store targets nodesTarget[i][0] = x; nodesTarget[i][1] = y; nodesTarget[i][2] = z; } } void randomForces(){ for (int i=0; i= nodeAmount-1){ cycle = 10; } } // data for all connected nodes, with their original distance stored void generateConnections() { int connectionCounter = 0; for (int nodei=0; nodeidefaultDistance) { iterate(a, b, speed); iterate(b, a, speed); } } void calcForces(){ for (int j=0; j