[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef3d-commits] r577 - in trunk: org.eclipse.draw3d/META-INF org.eclipse.draw3d/src/java/org/eclipse/draw3d org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking org.eclipse.draw3d/src/java/org/eclipse/draw3d/picking org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/camera org.eclipse.gef3d/src/java/org/eclipse/gef3d/tools

Author: jvonpilgrim
Date: 2011-05-23 09:32:06 -0400 (Mon, 23 May 2011)
New Revision: 577

Added:
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCameraPosition.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraPosition.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICameraPosition.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/AbstractStartEndMove.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ComposedMove.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ICameraMove.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMove.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMovement.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearRotation.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/MoveSeries.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/NoMove.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingShot.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingUtil.java
Modified:
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/camera/CameraInputHandler.java
   trunk/org.eclipse.draw3d/META-INF/MANIFEST.MF
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/AbstractSurface.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Locator1D.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCamera.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/FirstPersonCamera.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICamera.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/picking/GeometryPicker.java
   trunk/org.eclipse.gef3d/src/java/org/eclipse/gef3d/tools/CameraTool.java
Log:
Added camera trackings, see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=300319

Modified: trunk/org.eclipse.draw3d/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.eclipse.draw3d/META-INF/MANIFEST.MF	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/META-INF/MANIFEST.MF	2011-05-23 13:32:06 UTC (rev 577)
@@ -23,6 +23,7 @@
    org.eclipse.draw3d.shapes,
    org.eclipse.swt.widgets",
  org.eclipse.draw3d.camera;uses:="org.eclipse.draw3d.geometry",
+ org.eclipse.draw3d.camera.tracking,
  org.eclipse.draw3d.geometryext;uses:="org.eclipse.draw3d.geometry,org.eclipse.draw2d.geometry",
  org.eclipse.draw3d.graphics,
  org.eclipse.draw3d.graphics.optimizer,

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/AbstractSurface.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/AbstractSurface.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/AbstractSurface.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -41,7 +41,7 @@
 	private Vector3f[] m_cachedProjection;
 
 	/**
-	 * The surface normal.
+	 * The surface normal in world coordinates.
 	 */
 	private Vector3f m_normal = new Vector3fImpl();
 
@@ -51,6 +51,16 @@
 	private boolean m_normalValid = false;
 
 	/**
+	 * The up vector in world coordinates.
+	 */
+	private Vector3f m_upVector = new Vector3fImpl();
+
+	/**
+	 * Indicates whether the up vector is still valid.
+	 */
+	private boolean m_upVectorValid = false;
+
+	/**
 	 * The matrix that transforms a vector given in surface coordinates to world
 	 * coordinates.
 	 */
@@ -75,6 +85,18 @@
 	protected abstract void calculateNormal(Vector3f io_normal);
 
 	/**
+	 * Calculates the up vector of this surface. As the up vector is usually the
+	 * y-axis, this method calls {@link #getYAxis(Vector3f)} by default and
+	 * negates the result.
+	 * 
+	 * @param i_upVector
+	 */
+	protected void calculateUpVector(Vector3f o_upVector) {
+		getYAxis(o_upVector);
+		Math3D.negate(o_upVector, o_upVector);
+	}
+
+	/**
 	 * This method must be called whenever the surface coordinate system has
 	 * changed.
 	 */
@@ -83,6 +105,7 @@
 		m_surfaceToWorldValid = false;
 		m_worldToSurfaceValid = false;
 		m_normalValid = false;
+		m_upVectorValid = false;
 		m_cachedProjection = null;
 	}
 
@@ -102,6 +125,20 @@
 	}
 
 	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.ISurface#getUpVector()
+	 */
+	public IVector3f getUpVector() {
+		if (!m_upVectorValid) {
+			calculateUpVector(m_upVector);
+			m_upVectorValid = true;
+		}
+
+		return m_upVector;
+	}
+
+	/**
 	 * Returns the origin of this surface.
 	 * 
 	 * @param io_result the result vector, if <code>null</code>, a new vector

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -51,13 +51,23 @@
 	public IFigure3D getHost();
 
 	/**
-	 * Returns the normal vector of this surface.
+	 * Returns the normal vector of this surface in world coordinates.
 	 * 
 	 * @return the normal vector
 	 */
 	public IVector3f getNormal();
 
 	/**
+	 * Returns the up vector of this surface in world coordinates. The up vector
+	 * of a surface is similar to the up vector of a camera, much like the
+	 * (negated) normal vector corresponds to the normal vector of the camera.
+	 * Usually, the up vector is the normalized y-axis.
+	 * 
+	 * @return
+	 */
+	public IVector3f getUpVector();
+
+	/**
 	 * Returns the 2D surface coordinates of a point specified in world
 	 * coordinates.
 	 * 

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Locator1D.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Locator1D.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Locator1D.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -93,17 +93,17 @@
 		private float m_weight;
 
 		/**
-		 * Creates a new relative locator with the given weight. The weight
+		 * Creates a new relative locator with the given weights. The weights
 		 * specifies the relative offset between 0 and 1.
 		 * 
-		 * @param i_weight the weight, must be greater or equal to 0 and less or
+		 * @param i_weight the weights, must be greater or equal to 0 and less or
 		 *            equal to 1
 		 */
 		public Relative(float i_weight) {
 
 			if (i_weight < 0 || i_weight > 1)
 				throw new IllegalArgumentException(
-					"weight must be 0 <= weight <= 1, was " + i_weight);
+					"weights must be 0 <= weights <= 1, was " + i_weight);
 
 			m_weight = i_weight;
 		}

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -110,7 +110,7 @@
 
 			sLocation.setLocation(i_sx, i_sy);
 			currentSurface.getWorldLocation(sLocation, rayPoint);
