jdf / peasycam

Dead-simple mouse-driven camera for Processing
http://MrFeinberg.com/peasycam/
Apache License 2.0
116 stars 35 forks source link

fields of CameraState object are not visible #20

Closed kroko closed 7 years ago

kroko commented 9 years ago

hello,

i was previously using code below to save and load camera states. i really do not remember where i got peasy from (git, zip download), imho it was repacked to get rid of that version warning (console says it's PeasyCam v2.0.0+, jar is built on 04.06.13)

my specs

java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

OS X 10.7.5

anyways, here's code i'm using


import peasy.*;
import java.io.Serializable;
import peasy.org.apache.commons.math.geometry.*;
//import peasy.org.apache.commons.math.geometry.Rotation;
//import peasy.org.apache.commons.math.geometry.RotationOrder;
//import peasy.org.apache.commons.math.geometry.Vector3D;

PeasyCam cam;

// init as usual
cam = new PeasyCam(this, 600);

// i am setting and saving camera states as follows

public void cameraStateSave() {
  CameraState state = cam.getState(); // get a serializable settings object for current state

  // i used (saved) these variables from the camera state
  state.distance;

  state.rotation.getQ0();
  state.rotation.getQ1();
  state.rotation.getQ2();
  state.rotation.getQ3();

  state.center.getX();
  state.center.getY();
  state.center.getZ();
}

public void cameraStateLoad(int animMillis) {

  double inZoom = savedVal;

  double[] inQ = new double[4];
  inQ[0] = savedVal;
  inQ[1] = savedVal;
  inQ[2] = savedVal;
  inQ[3] = savedVal;

  Rotation inRotation = new Rotation(inQ[0], inQ[1], inQ[2], inQ[3], false); 

  double[] inCoord = new double[3];
  inCoord[0] = savedVal;
  inCoord[1] = savedVal;
  inCoord[2] = savedVal;

  Vector3D inVector3D = new Vector3D(inCoord[0], inCoord[1], inCoord[2]);

  CameraState newState = new CameraState(
  inRotation, 
  inVector3D, 
  inZoom);

  cam.setState(newState, animMillis);
}

after upgrading to peasycam_201 i get error

the field CameraState.distance is not visible

before digging deeper

or rewriting this to use getRotations(), setRotations(), getDistance(), setDistance() …although while there is getPosition(), don't see any method for setPosition() so imho it is not possible with this approach

i wanted to ask - has there been any changes lately in how CameraState is retrieved and set?

thanks you for the great lib!

jdf commented 9 years ago

Why not just use getState()?