summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2007-10-08 23:08:02 +0000
committerChien Yang <[email protected]>2007-10-08 23:08:02 +0000
commit97c00b2b21e951e613053da835a28f9551fe2a79 (patch)
tree9210f3ca17baddb4e2f4f3214cb5740a4906ee24
parent034f47daa35a98afc78e4db3c7142b448be8d077 (diff)
1) Fixed Issue 179 : OrbitBehavior.setRotationCenter gives spurious view shift
This fix is submitted by jeromerobert. 2) Removed unuse imports and private variables. git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@170 9497e636-51bd-65ba-982d-a4982e1767a5
-rw-r--r--src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java
index b4123bb..57168bf 100644
--- a/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java
+++ b/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java
@@ -44,19 +44,10 @@
package com.sun.j3d.utils.behaviors.vp;
-import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
-import java.awt.event.KeyEvent;
import java.awt.AWTEvent;
-import java.awt.Component;
-import java.awt.Cursor;
-import javax.swing.SwingUtilities;
-import javax.media.j3d.WakeupOnAWTEvent;
-import javax.media.j3d.WakeupOnElapsedFrames;
-import javax.media.j3d.TransformGroup;
import javax.media.j3d.Transform3D;
-import javax.media.j3d.View;
import javax.media.j3d.Canvas3D;
import javax.vecmath.Vector3d;
@@ -127,9 +118,7 @@ import com.sun.j3d.internal.J3dUtilsI18N;
*/
public class OrbitBehavior extends ViewPlatformAWTBehavior {
- private Transform3D velocityTransform = new Transform3D();
private Transform3D longditudeTransform = new Transform3D();
- private Transform3D rollTransform = new Transform3D();
private Transform3D latitudeTransform = new Transform3D();
private Transform3D rotateTransform = new Transform3D();
@@ -144,11 +133,8 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior {
private double longditude = 0.0;
private double latitude = 0.0;
- private double rollAngle = 0.0;
private double startDistanceFromCenter = 20.0;
private double distanceFromCenter = 20.0;
- private final double MAX_MOUSE_ANGLE = Math.toRadians( 3 );
- private final double ZOOM_FACTOR = 1.0;
private Point3d rotationCenter = new Point3d();
private Matrix3d rotMatrix = new Matrix3d();
private Transform3D currentXfm = new Transform3D();
@@ -441,6 +427,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior {
* super.setViewingPlatform(vp).
* NOTE: Applications should <i>not</i> call this method.
*/
+ @Override
public void setViewingPlatform(ViewingPlatform vp) {
super.setViewingPlatform( vp );
@@ -529,10 +516,18 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior {
* @param center The Point3d to set the center of rotation to
*/
public synchronized void setRotationCenter(Point3d center) {
- rotationCenter.x = center.x;
- rotationCenter.y = center.y;
- rotationCenter.z = center.z;
- centerVector.set(rotationCenter);
+ Point3d centerDelta = new Point3d();
+ centerDelta.sub(centerVector, center);
+ Transform3D invRot = new Transform3D(rotateTransform);
+ invRot.invert();
+ invRot.transform(centerDelta);
+ xtrans += centerDelta.x;
+ ytrans += centerDelta.y;
+ ztrans += centerDelta.z;
+ rotationCenter.x = center.x;
+ rotationCenter.y = center.y;
+ rotationCenter.z = center.z;
+ centerVector.set(rotationCenter);
}
/**