-
+			
 			Hit hit = picker.getHit(rayPoint, i_search);
 			if (hit != null)
 				return hit.getSearchResult();

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCamera.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCamera.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCamera.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -81,4 +81,6 @@
 			i_newCamera.addCameraListener(listener);
 		}
 	}
+	
+	
 }

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCameraPosition.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCameraPosition.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCameraPosition.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera;
+
+import org.eclipse.draw3d.geometry.IVector3f;
+import org.eclipse.draw3d.geometry.Vector3f;
+
+/**
+ * AbstractCameraPosition There should really be more documentation here.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public abstract class AbstractCameraPosition implements ICameraPosition {
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getPosition()
+	 */
+	public IVector3f getPosition() {
+		return getPosition(null);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getViewDirection()
+	 */
+	public IVector3f getViewDirection() {
+		return getViewDirection(null);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getUpVector()
+	 */
+	public IVector3f getUpVector() {
+		return getUpVector(null);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getRightVector()
+	 */
+	public IVector3f getRightVector() {
+		return getRightVector(null);
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/AbstractCameraPosition.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraPosition.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraPosition.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraPosition.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera;
+
+import org.eclipse.draw3d.geometry.IVector3f;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Math3DCache;
+import org.eclipse.draw3d.geometry.Matrix4f;
+import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.geometry.Vector3fImpl;
+
+/**
+ * Value object storing information about camera position, view direction and up
+ * vector. These three values are stored in this object, other values such as
+ * right vector, are derived.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public class CameraPosition extends AbstractCameraPosition {
+
+	protected Vector3fImpl position;
+
+	protected Vector3fImpl viewDir;
+
+	protected Vector3fImpl upVector;
+
+	/**
+	 * 
+	 */
+	public CameraPosition() {
+		position = new Vector3fImpl();
+		viewDir = new Vector3fImpl();
+		upVector = new Vector3fImpl();
+
+		position.set(0, 0, -1000);
+		viewDir.set(ICamera.VIEW_REF);
+		upVector.set(ICamera.UP_REF);
+	}
+
+	public CameraPosition(ICameraPosition src) {
+		position = new Vector3fImpl();
+		viewDir = new Vector3fImpl();
+		upVector = new Vector3fImpl();
+		setCameraPosition(src);
+
+	}
+
+	/**
+	 * @param cameraPos, must not be null
+	 */
+	public void setCameraPosition(ICameraPosition cameraPos) {
+		if (cameraPos == null) // parameter precondition
+			throw new NullPointerException("cameraPos must not be null");
+
+		cameraPos.getPosition(position);
+		cameraPos.getViewDirection(viewDir);
+		cameraPos.getUpVector(upVector);
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getPosition()
+	 */
+	public IVector3f getPosition(Vector3f o_result) {
+		if (o_result!=null) {
+			o_result.set(position);
+		}
+		return position;
+	}
+
+	/**
+	 * @param i_position the position to set
+	 */
+	public void setPosition(IVector3f i_position) {
+		position.set(i_position);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getViewDirection()
+	 */
+	public IVector3f getViewDirection(Vector3f o_result) {
+		if (o_result!=null) {
+			o_result.set(viewDir);
+		}
+		return viewDir;
+	}
+
+	/**
+	 * Sets the viewing direction. The setter normalizes the vector, so clients
+	 * do not have to normalize the parameter.
+	 * 
+	 * @param i_viewDir the viewDir to set (not necessarily normalized)
+	 */
+	public void setViewDirection(IVector3f i_viewDir) {
+		Math3D.normalise(i_viewDir, viewDir);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.ICameraPosition#getUpVector()
+	 */
+	public IVector3f getUpVector(Vector3f o_result) {
+		if (o_result!=null) {
+			o_result.set(upVector);
+		}
+		return upVector;
+	}
+
+	/**
+	 * Sets the up vector. The setter normalizes the vector, so clients do not
+	 * have to normalize the parameter.
+	 * 
+	 * @param i_upVector the upVector to set (not necessarily normalized)
+	 */
+	public void setUpVector(IVector3f i_upVector) {
+		Math3D.normalise(i_upVector, upVector);
+	}
+
+	/**
+	 * Returns the right vector, which is a derived value computed from view
+	 * direction and up vector.
+	 * 
+	 * @param rightVector, stores the result, may be null
+	 * @return
+	 */
+	public IVector3f getRightVector(Vector3f rightVector) {
+		if (rightVector == null) {
+			rightVector = new Vector3fImpl();
+		}
+
+		Math3D.cross(viewDir, upVector, rightVector);
+		return rightVector;
+	}
+
+	/**
+	 * Look at the given position. This simply calculates the view direction by
+	 * subtracting the current position from the given to location, and
+	 * normalizing the result.
+	 * 
+	 * @param i_position the position to look at
+	 */
+	public void lookAt(IVector3f i_to) {
+		Math3D.sub(i_to, position, viewDir);
+		Math3D.normalise(viewDir, viewDir);
+	}
+
+	/**
+	 * Moves the camera position around a location (called orbit center) by a
+	 * given angle.
+	 * 
+	 * @param i_center the orbit center
+	 * @param i_hAngle the horizontal orbit angle, in radians
+	 * @param i_vAngle the vertical orbit angle, in radians
+	 */
+	public void orbit(IVector3f i_center, float i_hAngle, float i_vAngle) {
+
+		Matrix4f rot = Math3DCache.getMatrix4f();
+		Vector3f tmp = Math3DCache.getVector3f();
+
+		try {
+			rot.setIdentity();
+			if (i_hAngle != 0)
+				Math3D.rotate(i_hAngle, upVector, rot, rot);
+
+			if (i_vAngle != 0)
+				Math3D.rotate(i_vAngle, getRightVector(tmp), rot, rot);
+
+			// camera position
+			Math3D.sub(position, i_center, tmp);
+			tmp.transform(rot);
+			Math3D.add(tmp, i_center, position);
+
+			// view direction and reference vectors
+			viewDir.transform(rot);
+			upVector.transform(rot);
+
+		} finally {
+			Math3DCache.returnMatrix4f(rot);
+			Math3DCache.returnVector3f(tmp);
+		}
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraPosition.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/FirstPersonCamera.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/FirstPersonCamera.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/FirstPersonCamera.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -14,6 +14,7 @@
 import java.nio.FloatBuffer;
 import java.util.logging.Logger;
 
+import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.draw2d.geometry.Point;
 import org.eclipse.draw2d.geometry.Rectangle;
 import org.eclipse.draw3d.RenderContext;
@@ -468,28 +469,18 @@
 	}
 
 	/**
-	 * Sets the position of this camera. {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.camera.ICamera#moveTo(float, float, float)
-	 */
-	public void moveTo(float i_x, float i_y, float i_z) {
-
-		m_position.set(i_x, i_y, i_z);
-
-		fireCameraChanged();
-	}
-
-	/**
 	 * {@inheritDoc}
 	 * 
 	 * @see org.eclipse.draw3d.camera.ICamera#moveTo(org.eclipse.draw3d.geometry.IVector3f)
 	 */
-	public void moveTo(IVector3f i_viewPoint) {
+	public void moveTo(IVector3f i_Position) {
 
-		if (i_viewPoint == null)
+		if (i_Position == null)
 			throw new NullPointerException("i_viewPoint must not be null");
 
-		moveTo(i_viewPoint.getX(), i_viewPoint.getY(), i_viewPoint.getZ());
+		m_position.set(i_Position);
+		
+		fireCameraChanged();
 	}
 
 	/**
@@ -633,6 +624,22 @@
 
 		fireCameraChanged();
 	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.ICamera#setCameraPosition(org.eclipse.draw3d.camera.ICameraPosition)
+	 */
+	public void setCameraPosition(ICameraPosition i_cameraPosition) {
+		if (i_cameraPosition == null) // parameter precondition
+			throw new NullPointerException("i_cameraPosition must not be null");
+		
+		i_cameraPosition.getPosition(m_position);
+		i_cameraPosition.getUpVector(m_up);
+		i_cameraPosition.getViewDirection(m_viewDir);
+		i_cameraPosition.getRightVector(m_right);
+		
+		fireCameraChanged();
+	}
 
 	public void rotate(float i_roll, float i_pitch, float i_yaw) {
 
@@ -671,6 +678,14 @@
 
 		fireCameraChanged();
 	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.ICamera#getViewPortSize()
+	 */
+	public Dimension getViewPortSize() {
+		return new Dimension(m_viewport.width, m_viewport.height);
+	}
 
 	/**
 	 * {@inheritDoc}
@@ -710,4 +725,20 @@
 			Math3DCache.returnMatrix4f(inversion);
 		}
 	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.ICamera#getCameraPosition(org.eclipse.draw3d.camera.CameraPosition)
+	 */
+	public ICameraPosition getCameraPosition(CameraPosition o_result) {
+		if (o_result==null) {
+			o_result = new CameraPosition();
+		}
+		o_result.setPosition(m_position);
+		o_result.setUpVector(m_up);
+		o_result.setViewDirection(m_viewDir);
+		return o_result;
+	}
+	
+	
 }

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICamera.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICamera.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICamera.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -11,7 +11,9 @@
 
 package org.eclipse.draw3d.camera;
 
+import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
 import org.eclipse.draw3d.RenderContext;
 import org.eclipse.draw3d.geometry.IMatrix4f;
 import org.eclipse.draw3d.geometry.IVector3f;
@@ -76,6 +78,24 @@
 	public float getNear();
 
 	/**
+	 * Returns the current camera position.
+	 * 
+	 * @param result if not null, this result object is used and returned.
+	 * @return
+	 */
+	public ICameraPosition getCameraPosition(CameraPosition result);
+
+	/**
+	 * Sets the camera's position, view direction, and up/right vector according
+	 * to the given camera position. Since different camera implementations may
+	 * restrict the possible values of these properties, the values provided by
+	 * the camera positions are only used as hints.
+	 * 
+	 * @param cameraPosition, must not be null
+	 */
+	public void setCameraPosition(ICameraPosition cameraPosition);
+
+	/**
 	 * Returns the camera's current position.
 	 * 
 	 * @param io_result the result vector, if <code>null</code>, a new vector
@@ -150,19 +170,10 @@
 	/**
 	 * Moves the camera to the given position.
 	 * 
-	 * @param i_x the X coordinate of the new position
-	 * @param i_y the Y coordinate of the new position
-	 * @param i_z the Z coordinate of the new position
-	 */
-	public void moveTo(float i_x, float i_y, float i_z);
-
-	/**
-	 * Moves the camera to the given position.
-	 * 
-	 * @param i_viewPoint the new view point
+	 * @param i_Position the new view point
 	 * @throws NullPointerException if the given vector is <code>null</code>
 	 */
-	public void moveTo(IVector3f i_viewPoint);
+	public void moveTo(IVector3f i_position);
 
 	/**
 	 * Moves the camera around a location (called orbit center) by a given
@@ -239,6 +250,12 @@
 	 * @param i_height the height of the viewport
 	 */
 	public void setViewport(int i_x, int i_y, int i_width, int i_height);
+	
+	/**
+	 * Returns the dimension of the view port. 
+	 * @return
+	 */
+	public Dimension getViewPortSize();
 
 	/**
 	 * Transfers all registered camera listeners from this camera to the given

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICameraPosition.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICameraPosition.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICameraPosition.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera;
+
+import org.eclipse.draw3d.geometry.IVector3f;
+import org.eclipse.draw3d.geometry.Vector3f;
+
+/**
+ * ICameraPosition There should really be more documentation here.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public interface ICameraPosition {
+
+	/**
+	 * Returns the position, the vector is stored in the given parameter
+	 * if this is not null.
+	 * 
+	 * @param o_result, if null, a new result object is created.
+	 * @return
+	 */
+	IVector3f getPosition(Vector3f o_result);
+	
+	IVector3f getPosition();
+
+	/**
+	 * Returns the view direction, the vector is stored in the given parameter
+	 * if this is not null.
+	 * 
+	 * @param o_result, if null, a new result object is created.
+	 * @return 
+	 */
+	IVector3f getViewDirection(Vector3f o_result);
+	
+	IVector3f getViewDirection();
+
+	/**
+	 * Returns the up vector, the vector is stored in the given parameter
+	 * if this is not null.
+	 * 
+	 * @param o_result
+	 * @return
+	 */
+	IVector3f getUpVector(Vector3f o_result);
+	
+	IVector3f getUpVector();
+	
+	/**
+	 * Returns the right vector, the vector is stored in the given parameter
+	 * if this is not null.
+	 * 
+	 * @param o_result
+	 * @return
+	 */
+	IVector3f getRightVector(Vector3f o_result);
+	
+	IVector3f getRightVector();
+	
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/ICameraPosition.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/AbstractStartEndMove.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/AbstractStartEndMove.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/AbstractStartEndMove.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import org.eclipse.draw3d.camera.ICameraPosition;
+
+/**
+ * Abstract camera move with a target.
+ *
+ * @author 	Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version	$Revision$
+ * @since 	May 22, 2011
+ */
+public abstract class AbstractStartEndMove implements ICameraMove {
+
+	ICameraPosition startPosition;
+	ICameraPosition endPosition;
+	
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#init(org.eclipse.draw3d.camera.ICameraPosition, org.eclipse.draw3d.camera.ICameraPosition)
+	 */
+	public ICameraPosition init(ICameraPosition i_startPosition,
+		ICameraPosition i_endPosition) {
+		startPosition = i_startPosition;
+		endPosition = i_endPosition;
+		return endPosition;
+	}
+	
+	/**
+	 * @return the startPosition
+	 */
+	public ICameraPosition getStartPosition() {
+		return startPosition;
+	}
+	
+	/**
+	 * @return the endPosition
+	 */
+	public ICameraPosition getEndPosition() {
+		return endPosition;
+	}
+	
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/AbstractStartEndMove.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ComposedMove.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ComposedMove.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ComposedMove.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICameraPosition;
+
+/**
+ * Composed camera move, all sub moves are executed simultaneously. This can be
+ * used to easily combine movement and panning of a camera.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public class ComposedMove implements ICameraMove {
+
+	List<ICameraMove> moves = new ArrayList<ICameraMove>();
+
+	public void addMove(ICameraMove move) {
+		moves.add(move);
+	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#init(org.eclipse.draw3d.camera.ICameraPosition, org.eclipse.draw3d.camera.ICameraPosition)
+	 */
+	public ICameraPosition init(ICameraPosition i_startPosition,
+		ICameraPosition i_endPosition) {
+		
+		ICameraPosition endPos = i_endPosition;
+		for (ICameraMove move : moves) {
+			endPos = move.init(i_startPosition, i_endPosition);
+		}
+		return endPos;
+		
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#updateCameraPosition(org.eclipse.draw3d.camera.CameraPosition,
+	 *      float, float)
+	 */
+	public void updateCameraPosition(CameraPosition io_cameraPosition,
+		float prevTick, float currentTick) {
+		for (ICameraMove move : moves) {
+			move.updateCameraPosition(io_cameraPosition, prevTick, currentTick);
+		}
+
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ComposedMove.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ICameraMove.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ICameraMove.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ICameraMove.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICameraPosition;
+
+/**
+ * ICameraMove There should really be more documentation here.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 20, 2011
+ */
+public interface ICameraMove {
+
+	/**
+	 * Initializes a move by setting a start position and an end position. Some
+	 * moves do not use an end position, but instead calculate the end position
+	 * from the start position. In any case, the end position of the move is
+	 * returned.
+	 * 
+	 * @param startPosition
+	 * @param endPosition
+	 * @return
+	 */
+	ICameraPosition init(ICameraPosition startPosition,
+		ICameraPosition endPosition);
+
+	/**
+	 * Calculates the camera position at the time of the animation. The camera
+	 * position passed to this method is updated, and used both for the result
+	 * of the track step as well as for the initial camera position (when
+	 * progress is 0).
+	 * <p>
+	 * The camera track task ensures this method is called at least with
+	 * progress is 1.
+	 * </p>
+	 * 
+	 * @param io_cameraPosition
+	 * @param prevTick
+	 * @param currentTick
+	 */
+	void updateCameraPosition(CameraPosition io_cameraPosition, float prevTick,
+		float currentTick);
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/ICameraMove.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMove.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMove.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMove.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+
+/**
+ * Combination of a {@link LinearMovement} and a {@link LinearRotation}.
+ *
+ * @author 	Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version	$Revision$
+ * @since 	May 22, 2011
+ */
+public class LinearMove extends ComposedMove {
+	
+	/**
+	 * 
+	 */
+	public LinearMove() {
+		addMove(new LinearMovement());
+		addMove(new LinearRotation());
+	}
+	
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMove.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMovement.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMovement.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMovement.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICameraPosition;
+import org.eclipse.draw3d.geometry.IVector3f;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Math3DCache;
+import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.geometry.Vector3fImpl;
+
+/**
+ * Linearly moves the camera from the start position to the end position.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ * @see LinearMove
+ */
+public class LinearMovement extends AbstractStartEndMove {
+
+	IVector3f direction;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.tracking.AbstractStartEndMove#init(org.eclipse.draw3d.camera.ICameraPosition,
+	 *      org.eclipse.draw3d.camera.ICameraPosition)
+	 */
+	@Override
+	public ICameraPosition init(ICameraPosition i_startPosition,
+		ICameraPosition i_endPosition) {
+		super.init(i_startPosition, i_endPosition);
+
+		direction =
+			Math3D.sub(i_endPosition.getPosition(),
+				i_startPosition.getPosition(), null);
+
+		return i_endPosition;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#updateCameraPosition(org.eclipse.draw3d.camera.CameraPosition,
+	 *      float, float)
+	 */
+	public void updateCameraPosition(CameraPosition io_cameraPosition,
+		float i_prevTick, float i_currentTick) {
+
+		if (i_currentTick == 1f) {
+			io_cameraPosition.setCameraPosition(getEndPosition());
+		} else if (i_currentTick == 0f) {
+			io_cameraPosition.setCameraPosition(getStartPosition());
+		} else {
+			Vector3f v = new Vector3fImpl();
+
+			Math3D.scale(i_currentTick, direction, v);
+			Math3D.add(getStartPosition().getPosition(), v, v);
+			io_cameraPosition.setPosition(v);
+
+		}
+	}
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearMovement.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearRotation.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearRotation.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearRotation.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICameraPosition;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Math3DCache;
+import org.eclipse.draw3d.geometry.Vector3f;
+
+/**
+ * Linearly rotates the camera from the start up and view vector to the desired
+ * end target. 
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ * @see LinearMove
+ */
+public class LinearRotation extends AbstractStartEndMove {
+
+	Vector3f upDir, viewDir;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.tracking.AbstractStartEndMove#init(org.eclipse.draw3d.camera.ICameraPosition,
+	 *      org.eclipse.draw3d.camera.ICameraPosition)
+	 */
+	@Override
+	public ICameraPosition init(ICameraPosition i_startPosition,
+		ICameraPosition i_endPosition) {
+		super.init(i_startPosition, i_endPosition);
+
+		upDir =
+			Math3D.sub(i_endPosition.getUpVector(),
+				i_startPosition.getUpVector(), null);
+		viewDir =
+			Math3D.sub(i_endPosition.getViewDirection(),
+				i_startPosition.getViewDirection(), null);
+
+		return i_endPosition;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#updateCameraPosition(org.eclipse.draw3d.camera.CameraPosition,
+	 *      float, float)
+	 */
+	public void updateCameraPosition(CameraPosition io_cameraPosition,
+		float i_prevTick, float i_currentTick) {
+
+		if (i_currentTick == 1f) {
+			io_cameraPosition.setCameraPosition(getEndPosition());
+		} else if (i_currentTick == 0f) {
+			io_cameraPosition.setCameraPosition(getStartPosition());
+		} else {
+			Vector3f v = Math3DCache.getVector3f();
+			try {
+				Math3D.scale(i_currentTick, upDir, v);
+				Math3D.add(getStartPosition().getUpVector(), v, v);
+				io_cameraPosition.setUpVector(v);
+
+				Math3D.scale(i_currentTick, viewDir, v);
+				Math3D.add(getStartPosition().getViewDirection(), v, v);
+				io_cameraPosition.setViewDirection(v);
+			} finally {
+				Math3DCache.returnVector3f(v);
+			}
+		}
+
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/LinearRotation.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/MoveSeries.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/MoveSeries.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/MoveSeries.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import java.util.List;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+
+/**
+ * A series of camera moves, executed one after the other. Each move is added
+ * with a relative weight.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public abstract class MoveSeries implements ICameraMove {
+
+	List<Float> weights;
+
+	List<ICameraMove> moves;
+
+	List<Float> startTicks;
+
+	List<Float> relativeDurations;
+
+	public void addCameraMove(ICameraMove move, float weight) {
+		if (weight <= 0) // parameter precondition
+			throw new IllegalArgumentException("Weight must be greater than 0");
+
+		weights.add(weight);
+		moves.add(move);
+		updateStartTicks();
+	}
+
+	/**
+	 * 
+	 */
+	protected void updateStartTicks() {
+		startTicks.clear();
+		relativeDurations.clear();
+
+		// calculate total duration
+		float totalWeight = 0;
+		for (float weight : weights) {
+			totalWeight += weight;
+		}
+
+		// calculate start ticks for each connected track
+		float passedDuration = 0;
+		float relativeDuration;
+		for (int i = 0; i < weights.size(); i++) {
+			startTicks.add(passedDuration);
+			relativeDuration = weights.get(i) / totalWeight;
+			passedDuration += relativeDuration;
+			relativeDurations.add(relativeDuration);
+		}
+
+	}
+	
+	
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#updateCameraPosition(org.eclipse.draw3d.camera.CameraPosition,
+	 *      float, float)
+	 */
+	public void updateCameraPosition(CameraPosition io_cameraPosition,
+		float prevTick, float currentTick) {
+
+		int currentMoveNumber = findMove(currentTick);
+		int prevMoveNumber = findMove(prevTick);
+
+		if (prevMoveNumber >= 0 && currentMoveNumber != prevMoveNumber) {
+			float relativePrevTick =
+				makeTickRelative(prevTick, prevMoveNumber);
+			if (relativePrevTick != 1f) {
+				moves.get(prevMoveNumber).updateCameraPosition(
+					io_cameraPosition, relativePrevTick, 1f);
+			}
+		}
+
+		float relativePrevTick = makeTickRelative(prevTick, currentMoveNumber);
+		float relativeCurrentTick =
+			makeTickRelative(currentTick, currentMoveNumber);
+		moves.get(currentMoveNumber).updateCameraPosition(
+			io_cameraPosition, relativePrevTick, relativeCurrentTick);
+	}
+
+	/**
+	 * <pre>
+	 * .........s......................s+d.........
+	 *          0......................1 
+	 *   			  t
+	 * </pre>
+	 * 
+	 * @param i_prevTick
+	 * @param i_prevMoveNumber
+	 * @return
+	 */
+	protected float makeTickRelative(float i_Tick, int i_MoveNumber) {
+		// short cut, ensures 1f is reached
+		if (i_Tick == 1f)
+			return 1f;
+		
+		float relativeDuration = relativeDurations.get(i_MoveNumber);
+		float tick =
+			(i_Tick - startTicks.get(i_MoveNumber)) / relativeDuration;
+		if (tick < 0)
+			return -1f;
+		if (tick > 1)
+			tick = 1f;
+		return tick;
+	}
+
+	/**
+	 * @param i_lastTick
+	 * @return
+	 */
+	protected int findMove(float i_tick) {
+		if (i_tick < 0)
+			return -1;
+		if (i_tick > 1f)
+			return moves.size() - 1;
+
+		for (int i = moves.size() - 1; i > 0; i--) {
+			if (startTicks.get(i) <= i_tick) {
+				return i;
+			}
+		}
+		return 0;
+
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/MoveSeries.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/NoMove.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/NoMove.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/NoMove.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICameraPosition;
+
+/**
+ * Pseudo move to be used in {@link MoveSeries} when camera is supposed
+ * to be not moved during a given period of the whole move. This is especially
+ * interesting when two {@link MoveSeries} are composed in a 
+ * {@link ComposedMove}. E.g., one series defines the panning of the camera, 
+ * while the second defines the movement. Sometimes, the camera should 
+ * pan to the direction of the movement, while the camera is already moving.
+ * Then the camera is moved to the target location, and shortly before reaching
+ * this location, it should be panned again to a given target. The time 
+ * between the two pannings can then be filled with a no move. 
+ *
+ * @author 	Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version	$Revision$
+ * @since 	May 22, 2011
+ */
+public class NoMove implements ICameraMove {
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#init(org.eclipse.draw3d.camera.ICameraPosition, org.eclipse.draw3d.camera.ICameraPosition)
+	 */
+	public ICameraPosition init(ICameraPosition i_startPosition,
+		ICameraPosition i_endPosition) {
+		return i_startPosition;
+	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw3d.camera.tracking.ICameraMove#updateCameraPosition(org.eclipse.draw3d.camera.CameraPosition, float, float)
+	 */
+	public void updateCameraPosition(CameraPosition io_cameraPosition,
+		float i_prevTick, float i_currentTick) {
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/NoMove.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingShot.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingShot.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingShot.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import java.util.TimerTask;
+
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICamera;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public class TrackingShot extends TimerTask {
+	/**
+	 * Logger for this class
+	 */
+	// @SuppressWarnings("unused") //$NON-NLS-1$
+	private static final Logger log = Logger.getLogger(TrackingShot.class.getName());
+
+	/**
+	 * The duration of the shot in mili seconds.
+	 */
+	long duration;
+
+	/**
+	 * The camera used.
+	 */
+	ICamera camera;
+
+	/**
+	 * The move of this tracking shot.
+	 */
+	ICameraMove move;
+
+	/**
+	 * Internal state indicating first run
+	 */
+	long firstRun = -1;
+	
+	/**
+	 * Internal helper variable storing camera position.
+	 */
+	CameraPosition cameraPosition;
+	
+	/**
+	 * Internal helper variable storing last tick.
+	 */
+	float prevTick;
+
+	/**
+	 * @param i_duration
+	 * @param i_camera
+	 */
+	public TrackingShot(long i_duration, ICamera i_camera, ICameraMove i_move) {
+		duration = i_duration;
+		camera = i_camera;
+		move = i_move;
+		cameraPosition = new CameraPosition();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.util.TimerTask#run()
+	 */
+	@Override
+	public void run() {
+		try {
+		long current = System.currentTimeMillis();
+		if (firstRun == -1) {
+			firstRun = current;
+			prevTick = -1f;
+		}
+		long delta = current - firstRun;
+		float currentTick = (float) delta / (float) duration;
+		if (currentTick > 1f)
+			currentTick = 1f;
+
+		camera.getCameraPosition(cameraPosition);
+		move.updateCameraPosition(cameraPosition, prevTick, currentTick);
+
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				camera.setCameraPosition(cameraPosition);
+			}
+		});
+
+		if (currentTick == 1f)
+			cancel();
+		prevTick = currentTick;
+		} catch (RuntimeException t) {
+			cancel();
+			throw t;
+		}
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingShot.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Added: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingUtil.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingUtil.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingUtil.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens von Pilgrim - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.camera.tracking;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw3d.Figure3DHelper;
+import org.eclipse.draw3d.IFigure3D;
+import org.eclipse.draw3d.ISurface;
+import org.eclipse.draw3d.camera.CameraPosition;
+import org.eclipse.draw3d.camera.ICamera;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Math3DCache;
+import org.eclipse.draw3d.geometry.Matrix4f;
+import org.eclipse.draw3d.geometry.Vector3f;
+
+/**
+ * Utility methods for calculating the camera position.
+ * 
+ * @author Jens von Pilgrim (developer@xxxxxxxxx)
+ * @version $Revision$
+ * @since May 22, 2011
+ */
+public class TrackingUtil {
+
+	public static CameraPosition figureToScreen(IFigure figure, ICamera camera) {
+		IFigure3D fig3D = Figure3DHelper.getAncestor3D(figure);
+		if (fig3D == null) {
+			throw new IllegalArgumentException("Cannot retrieve 3D ancestor");
+		}
+		ISurface surface = fig3D.getSurface();
+		if (surface == null) {
+			throw new IllegalArgumentException("No surface found.");
+		}
+
+		CameraPosition pos = new CameraPosition();
+
+		Vector3f v = Math3DCache.getVector3f(), v1 = Math3DCache.getVector3f(), v2 =
+			Math3DCache.getVector3f(), v3 = Math3DCache.getVector3f();
+		try {
+
+			// up vector
+			pos.setUpVector(surface.getUpVector());
+
+			// view direction
+			Math3D.scale(-1f, surface.getNormal(), v);
+			pos.setViewDirection(v);
+
+			// position
+			if (figure instanceof IFigure3D) {
+				IFigure3D f3D = (IFigure3D) figure;
+				v1.set(f3D.getPosition3D().getCenter3D());
+			} else {
+				Point p2D = figure.getBounds().getCenter();
+				surface.getWorldLocation(p2D, v1);
+			}
+
+			float near = camera.getNear();
+			camera.unProject(0, 0, 0, Matrix4f.IDENTITY, v2);
+			camera.unProject(100, 100, 0, Matrix4f.IDENTITY, v3);
+
+			float projLength = Math3D.distance(v2, v3);
+			float orgLengh = (float) Math.sqrt(2 * 100 * 100);
+
+			float scale = (near) * (orgLengh / projLength);
+
+			Math3D.scale(scale, v, v);
+			Math3D.sub(v1, v, v1);
+
+			pos.setPosition(v1);
+		} finally {
+			Math3DCache.returnVector3f(v, v1, v2, v3);
+		}
+		return pos;
+	}
+
+}


Property changes on: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/tracking/TrackingUtil.java
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/picking/GeometryPicker.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/picking/GeometryPicker.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/picking/GeometryPicker.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -32,8 +32,8 @@
 public class GeometryPicker implements Picker {
 
 	@SuppressWarnings("unused")
-	private static final Logger log =
-		Logger.getLogger(GeometryPicker.class.getName());
+	private static final Logger log = Logger.getLogger(GeometryPicker.class
+		.getName());
 
 	private ISurface m_currentSurface;
 
@@ -160,9 +160,12 @@
 			ICamera camera = m_scene.getCamera();
 			camera.getPosition(rayOrigin);
 
-			if (rayOrigin.equals(i_rayPoint))
-				throw new IllegalArgumentException(
-					"rayOrigin must not be equal to the camera position");
+			if (rayOrigin.equals(i_rayPoint)) {
+				// throw new IllegalArgumentException(
+				// "rayPoint must not be equal to the camera position");
+				log.warning("rayPoint must not be equal to the camera position");
+				return null;
+			}
 
 			Math3D.getRayDirection(rayOrigin, i_rayPoint, rayDirection);
 			return getHit(rayOrigin, rayDirection, i_search);

Modified: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/camera/CameraInputHandler.java
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/camera/CameraInputHandler.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/camera/CameraInputHandler.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -10,14 +10,24 @@
  ******************************************************************************/
 package org.eclipse.draw3d.ui.camera;
 
+import java.util.logging.Level;
+
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Timer;
 import java.util.logging.Logger;
 
+import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.geometry.Point;
 import org.eclipse.draw3d.IScene;
+import org.eclipse.draw3d.camera.CameraPosition;
 import org.eclipse.draw3d.camera.ICamera;
+import org.eclipse.draw3d.camera.tracking.LinearMove;
+import org.eclipse.draw3d.camera.tracking.TrackingShot;
+import org.eclipse.draw3d.camera.tracking.TrackingUtil;
 import org.eclipse.draw3d.geometry.IVector3f;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Vector3fImpl;
 import org.eclipse.draw3d.picking.Hit;
 import org.eclipse.draw3d.picking.Picker;
 import org.eclipse.jface.bindings.keys.KeySequence;
@@ -53,16 +63,15 @@
 	private final static float FACTOR_ORBIT = 0.0009f;
 
 	@SuppressWarnings("unused")
-	private static final Logger log =
-		Logger.getLogger(CameraInputHandler.class.getName());
+	private static final Logger log = Logger.getLogger(CameraInputHandler.class
+		.getName());
 
 	@SuppressWarnings("unused")
-	private static final Logger logger =
-		Logger.getLogger(CameraInputHandler.class.getName());
+	private static final Logger logger = Logger
+		.getLogger(CameraInputHandler.class.getName());
 
-	private static final int MODIFIER_MASK =
-		SWT.ALT | SWT.SHIFT | SWT.CONTROL | SWT.MOD1 | SWT.MOD2 | SWT.MOD3
-			| SWT.MOD4;
+	private static final int MODIFIER_MASK = SWT.ALT | SWT.SHIFT | SWT.CONTROL
+		| SWT.MOD1 | SWT.MOD2 | SWT.MOD3 | SWT.MOD4;
 
 	/**
 	 * The key sequence to center the camera.
@@ -178,6 +187,11 @@
 	private float m_wheelSpeed = 20;
 
 	/**
+	 * The timer used for camera trackings
+	 */
+	Timer timer = null;
+
+	/**
 	 * Handles a mouse button down event.
 	 * 
 	 * @param i_button the mouse button
@@ -186,12 +200,21 @@
 	 * @param i_y the mouse Y coordinate
 	 */
 	public void buttonDown(int i_button, int i_stateMask, int i_x, int i_y) {
-
+		stopCameraTracking();
 		int modifiers = getModifiers(i_stateMask);
 		doButtonDown(i_button, modifiers, i_x, i_y);
 	}
 
 	/**
+	 * 
+	 */
+	protected void stopCameraTracking() {
+		if (timer != null)
+			timer.cancel();
+		timer = null;
+	}
+
+	/**
 	 * Handles a mouse button up event.
 	 * 
 	 * @param i_button the mouse button
@@ -348,7 +371,7 @@
 	 * @param i_event the key down event
 	 */
 	public void keyDown(KeyEvent i_event) {
-
+		stopCameraTracking();
 		m_currentModifiers = getModifiers(i_event.stateMask);
 
 		float speed = m_keySpeed;
@@ -462,6 +485,66 @@
 	}
 
 	/**
+	 * Handles double click, that is activates a camera track to figure under
+	 * cursor.
+	 * 
+	 * @param i_button
+	 * @param i_stateMask
+	 * @param i_x
+	 * @param i_y
+	 */
+	public void doubleClick(int i_button, int i_stateMask, int i_mx, int i_my) {
+		stopCameraTracking();
+		Picker picker = getScene().getPicker();
+		Hit hit = picker.getHit(i_mx, i_my);
+		CameraPosition cameraPos = null;
+		if (hit != null) {
+			IFigure figure = hit.getSearchResult();
+			cameraPos = TrackingUtil.figureToScreen(figure, getCamera());
+		} else {
+			cameraPos = new CameraPosition();
+
+			if ((i_stateMask & m_orbitModifiers) != 0) {
+				if ((i_stateMask & SWT.SHIFT) == 0) {
+					cameraPos.setViewDirection(new Vector3fImpl(1, 0, 0));
+					cameraPos.setPosition(new Vector3fImpl(-1000, 0, 0));
+				} else {
+					cameraPos.setViewDirection(new Vector3fImpl(0, 1, 0));
+					cameraPos.setUpVector(new Vector3fImpl(0,0,1));
+					cameraPos.setPosition(new Vector3fImpl(0, -1000, 0));
+				}
+			}
+
+		}
+		if (cameraPos != null) {
+
+			LinearMove move = new LinearMove();
+			move.init(getCamera().getCameraPosition(null), cameraPos);
+
+			float moveLength =
+				Math3D.distance(getCamera().getCameraPosition(null)
+					.getPosition(), cameraPos.getPosition());
+
+			long duration = (long) (Math.log(moveLength * moveLength) * 50);
+
+			if (log.isLoggable(Level.INFO)) {
+				log.info("duration=" + duration); //$NON-NLS-1$
+			}
+
+			if (duration > 2000)
+				duration = 2000;
+			if (duration < 0)
+				duration = 100;
+
+			TrackingShot shot = new TrackingShot(duration, getCamera(), move);
+			timer=new Timer();
+			timer.schedule(shot, 0, 50);
+
+		}
+
+	}
+
+	/**
 	 * Handles a drag finished event. This is neccessary because in the case of
 	 * native drags, the mouse up event gets lost.
 	 * 
@@ -670,4 +753,5 @@
 
 		m_wheelSpeed = i_wheelSpeed;
 	}
+
 }

Modified: trunk/org.eclipse.gef3d/src/java/org/eclipse/gef3d/tools/CameraTool.java
===================================================================
--- trunk/org.eclipse.gef3d/src/java/org/eclipse/gef3d/tools/CameraTool.java	2011-04-27 13:37:19 UTC (rev 576)
+++ trunk/org.eclipse.gef3d/src/java/org/eclipse/gef3d/tools/CameraTool.java	2011-05-23 13:32:06 UTC (rev 577)
@@ -159,6 +159,21 @@
 
         return true;
     }
+    
+    /** 
+     * {@inheritDoc}
+     * @see org.eclipse.gef.tools.AbstractTool#handleDoubleClick(int)
+     */
+    @Override
+    protected boolean handleDoubleClick(int i_button) {
+    	
+    	m_handler.setScene(getScene());
+    	Input3D input = getCurrentInput3D();
+    	m_handler.doubleClick(i_button, getStateMask(input),
+    		input.getRealMouseLocation().x, input.getRealMouseLocation().y);
+    		
+    	return true;
+    }
 
     /**
      * {@inheritDoc}