public class VirtualSphere extends MouseBehavior
Reference: Chen, Michael, Mountford, S. Jay, Sellen, Abigail, "A Study in Interactive 3-D Rotation Using 2-D Control Devices," ACM Siggraph '88 Proceedings, Volume 22, Number 4, August 1988.
To use this utility, first create a transform group that this mouse input behavior will operate on. Then,
The above code will add the virtual sphere behavior to the transform group. The user can then rotate, translate and scale any object attached to the objTrans. This class implements mouse rotation, translation, scaling and mouse wheel scaling actions.VirtualSphere behavior = new VirtualSphere(canvas3D); behavior.setTransformGroup(objTrans); objTrans.addChild(behavior); behavior.setSchedulingBounds(bounds);
Modified by: Joseph A.Huwaldt
Constructor and Description |
---|
VirtualSphere(Canvas3D canvas)
Creates a
VirtualSphere behavior associated with the specified canvas. |
VirtualSphere(JCanvas3D canvas)
Creates a
VirtualSphere behavior associated with the specified canvas. |
Modifier and Type | Method and Description |
---|---|
void |
addTransformChangeListener(TransformChangeListener listener)
Add a
TransformChangeListener to this object. |
BGFGImage |
getFeedbackOverlay()
Returns an
BGFGImage for use in an BGFGCanvas3D that displays a
visual representation of the Virtual Sphere for user feedback. |
double |
getMouseZoomFactor()
Return the mouse zoom multiplier.
|
java.awt.Paint |
getOverlayPaint()
Returns the
Paint used to render the virtual sphere overlay graphics. |
double |
getWheelZoomFactor()
Return the scroll wheel zoom multiplier.
|
double |
getXTranslationFactor()
Return the x-axis translation multiplier.
|
double |
getYTranslationFactor()
Return the y-axis translation multiplier.
|
double |
getZoomScale()
Return the zoom scale.
|
void |
initialize()
Initializes the behavior.
|
void |
processStimulus(java.util.Enumeration criteria)
Processes the MouseBehavior stimulus.
|
void |
removeTransformChangeListener(TransformChangeListener listener)
Remove a
TransformChangeListener from this object. |
void |
setMouseZoomFactor(double factor)
Set the mouse zoom multiplier factor.
|
void |
setOverlayPaint(java.awt.Paint paint)
Sets the
Paint used to render the virtual sphere overlay graphics. |
void |
setRotation(Matrix3d rotationMatrix)
Change the current rotation matrix to the one specified.
|
void |
setRotationCenter(Point3d rotationCenter)
Set the center of rotation on the model for the virtual sphere.
|
void |
setRotationCenter(Point3d rotationCenter,
double zoomScale)
Set the center of rotation on the model and the zoom scale for the virtual sphere.
|
void |
setTranslationFactor(double factor)
Set the X-axis and Y-axis translation multiplier factor.
|
void |
setTranslationFactor(double xFactor,
double yFactor)
Set the X-axis and Y-axis translation multiplier with xFactor and yFactor
respectively.
|
void |
setupCallback(MouseBehaviorCallback callback)
The transformChanged method in the callback class will be called every time the
transform is updated
|
void |
setWheelZoomFactor(double factor)
Set the scroll wheel zoom multiplier with factor.
|
void |
setZoomScale(double zoomScale)
Set the zoom scale.
|
void |
transformChanged(Transform3D transform)
Users can overload this method which is called every time the Behavior updates the
transform.
|
public VirtualSphere(Canvas3D canvas)
VirtualSphere
behavior associated with the specified canvas.canvas
- The Java3D canvas to associate this virtual sphere with.public VirtualSphere(JCanvas3D canvas)
VirtualSphere
behavior associated with the specified canvas.canvas
- The Java3D canvas to associate this virtual sphere with.public void initialize()
public double getXTranslationFactor()
public double getYTranslationFactor()
public double getMouseZoomFactor()
public double getWheelZoomFactor()
public void setTranslationFactor(double factor)
factor
- The factor to set the X & Y axis translation multiplier to.public void setTranslationFactor(double xFactor, double yFactor)
xFactor
- The X-axis translation multiplier factor.yFactor
- The Y-axis translation multiplier factor.public void setMouseZoomFactor(double factor)
factor
- The mouse zoom multiplier.public void setWheelZoomFactor(double factor)
factor
- The scroll wheel zoom multiplier.public double getZoomScale()
public void setZoomScale(double zoomScale)
zoomScale
- The zoom scale to set.public void setRotationCenter(Point3d rotationCenter)
rotationCenter
- The point about which the model should be rotated in virtual
world coordinates.public void setRotationCenter(Point3d rotationCenter, double zoomScale)
rotationCenter
- The point about which the model should be rotated in virtual
world coordinates.zoomScale
- The scale factor used to zoom the model.setZoomScale(double)
public void setRotation(Matrix3d rotationMatrix)
rotationMatrix
- The rotation matrix to be used.public void addTransformChangeListener(TransformChangeListener listener)
TransformChangeListener
to this object.listener
- The listener to add.public void removeTransformChangeListener(TransformChangeListener listener)
TransformChangeListener
from this object.listener
- The listener to add.public BGFGImage getFeedbackOverlay()
BGFGImage
for use in an BGFGCanvas3D
that displays a
visual representation of the Virtual Sphere for user feedback. This overlay is
specific to the canvas that was used to create this virtual sphere and should not
be used with any other canvas.public java.awt.Paint getOverlayPaint()
Paint
used to render the virtual sphere overlay graphics.public void setOverlayPaint(java.awt.Paint paint)
Paint
used to render the virtual sphere overlay graphics.paint
- The paint to use for the virtual sphere overlay graphics.public void processStimulus(java.util.Enumeration criteria)
criteria
- An enumeration of triggered wakeup criteria for this behavior.public void transformChanged(Transform3D transform)
transform
- The new 3D transform.public void setupCallback(MouseBehaviorCallback callback)
callback
- The mouse behavior callback. May pass null for no callback.