|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.media.j3d.SceneGraphObject
javax.media.j3d.Node
javax.media.j3d.Leaf
javax.media.j3d.Behavior
com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior
com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior
com.sun.j3d.utils.behaviors.vp.OrbitBehavior
public class OrbitBehavior
Moves the View around a point of interest when the mouse is dragged with a mouse button pressed. Includes rotation, zoom, and translation actions. Zooming can also be obtained by using mouse wheel.
This behavior must be added to the ViewingPlatform
using the ViewingPlatform.setViewPlatformBehavior
method.
The rotate action rotates the ViewPlatform around the point of interest when the mouse is moved with the main mouse button pressed. The rotation is in the direction of the mouse movement, with a default rotation of 0.01 radians for each pixel of mouse movement.
The zoom action moves the ViewPlatform closer to or further from the point of interest when the mouse is moved with the middle mouse button pressed (or Alt-main mouse button on systems without a middle mouse button). The default zoom action is to translate the ViewPlatform 0.01 units for each pixel of mouse movement. Moving the mouse up moves the ViewPlatform closer, moving the mouse down moves the ViewPlatform further away.
By default, the zoom action allows the ViewPlatform to move through
the center of rotation to orbit at a negative radius.
The STOP_ZOOM
constructor flag will stop the ViewPlatform at
a minimum radius from the center. The default minimum radius is 0.0
and can be set using the setMinRadius
method.
The PROPORTIONAL_ZOOM
constructor flag changes the zoom action
to move the ViewPlatform proportional to its distance from the center
of rotation. For this mode, the default action is to move the ViewPlatform
by 1% of its distance from the center of rotation for each pixel of
mouse movement.
The translate action translates the ViewPlatform when the mouse is moved with the right mouse button pressed (Shift-main mouse button on systems without a right mouse button). The translation is in the direction of the mouse movement, with a default translation of 0.01 units for each pixel of mouse movement.
The sensitivity of the actions can be scaled using the
set
ActionFactor()
methods which scale
the default movement by the factor. The rotate and translate actions
have separate factors for x and y.
The actions can be reversed using the REVERSE_
ACTION
constructor flags. The default action moves the ViewPlatform around the
objects in the scene. The REVERSE_
ACTION flags can
make the objects in the scene appear to be moving in the direction
of the mouse movement.
The actions can be disabled by either using the
DISABLE_
ACTION constructor flags or the
set
ActionEnable
methods.
The default center of rotation is (0, 0, 0) and can be set using the
setRotationCenter()
method.
Field Summary | |
---|---|
private Vector3d |
centerVector
|
private Transform3D |
currentXfm
|
static int |
DISABLE_ROTATE
Constructor flag to disable rotate |
static int |
DISABLE_TRANSLATE
Constructor flag to disable translate |
static int |
DISABLE_ZOOM
Constructor flag to disable zoom |
private double |
distanceFromCenter
|
private Vector3d |
distanceVector
|
private Vector3d |
invertCenterVector
|
private double |
latitude
|
private Transform3D |
latitudeTransform
|
private int |
leftButton
|
private double |
longditude
|
private Transform3D |
longditudeTransform
|
private int |
middleButton
|
private double |
minRadius
|
private int |
mouseX
|
private int |
mouseY
|
private static double |
NOMINAL_PZOOM_FACTOR
|
private static double |
NOMINAL_ROT_FACTOR
|
private static double |
NOMINAL_TRANS_FACTOR
|
private static double |
NOMINAL_ZOOM_FACTOR
|
static int |
PROPORTIONAL_ZOOM
Constructor flag to use proportional zoom, which determines how much you zoom based on view's distance from the center of rotation. |
private boolean |
proportionalZoom
|
static int |
REVERSE_ALL
Constructor flag to reverse all the behaviors |
static int |
REVERSE_ROTATE
Constructor flag to reverse the rotate behavior |
static int |
REVERSE_TRANSLATE
Constructor flag to reverse the translate behavior |
static int |
REVERSE_ZOOM
Constructor flag to reverse the zoom behavior |
private boolean |
reverseRotate
|
private boolean |
reverseTrans
|
private boolean |
reverseZoom
|
private int |
rightButton
|
private static int |
ROTATE
Used to set the fuction for a mouse button to Rotate |
private boolean |
rotateEnabled
|
private Transform3D |
rotateTransform
|
private Point3d |
rotationCenter
|
private Matrix3d |
rotMatrix
|
private double |
rotXFactor
|
private double |
rotXMul
|
private double |
rotYFactor
|
private double |
rotYMul
|
private double |
startDistanceFromCenter
|
static int |
STOP_ZOOM
Constructor flag that indicates zoom should stop when it reaches the minimum orbit radius set by setMinRadius(). |
private boolean |
stopZoom
|
private Transform3D |
temp1
|
private Transform3D |
temp2
|
private static int |
TRANSLATE
Used to set the function for a mouse button to Translate |
private boolean |
translateEnabled
|
private Transform3D |
translation
|
private Vector3d |
transVector
|
private double |
transXFactor
|
private double |
transXMul
|
private double |
transYFactor
|
private double |
transYMul
|
private float |
wheelZoomFactor
|
private double |
xtrans
|
private double |
ytrans
|
private static int |
ZOOM
Used to set the function for a mouse button to Zoom |
private boolean |
zoomEnabled
|
private double |
zoomFactor
|
private double |
zoomMul
|
private double |
ztrans
|
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior |
---|
canvases, frameWakeup, KEY_LISTENER, motion, MOUSE_LISTENER, MOUSE_MOTION_LISTENER, MOUSE_WHEEL_LISTENER, POST_ID, postWakeup, targetTransform |
Fields inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior |
---|
homeTransform, targetTG, vp |
Constructor Summary | |
---|---|
OrbitBehavior()
Parameterless constructor for this behavior. |
|
OrbitBehavior(Canvas3D c)
Creates a new OrbitBehavior |
|
OrbitBehavior(Canvas3D c,
int flags)
Creates a new OrbitBehavior |
Method Summary | |
---|---|
private void |
doZoomOperations(int ychange)
|
double |
getMinRadius()
Returns the minimum orbit radius. |
boolean |
getRotateEnable()
Retrieves the state of rotate enabled |
void |
getRotationCenter(Point3d center)
Places the value of the center around which the View rotates into the Point3d. |
double |
getRotXFactor()
Returns the x rotation movement multiplier |
double |
getRotYFactor()
Returns the y rotation movement multiplier |
boolean |
getTranslateEnable()
Retrieves the state of translate enabled |
double |
getTransXFactor()
Returns the x translation movement multiplier |
double |
getTransYFactor()
Returns the y translation movement multiplier |
boolean |
getZoomEnable()
Retrieves the state of zoom enabled |
double |
getZoomFactor()
Returns the zoom movement multiplier |
protected void |
integrateTransforms()
Called once per frame (if the view is moving) to calculate the new view platform transform |
void |
MinRadius(java.lang.Object[] r)
Property which sets the minimum radius for the OrbitBehavior. |
protected void |
processAWTEvents(java.awt.AWTEvent[] events)
This is called once per frame if there are any AWT events to process. |
protected void |
processMouseEvent(java.awt.event.MouseEvent evt)
|
void |
ProportionalZoom(java.lang.Object[] state)
Property which sets proportional zoom behavior. |
private void |
resetView()
Reset the orientation and distance of this behavior to the current values in the ViewPlatform Transform Group |
void |
ReverseRotate(java.lang.Object[] state)
Property which sets reverse rotate behavior. |
void |
ReverseTranslate(java.lang.Object[] state)
Property which sets reverse translate behavior. |
void |
ReverseZoom(java.lang.Object[] state)
Property which sets reverse zoom behavior. |
(package private) boolean |
rotate(java.awt.event.MouseEvent evt)
|
void |
RotateEnable(java.lang.Object[] enabled)
Property which enables or disables rotation. |
void |
RotationCenter(java.lang.Object[] center)
Property which sets the center around which the View rotates. |
void |
RotFactors(java.lang.Object[] factors)
Property which sets the rotation x and y factors. |
void |
RotXFactor(java.lang.Object[] xFactor)
Property which sets the rotation x factor. |
void |
RotYFactor(java.lang.Object[] yFactor)
Property which sets the rotation y factor. |
void |
setMinRadius(double r)
Sets the minimum radius for the OrbitBehavior. |
void |
setProportionalZoom(boolean state)
Set proportional zoom behavior. |
void |
setReverseRotate(boolean state)
Set reverse rotate behavior. |
void |
setReverseTranslate(boolean state)
Set reverse translate behavior. |
void |
setReverseZoom(boolean state)
Set reverse zoom behavior. |
void |
setRotateEnable(boolean enabled)
Enables or disables rotation. |
void |
setRotationCenter(Point3d center)
Sets the center around which the View rotates. |
void |
setRotFactors(double xfactor,
double yfactor)
Sets the rotation x and y factors. |
void |
setRotXFactor(double xfactor)
Sets the rotation x factor. |
void |
setRotYFactor(double yfactor)
Sets the rotation y factor. |
void |
setTransFactors(double xfactor,
double yfactor)
Sets the translation x and y factors. |
void |
setTranslateEnable(boolean enabled)
Enables or disables translate. |
void |
setTransXFactor(double xfactor)
Sets the translation x factor. |
void |
setTransYFactor(double yfactor)
Sets the translation y factor. |
void |
setViewingPlatform(ViewingPlatform vp)
Sets the ViewingPlatform for this behavior. |
void |
setZoomEnable(boolean enabled)
Enables or disables zoom. |
void |
setZoomFactor(double zfactor)
Sets the zoom factor. |
void |
TransFactors(java.lang.Object[] factors)
Property which sets the translation x and y factors. |
(package private) boolean |
translate(java.awt.event.MouseEvent evt)
|
void |
TranslateEnable(java.lang.Object[] enabled)
Property which enables or disables translate. |
void |
TransXFactor(java.lang.Object[] xFactor)
Property which sets the translation x factor. |
void |
TransYFactor(java.lang.Object[] yFactor)
Property which sets the translation y factor. |
(package private) boolean |
zoom(java.awt.event.MouseEvent evt)
|
void |
ZoomEnable(java.lang.Object[] enabled)
Property which enables or disables zoom. |
void |
ZoomFactor(java.lang.Object[] zFactor)
Property which sets the zoom factor. |
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformAWTBehavior |
---|
initialize, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, processStimulus, queueAWTEvent, setEnable, setListenerFlags |
Methods inherited from class com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior |
---|
getHomeTransform, getViewingPlatform, goHome, setHomeTransform |
Methods inherited from class javax.media.j3d.Behavior |
---|
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn |
Methods inherited from class javax.media.j3d.Node |
---|
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable |
Methods inherited from class javax.media.j3d.SceneGraphObject |
---|
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Transform3D longditudeTransform
private Transform3D latitudeTransform
private Transform3D rotateTransform
private Transform3D temp1
private Transform3D temp2
private Transform3D translation
private Vector3d transVector
private Vector3d distanceVector
private Vector3d centerVector
private Vector3d invertCenterVector
private double longditude
private double latitude
private double startDistanceFromCenter
private double distanceFromCenter
private Point3d rotationCenter
private Matrix3d rotMatrix
private Transform3D currentXfm
private int mouseX
private int mouseY
private double rotXFactor
private double rotYFactor
private double transXFactor
private double transYFactor
private double zoomFactor
private double xtrans
private double ytrans
private double ztrans
private boolean zoomEnabled
private boolean rotateEnabled
private boolean translateEnabled
private boolean reverseRotate
private boolean reverseTrans
private boolean reverseZoom
private boolean stopZoom
private boolean proportionalZoom
private double minRadius
private int leftButton
private int rightButton
private int middleButton
private float wheelZoomFactor
public static final int REVERSE_ROTATE
public static final int REVERSE_TRANSLATE
public static final int REVERSE_ZOOM
public static final int REVERSE_ALL
public static final int STOP_ZOOM
public static final int DISABLE_ROTATE
public static final int DISABLE_TRANSLATE
public static final int DISABLE_ZOOM
public static final int PROPORTIONAL_ZOOM
private static final int ROTATE
private static final int TRANSLATE
private static final int ZOOM
private static final double NOMINAL_ZOOM_FACTOR
private static final double NOMINAL_PZOOM_FACTOR
private static final double NOMINAL_ROT_FACTOR
private static final double NOMINAL_TRANS_FACTOR
private double rotXMul
private double rotYMul
private double transXMul
private double transYMul
private double zoomMul
Constructor Detail |
---|
public OrbitBehavior()
public OrbitBehavior(Canvas3D c)
c
- The Canvas3D to add the behavior topublic OrbitBehavior(Canvas3D c, int flags)
c
- The Canvas3D to add the behavior toflags
- The option flagsMethod Detail |
---|
protected void processAWTEvents(java.awt.AWTEvent[] events)
ViewPlatformAWTBehavior
motion
variable will be true when the method
is called. If it is true when the method returns integrateTransforms
will be called immediately.
The AWTEvents are presented in the array in the order in which they
arrived from AWT.
processAWTEvents
in class ViewPlatformAWTBehavior
protected void processMouseEvent(java.awt.event.MouseEvent evt)
private void doZoomOperations(int ychange)
public void setViewingPlatform(ViewingPlatform vp)
setViewingPlatform
in class ViewPlatformAWTBehavior
vp
- the target ViewingPlatform for this behaviorprivate void resetView()
protected void integrateTransforms()
ViewPlatformAWTBehavior
integrateTransforms
in class ViewPlatformAWTBehavior
public void setRotationCenter(Point3d center)
center
- The Point3d to set the center of rotation topublic void RotationCenter(java.lang.Object[] center)
center
- array of length 1 containing an instance of Point3dpublic void getRotationCenter(Point3d center)
center
- The Point3dpublic void setRotFactors(double xfactor, double yfactor)
xfactor
- The x movement multiplieryfactor
- The y movement multiplierpublic void RotFactors(java.lang.Object[] factors)
factors
- array of length 2 containing instances of Doublepublic void setRotXFactor(double xfactor)
xfactor
- The x movement multiplierpublic void RotXFactor(java.lang.Object[] xFactor)
xFactor
- array of length 1 containing instance of Doublepublic void setRotYFactor(double yfactor)
yfactor
- The y movement multiplierpublic void RotYFactor(java.lang.Object[] yFactor)
yFactor
- array of length 1 containing instance of Doublepublic void setTransFactors(double xfactor, double yfactor)
xfactor
- The x movement multiplieryfactor
- The y movement multiplierpublic void TransFactors(java.lang.Object[] factors)
factors
- array of length 2 containing instances of Doublepublic void setTransXFactor(double xfactor)
xfactor
- The x movement multiplierpublic void TransXFactor(java.lang.Object[] xFactor)
xFactor
- array of length 1 containing instance of Doublepublic void setTransYFactor(double yfactor)
yfactor
- The y movement multiplierpublic void TransYFactor(java.lang.Object[] yFactor)
yFactor
- array of length 1 containing instance of Doublepublic void setZoomFactor(double zfactor)
zfactor
- The movement multiplierpublic void ZoomFactor(java.lang.Object[] zFactor)
zFactor
- array of length 1 containing instance of Doublepublic double getRotXFactor()
public double getRotYFactor()
public double getTransXFactor()
public double getTransYFactor()
public double getZoomFactor()
public void setRotateEnable(boolean enabled)
enabled
- true or false to enable or disable rotatepublic void RotateEnable(java.lang.Object[] enabled)
enabled
- array of length 1 containing instance of Booleanpublic void setZoomEnable(boolean enabled)
enabled
- true or false to enable or disable zoompublic void ZoomEnable(java.lang.Object[] enabled)
enabled
- array of length 1 containing instance of Booleanpublic void setTranslateEnable(boolean enabled)
enabled
- true or false to enable or disable translatepublic void TranslateEnable(java.lang.Object[] enabled)
enabled
- array of length 1 containing instance of Booleanpublic boolean getRotateEnable()
public boolean getZoomEnable()
public boolean getTranslateEnable()
boolean rotate(java.awt.event.MouseEvent evt)
boolean zoom(java.awt.event.MouseEvent evt)
boolean translate(java.awt.event.MouseEvent evt)
public void setMinRadius(double r)
r
- the minimum radius
java.lang.IllegalArgumentException
- if the radius is less than 0.0public void MinRadius(java.lang.Object[] r)
r
- array of length 1 containing instance of Doublepublic double getMinRadius()
public void setReverseTranslate(boolean state)
state
- if true, reverse translate behaviorpublic void ReverseTranslate(java.lang.Object[] state)
state
- array of length 1 containing instance of Booleanpublic void setReverseRotate(boolean state)
state
- if true, reverse rotate behaviorpublic void ReverseRotate(java.lang.Object[] state)
state
- array of length 1 containing instance of Booleanpublic void setReverseZoom(boolean state)
state
- if true, reverse zoom behaviorpublic void ReverseZoom(java.lang.Object[] state)
state
- array of length 1 containing instance of Booleanpublic void setProportionalZoom(boolean state)
state
- if true, use proportional zoom behaviorpublic void ProportionalZoom(java.lang.Object[] state)
state
- array of length 1 containing instance of Boolean
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |