Hello! Wondering if anyone is knowledgeable around using nervoussystem library for obj export from Processing. I used it on one file and it worked - now trying it on a different file and it’s creating the obj, says there are __bites (usually 75-150 bites), but the file seems corrupt and won’t open in other applications. Thinking I’m putting the if (record) lines in incorrect spot, but I tried other places and can’t seem to find one that works.
Here’s my code below – sorry for the messiness as I’m a new coder.
Thanks in advance, kirstee_baxt
import nervoussystem.obj.*;
import peasy.*;
Table myTable;
String table_fn="data/data-test.csv";
int numEntries;
float time, radius, day;
boolean diagp = true;
PShape[] myShapes;
PeasyCam cam;
//for export
boolean record = false;
String filename = "Data_TypeA_"+month()+day()+hour()+minute()+".obj";
void setup(){
size(800, 800, P3D);
myTable = loadTable(table_fn, "header");
if (diagp) println("load file: "+table_fn);
numEntries = myTable.getRowCount();
make_shapes();
cam = new PeasyCam(this,1000);
}
void make_shapes(){
noFill();
int startday = myTable.getRow(0).getInt("Day");
int endday = myTable.getRow(numEntries-1).getInt("Day");
int days = endday - startday+1;
if (diagp) println("start day "+startday+" endday "+endday+" days "+days);
myShapes = new PShape[days];
int k = 0;
for ( int goday = startday; goday <= endday; goday++ ) { // group shapes per day
myShapes[k] = createShape();
println("make shape "+k);
myShapes[k].beginShape();
for (int i = 0; i < numEntries; i++) {
time = myTable.getRow(i).getFloat("Time Decimal");
radius = myTable.getRow(i).getFloat("Productivity Level");
day = myTable.getRow(i).getFloat("Day");
//time is x, radius is y, day is z
if ( day == goday ) {
if (diagp) println("#:i "+i+" x", time+" time decimal ", radius +" productivity ", day +"day");
float angle = map(time, 0, 1, 0, TWO_PI);
float xCenter = width/20;
float yCenter = height/20;
float xCoord = xCenter + cos(angle-(TWO_PI/4)) * (radius*3);
float yCoord = yCenter + sin(angle-(TWO_PI/4)) * (radius*3);
float zCoord = (day * 80); //multiplier is random for separation
myShapes[k].vertex(xCoord, yCoord, zCoord);
}
}
myShapes[k].endShape();
k++;
}
}
void draw() {
//background(135); //removed because creates plane with obj export
if (record) {
beginRecord("nervoussystem.obj.OBJExport", filename);
}
for ( int k = 0 ; k < myShapes.length; k++ ) {
shape(myShapes[k]);
endShape();
}
if (record) {
endRecord();
record = false;
}
}
void keyPressed() {
if (key == 's') {
record = true;
}
}