public class GenericFrame extends Frame implements Grabber, Trackable
Frame
implementing the
Grabber
interface, which converts user gestures into
translation, rotation and scaling Frame
updates (see
translationSensitivity()
, rotationSensitivity()
and
scalingSensitivity()
). A generic-frame may thus be attached to some of your
scene objects to control their motion using an Agent
, such
as the AbstractScene.motionAgent()
and the
AbstractScene.keyboardAgent()
(see
GenericFrame(AbstractScene)
and all the constructors that take an scene
parameter). To attach a generic-frame to MyObject
use code like this:
public class MyObject {
public GenericFrame gFrame;
public void draw() {
gFrame.scene().pushModelView();
gFrame.applyWorldTransformation();
drawMyObject();
gFrame.scene().popModelView();
}
}
See applyTransformation()
, applyWorldTransformation()
,
scene()
, AbstractScene.pushModelView()
and
AbstractScene.popModelView()
A generic-frame may also be attached to an Eye
, such as
the AbstractScene.eyeFrame()
which in turn is attached
to the AbstractScene.eye()
(see isEyeFrame()
).
Some user gestures are then interpreted in a negated way, respect to non-eye frames.
For instance, with a move-to-the-right user gesture the
AbstractScene.eyeFrame()
has to go to the left,
so that the scene seems to move to the right. A generic-frame can be attached to
an eye only at construction times (see GenericFrame(Eye)
and all the
constructors that take an eye parameter). An eye may have more than one generic-frame
attached to it. To set one of them as the Eye.frame()
,
call Eye.setFrame(GenericFrame)
.
This class provides several gesture-to-motion converting methods, such as:
rotate(MotionEvent)
, moveForward(DOF2Event, boolean)
,
translateX(boolean)
, etc. To use them, derive from this class and override the
version of performInteraction
with the (bogus-event) parameter type you want to
customize (see performInteraction(MotionEvent)
,
performInteraction(KeyboardEvent)
, etc.). For example, with the following
code:
protected void performInteraction(DOF2Event event) {
if(event.id() == LEFT)
gestureArcball(event);
if(event.id() == RIGHT)
gestureTranslateXY(event);
}
your custom generic-frame will then accordingly react to the LEFT and RIGHT mouse
buttons, provided it's added to the mouse-agent first (see
Agent.addGrabber(Grabber)
.
Picking a generic-frame is done accordingly to a pickingPrecision()
. Refer to
setPickingPrecision(PickingPrecision)
for details.
A generic-frame is loosely-coupled with the scene object used to instantiate it, i.e.,
the transformation it represents may be applied to a different scene. See
applyTransformation()
and applyTransformation(AbstractScene)
.
Two generic-frames can be synced together (sync(GenericFrame, GenericFrame)
),
meaning that they will share their global parameters (position, orientation and
magnitude) taken the one that has been most recently updated. Syncing can be useful to
share frames among different off-screen scenes (see ProScene's CameraCrane and the
AuxiliarViewer examples).
Finally, a generic-frame can be followed by an Eye
,
defining a 'third-person' eye mode, see Trackable
documentation. See also setTrackingEyeDistance(float)
,
setTrackingEyeAzimuth(float)
and setTrackingEyeInclination(float)
.
Modifier and Type | Class and Description |
---|---|
static class |
GenericFrame.PickingPrecision
Enumerates the Picking precision modes.
|
Modifier and Type | Field and Description |
---|---|
boolean |
dirIsFixed |
DOF2Event |
initEvent |
Constructor and Description |
---|
GenericFrame(AbstractScene scn)
Same as
this(scn, null, new Vec(), scn.is3D() ? new Quat() : new Rot(), 1) . |
GenericFrame(AbstractScene scn,
float s)
Same as
this(scn, null, new Vec(), scn.is3D() ? new Quat() : new Rot(), s) . |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame)
Same as
this(scn, referenceFrame, new Vec(), scn.is3D() ? new Quat() : new Rot(), 1)
. |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
float s)
Same as
this(scn, referenceFrame, new Vec(), scn.is3D() ? new Quat() : new Rot(), s)
. |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
Rotation r)
Same as
this(scn, referenceFrame, new Vec(), r, 1) . |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
Rotation r,
float s)
Same as
this(scn, referenceFrame, new Vec(), r, s) . |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
Vec p)
Same as
this(scn, referenceFrame, p, scn.is3D() ? new Quat() : new Rot(), 1)
. |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
Vec p,
float s)
Same as
this(scn, referenceFrame, p, scn.is3D() ? new Quat() : new Rot(), s)
. |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
Vec p,
Rotation r)
Same as
this(scn, referenceFrame, p, r, 1) . |
GenericFrame(AbstractScene scn,
GenericFrame referenceFrame,
Vec p,
Rotation r,
float s)
Creates a scene generic-frame with
referenceFrame as
referenceFrame() , and p , r and s as the frame
Frame.translation() , Frame.rotation() and Frame.scaling() , respectively. |
GenericFrame(AbstractScene scn,
Rotation r)
Same as
this(scn, null, new Vec(), r, 1) . |
GenericFrame(AbstractScene scn,
Rotation r,
float s)
Same as
this(scn, null, new Vec(), r, s) . |
GenericFrame(AbstractScene scn,
Vec p)
Same as
this(scn, null, p, scn.is3D() ? new Quat() : new Rot(), 1) . |
GenericFrame(AbstractScene scn,
Vec p,
float s)
Same as
this(scn, null, p, scn.is3D() ? new Quat() : new Rot(), s) . |
GenericFrame(AbstractScene scn,
Vec p,
Rotation r)
Same as
this(scn, null, p, r, 1) . |
GenericFrame(AbstractScene scn,
Vec p,
Rotation r,
float s)
Same as
this(scn, null, p, r, s) . |
GenericFrame(Eye eye)
Same as
this(eye, null, new Vec(), eye.scene().is3D() ? new Quat() : new Rot(), 1) . |
GenericFrame(Eye eye,
float s)
Same as
this(eye, null, new Vec(), eye.scene().is3D() ? new Quat() : new Rot(), s) . |
GenericFrame(Eye eye,
GenericFrame referenceFrame) |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
float s)
Same as
this(eye, referenceFrame, new Vec(), eye.scene().is3D() ? new Quat() : new Rot(), s)
. |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
Rotation r)
Same as
this(eye, referenceFrame, new Vec(), r, 1) . |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
Rotation r,
float s)
Same as
this(eye, referenceFrame, new Vec(), r, s) . |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
Vec p)
Same as
this(eye, referenceFrame, p, eye.scene().is3D() ? new Quat() : new Rot(), 1)
. |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
Vec p,
float s)
Same as
this(eye, referenceFrame, p, eye.scene().is3D() ? new Quat() : new Rot(), s)
. |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
Vec p,
Rotation r)
Same as
this(eye, referenceFrame, p, r, 1) . |
GenericFrame(Eye eye,
GenericFrame referenceFrame,
Vec p,
Rotation r,
float s)
Creates an eye generic-frame with
referenceFrame as referenceFrame()
, and p , r and s as the frame Frame.translation() ,
Frame.rotation() and Frame.scaling() , respectively. |
GenericFrame(Eye eye,
Rotation r)
Same as
this(eye, null, new Vec(), r, 1) . |
GenericFrame(Eye eye,
Rotation r,
float s)
Same as
this(eye, null, new Vec(), r, s) . |
GenericFrame(Eye eye,
Vec p)
Same as
this(eye, null, p, eye.scene().is3D() ? new Quat() : new Rot(), 1) . |
GenericFrame(Eye eye,
Vec p,
float s)
Same as
this(eye, null, p, eye.scene().is3D() ? new Quat() : new Rot(), s) . |
GenericFrame(Eye eye,
Vec p,
Rotation r)
Same as
this(eye, null, p, r, 1) . |
Modifier and Type | Method and Description |
---|---|
void |
align()
Wrapper method for
Frame.alignWithFrame(Frame, boolean, float) that discriminates
between eye and non-eye frames. |
void |
anchorFromPixel(ClickEvent event)
User gesture into anchor from pixel conversion routine.
|
void |
applyTransformation()
Convenience function that simply calls
applyTransformation(scene) . |
void |
applyTransformation(AbstractScene scn)
Convenience function that simply calls
scn.applyTransformation(this) . |
void |
applyWorldTransformation()
Convenience function that simply calls
applyWorldTransformation(scene) . |
void |
applyWorldTransformation(AbstractScene scn)
Convenience function that simply calls
scn.applyWorldTransformation(this) . |
void |
center()
Centers the generic-frame into the scene.
|
boolean |
checkIfGrabsInput(BogusEvent event)
Defines the rules to set the grabber as an agent input-grabber.
|
boolean |
checkIfGrabsInput(ClickEvent event)
Internal use.
|
boolean |
checkIfGrabsInput(DOF1Event event)
Internal use.
|
boolean |
checkIfGrabsInput(DOF2Event event)
Internal use.
|
boolean |
checkIfGrabsInput(DOF3Event event)
Internal use.
|
boolean |
checkIfGrabsInput(DOF6Event event)
Internal use.
|
boolean |
checkIfGrabsInput(float x,
float y)
Picks the generic-frame according to the
pickingPrecision() . |
boolean |
checkIfGrabsInput(KeyboardEvent event)
Internal use.
|
boolean |
checkIfGrabsInput(MotionEvent event)
Internal use.
|
List<GenericFrame> |
children()
Returns a list of the frame children, i.e., frame which
referenceFrame() is
this. |
float |
damping()
Defines the spinning deceleration.
|
Rotation |
deformedBallRotation(DOF2Event event,
Vec center)
Returns a Rotation computed according to the mouse motion.
|
void |
disableVisit()
Disables
visit() of this frame when performing the
AbstractScene.traverseTree() . |
void |
disableVisualHint()
Disables drawing of the frame picking hint.
|
void |
drive(DOF2Event event)
User gesture into drive conversion routine.
|
void |
drive(MotionEvent event)
User gesture into drive conversion routine.
|
void |
enableVisit()
Enables
visit() of this frame when performing the
AbstractScene.traverseTree() . |
void |
enableVisualHint()
Enables drawing of the frame picking hint.
|
Eye |
eye()
Returns the eye object this generic-frame is attached to.
|
Vec |
eyeToReferenceFrame(float x,
float y,
float z)
Same as
return eyeToReferenceFrame(new Vec(x, y, z)) . |
Vec |
eyeToReferenceFrame(Vec trns)
Converts the vector from eye coordinates to
referenceFrame() coordinates. |
Vec |
flyDirection()
Returns the incremental translation that is applied by
damping() to the
generic-frame position when it isFlying() . |
float |
flySpeed()
Returns the fly speed, expressed in virtual scene units.
|
GenericFrame |
get()
Perform a deep, non-recursive copy of this generic-frame.
|
boolean |
grabsInput()
Checks if the frame grabs input from any agent registered at the scene input handler.
|
boolean |
grabsInput(Agent agent)
Check if this object is the
Agent.inputGrabber() . |
float |
grabsInputThreshold()
Returns the grabs input threshold which is used by the interactive frame to
checkIfGrabsInput(BogusEvent) . |
void |
hinge(DOF6Event event)
User gesture into hinge conversion routine.
|
void |
hinge(MotionEvent event)
User gesture into hinge conversion routine.
|
boolean |
isEyeFrame()
Returns true if the generic-frame is attached to an eye, and false otherwise.
|
boolean |
isFlying()
Returns
true when the generic-frame is tossing. |
boolean |
isSceneAvatar()
Same as
return scene().avatar() == this . |
boolean |
isSpinning()
Returns
true when the generic-frame is spinning. |
boolean |
isVisitEnabled()
Returns true if
visit() of this frame when performing the
is enabled . |
boolean |
isVisualHintEnabled()
Returns
true if drawing of the frame picking hint is enabled and
false otherwise. |
float |
keyboardSensitivity()
Returns the keyboard sensitivity.
|
long |
lastUpdate() |
void |
lookAround(MotionEvent event) |
void |
moveBackward(MotionEvent event)
User gesture into move-backward conversion routine.
|
void |
moveForward(MotionEvent event)
User gesture into move-forward conversion routine.
|
void |
performInteraction(BogusEvent event)
Defines how the grabber should react according to the given bogus-event.
|
GenericFrame.PickingPrecision |
pickingPrecision()
Returns the frame picking precision.
|
GenericFrame |
referenceFrame()
Returns the reference Frame, in which coordinates system the Frame is defined.
|
void |
rotate(DOF2Event event)
User gesture into arcball-rotation conversion routine.
|
void |
rotate(MotionEvent event)
User gesture into arcball-rotation conversion routine.
|
void |
rotateAroundFrame(float roll,
float pitch,
float yaw,
Frame frame) |
void |
rotateCAD(DOF2Event event)
User gesture into CAD-rotation conversion routine.
|
void |
rotateCAD(MotionEvent event)
User gesture into CAD-rotation conversion routine.
|
void |
rotateX(DOF1Event event)
User gesture into x-rotation conversion routine.
|
void |
rotateX(MotionEvent event)
User gesture into x-rotation conversion routine.
|
void |
rotateXNeg()
User gesture into x-rotation conversion routine.
|
void |
rotateXPos()
User gesture into x-rotation conversion routine.
|
void |
rotateXYZ(DOF3Event event)
User gesture into xyz-rotation conversion routine.
|
void |
rotateY(DOF1Event event)
User gesture into y-rotation conversion routine.
|
void |
rotateY(MotionEvent event)
User gesture into y-rotation conversion routine.
|
void |
rotateYNeg()
User gesture into y-rotation conversion routine.
|
void |
rotateYPos()
User gesture into y-rotation conversion routine.
|
void |
rotateZ(DOF1Event event)
User gesture into z-rotation conversion routine.
|
void |
rotateZ(MotionEvent event)
User gesture into z-rotation conversion routine.
|
void |
rotateZNeg()
User gesture into z-rotation conversion routine.
|
void |
rotateZPos()
User gesture into z-rotation conversion routine.
|
float |
rotationSensitivity()
Returns the influence of a gesture displacement on the generic-frame rotation.
|
void |
scale(DOF1Event event)
User gesture into scaling conversion routine.
|
void |
scale(MotionEvent event)
User gesture into scaling conversion routine.
|
void |
scaleNeg()
User gesture into scaling conversion routine.
|
void |
scalePos()
User gesture into scaling conversion routine.
|
float |
scalingSensitivity()
Returns the influence of a gesture displacement on the generic-frame scaling.
|
AbstractScene |
scene()
Returns the scene this object belongs to.
|
Vec |
sceneUpVector()
Returns the up vector used in
moveForward(MotionEvent) in which horizontal
displacements of the motion device (e.g., mouse) rotate generic-frame around this
vector. |
void |
screenRotate(DOF2Event event)
User gesture screen-rotation conversion routine.
|
void |
screenRotate(MotionEvent event)
User gesture screen-rotation conversion routine.
|
Vec |
screenToEye(float x,
float y,
float z)
Same as
return screenToEye(new Vec(x, y, z)) . |
Vec |
screenToEye(Vec trns)
Converts the vector from screen (device) coordinates into eye coordinates.
|
Quat |
screenToQuat(float roll,
float pitch,
float yaw)
Reduces the screen (device)
Extrinsic
rotation into a
Quat . |
Quat |
screenToQuat(Vec angles)
Same as
return screenToQuat(angles.vec[0], angles.vec[1], angles.vec[2]) . |
Vec |
screenToVec(float x,
float y,
float z)
Same as
return screenToVec(new Vec(x, y, z)) . |
Vec |
screenToVec(Vec trns)
Same as
return eyeToReferenceFrame(screenToEye(trns)) . |
void |
screenTranslate(DOF2Event event)
User gesture screen-translate conversion routine.
|
void |
screenTranslate(MotionEvent event)
User gesture screen-translate conversion routine.
|
void |
setDamping(float f)
Defines the
damping() . |
void |
setFlyDirection(Vec dir)
Defines the
flyDirection() in the reference frame coordinate system. |
void |
setFlySpeed(float speed)
Sets the
flySpeed() , defined in virtual scene units. |
void |
setGrabsInputThreshold(float threshold)
Sets the length of the squared area around the frame
center() screen
projection that defined the checkIfGrabsInput(BogusEvent) condition used for
frame picking. |
void |
setKeyboardSensitivity(float sensitivity)
Defines the
keyboardSensitivity() . |
void |
setPickingPrecision(GenericFrame.PickingPrecision precision)
Sets the picking precision of the frame.
|
void |
setReferenceFrame(Frame frame)
Sets the
Frame.referenceFrame() of the Frame. |
void |
setReferenceFrame(GenericFrame frame) |
void |
setRotationSensitivity(float sensitivity)
Defines the
rotationSensitivity() . |
void |
setScalingSensitivity(float sensitivity)
Defines the
scalingSensitivity() . |
void |
setSceneUpVector(Vec up)
Sets the
sceneUpVector() , defined in the world coordinate system. |
void |
setSpinningRotation(Rotation spinningRotation)
Defines the
spinningRotation() . |
void |
setSpinningSensitivity(float sensitivity)
Defines the
spinningSensitivity() . |
void |
setTrackingEyeAzimuth(float a)
Sets the
trackingEyeAzimuth() of the tracking camera. |
void |
setTrackingEyeDistance(float d)
Sets the distance between the frame and the tracking camera.
|
void |
setTrackingEyeInclination(float i)
Sets the
trackingEyeInclination() of the tracking camera. |
void |
setTranslationSensitivity(float sensitivity)
Defines the
translationSensitivity() . |
void |
setWheelSensitivity(float sensitivity)
Defines the
wheelSensitivity() . |
Rotation |
spinningRotation()
Returns the incremental rotation that is applied by
spin() to the
generic-frame orientation when it isSpinning() . |
float |
spinningSensitivity()
Returns the minimum gesture speed required to make the generic-frame
spin() . |
void |
startFlying(Vec direction,
float speed)
Starts the tossing of the generic-frame.
|
void |
startSpinning(Rotation rt,
float speed,
long delay)
Starts the spinning of the generic-frame.
|
void |
stopFlying()
Stops the tossing motion started using
startFlying(MotionEvent, Vec) . |
void |
stopSpinning()
Stops the spinning motion started using
startSpinning(MotionEvent, Rotation)
. |
void |
sync(GenericFrame otherFrame)
Same as
sync(this, otherFrame) . |
static void |
sync(GenericFrame f1,
GenericFrame f2)
If
f1 has been more recently updated than f2 , calls
f2.setWorldMatrix(f1) , otherwise calls f1.setWorldMatrix(f2) . |
void |
toggleVisit()
Toggles
visit() of this frame when performing the
AbstractScene.traverseTree() . |
void |
toggleVisualHint()
Toggles drawing of the frame picking hint.
|
float |
trackingEyeAzimuth()
Returns the azimuth of the tracking camera measured respect to the frame's
Frame.zAxis() . |
float |
trackingEyeDistance()
Returns the distance between the frame and the tracking camera.
|
GenericFrame |
trackingEyeFrame()
Overloading of
Trackable.trackingEyeFrame() . |
float |
trackingEyeInclination()
Returns the inclination of the tracking camera measured respect to the frame's
Frame.yAxis() . |
void |
translate(DOF2Event event)
User gesture into xy-translation conversion routine.
|
void |
translate(MotionEvent event)
User gesture into xy-translation conversion routine.
|
void |
translateRotateXYZ(MotionEvent event)
User gesture into xyz-translation and rotation conversion routine.
|
void |
translateX(DOF1Event event)
User gesture into x-translation conversion routine.
|
void |
translateX(MotionEvent event)
User gesture into x-translation conversion routine.
|
void |
translateXNeg()
User gesture into x-translation conversion routine.
|
void |
translateXPos()
User gesture into x-translation conversion routine.
|
void |
translateXYZ(DOF3Event event)
User gesture into xyz-translation conversion routine.
|
void |
translateXYZ(MotionEvent event)
User gesture into xyz-translation conversion routine.
|
void |
translateY(DOF1Event event)
User gesture into y-translation conversion routine.
|
void |
translateY(MotionEvent event)
User gesture into x-translation conversion routine.
|
void |
translateYNeg()
User gesture into y-translation conversion routine.
|
void |
translateYPos()
User gesture into y-translation conversion routine.
|
void |
translateZ(DOF1Event event)
User gesture into z-translation conversion routine.
|
void |
translateZ(MotionEvent event)
User gesture into z-translation conversion routine.
|
void |
translateZNeg()
User gesture into z-translation conversion routine.
|
void |
translateZPos()
User gesture into z-translation conversion routine.
|
float |
translationSensitivity()
Returns the influence of a gesture displacement on the generic-frame translation.
|
void |
updateSceneUpVector()
This method will be called by the Eye when its orientation is changed, so that the
sceneUpVector() is changed accordingly. |
void |
visitCallback() |
float |
wheelSensitivity()
Returns the wheel sensitivity.
|
void |
zoomOnAnchor(MotionEvent event)
User gesture into zoom-on-anchor conversion routine.
|
void |
zoomOnAnchorNeg()
User gesture into zoom-on-anchor conversion routine.
|
void |
zoomOnAnchorPos()
User gesture into zoom-on-anchor conversion routine.
|
void |
zoomOnPixel(ClickEvent event)
User gesture into zoom on pixel conversion routine.
|
void |
zoomOnRegion(DOF2Event event)
User gesture into zoom-on-region conversion routine.
|
void |
zoomOnRegion(MotionEvent event)
User gesture into zoom-on-region conversion routine.
|
alignWithFrame, alignWithFrame, alignWithFrame, alignWithFrame, constraint, coordinatesOf, coordinatesOfFrom, coordinatesOfIn, equals, fromMatrix, fromMatrix, hashCode, inverse, inverseCoordinatesOf, inverseTransformOf, is2D, is3D, localCoordinatesOf, localInverseCoordinatesOf, localInverseTransformOf, localTransformOf, magnitude, matrix, orientation, position, projectOnLine, rotate, rotate, rotateAroundFrame, rotateAroundPoint, rotation, scale, scaling, set, setConstraint, setMagnitude, setMatrix, setOrientation, setOrientation, setOrientationWithConstraint, setPosition, setPosition, setPosition, setPositionWithConstraint, setRotation, setRotation, setRotation, setRotationWithConstraint, setScaling, settingAsReferenceFrameWillCreateALoop, setTranslation, setTranslation, setTranslation, setTranslationWithConstraint, setWorldMatrix, setXAxis, setYAxis, setZAxis, transformOf, transformOfFrom, transformOfIn, translate, translate, translate, translation, worldInverse, worldMatrix, xAxis, xAxis, yAxis, yAxis, zAxis, zAxis
public boolean dirIsFixed
public DOF2Event initEvent
public GenericFrame(AbstractScene scn)
this(scn, null, new Vec(), scn.is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(Eye eye)
this(eye, null, new Vec(), eye.scene().is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(AbstractScene scn, Vec p)
this(scn, null, p, scn.is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(Eye eye, Vec p)
this(eye, null, p, eye.scene().is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(AbstractScene scn, Rotation r)
this(scn, null, new Vec(), r, 1)
.public GenericFrame(AbstractScene scn, float s)
this(scn, null, new Vec(), scn.is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(Eye eye, float s)
this(eye, null, new Vec(), eye.scene().is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(AbstractScene scn, Vec p, float s)
this(scn, null, p, scn.is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(Eye eye, Vec p, float s)
this(eye, null, p, eye.scene().is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(AbstractScene scn, Vec p, Rotation r)
this(scn, null, p, r, 1)
.public GenericFrame(AbstractScene scn, Rotation r, float s)
this(scn, null, new Vec(), r, s)
.public GenericFrame(Eye eye, Rotation r, float s)
this(eye, null, new Vec(), r, s)
.public GenericFrame(AbstractScene scn, Vec p, Rotation r, float s)
this(scn, null, p, r, s)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame)
this(scn, referenceFrame, new Vec(), scn.is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(Eye eye, GenericFrame referenceFrame)
public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, Vec p)
this(scn, referenceFrame, p, scn.is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(Eye eye, GenericFrame referenceFrame, Vec p)
this(eye, referenceFrame, p, eye.scene().is3D() ? new Quat() : new Rot(), 1)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, Rotation r)
this(scn, referenceFrame, new Vec(), r, 1)
.public GenericFrame(Eye eye, GenericFrame referenceFrame, Rotation r)
this(eye, referenceFrame, new Vec(), r, 1)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, float s)
this(scn, referenceFrame, new Vec(), scn.is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(Eye eye, GenericFrame referenceFrame, float s)
this(eye, referenceFrame, new Vec(), eye.scene().is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, Vec p, float s)
this(scn, referenceFrame, p, scn.is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(Eye eye, GenericFrame referenceFrame, Vec p, float s)
this(eye, referenceFrame, p, eye.scene().is3D() ? new Quat() : new Rot(), s)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, Vec p, Rotation r)
this(scn, referenceFrame, p, r, 1)
.public GenericFrame(Eye eye, GenericFrame referenceFrame, Vec p, Rotation r)
this(eye, referenceFrame, p, r, 1)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, Rotation r, float s)
this(scn, referenceFrame, new Vec(), r, s)
.public GenericFrame(Eye eye, GenericFrame referenceFrame, Rotation r, float s)
this(eye, referenceFrame, new Vec(), r, s)
.public GenericFrame(AbstractScene scn, GenericFrame referenceFrame, Vec p, Rotation r, float s)
referenceFrame
as
referenceFrame()
, and p
, r
and s
as the frame
Frame.translation()
, Frame.rotation()
and Frame.scaling()
, respectively.
The AbstractScene.inputHandler()
will attempt to add
the generic-frame to all its InputHandler.agents()
, such
as the AbstractScene.motionAgent()
and the
AbstractScene.keyboardAgent()
.
The generic-frame sensitivities are set to their default values, see
spinningSensitivity()
, wheelSensitivity()
,
keyboardSensitivity()
, rotationSensitivity()
,
translationSensitivity()
and scalingSensitivity()
.
Sets the pickingPrecision()
to GenericFrame.PickingPrecision.FIXED
.
After object creation a call to isEyeFrame()
will return false
.
public GenericFrame(Eye eye, GenericFrame referenceFrame, Vec p, Rotation r, float s)
referenceFrame
as referenceFrame()
, and p
, r
and s
as the frame Frame.translation()
,
Frame.rotation()
and Frame.scaling()
, respectively.
The generic-frame isn't added to any of the
AbstractScene.inputHandler()
InputHandler.agents()
. A call to
AbstractScene.setEye(Eye)
will do it.
The generic-frame sensitivities are set to their default values, see
spinningSensitivity()
, wheelSensitivity()
,
keyboardSensitivity()
, rotationSensitivity()
,
translationSensitivity()
and scalingSensitivity()
.
After object creation a call to isEyeFrame()
will return true
.
public GenericFrame get()
The copied frame will keep this frame referenceFrame()
, but its children
aren't copied.
public GenericFrame referenceFrame()
Frame
The Frame Frame.translation()
, Frame.rotation()
and Frame.scaling()
are
defined with respect to the Frame.referenceFrame()
coordinate system. A
null
reference Frame (default value) means that the Frame is defined in the
world coordinate system.
Use Frame.position()
, Frame.orientation()
and Frame.magnitude()
to
recursively convert values along the reference Frame chain and to get values
expressed in the world coordinate system. The values match when the reference Frame
is null
.
Use Frame.setReferenceFrame(Frame)
to set this value and create a Frame hierarchy.
Convenient functions allow you to convert coordinates from one Frame to another: see
Frame.coordinatesOf(Vec)
, Frame.localCoordinatesOf(Vec)
,
Frame.coordinatesOfIn(Vec, Frame)
and their inverse functions.
Vectors can also be converted using Frame.transformOf(Vec)
,
Frame.transformOfIn(Vec, Frame)
, Frame.localTransformOf(Vec)
and their inverse
functions.
referenceFrame
in class Frame
public void setReferenceFrame(Frame frame)
Frame
Frame.referenceFrame()
of the Frame.
The Frame Frame.translation()
, Frame.rotation()
and Frame.scaling()
are then
defined in the Frame.referenceFrame()
coordinate system.
Use Frame.position()
, Frame.orientation()
and Frame.magnitude()
to express
these in the world coordinate system.
Using this method, you can create a hierarchy of Frames. This hierarchy needs to be a
tree, which root is the world coordinate system (i.e., null
Frame.referenceFrame()
). No action is performed if setting refFrame
as the
Frame.referenceFrame()
would create a loop in the Frame hierarchy.
setReferenceFrame
in class Frame
public void setReferenceFrame(GenericFrame frame)
public final List<GenericFrame> children()
referenceFrame()
is
this.public void visitCallback()
public void enableVisit()
visit()
of this frame when performing the
AbstractScene.traverseTree()
.disableVisit()
,
toggleVisit()
,
isVisitEnabled()
public void disableVisit()
visit()
of this frame when performing the
AbstractScene.traverseTree()
.enableVisit()
,
toggleVisit()
,
isVisitEnabled()
public void toggleVisit()
visit()
of this frame when performing the
AbstractScene.traverseTree()
.enableVisit()
,
disableVisit()
,
isVisitEnabled()
public boolean isVisitEnabled()
visit()
of this frame when performing the
is enabled
.enableVisit()
,
disableVisit()
,
toggleVisit()
public void enableVisualHint()
public void disableVisualHint()
public void toggleVisualHint()
public boolean isVisualHintEnabled()
true
if drawing of the frame picking hint is enabled and
false
otherwise. Always returns false
if frame is an eye frame.public AbstractScene scene()
Note that if this isEyeFrame()
then returns eye().scene()
.
eye()
,
Eye.scene()
public Eye eye()
isEyeFrame()
public boolean isEyeFrame()
eye()
public boolean checkIfGrabsInput(BogusEvent event)
Grabber
checkIfGrabsInput
in interface Grabber
Agent.updateTrackedGrabber(BogusEvent)
,
Agent.inputGrabber()
public boolean checkIfGrabsInput(MotionEvent event)
public boolean checkIfGrabsInput(ClickEvent event)
public boolean checkIfGrabsInput(KeyboardEvent event)
Override this method when you want the object to be picked from a KeyboardEvent
.
public boolean checkIfGrabsInput(DOF1Event event)
Override this method when you want the object to be picked from a DOF1Event
.
public boolean checkIfGrabsInput(DOF2Event event)
public boolean checkIfGrabsInput(float x, float y)
pickingPrecision()
.public boolean checkIfGrabsInput(DOF3Event event)
public boolean checkIfGrabsInput(DOF6Event event)
public void performInteraction(BogusEvent event)
Grabber
performInteraction
in interface Grabber
Agent.handle(BogusEvent)
public void applyTransformation()
applyTransformation(scene)
. It applies
the transformation defined by the frame to the scene used to instantiated.applyTransformation(AbstractScene)
,
Frame.matrix()
public void applyWorldTransformation()
applyWorldTransformation(scene)
. It
applies the world transformation defined by the frame to the scene used to
instantiated.public void applyTransformation(AbstractScene scn)
scn.applyTransformation(this)
. You may
apply the transformation represented by this frame to any scene you want using this
method.
Very efficient prefer always this than
public void applyWorldTransformation(AbstractScene scn)
scn.applyWorldTransformation(this)
.
You may apply the world transformation represented by this frame to any scene you
want using this method.public long lastUpdate()
public void sync(GenericFrame otherFrame)
sync(this, otherFrame)
.sync(GenericFrame, GenericFrame)
public static void sync(GenericFrame f1, GenericFrame f2)
f1
has been more recently updated than f2
, calls
f2.setWorldMatrix(f1)
, otherwise calls f1.setWorldMatrix(f2)
. Does
nothing if both objects were updated at the same frame.
This method syncs only the global geometry attributes (Frame.position()
,
Frame.orientation()
and Frame.magnitude()
) among the two frames. The
referenceFrame()
and Frame.constraint()
(if any) of each frame are kept
separately.
Frame.set(Frame)
public float damping()
Default value is 0.5. Use setDamping(float)
to tune this value. A higher
value will make damping more difficult (a value of 1.0 forbids damping).
public void setDamping(float f)
damping()
. Values must be in the range [0..1].public final void setRotationSensitivity(float sensitivity)
rotationSensitivity()
.public final void setScalingSensitivity(float sensitivity)
scalingSensitivity()
.public final void setTranslationSensitivity(float sensitivity)
translationSensitivity()
.public final void setSpinningSensitivity(float sensitivity)
spinningSensitivity()
.public final void setWheelSensitivity(float sensitivity)
wheelSensitivity()
.public final void setKeyboardSensitivity(float sensitivity)
keyboardSensitivity()
.public final float rotationSensitivity()
Default value is 1.0 (which matches an identical mouse displacement), a higher value
will generate a larger rotation (and inversely for lower values). A 0.0 value will
forbid rotation (see also Frame.constraint()
).
public final float scalingSensitivity()
Default value is 1.0, a higher value will generate a larger scaling (and inversely
for lower values). A 0.0 value will forbid scaling (see also Frame.constraint()
).
public final float translationSensitivity()
Default value is 1.0 which in the case of a mouse interaction makes the generic-frame precisely stays under the mouse cursor.
With an identical gesture displacement, a higher value will generate a larger
translation (and inversely for lower values). A 0.0 value will forbid translation
(see also Frame.constraint()
).
public final float spinningSensitivity()
spin()
.
Spinning requires to set to damping()
to 0.
See spin()
, spinningRotation()
and
startSpinning(MotionEvent, Rotation)
for details.
Gesture speed is expressed in pixels per milliseconds. Default value is 0.3 (300
pixels per second). Use setSpinningSensitivity(float)
to tune this value. A
higher value will make spinning more difficult (a value of 100.0 forbids spinning in
practice).
public float wheelSensitivity()
Default value is 15.0. A higher value will make the wheel action more efficient (usually meaning faster motion). Use a negative value to invert the operation direction.
public float keyboardSensitivity()
Default value is 10. A higher value will make the keyboard more efficient (usually meaning faster motion).
public final boolean isSpinning()
true
when the generic-frame is spinning.
During spinning, spin()
rotates the generic-frame by its
spinningRotation()
at a frequency defined when the generic-frame
startSpinning(MotionEvent, Rotation)
.
Use startSpinning(MotionEvent, Rotation)
and stopSpinning()
to
change this state. Default value is false
.
isFlying()
public final Rotation spinningRotation()
spin()
to the
generic-frame orientation when it isSpinning()
.
Default value is a null
rotation. Use setSpinningRotation(Rotation)
to change this value.
The spinningRotation()
axis is defined in the generic-frame coordinate
system. You can use Frame.transformOfFrom(Vec, Frame)
to convert this axis from another Frame coordinate system.
Attention: Spinning may be decelerated according to damping()
till it
stops completely.
flyDirection()
public final void setSpinningRotation(Rotation spinningRotation)
spinningRotation()
. Its axis is defined in the generic-frame
coordinate system.setFlyDirection(Vec)
public final void stopSpinning()
startSpinning(MotionEvent, Rotation)
. isSpinning()
will return false
after this call.
Attention: This method may be called by spin()
, since spinning may be
decelerated according to damping()
till it stops completely.
damping()
public void startSpinning(Rotation rt, float speed, long delay)
This method starts a timer that will call spin()
every
updateInterval
milliseconds. The generic-frame isSpinning()
until
you call stopSpinning()
.
Attention: Spinning may be decelerated according to damping()
till it
stops completely.
damping()
,
startFlying(Vec, float)
public Rotation deformedBallRotation(DOF2Event event, Vec center)
center.x()
, center.y()
).public void align()
Frame.alignWithFrame(Frame, boolean, float)
that discriminates
between eye and non-eye frames.public void center()
public void translateX(MotionEvent event)
public void translateX(DOF1Event event)
public void translateXPos()
public void translateXNeg()
public void translateY(MotionEvent event)
public void translateY(DOF1Event event)
public void translateYPos()
public void translateYNeg()
public void translateZ(MotionEvent event)
public void translateZ(DOF1Event event)
public void translateZPos()
public void translateZNeg()
public void translate(MotionEvent event)
public void translate(DOF2Event event)
public void translateXYZ(MotionEvent event)
public void translateRotateXYZ(MotionEvent event)
public void translateXYZ(DOF3Event event)
public void zoomOnAnchor(MotionEvent event)
Eye.anchor()
public void zoomOnAnchorPos()
Eye.anchor()
public void zoomOnAnchorNeg()
Eye.anchor()
public void zoomOnRegion(MotionEvent event)
public void zoomOnRegion(DOF2Event event)
public void rotateX(MotionEvent event)
public void rotateX(DOF1Event event)
public void rotateXPos()
public void rotateXNeg()
public void rotateY(MotionEvent event)
public void rotateY(DOF1Event event)
public void rotateYPos()
public void rotateYNeg()
public void rotateZ(MotionEvent event)
public void rotateZ(DOF1Event event)
public void rotateZPos()
public void rotateZNeg()
public void rotateXYZ(DOF3Event event)
public void rotate(MotionEvent event)
public void rotate(DOF2Event event)
public void scale(MotionEvent event)
public void scale(DOF1Event event)
public void scalePos()
public void scaleNeg()
public void lookAround(MotionEvent event)
public void moveBackward(MotionEvent event)
public void moveForward(MotionEvent event)
public void drive(MotionEvent event)
public void drive(DOF2Event event)
public void rotateCAD(MotionEvent event)
public void rotateCAD(DOF2Event event)
public void hinge(MotionEvent event)
public void hinge(DOF6Event event)
public void screenTranslate(MotionEvent event)
public void screenTranslate(DOF2Event event)
public void screenRotate(MotionEvent event)
public void screenRotate(DOF2Event event)
public void anchorFromPixel(ClickEvent event)
public void zoomOnPixel(ClickEvent event)
public Vec screenToVec(float x, float y, float z)
return screenToVec(new Vec(x, y, z))
.screenToVec(Vec)
public Vec screenToVec(Vec trns)
return eyeToReferenceFrame(screenToEye(trns))
. Transforms the vector
from screen (device) coordinates to referenceFrame()
coordinates.screenToEye(Vec)
,
eyeToReferenceFrame(Vec)
public Vec eyeToReferenceFrame(float x, float y, float z)
return eyeToReferenceFrame(new Vec(x, y, z))
.eyeToReferenceFrame(Vec)
public Vec eyeToReferenceFrame(Vec trns)
referenceFrame()
coordinates.
It's worth noting that all gesture to generic-frame motion converting methods, are
implemented from just screenToEye(Vec)
, eyeToReferenceFrame(Vec)
and screenToQuat(float, float, float)
.
public Vec screenToEye(float x, float y, float z)
return screenToEye(new Vec(x, y, z))
.screenToEye(Vec)
public Vec screenToEye(Vec trns)
It's worth noting that all gesture to generic-frame motion converting methods, are
implemented from just screenToEye(Vec)
, eyeToReferenceFrame(Vec)
and screenToQuat(float, float, float)
.
public Quat screenToQuat(Vec angles)
return screenToQuat(angles.vec[0], angles.vec[1], angles.vec[2])
.screenToQuat(float, float, float)
public Quat screenToQuat(float roll, float pitch, float yaw)
Quat
.
It's worth noting that all gesture to generic-frame motion converting methods, are
implemented from just screenToEye(Vec)
, eyeToReferenceFrame(Vec)
and screenToQuat(float, float, float)
.
roll
- Rotation angle in radians around the screen x-Axispitch
- Rotation angle in radians around the screen y-Axisyaw
- Rotation angle in radians around the screen z-AxisQuat.fromEulerAngles(float, float, float)
public void rotateAroundFrame(float roll, float pitch, float yaw, Frame frame)
rotateAroundFrame
in class Frame
public Vec sceneUpVector()
moveForward(MotionEvent)
in which horizontal
displacements of the motion device (e.g., mouse) rotate generic-frame around this
vector. Vertical displacements rotate always around the generic-frame X
axis.
This value is also used within rotateCAD(MotionEvent)
to define the up
vector (and incidentally the 'horizon' plane) around which the generic-frame will
rotate.
Default value is (0,1,0), but it is updated by the Eye when set as its
Eye.frame()
.
Eye.setOrientation(Rotation)
and
Eye.setUpVector(Vec)
modify this value and should be
used instead.
public void setSceneUpVector(Vec up)
sceneUpVector()
, defined in the world coordinate system.
Default value is (0,1,0), but it is updated by the Eye when set as its
Eye.frame()
. Use
Eye.setUpVector(Vec)
instead in that case.
public final void updateSceneUpVector()
sceneUpVector()
is changed accordingly. You should not need to call this
method.public final boolean isFlying()
true
when the generic-frame is tossing.
During tossing, damping()
translates the generic-frame by its
flyDirection()
at a frequency defined when the generic-frame
startFlying(MotionEvent, Vec)
.
Use startFlying(MotionEvent, Vec)
and stopFlying()
to change this
state. Default value is false
.
public final void stopFlying()
startFlying(MotionEvent, Vec)
.
isFlying()
will return false
after this call.
Attention: This method may be called by damping()
, since tossing may
be decelerated according to damping()
till it stops completely.
public final Vec flyDirection()
damping()
to the
generic-frame position when it isFlying()
.
Default value is no translation. Use setFlyDirection(Vec)
to change this
value.
Attention: Tossing may be decelerated according to damping()
till it
stops completely.
spinningRotation()
public final void setFlyDirection(Vec dir)
flyDirection()
in the reference frame coordinate system.setSpinningRotation(Rotation)
public void startFlying(Vec direction, float speed)
This method starts a timer that will call damping()
every FLY_UPDATE_PERDIOD
milliseconds. The generic-frame isFlying()
until you call
stopFlying()
.
Attention: Tossing may be decelerated according to damping()
till it
stops completely.
public float flySpeed()
It corresponds to the incremental displacement that is periodically applied to the
generic-frame by moveForward(MotionEvent, boolean)
.
Attention: When the generic-frame is set as the
Eye.frame()
or when it is set as the
AbstractScene.avatar()
, this value is set according
to the AbstractScene.radius()
by
AbstractScene.setRadius(float)
.
public void setFlySpeed(float speed)
flySpeed()
, defined in virtual scene units.
Default value is 0.0, but it is modified according to the
AbstractScene.radius()
when the generic-frame is set
as the Eye.frame()
or when the generic-frame is set
as the AbstractScene.avatar()
.
public float grabsInputThreshold()
checkIfGrabsInput(BogusEvent)
.setGrabsInputThreshold(float)
public GenericFrame.PickingPrecision pickingPrecision()
setPickingPrecision(PickingPrecision)
for details.public void setPickingPrecision(GenericFrame.PickingPrecision precision)
When pickingPrecision()
is GenericFrame.PickingPrecision.FIXED
or
GenericFrame.PickingPrecision.ADAPTIVE
Picking is done by checking if the pointer lies
within a squared area around the frame center()
screen projection which size
is defined by setGrabsInputThreshold(float)
.
When pickingPrecision()
is GenericFrame.PickingPrecision.EXACT
, picking is done
in a precise manner according to the projected pixels of the graphics related to the
frame. It is meant to be implemented by generic frame derived classes and requires
the scene to implement a so called picking buffer (see the proscene
Scene class for a possible implementation) and the frame to implement means to
attach graphics to it (see the proscene
InteractiveFrame class for a possible implementation). Default implementation of
this policy will behave like GenericFrame.PickingPrecision.FIXED
.
pickingPrecision()
,
setGrabsInputThreshold(float)
public void setGrabsInputThreshold(float threshold)
center()
screen
projection that defined the checkIfGrabsInput(BogusEvent)
condition used for
frame picking.
If pickingPrecision()
is GenericFrame.PickingPrecision.FIXED
, the
threshold
is expressed in pixels and directly defines the fixed length of the
AbstractScene.drawShooterTarget(Vec, float)
, centered
at the projection of the frame origin onto the screen.
If pickingPrecision()
is GenericFrame.PickingPrecision.ADAPTIVE
, the
threshold
is expressed in object space (world units) and defines the edge
length of a squared bounding box that leads to an adaptive length of the
AbstractScene.drawShooterTarget(Vec, float)
,
centered at the projection of the frame origin onto the screen. Use this version only
if you have a good idea of the bounding box size of the object you are attaching to
the frame.
The value is meaningless when the pickingPrecision()
is
GenericFrame.PickingPrecision.EXACT
. See setPickingPrecision(PickingPrecision)
for details.
Default behavior is to set the grabsInputThreshold()
(in a non-adaptive
manner) to 20 length if AbstractScene.platform()
is
DESKTOP or to 50 pixels if it is ANDROID.
Negative threshold
values are silently ignored.
public boolean grabsInput(Agent agent)
Agent.inputGrabber()
. Returns
true
if this object grabs the agent and false
otherwise.public boolean grabsInput()
public boolean isSceneAvatar()
return scene().avatar() == this
.public float trackingEyeDistance()
AbstractScene.setAvatar(Trackable)
public void setTrackingEyeDistance(float d)
AbstractScene.setAvatar(Trackable)
public float trackingEyeAzimuth()
Frame.zAxis()
. Only meaningful when this frame has been set as the scene avatar.AbstractScene.setAvatar(Trackable)
public void setTrackingEyeAzimuth(float a)
trackingEyeAzimuth()
of the tracking camera. Only meaningful when
this frame has been set as the scene avatar.AbstractScene.setAvatar(Trackable)
public float trackingEyeInclination()
Frame.yAxis()
. Only meaningful when this frame has been set as the scene avatar.AbstractScene.setAvatar(Trackable)
public void setTrackingEyeInclination(float i)
trackingEyeInclination()
of the tracking camera. Only meaningful
when this frame has been set as the scene avatar.AbstractScene.setAvatar(Trackable)
public GenericFrame trackingEyeFrame()
Trackable.trackingEyeFrame()
. Returns
the world coordinates of the camera position computed in
updateTrackingEyeFrame()
. Only meaningful when this frame has been set as
the scene avatar.trackingEyeFrame
in interface Trackable
AbstractScene.setAvatar(Trackable)
Processing Library proscene by Jean Pierre Charalambos. (c) 2014-2017 National University of Colombia