Package snap.gfx3d
Class Trackball
java.lang.Object
snap.props.PropObject
snap.view.View
snap.view.ParentView
snap.gfx3d.Trackball
- All Implemented Interfaces:
PropChange.DoChange
,XMLArchiver.Archivable
This class implements the trackball widget. It is an optional replacement for the Scene3DControl.
Trackball encapsulates the Scene3D's behavior, which is that mouse motion in the x direction changes the pitch, and
mouse motion in the y direction changes the yaw. The controll adds rotation about the z axis (roll) by clicking
on a ring outside the trackball.
Note that this particular behavior quickly goes wrong, since
Rotate(y,x,z) * Rotate(dy,dx,dz) != Rotate (y+dy, x+dx, z+dz)
To make the behavior more reasonable, we could try
any of :
1. Make Scene3D keep a matrix,instead of the euler angles and just keep rotating that by dx,dy,dz
2. Get the matrix, rotate by dx,dy,dz, decompose into new euler angles and set those
3. Use quaternions (gasp)
-
Field Summary
Fields inherited from class snap.view.ParentView
_children, Child_Prop, NeedsLayout_Prop
Fields inherited from class snap.view.View
_align, _borderRadius, _effect, _font, _margin, _padding, _repaintRect, _showing, _spacing, _vertical, Action, Align_Prop, Border_Prop, BorderRadius_Prop, Clip_Prop, Cursor_Prop, DEFAULT_ALIGN, DEFAULT_MARGIN, DEFAULT_PADDING, DEFAULT_SPACING, Disabled_Prop, DragEvents, Effect_Prop, Fill_Prop, Focusable_Prop, Focused_Prop, FocusWhenPressed_Prop, Font_Prop, GrowHeight_Prop, GrowWidth_Prop, Height_Prop, KeyEvents, KeyPress, KeyRelease, KeyType, LeanX_Prop, LeanY_Prop, Managed_Prop, Margin_Prop, MaxHeight_Prop, MaxWidth_Prop, MinHeight_Prop, MinWidth_Prop, MouseDrag, MouseEnter, MouseEvents, MouseExit, MouseMove, MousePress, MouseRelease, Name_Prop, Opacity_Prop, Padding_Prop, Paintable_Prop, Parent_Prop, Pickable_Prop, PrefHeight_Prop, PrefWidth_Prop, Rotate_Prop, ScaleX_Prop, ScaleY_Prop, Scroll, Showing_Prop, Spacing_Prop, Text_Prop, ToolTip_Prop, TransX_Prop, TransY_Prop, Vertical_Prop, Visible_Prop, Width_Prop, X_Prop, Y_Prop
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds scuffmark polygons at random points on the trackball.double
getPitch()
Returns the rotation about the X axis in degrees.double
getRoll()
Returns the rotation about the Z axis in degrees.double
getYaw()
Returns the rotation about the Y axis in degrees.protected void
mouseDragged
(ViewEvent anEvent) Handle mouse drag.protected void
mousePressed
(ViewEvent anEvent) Handle mouse press.protected void
mouseReleased
(ViewEvent anEvent) Handle mouse release.protected void
paintAbove
(Painter aPntr) Override to paint scene.protected void
processEvent
(ViewEvent anEvent) Handle events.void
setPitch
(double aValue) Sets the rotation about the X axis in degrees.void
setRoll
(double aValue) Sets the rotation about the Z axis in degrees.void
setWidth
(double aValue) Override to add scuff marks.void
setYaw
(double aValue) Sets the rotation about the Y axis in degrees.void
Sync from given camera to this trackball.void
Sync to a given camera from this trackball.Methods inherited from class snap.view.ParentView
addChild, addChild, addDeepChangeListener, childDidDeepChange, childDidPropChange, fromXML, fromXMLChildren, fromXMLView, getChild, getChildAt, getChildAt, getChildCount, getChildCountManaged, getChildForClass, getChildForName, getChildLast, getChildren, getChildrenForClass, getChildrenInPaintOrder, getChildrenManaged, getFocusNext, getFocusPrev, getPropValue, getViewList, getViewProxy, indexOfChild, initProps, intersectsShape, isInLayout, isNeedsLayout, isNeedsLayoutDeep, isNeedsRepaintDeep, layout, layoutDeep, layoutDeepImpl, layoutFloatingViews, layoutImpl, paintAll, paintChildren, parentFontChanged, processPropChange, relayout, removeChild, removeChild, removeChildren, removeDeepChangeListener, setChildren, setFont, setNeedsLayout, setNeedsLayoutDeep, setNeedsRepaintDeep, setOwner, setOwnerChildren, setPropValue, setShowing, themeChanged, toXML, toXMLChildren, toXMLView
Methods inherited from class snap.view.View
addBinding, addEventFilter, addEventHandler, clone, contains, contains, containsShape, createActionEvent, disableEvents, enableEvents, fireActionEvent, getAlign, getAlignX, getAlignY, getAnim, getAnimCleared, getAnimTimeDeep, getBestHeight, getBestSize, getBestWidth, getBinding, getBinding, getBindingCount, getBindings, getBorder, getBorderRadius, getBounds, getBoundsLocal, getBoundsParent, getBoundsShape, getBoundsShapeParent, getClip, getClipAll, getClipAllBounds, getClipBounds, getClippedRect, getCursor, getDefaultBorder, getDefaultFill, getDefaultFont, getEffect, getEnv, getEventAdapter, getFill, getFillColor, getFocusNext, getFocusPrev, getFont, getHeight, getHost, getInsetsAll, getLean, getLeanX, getLeanY, getLocalToParent, getLocalToParent, getMargin, getMaxHeight, getMaxSize, getMaxWidth, getMaxX, getMaxY, getMidX, getMidY, getMinHeight, getMinHeightImpl, getMinSize, getMinWidth, getMinWidthImpl, getName, getOpacity, getOpacityAll, getOwner, getOwner, getPadding, getParent, getParent, getParentCount, getParentToLocal, getParentToLocal, getPhysics, getPhysics, getPrefHeight, getPrefHeight, getPrefHeightImpl, getPrefSize, getPrefWidth, getPrefWidth, getPrefWidthImpl, getProp, getPropDefault, getProps, getRealClassName, getRepaintRect, getRepaintRectExpanded, getRootView, getRotate, getScale, getScaleX, getScaleY, getSize, getSpacing, getText, getToolTip, getToolTip, getTransX, getTransY, getUpdater, getValuePropName, getVisRect, getWidth, getWindow, getX, getXY, getY, indexInHost, indexInParent, isActionable, isAncestor, isClipToBounds, isDisabled, isEnabled, isFocusable, isFocused, isFocusKeysEnabled, isFocusPainted, isFocusWhenPressed, isFontSet, isGrowHeight, isGrowWidth, isGuest, isHorizontal, isLocalToParentSimple, isManaged, isManagedVisible, isMaxHeightSet, isMaxWidthSet, isMinHeightSet, isMinWidthSet, isMouseDown, isMouseOver, isNeedsRepaint, isPaintable, isPickable, isPickableVisible, isPrefHeightSet, isPrefWidthSet, isShowing, isToolTipEnabled, isVertical, isVisible, localToParent, localToParent, localToParent, localToParent, localToScreen, paintBack, paintFront, parentToLocal, parentToLocal, parentToLocal, parentToLocal, playAnimDeep, processEventAll, processEventFilters, processEventHandlers, relayoutParent, removeBinding, removeBinding, removeEventFilter, removeEventHandler, repaint, repaint, repaint, repaintInParent, requestFocus, runDelayed, runIntervals, runLater, scrollToVisible, setActionable, setAlign, setAlignX, setAlignY, setAnimProps, setAnimString, setAnimTimeDeep, setBorder, setBorder, setBorderRadius, setBounds, setBounds, setBoundsLocal, setClip, setClipToBounds, setCursor, setDisabled, setEffect, setEnabled, setFill, setFocusable, setFocused, setFocusKeysEnabled, setFocusPainted, setFocusWhenPressed, setGrowHeight, setGrowWidth, setHeight, setLean, setLeanX, setLeanY, setManaged, setMargin, setMargin, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinWidth, setName, setOpacity, setPadding, setPadding, setPaintable, setParent, setPickable, setPrefHeight, setPrefSize, setPrefSize, setPrefWidth, setProp, setRealClassName, setRotate, setScale, setScaleX, setScaleY, setSize, setSize, setSizeLocal, setSizeToBestSize, setSizeToPrefSize, setSpacing, setText, setToolTip, setToolTipEnabled, setTransX, setTransY, setVertical, setVisible, setX, setXY, setXYLocal, setY, stopAnimDeep, stopIntervals, toStringProps
Methods inherited from class snap.props.PropObject
addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, isPropDefault, removePropChangeListener, removePropChangeListener, setPropsString, setPropValues, toString
-
Constructor Details
-
Trackball
public Trackball()Creates a Trackball.
-
-
Method Details
-
getYaw
public double getYaw()Returns the rotation about the Y axis in degrees. -
setYaw
public void setYaw(double aValue) Sets the rotation about the Y axis in degrees. -
getPitch
public double getPitch()Returns the rotation about the X axis in degrees. -
setPitch
public void setPitch(double aValue) Sets the rotation about the X axis in degrees. -
getRoll
public double getRoll()Returns the rotation about the Z axis in degrees. -
setRoll
public void setRoll(double aValue) Sets the rotation about the Z axis in degrees. -
setWidth
public void setWidth(double aValue) Override to add scuff marks. -
addScuffMarks
protected void addScuffMarks()Adds scuffmark polygons at random points on the trackball. -
paintAbove
Override to paint scene.- Overrides:
paintAbove
in classParentView
-
processEvent
Handle events.- Overrides:
processEvent
in classView
-
mousePressed
Handle mouse press. -
mouseDragged
Handle mouse drag. -
mouseReleased
Handle mouse release. -
syncFrom
Sync from given camera to this trackball. -
syncTo
Sync to a given camera from this trackball.
-