Improvements and fixes to 3D graphics. Camera panning is now smoother.
diff --git a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/.classpath b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/.classpath
index 45f024e..8a8f166 100644
--- a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/.classpath
+++ b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/.classpath
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>

 <classpath>

-	<classpathentry kind="src" path="src"/>

-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>

+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>

 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>

+	<classpathentry kind="src" path="src"/>

 	<classpathentry kind="output" path="bin"/>

 </classpath>

diff --git a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/META-INF/MANIFEST.MF b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/META-INF/MANIFEST.MF
index 544a813..3a9f153 100644
--- a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/META-INF/MANIFEST.MF
+++ b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/META-INF/MANIFEST.MF
@@ -20,3 +20,4 @@
 Export-Package: org.eclipse.amp.agf3d,
  org.eclipse.amp.agf3d.ui
 Bundle-ClassPath: .
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/GEF3DViewPart.java b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/GEF3DViewPart.java
index f5ebe4f..1142a35 100644
--- a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/GEF3DViewPart.java
+++ b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/GEF3DViewPart.java
@@ -3,6 +3,8 @@
 import org.eclipse.amp.agf.gef.EditPartListener;

 import org.eclipse.amp.agf.gef.EditPartViewPart;

 import org.eclipse.amp.axf.view.IModelPart;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.gef.EditPartFactory;

 import org.eclipse.gef.EditPartViewer;

 import org.eclipse.gef.RootEditPart;

 import org.eclipse.gef3d.editparts.ScalableFreeformRootEditPart3D;

@@ -30,6 +32,23 @@
     EditPartListener rootListener;

     private CameraTool camera;

 

+    public EditPartFactory createFactory() {

+        return getFactory3DProvider().getEditPart3DFactory();

+    }

+

+    public I3DModelFactoryProvider getFactory3DProvider() {

+        if (getModel() instanceof I3DModelFactoryProvider) {

+            return (I3DModelFactoryProvider) getModel();

+        } else {

+            I3DModelFactoryProvider adapter = (I3DModelFactoryProvider) Platform.getAdapterManager()

+                    .getAdapter(getModel(), I3DModelFactoryProvider.class);

+            if (adapter == null) {

+                throw new RuntimeException("No I3DModelFactoryProvider adapter defined for: " + getModel());

+            }

+            return adapter;

+        }

+    }

+

     public void createModelListeners() {

         if (viewer.getContents() instanceof IModelPart) {

             ((IModelPart) viewer.getContents()).createModelListeners();

diff --git a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/ScapeEdit3DPart.java b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/ScapeEdit3DPart.java
index afee490..00711a6 100644
--- a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/ScapeEdit3DPart.java
+++ b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/ScapeEdit3DPart.java
@@ -32,6 +32,8 @@
 

 public class ScapeEdit3DPart extends ScapeEditPart {

 

+    IModel model;

+

     private final class RenderUpdateListener extends SWTAsyncModelListener {

         private final Figure figure;

 

@@ -41,6 +43,7 @@
         }

 

         public void observeCreate(IObservationProvider observed) {

+            model = (IModel) observed;

             super.observeCreate(observed);

             animateCamera = false;

             moveCameraHelicopter();

@@ -116,26 +119,27 @@
             IFigure3D agentFigure = (IFigure3D) editPart.getFigure();

             IVector3f endPoint = new Vector3fImpl((float) GenericEditPart.SCALE * location.getX(),

                                                   (float) GenericEditPart.SCALE * location.getY(), -GenericEditPart.SCALE);

-            // if (((Scape) getMemberProvider().getParent(getModel())).getPeriod() > 0) {

-            // IVector3f startPoint;

-            // Vector3f addPoint;

-            // if (animationStep == 0) {

-            // startPoint = agentFigure.getPosition3D().getLocation3D();

-            // startPoints.put(agent, startPoint);

-            // addPoint = new Vector3fImpl();

-            // calculateDelta(startPoint, endPoint, addPoint, animationStepCount);

-            // addPoints.put(agent, addPoint);

-            // } else {

-            // startPoint = startPoints.get(agent);

-            // addPoint = addPoints.get(agent);

-            // }

-            // Vector3f intermediatePoint = new Vector3fImpl();

-            // IVector3f currentPoint = agentFigure.getPosition3D().getLocation3D();

-            // Math3DVector3f.add(currentPoint, addPoint, intermediatePoint);

-            // agentFigure.getPosition3D().setLocation3D(intermediatePoint);

-            // } else {

-            agentFigure.getPosition3D().setLocation3D(endPoint);

-            // }

+            if (animationStepCount > 1 && model != null && model.getPeriod() > 0) {

+                IVector3f startPoint;

+                Vector3f addPoint;

+                if (animationStep == 0) {

+                    startPoint = agentFigure.getPosition3D().getLocation3D();

+                    startPoints.put(agent, startPoint);

+                    addPoint = new Vector3fImpl();

+                    calculateDelta(startPoint, endPoint, addPoint, animationStepCount);

+                    addPoints.put(agent, addPoint);

+                } else {

+                    startPoint = startPoints.get(agent);

+                    addPoint = addPoints.get(agent);

+                }

+                Vector3f intermediatePoint = new Vector3fImpl();

+                IVector3f currentPoint = agentFigure.getPosition3D().getLocation3D();

+                Math3DVector3f.add(currentPoint, addPoint, intermediatePoint);

+                agentFigure.getPosition3D().setLocation3D(intermediatePoint);

+

+            } else {

+                agentFigure.getPosition3D().setLocation3D(endPoint);

+            }

         }

     }

 

@@ -172,8 +176,8 @@
                                                                                        * targetZ));

     }

 

