Lower the bar for mouse movement on the photo renderer.

Map X & Y to view alt & az. It gimble locks, it inverts when you are
upside down, but it actually mostly works.
This commit is contained in:
bkuker 2014-01-11 17:22:48 -05:00
parent 007f760782
commit f4cc2f6382
3 changed files with 7 additions and 51 deletions

View File

@ -76,7 +76,6 @@ public class PhotoPanel extends JPanel implements GLEventListener {
private RocketRenderer rr;
private PhotoSettings p;
private Trackball trackball = new Trackball();
void setDoc(final OpenRocketDocument doc) {
((GLAutoDrawable) canvas).invoke(false, new GLRunnable() {
@ -204,21 +203,14 @@ public class PhotoPanel extends JPanel implements GLEventListener {
final double y1 = (2 * lastY - height) / height;
final double x2 = (width - 2 * e.getX()) / width;
final double y2 = (2 * e.getY() - height) / height;
trackball.swipe(x1, y1, x2, y2, p.getViewAz(), p.getViewAlt());
p.setPitchYawRoll(trackball.getPitch(), trackball.getYaw(), trackball.getRoll());
p.setViewAltAz(p.getViewAlt() - (y1-y2), p.getViewAz() + (x1-x2));
lastX = e.getX();
lastY = e.getY();
}
};
p.addChangeListener(new StateChangeListener() {
@Override
public void stateChanged(EventObject e) {
trackball.setPitchYawRoll(p.getPitch(), p.getYaw(), p.getRoll());
}
});
canvas.addMouseMotionListener(a);
canvas.addMouseListener(a);
}

View File

@ -86,6 +86,11 @@ public class PhotoSettings extends AbstractChangeSource implements FlameSettings
return viewAlt;
}
public void setViewAltAz(double viewAlt, double viewAz){
this.viewAz = viewAz;
this.viewAlt = viewAlt;
fireChangeEvent();
}
public void setViewAlt(double viewAlt) {
this.viewAlt = viewAlt;
fireChangeEvent();

View File

@ -1,41 +0,0 @@
package net.sf.openrocket.gui.figure3d.photo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Trackball {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(Trackball.class);
private double pitch, yaw, roll;
public Trackball() {
}
public void setPitchYawRoll(final double pitch, final double yaw, final double roll) {
this.pitch = pitch;
this.yaw = yaw;
this.roll = roll;
}
public double getPitch() {
return pitch;
}
public double getYaw() {
return yaw;
}
public double getRoll() {
return roll;
}
public void swipe
(final double p1x, final double p1y, final double p2x, final double p2y, final double vAz, final double vAlt) {
}
}