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; 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*3][4]; void setup() { size(600, 400, OPENGL); framerate(30); eyeRotation = PI/3; eyeX = sin(eyeRotation)*100; eyeY = cos(eyeRotation)*100; generateNodes(); generateConnections(); //noFill(); setCamera(); } void draw() { background(100); calcForces(); stroke(200); drawNodes(); stroke(100); drawConnections(); if(keyPressed) { if(key == 'r' || key == 'R') { randomForces(); } } } // generate data *********************************************************************************** void generateNodes() { float x = -60; float y = -70; float z = 0.0; for (int i=0; i50) && (x%2==0) ) { x = -63; y += sqrt(27); } else if (x>50){ x = -60; y += sqrt(27); } 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; idefaultDistance) { iterate(a, b, speed); iterate(b, a, speed); } } void calcForces(){ for (int j=0; j