I get an 'Invalid memory access of location' error with even the most basic sketch using both. But I haven't found any other evidence of this on teh interwebs, so maybe someone can help me out.
import processing.serial.*;
import processing.opengl.*;
Serial myPort; // the serial port
void setup() {
size(1000,750,OPENGL);
background(255);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
}
void draw() {
}
void serialEvent(Serial myPort) {
background(255);
println("serial");
}
Changing the OPENGL to P3D allows the sketch to run fine. Thanks in advance for any help.
Note: this is really just an implementation of the quickhull3d package from John Lloyd, with a few minor tweaks. Much props to Mr. Lloyd for the heavy lifting.
A simple example below:
/* Simple NewHull Library Example
* by Ben Leduc-Mills
* 2.02.11
*/
import newhull.*;
QuickHull3D hull = new QuickHull3D(); //init quickhull
My problem is that I'm dealing with a dynamically changing set of points, anywhere from 0 to 64 (they correspond to coordinates from switches coming in serially from arduino) - I adapted the quickhull3d library that the Mesh lib is based on - and it works great as long as the points form a shape with a convex hull (not colinear, coincident, or coplanar) - otherwise it throws an illegal argument exception that crashes the sketch.
So, I'm wondering if there's a way to create a 3d mesh that can gracefully degrade into lines or 2d planes, or if someone can give me some pointers as to how to change the illegal argument exceptions in Java into something I can write a check method to that won't crash the program. I looked at toxiclibs, but I didn't see a way to get a mesh just through an array of points (without having faces or triangles first).
Here's version of the code that doesn't use serial input, I just use to test the software:
/* UCube v.0x2
* 3d modeling input device and stl export
* No Serial communication, used for software feature building
* by Ben Leduc-Mills
*/
import controlP5.*;
import unlekker.util.*;
import unlekker.geom.*;
import unlekker.data.*;
import ec.util.*;
import quickhull3d.*;
//import processing.serial.*;
//Serial myPort; // the serial port
ControlP5 controlP5;
PFont myFont; //init font for text
STL stl; //init STL object
FaceList poly; //FaceList object for .stl import
QuickHull3D hull = new QuickHull3D(); //init quickhull
Point3d[] points; //init Point3d array
float rotX, rotY; //for manual roatation
int gridSize = 4; //size of grid (assumes all dimensions are equal)
int spacing = 50; //distance between points
int counter = 0; //wireframe toggle
String inString; //string of coordinates from arduino
void setup() {
// String[] fontList = PFont.list();
// println(fontList);
controlP5 = new ControlP5(this);
controlP5.addButton("Refresh",0,100,100,80,19);
controlP5.addButton("Mode", 0,100,120,80,19);
controlP5.addButton("Export", 0,100,140,80,19);
controlP5.addButton("Import", 0,100,160,80,19);
myFont = createFont("FFScala", 32);
textFont(myFont);
size(1000, 750, P3D);
// println(Serial.list()); // list available serial ports
// myPort = new Serial(this, Serial.list()[0], 9600);
// myPort.bufferUntil(' ');
background(255); //set initial background color (just looks nicer on startup)