The resolved processing sketch is outlined below. I have annotated it well so it can be followed. Important information is highlighted in blue. I am unable to post this to open processing for to reasons; it contains librarys and more importantly the version of Processing 3.0 that I used is not compatible with the javascript plugin. I will document the sketch working in final presentation.
import wblut.math.*;
import wblut.processing.*;
import wblut.core.*;
import wblut.hemesh.*;
import wblut.geom.*;
import processing.serial.*;
HE_Mesh mesh, copymesh; //mesh is the sphere, copymesh is when it is 'broken'
WB_Render render;
int baud = 14400; //baud set, make sure is the same as arduino
int lf = 10; // linefeed in ASCII
String myString = null;
Serial myPort; // serial port that is being used
float num;
//easing
float y;
float easing = 0.01; // speed at which the mesh returns to a sphere, higher is faster
//rotation, left as three values for if needs to be chnged later
float a = 0.0;
float b = 0.0;
float c = 0.0;
void setup() {
//fullScreen(OPENGL); // screen fill window
size(800, 800, OPENGL); //for testing
surface.setResizable(true); //fits the window to the screen size
noCursor(); //hides the cursor when it is over the window
myPort = new Serial(this, Serial.list()[0], baud); //port number [0] and baud rate set
myPort.clear();
HEC_Sphere creator=new HEC_Sphere(); // sphere created
creator.setRadius(100); //radius of sphere
creator.setUFacets(64); //complexity of sphere
creator.setVFacets(64);
mesh=new HE_Mesh(creator);
HET_Diagnosis.validate(mesh);
stroke(255,255,255); // stroke colour and weight if wireframe renderer is applicable
strokeWeight(0.5);
render=new WB_Render(this); //render!
}
void draw() {
background(0,0,0,0); //background colour, set to all black as not to show on projector
//light movement
b += 0.001;
c = sin(b)*5; // sin causes swing effect is light movement
directionalLight(255, 255, 255, c, c, -1); // all white light, movement on x and y axises
//directionalLight(127, 127, 127, 1, -1, 1); // secondary light
translate(width/2,height/2, 0); //light centred to window
//rotation of mesh
a += 0.001; // rotation speed
if(a > TWO_PI) { //two pi indicates a full rotaion
a = 0.0; //return to zero after completing a rotation
}
//readings sent from arduino from sensor
while (myPort.available() > 0) {
myString = myPort.readStringUntil(lf);
if (myString != null) {
print(myString); // prints string
num=float(myString); // converts and prints float
println(num);
}
}
myPort.clear();
rotateY(a); //option to rotate starting position of mesh
rotateX(-a);
HEM_Noise modifier=new HEM_Noise(); // noise modifier causes breaking effect
copymesh=mesh.get(); //mesh copied from sphere
float targetY = ((num-10)*4);
float dy = targetY - y; //easing applied
y += dy * easing;
modifier.setDistance(constrain((-y)+350,0,350)); // min/max distance set for sensor in relation to sphere size
//values reversed by (-y)+350
modifier.setSeed(100);
copymesh.modify(modifier);
//HEM_Wireframe wireframe=new HEM_Wireframe(); // option to apply wireframe render
//appearance
fill(255); //mesh white, i don't like colour ;)
noStroke(); // stroke removed
render.drawFaces(copymesh);
//render.drawEdges(copymesh); // for wireframe
/* println(mouseY);
delay(100); */
}