Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6631/src/net/sourceforge/bprocessor/gl/tool
Added Files:
CameraFlyTool.java
Log Message:
Not done yet so aint in the gui...
--- NEW FILE: CameraFlyTool.java ---
//---------------------------------------------------------------------------------
// $Id: CameraFlyTool.java,v 1.1 2005/12/13 12:52:06 rimestad Exp $
//
// Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net)
// Released under the Lesser GNU Public License v2.1
//---------------------------------------------------------------------------------
package net.sourceforge.bprocessor.gl.tool;
import net.sourceforge.bprocessor.gl.GLView;
import net.sourceforge.bprocessor.model.Camera;
//import java.awt.event.KeyEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.Cursor;
import org.apache.log4j.Logger;
/**
* The camera fly tool
*/
public class CameraFlyTool extends AbstractTool {
/** The logger */
private static Logger log = Logger.getLogger(CameraFlyTool.class);
/**
* Constructor
* @param glv The 3D canvas
* @param cursor the cursor
*/
public CameraFlyTool(GLView glv, Cursor cursor) {
super(glv, cursor);
}
/**
* Invoked when the mouse cursor has been moved
* @param e The MouseEvent object
*/
protected void moved(MouseEvent e) {
Camera c = glv.getView().getCamera();
double angleX = ((double)(e.getX() - previousPos[0]) / 360) * Math.PI;
double angleY = ((double)(e.getY() - previousPos[1]) / 360) * Math.PI;
Camera.rotateHorizontallyEye(c, angleX);
Camera.rotateVerticallyEye(c, angleY);
}
/**
* Invoked when the mouse is held pressed and moved
* @param e The MouseEvent object
*/
protected void dragged(MouseEvent e) {
}
/**
* Invoked when a mouse button has been pressed on a component.
* @param e The MouseEvent object
*/
protected void pressed(MouseEvent e) {
}
/**
* Invoked when a mouse button has been released on a component.
* @param e The MouseEvent
*/
protected void released(MouseEvent e) {
}
/**
* Invoked when a key has been pressed. Lets user control the speed
* and mode of movement.
* @param e The KeyEvent
*/
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
// move forward
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
// move backward
} else {
super.keyPressed(e);
}
glv.repaint(true);
}
}
|