-    private void moveCamera(final IVector3f endPoint, final IVector3f targetPoint) {

-        final ICamera camera = ((IScene) getViewer()).getCamera();

+    private void moveCamera(final IVector3f endPoint, final IVector3f endLookPoint) {

+        final ICamera camera = getCamera();

         if (animateCamera) {

             new Thread() {

                 public void run() {

@@ -183,44 +187,65 @@
                     camera.getPosition(startPoint);

                     Vector3f addPoint = new Vector3fImpl();

                     calculateDelta(startPoint, endPoint, addPoint, moveCount);

-                    // Display.getDefault().syncExec(new Runnable() {

-                    // public void run() {

-                    // camera.lookAt(targetPoint, new Vector3fImpl(0, 0, 1));

-                    // }

-                    // });

-                    Display.getDefault().syncExec(new Runnable() {

-                        public void run() {

-                            camera.lookAt(targetPoint, new Vector3fImpl(0, 0, 1));

-                        }

-                    });

-                    for (int i = 0; i < moveCount - 1; i++) {

-                        Math3DVector3f.add(startPoint, addPoint, startPoint);

-                        Display.getDefault().syncExec(new Runnable() {

-                            public void run() {

-                                camera.moveTo(startPoint.getX(), startPoint.getY(), startPoint.getZ());

+

+                    if (!cancelCamera) {

+                        for (int i = 0; i < moveCount - 1; i++) {

+                            Math3DVector3f.add(startPoint, addPoint, startPoint);

+                            moveToNow(startPoint);

+                            if (cancelCamera) {

+                                break;

                             }

-                        });

-                        if (i % 10 == 0) {

+                        }

+                        // moveToNow((Vector3f) endPoint);

+                    }

+                    final Vector3fImpl upVector = new Vector3fImpl(0, 0, 1);

+                    final Vector3f currentLookPoint = new Vector3fImpl();

+                    camera.getViewDirection(currentLookPoint);

+                    Math3DVector3f.add(currentLookPoint, endPoint, currentLookPoint);

+                    Vector3f addLookPoint = new Vector3fImpl();

+                    calculateDelta(currentLookPoint, endLookPoint, addLookPoint, moveCount);

+                    if (!cancelCamera) {

+                        for (int i = 0; i < moveCount - 1; i++) {

+                            Math3DVector3f.add(currentLookPoint, addLookPoint, currentLookPoint);

                             Display.getDefault().syncExec(new Runnable() {

                                 public void run() {

-                                    camera.lookAt(targetPoint, new Vector3fImpl(0, 0, 1));

+                                    camera.lookAt(currentLookPoint, upVector);

                                 }

                             });

+                            if (cancelCamera) {

+                                break;

+                            }

                         }

-                        if (cancelCamera) {

-                            break;

-                        }

+                        Display.getDefault().syncExec(new Runnable() {

+                            public void run() {

+                                // Take care of any small deltas

+                                // camera.lookAt(endLookPoint, upVector);

+                            }

+                        });

                     }

-                    camera.lookAt(targetPoint, new Vector3fImpl(0, 0, 1));

                     cameraMoving = false;

                 }

+

             }.start();

         } else {

             camera.moveTo(endPoint.getX(), endPoint.getY(), endPoint.getZ());

-            camera.lookAt(targetPoint, new Vector3fImpl(0, -0, 1));

+            camera.lookAt(endLookPoint, new Vector3fImpl(0, -0, 1));

         }

     }

 

+    private void moveToNow(final Vector3f movePoint) {

+        Display.getDefault().syncExec(new Runnable() {

+            public void run() {

+                getCamera().moveTo(movePoint.getX(), movePoint.getY(), movePoint.getZ());

+            }

+        });

+    }

+

+    private ICamera getCamera() {

+        final ICamera camera = ((IScene) getViewer()).getCamera();

+        return camera;

+    }

+

     public boolean isAnimateCamera() {

         return animateCamera;

     }

diff --git a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/SolidShape.java b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/SolidShape.java
index 2366373..3e40feb 100644
--- a/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/SolidShape.java
+++ b/org.eclipse.amp.agf/plugins/org.eclipse.amp.agf3d/src/org/eclipse/amp/agf3d/SolidShape.java
@@ -65,34 +65,6 @@
 

         };

 

-        Runnable texture = new Runnable() {

-

-            public void run() {

-                g3d.glBegin(Graphics3DDraw.GL_QUADS);

-                g3d.glNormal3f(0, 0, -1);

-                g3d.glTexCoord2f(0, 1);

-                g3d.glVertex3f(0, 0, 0);

-                g3d.glTexCoord2f(0, 0);

-                g3d.glVertex3f(0, 1, 0);

-                g3d.glTexCoord2f(1, 0);

-                g3d.glVertex3f(1, 1, 0);

-                g3d.glTexCoord2f(1, 1);

-                g3d.glVertex3f(1, 0, 0);

-

-                g3d.glNormal3f(0, 0, 1);

-                g3d.glTexCoord2f(1, 1);

-                g3d.glVertex3f(1, 0, 0);

-                g3d.glTexCoord2f(1, 0);

-                g3d.glVertex3f(1, 1, 0);

-                g3d.glTexCoord2f(0, 0);

-                g3d.glVertex3f(0, 1, 0);

-                g3d.glTexCoord2f(0, 1);

-                g3d.glVertex3f(0, 0, 0);

-                g3d.glEnd();

-            }

-

-        };

-

         Runnable rest = new Runnable() {

             public void run() {

                 renderRest();