org.deegree.rendering.r3d.opengl.display
Class TrackBall
java.lang.Object
java.awt.event.MouseAdapter
org.deegree.rendering.r3d.opengl.display.TrackBall
- All Implemented Interfaces:
- MouseListener, MouseMotionListener, MouseWheelListener, EventListener
public class TrackBall
- extends MouseAdapter
The TrackBall
pretends that a ball encloses the 3d view. You roll this ball with the mouse. For example,
if you click on the center of the ball and move the ball directly right, you rotate around y. Click on edge of ball
and roll to get a z rotation.
The idea isn't too hard. Start with a vector from the first mouse click to the center of the 3d view. Set the radius
of the ball to the smaller dimension of the 3d view. As you drag around, a second vector is determined from the
surface to center of the ball. Axis of rotation is cross-product of those two vectors, and the angle is the angle
between the vectors.
This class was copied from a cpp file I once used in my Computer Graphic classes. I don't know who the original
author was, but since I only created the java representation of the working code, I would like to thank him/her.
- Version:
- $Revision: 29127 $, $Date: 2011-01-10 16:13:35 +0100 (Mon, 10 Jan 2011) $
- Author:
- Rutger Bezema, last edited by: $Author: aschmitz $
Constructor Summary |
TrackBall()
Set the rotation matrices to the initial state (0,1,0,0) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TrackBall
public TrackBall()
- Set the rotation matrices to the initial state (0,1,0,0)
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressed
in interface MouseListener
- Overrides:
mousePressed
in class MouseAdapter
mouseWheelMoved
public void mouseWheelMoved(MouseWheelEvent e)
- Specified by:
mouseWheelMoved
in interface MouseWheelListener
- Overrides:
mouseWheelMoved
in class MouseAdapter
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleased
in interface MouseListener
- Overrides:
mouseReleased
in class MouseAdapter
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDragged
in interface MouseMotionListener
- Overrides:
mouseDragged
in class MouseAdapter
multModelMatrix
public void multModelMatrix(javax.media.opengl.GL context,
float[] worldTranslation)
- Multiply the rotation vectors on top of the current context, the multiplication also uses the translation
- Parameters:
context
- to multiply the rotations upon.worldTranslation
- a float[3] which contains a translation vector (normally the center of the scene ), if null or length
!= 3 no translation will be done.
reset
public void reset()
- Reset the rotation vectors
Copyright © 2011. All Rights Reserved.