diff options
author | Michael Bien <[email protected]> | 2010-04-12 22:27:03 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-04-12 22:27:03 +0200 |
commit | 2c85c416d85205ab98b33e1a0b0daab32d4d81ff (patch) | |
tree | 4187ba06dec81da46495a300bb4f914e931f0c58 /src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java | |
parent | b51f2e1c254cdd74c9e43904c62694f64e6ae7e6 (diff) |
changes due to package renaming in jocl.
Diffstat (limited to 'src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java')
-rw-r--r-- | src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java b/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java deleted file mode 100644 index bec2d28..0000000 --- a/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.mbien.opencl.demos.joglinterop; - -import java.awt.Component; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; -import javax.media.opengl.GL2; - -/** - * Utility class for interacting with a scene. Supports rotation and zoom around origin. - * @author Michael Bien - */ -public class UserSceneInteraction { - - private float z = -20; - private float rotx = 45; - private float roty = 30; - - private Point dragstart; - private enum MOUSE_MODE { DRAG_ROTATE, DRAG_ZOOM } - private MOUSE_MODE dragmode = MOUSE_MODE.DRAG_ROTATE; - - - public void init(Component component) { - initMouseListeners(component); - } - - private void initMouseListeners(Component component) { - component.addMouseMotionListener(new MouseMotionAdapter() { - - @Override - public void mouseDragged(MouseEvent e) { - - if (dragstart != null) { - switch (dragmode) { - case DRAG_ROTATE: - rotx += e.getY() - dragstart.getY(); - roty += e.getX() - dragstart.getX(); - break; - case DRAG_ZOOM: - z += (e.getY() - dragstart.getY()) / 5.0f; - break; - } - } - - dragstart = e.getPoint(); - } - }); - component.addMouseWheelListener(new MouseWheelListener() { - - public void mouseWheelMoved(MouseWheelEvent e) { - z += e.getWheelRotation()*5; - } - - }); - component.addMouseListener(new MouseAdapter() { - - @Override - public void mousePressed(MouseEvent e) { - switch (e.getButton()) { - case (MouseEvent.BUTTON1): - dragmode = MOUSE_MODE.DRAG_ROTATE; - break; - case (MouseEvent.BUTTON2): - dragmode = MOUSE_MODE.DRAG_ZOOM; - break; - case (MouseEvent.BUTTON3): - dragmode = MOUSE_MODE.DRAG_ZOOM; - break; - } - } - - @Override - public void mouseReleased(MouseEvent e) { - switch (e.getButton()) { - case (MouseEvent.BUTTON1): - dragmode = MOUSE_MODE.DRAG_ZOOM; - break; - case (MouseEvent.BUTTON2): - dragmode = MOUSE_MODE.DRAG_ROTATE; - break; - case (MouseEvent.BUTTON3): - dragmode = MOUSE_MODE.DRAG_ROTATE; - break; - } - - dragstart = null; - } - }); - } - - - public void interact(GL2 gl) { - gl.glTranslatef(0, 0, z); - gl.glRotatef(rotx, 1f, 0f, 0f); - gl.glRotatef(roty, 0f, 1.0f, 0f); - } - - -}
\ No newline at end of file |