Save/Load JSON based Cameras in Proscene

edited June 2016 in Library Questions

^ that's a link to my code

Someone else was apparently able to save/load cameras in proscene from a file:

But I'm having trouble implementing their code. I have a feeling it's a basic problem that I just don't understand. When I run this:


//this is how you save the camera, theoretically;
//save a Proscene scene current camera settings in as a JSON string in a file
void saveCamera(Scene scene, String fileName ) { json = new JSONObject();
  json.setFloat("fov", );  
  setVector(json, "position", );
  setVector(json, "viewdirection", );
  setVector(json, "upvector", );
  saveJSONObject(json, fileName);
//Add a PVector as a string representation of a float array to a JSON object
void setVector(JSONObject json, String attributeName, Vec v) {
  json.setString( attributeName, Arrays.toString( new float[]{ v.x, v.y, v.z} ) );

//#####this is how you load the camera, theoretically;
void loadCamera(Scene scene, String fileName) {
  JSONObject json = loadJSONObject(fileName); json.getFloat("fov") ); getVector(json, "upvector") ); getVector(json, "viewdirection") ); getVector(json, "position") );
//Parse a PVector from its string representation as an array of float in a JSON object
PVector getVector(JSONObject json, String attributeName) {
  String o =  json.getString(attributeName);
  String[] arr = o.substring(1, o.length()-1).split(", ");
  float[] f = new float[arr.length];
  int i = 0;
  for (String s : arr) {
    f[i] = Float.parseFloat(s);
  return new PVector(f[0], f[1], f[2]);

"Arrays" isn't pointing to anything, and I'm not sure what to do about it?


Sign In or Register to comment.