Scroll Camera Works
This commit is contained in:
parent
3fe3b481d8
commit
41fc399f70
@ -9,7 +9,7 @@ public class Main {
|
||||
|
||||
MainFrame frame = new MainFrame();
|
||||
frame.setVisible(true);
|
||||
//SwingGLCanvas canvas = new SwingGLCanvas();
|
||||
SwingGLCanvas canvas = new SwingGLCanvas();
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,6 @@ public class DrawHelper {
|
||||
gl.glRasterPos3f(canvas.camera[0], canvas.camera[1], canvas.camera[2] - 1);
|
||||
gl.glColor3f(1f,1f, 1f);
|
||||
glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18,
|
||||
"x=" + canvas.camera[0] + ", y=" + canvas.camera[1] + ", z=" + canvas.camera[2]);
|
||||
"x=" + canvas.camera[0] + ", y=" + canvas.camera[1] + ", z=" + canvas.camera[2]+"\n yaw = " + canvas.camera[3] + " pitch = " + canvas.camera[4] + " roll = " + canvas.camera[5]);
|
||||
}
|
||||
}
|
||||
|
@ -75,9 +75,19 @@ public class JoglMouseListener implements MouseListener, MouseMotionListener, Mo
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
canvas.camera[0] += e.getWheelRotation() * 0.25 * canvas.camera[3];
|
||||
canvas.camera[1] += e.getWheelRotation() * 0.25 * canvas.camera[4];
|
||||
if( 45 > Math.abs(canvas.camera[3]))
|
||||
canvas.camera[0] += e.getWheelRotation()*Math.tan(Math.toRadians(-canvas.camera[3]))*0.25;
|
||||
else
|
||||
canvas.camera[0] += e.getWheelRotation()*Math.tan(Math.toRadians(canvas.camera[3]))*0.25;
|
||||
if(45>Math.abs(canvas.camera[4]))
|
||||
canvas.camera[1] += e.getWheelRotation()*Math.tan(Math.toRadians(canvas.camera[4]))*0.25;
|
||||
else
|
||||
canvas.camera[1] += e.getWheelRotation()*Math.tan(Math.toRadians(-canvas.camera[4]))*0.25;
|
||||
|
||||
if( 45 < Math.abs(canvas.camera[3]) || 45<Math.abs(canvas.camera[4]))
|
||||
canvas.camera[2] += -e.getWheelRotation()*0.25;
|
||||
else
|
||||
canvas.camera[2] += e.getWheelRotation()*0.25;
|
||||
|
||||
canvas.camera[2] += Math.sin(e.getWheelRotation() + Math.PI / 2) * 0.25;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user