public abstract class AbstractScene extends AnimatorObject implements Grabber
Grabber
scene.
Main package class representing an interface between Dandelion and the outside world. For an introduction to DANDELION please refer to this.
Instantiated scene GenericFrame
s form a scene-tree of
transformations which may be traverse with traverseTree()
. The frame
collection belonging to the scene may be retrieved with frames(boolean)
. The
scene provides other useful routines to handle the hierarchy, such as
pruneBranch(GenericFrame)
, appendBranch(List)
,
isFrameReachable(GenericFrame)
, branch(GenericFrame, boolean)
, and
clearTree()
.
Each AbstractScene provides the following main object instances:
eye()
which represents the 2D ( Window
)
or 3D ( Camera
) controlling object. For details please
refer to the Eye
class.AnimatorObject.timingHandler()
which control (single-threaded) timing operations. For
details please refer to the TimingHandler
class.inputHandler()
which handles all user input through
Agent
s (for details please refer to the
InputHandler
class). The inputHandler()
holds a
(default) motionAgent()
and a (default) keyboardAgent()
which should
be instantiated by derived classes at construction time.matrixHelper()
which handles matrix operations either through the
MatrixStackHelper
or through a third party matrix stack
(like it's done with Processing). For details please refer to the
MatrixHelper
interface.AnimatorObject.animate()
method. In this case, once you declare
a Scene derived class, you should implement AnimatorObject.animate()
which defines how your
scene objects evolve over time.
AnimatorObject.timer()
was triggered within the frame.
A grabber scene implements the Grabber
interface and thus
can react to user (keyboard) gestures, (see performInteraction(KeyboardEvent)
and checkIfGrabsInput(KeyboardEvent)
). For example, with the following code:
protected void performInteraction(KeyboardEvent event) {
if(event.key() == 'z')
toggleCameraType();
}
your custom scene will toggleCameraType()
when the key 'z' is pressed
(provided that scene is the keyboardAgent()
Agent.inputGrabber()
).
Modifier and Type | Class and Description |
---|---|
static class |
AbstractScene.Platform |
Modifier and Type | Field and Description |
---|---|
static int |
AXES
Visual hints as "the last shall be first"
|
static long |
frameCount |
static int |
GRID |
static int |
PATHS |
static int |
PICKING |
static int |
ROTATE |
static int |
ZOOM |
Constructor and Description |
---|
AbstractScene()
Default constructor which defines a right-handed OpenGL compatible Scene with its own
MatrixStackHelper . |
Modifier and Type | Method and Description |
---|---|
void |
addKeyFrameToPath1()
Same as
eye().addKeyFrameToPath(1) . |
void |
addKeyFrameToPath2()
Same as
eye().addKeyFrameToPath(2) . |
void |
addKeyFrameToPath3()
Same as
eye().addKeyFrameToPath(1) . |
Vec |
anchor()
Returns the
Eye.anchor() . |
void |
appendBranch(List<GenericFrame> branch)
Appends the branch which typically should come from the one pruned (and cached) with
pruneBranch(GenericFrame) . |
void |
applyModelView(Mat source)
Wrapper for
MatrixHelper.applyModelView(Mat) |
void |
applyProjection(Mat source)
Wrapper for
MatrixHelper.applyProjection(Mat) |
void |
applyTransformation(Frame frame)
Apply the local transformation defined by
frame , i.e., respect to the frame
Frame.referenceFrame() . |
void |
applyWorldTransformation(Frame frame)
Same as
applyTransformation(Frame) but applies the global transformation
defined by the frame. |
boolean |
areBoundaryEquationsEnabled()
Returns
true if automatic update of the camera frustum plane equations is
enabled and false otherwise. |
float |
aspectRatio()
|
Trackable |
avatar()
Returns the avatar object to be tracked by the Camera when it is in Third Person
mode.
|
boolean |
axesVisualHint()
Returns
true if axes are currently being drawn and false otherwise. |
Eye.Visibility |
ballVisibility(Vec center,
float radius)
Same as
return eye().ballIsVisible(center, radius) . |
void |
beginScreenDrawing()
Wrapper for
MatrixHelper.beginScreenDrawing() . |
Eye.Visibility |
boxVisibility(Vec p1,
Vec p2)
Same as
return eye().boxIsVisible(p1, p2) . |
ArrayList<GenericFrame> |
branch(GenericFrame frame,
boolean eyeframes)
Collects
frame and all its descendant frames. |
Camera |
camera()
If
is3D() returns the associated Camera, never null . |
Camera.Type |
cameraType()
Returns the current
eye() type. |
Vec |
center()
Returns the scene center.
|
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(KeyboardEvent event)
Override this method when you want the object to be picked from a
KeyboardEvent . |
boolean |
checkIfGrabsInput(MotionEvent event)
Internal use.
|
void |
clearTree()
Same as
for(GenericFrame frame : leadingFrames()) pruneBranch(frame) . |
void |
deletePath1()
Same as
eye().deletePath(1) . |
void |
deletePath2()
Same as
eye().deletePath(2) . |
void |
deletePath3()
Same as
eye().deletePath(3) . |
void |
disableBoundaryEquations()
Disables automatic update of the camera frustum plane equations every frame.
|
abstract void |
disableDepthTest()
Disables z-buffer.
|
boolean |
disableKeyboardAgent()
Disables the default
Agent and returns it. |
boolean |
disableMotionAgent()
Disables the default motion agent and returns it.
|
void |
displayInfo()
Convenience function that simply calls
displayInfo(true) . |
void |
displayInfo(boolean onConsole)
Displays the
info() bindings. |
void |
drawArrow(float length)
Simply calls
drawArrow(length, 0.05f * length) |
void |
drawArrow(float length,
float radius)
Draws a 3D arrow along the positive Z axis.
|
void |
drawArrow(Vec from,
Vec to,
float radius)
Draws a 3D arrow between the 3D point
from and the 3D point to , both
defined in the current world coordinate system. |
void |
drawAxes()
Convenience function that simply calls
drawAxis(100) . |
abstract void |
drawAxes(float length)
Draws axes of length
length which origin correspond to the world coordinate
system origin. |
void |
drawCone(float r,
float h)
Same as
cone(12, 0, 0, r, h); |
void |
drawCone(float r1,
float r2,
float h)
Same as
cone(18, 0, 0, r1, r2, h); |
void |
drawCone(int det,
float r,
float h)
Same as
cone(det, 0, 0, r, h); |
void |
drawCone(int det,
float r1,
float r2,
float h)
Same as
cone(det, 0, 0, r1, r2, h); |
abstract void |
drawCone(int detail,
float x,
float y,
float r,
float h)
Draws a cone along the positive
z axis, with its base centered at
(x,y) , height h , and radius r . |
abstract void |
drawCone(int detail,
float x,
float y,
float r1,
float r2,
float h)
Draws a truncated cone along the positive
z axis, with its base centered at
(x,y) , height h , and radii r1 and r2 (basis and
height respectively). |
void |
drawCross(float px,
float py)
Convenience function that simply calls
drawCross(pg3d.color(255, 255, 255), px, py, 15, 3) . |
abstract void |
drawCross(float px,
float py,
float size)
Draws a cross on the screen centered under pixel
(px, py) , and edge of size
size . |
abstract void |
drawCylinder(float w,
float h)
Draws a cylinder of width
w and height h , along the positive
z axis. |
void |
drawDottedGrid()
Convenience function that simplt calls
drawDottedGrid(100, 10) . |
void |
drawDottedGrid(float size)
Convenience function that simplt calls
drawDottedGrid(size, 10) . |
abstract void |
drawDottedGrid(float size,
int nbSubdivisions)
Draws a dotted-grid in the XY plane, centered on (0,0,0) (defined in the current
coordinate system).
|
void |
drawDottedGrid(int nbSubdivisions)
Convenience function that simplt calls
drawDottedGrid(100, nbSubdivisions) . |
abstract void |
drawEye(Eye eye)
Draws a representation of the
eye in the scene. |
abstract void |
drawFilledCircle(int subdivisions,
Vec center,
float radius)
Draws a filled circle using screen coordinates.
|
void |
drawFilledCircle(Vec center,
float radius)
Convenience function that simply calls
drawFilledCircle(40, center, radius) . |
abstract void |
drawFilledSquare(Vec center,
float edge)
Draws a filled square using screen coordinates.
|
void |
drawGrid()
Convenience function that simply calls
drawGrid(100, 10) |
void |
drawGrid(float size)
Convenience function that simply calls
drawGrid(size, 10) |
abstract void |
drawGrid(float size,
int nbSubdivisions)
Draws a grid in the XY plane, centered on (0,0,0) (defined in the current coordinate
system).
|
void |
drawGrid(int nbSubdivisions)
Convenience function that simply calls
drawGrid(100, nbSubdivisions) |
abstract void |
drawHollowCylinder(int detail,
float w,
float h,
Vec m,
Vec n)
Draws a cylinder whose bases are formed by two cutting planes (
m and
n ), along the Camera positive z axis. |
void |
drawPath(KeyFrameInterpolator kfi)
Convenience function that simply calls
drawPath(kfi, 1, 6, 100) . |
void |
drawPath(KeyFrameInterpolator kfi,
float scale)
Convenience function that simply calls
drawPath(kfi, 1, 6, scale) |
void |
drawPath(KeyFrameInterpolator kfi,
int mask,
int nbFrames)
Convenience function that simply calls
drawPath(kfi, mask, nbFrames, * 100) |
abstract void |
drawPath(KeyFrameInterpolator kfi,
int mask,
int nbFrames,
float scale)
Draws the path used to interpolate the
KeyFrameInterpolator.frame() |
abstract void |
drawPickingTarget(GenericFrame gFrame)
Draws all GrabberFrames' picking targets: a shooter target visual hint of
GenericFrame.grabsInputThreshold() pixels size. |
abstract void |
drawShooterTarget(Vec center,
float length)
Draws the classical shooter target on the screen.
|
void |
drawTorusSolenoid()
Convenience function that simply calls
drawTorusSolenoid(6) . |
void |
drawTorusSolenoid(float insideRadius)
Convenience function that simply calls
drawTorusSolenoid(6, insideRadius) . |
void |
drawTorusSolenoid(int faces)
Convenience function that simply calls
drawTorusSolenoid(faces, 0.07f * radius()) . |
void |
drawTorusSolenoid(int faces,
float insideRadius)
Convenience function that simply calls
drawTorusSolenoid(faces, 100, insideRadius, insideRadius * 1.3f) . |
abstract void |
drawTorusSolenoid(int faces,
int detail,
float insideRadius,
float outsideRadius)
Draws a torus solenoid.
|
void |
enableBoundaryEquations()
Enables automatic update of the camera frustum plane equations every frame.
|
void |
enableBoundaryEquations(boolean flag)
Enables or disables automatic update of the camera frustum plane equations every
frame according to
flag . |
abstract void |
enableDepthTest()
Enables z-buffer.
|
void |
enableKeyboardAgent()
Enables keyboard handling through the
keyboardAgent() . |
void |
enableMotionAgent()
Enables motion handling through the
motionAgent() . |
void |
endScreenDrawing()
Wrapper for
MatrixHelper.endScreenDrawing() . |
Eye |
eye()
Returns the associated Eye, never
null . |
GenericFrame |
eyeFrame() |
void |
flip()
|
long |
frameCount()
Returns the number of frames displayed since the scene was instantiated.
|
ArrayList<GenericFrame> |
frames(boolean eyeframes)
Returns a list of all the frames that are reachable by the
traverseTree()
algorithm, including the EyeFrames (when eyeframes is true ). |
Mat |
getModelView(Mat target)
Wrapper for
MatrixHelper.getModelView(Mat) |
Mat |
getProjection(Mat target)
Wrapper for
MatrixHelper.getProjection(Mat) |
boolean |
grabsInput()
Checks if the scene grabs input from any agent registered at the input handler.
|
boolean |
grabsInput(Agent agent)
Check if this object is the
Agent.inputGrabber() . |
boolean |
gridIsDotted()
Returns true grid is dotted.
|
boolean |
gridVisualHint()
Returns
true if grid is currently being drawn and false otherwise. |
abstract int |
height() |
abstract String |
info()
Convenience function that simply returns
inputHandler().info() . |
void |
init()
This method is called before the first drawing happen and should be overloaded to
initialize stuff.
|
InputHandler |
inputHandler()
Returns the scene
InputHandler . |
void |
interpolateToFitScene()
Same as
eye().interpolateToFitScene() . |
boolean |
is2D() |
abstract boolean |
is3D() |
boolean |
isAnimatorRegistered(Animator object)
Convenience wrapper function that simply returns
timingHandler().isAnimatorRegistered(object) . |
boolean |
isConeBackFacing(Vec vertex,
Vec[] normals)
Same as
return camera().isConeBackFacing(vertex, normals) . |
boolean |
isConeBackFacing(Vec vertex,
Vec axis,
float angle)
Same as
return camera().isConeBackFacing(vertex, axis, angle) . |
boolean |
isFaceBackFacing(Vec a,
Vec b,
Vec c)
Same as
return camera().isFaceBackFacing(a, b, c) . |
boolean |
isFrameReachable(GenericFrame frame)
|
boolean |
isKeyboardAgentEnabled()
|
boolean |
isLeftHanded()
Returns true if scene is left handed.
|
boolean |
isMotionAgentEnabled()
|
boolean |
isOffscreen()
Returns
true if this Scene is associated to an off-screen renderer and
false otherwise. |
boolean |
isPointVisible(Vec point)
Same as
return eye().pointIsVisible(point) . |
boolean |
isRightHanded()
Returns true if scene is right handed.
|
boolean |
isTimingTaskRegistered(TimingTask task)
Convenience wrapper function that simply returns
timingHandler().isTaskRegistered(task) . |
boolean |
isUnprojectedCoordinatesOfOptimized()
Wrapper for
MatrixHelper.isProjectionViewInverseCached() . |
Agent |
keyboardAgent()
Returns the default
Agent keyboard agent. |
List<GenericFrame> |
leadingFrames()
Returns the top-level frames (those which referenceFrame is null).
|
MatrixHelper |
matrixHelper()
Returns the
MatrixHelper . |
Mat |
modelView()
Wrapper for
MatrixHelper.modelView() |
Agent |
motionAgent()
Returns the default motion agent.
|
void |
optimizeUnprojectedCoordinatesOf(boolean optimise)
Wrapper for
MatrixHelper.cacheProjectionViewInverse(boolean) . |
Point |
originCorner()
Returns the upper left corner of the Scene window.
|
boolean |
pathsVisualHint()
Returns
true if the eye paths visual hints are currently being drawn and
false otherwise. |
void |
performInteraction(BogusEvent event)
Defines how the grabber should react according to the given bogus-event.
|
boolean |
pickingVisualHint()
Returns
true if the picking selection visual hint is currently being drawn
and false otherwise. |
float |
pixelDepth(float x,
float y) |
abstract float |
pixelDepth(Point pixel)
Returns the depth (z-value) of the object under the
pixel . |
static AbstractScene.Platform |
platform()
Returns the platform where dandelion is running.
|
void |
playPath1()
Same as
eye().playPath(1) . |
void |
playPath2()
Same as
eye().playPath(2) . |
void |
playPath3()
Same as
eye().playPath(3) . |
Vec |
pointUnderPixel(float x,
float y)
Same as
return pointUnderPixel(new Point(x, y)) . |
Vec |
pointUnderPixel(Point pixel)
Returns the world coordinates of the 3D point located at
pixel (x,y) on
screen. |
void |
popModelView()
Wrapper for
MatrixHelper.popModelView() |
void |
popProjection()
Wrapper for
MatrixHelper.popProjection() |
void |
postDraw()
Called after your main drawing and performs the following:
Calls
TimingHandler.handle() and increments the the
frameCount()
Increments the frameCount()
Calls InputHandler.handle()
|
void |
preDraw()
Called before your main drawing and performs the following:
Handles the
avatar()
Calls bindMatrices()
Calls Eye.updateBoundaryEquations() if
areBoundaryEquationsEnabled()
Calls proscenium()
Calls displayVisualHints() .
|
void |
printModelView()
Wrapper for
MatrixHelper.printModelView() |
void |
printProjection()
Wrapper for
MatrixHelper.printProjection() |
Vec |
projectedCoordinatesOf(Vec src)
Same as
Eye.projectedCoordinatesOf(Mat, Vec) . |
Mat |
projection()
Wrapper for
MatrixHelper.projection() |
void |
proscenium()
The method that actually defines the scene.
|
ArrayList<GenericFrame> |
pruneBranch(GenericFrame frame)
Make all the frames in the
frame branch eligible for garbage collection. |
void |
pushModelView()
Wrapper for
MatrixHelper.pushModelView() |
void |
pushProjection()
Wrapper for
MatrixHelper.pushProjection() |
float |
radius()
Returns the scene radius.
|
void |
registerAnimator(Animator object)
Convenience wrapper function that simply calls
timingHandler().registerAnimator(object) . |
void |
registerTimingTask(TimingTask task)
Convenience wrapper function that simply calls
timingHandler().registerTask(task) . |
void |
resetAnchor()
Same as
eye().setAnchor(new Vec(0, 0, 0)) . |
Trackable |
resetAvatar()
Returns the current avatar before resetting it (i.e., setting it to null).
|
void |
resetModelView()
Wrapper for
MatrixHelper.resetModelView() |
void |
resetProjection()
Wrapper for
MatrixHelper.resetProjection() |
void |
rotate(float angle)
Wrapper for
MatrixHelper.rotate(float) |
void |
rotate(float angle,
float vx,
float vy,
float vz)
Wrapper for
MatrixHelper.rotate(float, float, float, float) |
boolean |
rotateVisualHint()
Internal.
|
void |
rotateX(float angle)
Wrapper for
MatrixHelper.rotateX(float) |
void |
rotateY(float angle)
Wrapper for
MatrixHelper.rotateY(float) |
void |
rotateZ(float angle)
Wrapper for
MatrixHelper.rotateZ(float) |
void |
scale(float s)
Wrapper for
MatrixHelper.scale(float) |
void |
scale(float sx,
float sy)
Wrapper for
MatrixHelper.scale(float, float) |
void |
scale(float x,
float y,
float z)
Wrapper for
MatrixHelper.scale(float, float, float) |
void |
setAnchor(Vec anchor)
Same as
Eye.setAnchor(Vec) . |
boolean |
setAnchorFromPixel(float x,
float y) |
boolean |
setAnchorFromPixel(Point pixel)
Convenience wrapper function that simply returns
eye().setAnchorFromPixel(pixel) . |
void |
setAvatar(Trackable t)
Sets the avatar object to be tracked by the Camera when it is in Third Person mode.
|
void |
setAxesVisualHint(boolean draw)
Sets the display of the axes according to
draw |
void |
setBoundingBox(Vec min,
Vec max)
|
void |
setBoundingRect(Vec min,
Vec max) |
void |
setCamera(Camera cam)
If
is3D() sets the Camera. |
void |
setCameraType(Camera.Type type)
Sets the
eye() type. |
void |
setCenter(Vec center)
Sets the
center() of the Scene. |
boolean |
setCenterFromPixel(float x,
float y) |
boolean |
setCenterFromPixel(Point pixel)
Convenience wrapper function that simply returns
camera().setSceneCenterFromPixel(pixel) |
void |
setDottedGrid(boolean dotted)
Sets the drawing of the grid visual hint as dotted or not.
|
void |
setEye(Eye vp)
Replaces the current
eye() with vp . |
void |
setEyeConstraint(Constraint constraint)
Same as
eye().frame().setConstraint(constraint) . |
void |
setGridVisualHint(boolean draw)
Sets the display of the grid according to
draw |
void |
setLeftHanded()
Set the scene as left handed.
|
void |
setMatrixHelper(MatrixHelper r)
Sets the
MatrixHelper defining how dandelion matrices
are to be handled. |
void |
setModelView(Mat source)
Wrapper for
MatrixHelper.setModelView(Mat) |
void |
setPathsVisualHint(boolean draw)
Sets the display of the camera key frame paths according to
draw |
void |
setPickingVisualHint(boolean draw)
Sets the display of the interactive frames' selection hints according to
draw |
void |
setProjection(Mat source)
Wrapper for
MatrixHelper.setProjection(Mat) |
void |
setRadius(float radius)
Sets the
radius() of the Scene. |
void |
setRightHanded()
Set the scene as right handed.
|
void |
setRotateVisualHint(boolean draw)
Internal.
|
void |
setVisualHints(int flag)
Low level setting of visual flags.
|
void |
setWindow(Window win)
If
is2D() sets the Window. |
void |
setZoomVisualHint(boolean draw)
Internal.
|
void |
showAll()
Convenience wrapper function that simply calls
camera().showEntireScene() |
static void |
showDepthWarning(String method)
Display a warning that the specified method is only available in 3D.
|
static void |
showEventVariationWarning(String method)
Display a warning that the specified method can only be implemented from a relative
bogus event.
|
static void |
showMinDOFsWarning(String themethod,
int dofs) |
static void |
showMissingImplementationWarning(String method,
String theclass)
Display a warning that the specified method lacks implementation.
|
static void |
showOnlyEyeWarning(String method)
Same as
showOnlyEyeWarning(method, true) . |
static void |
showOnlyEyeWarning(String method,
boolean eye)
Display a warning that the specified method is only available for an eye-frame if
eye is true or a frame, different than an eye-frame, if eye
is false . |
static void |
showPlatformVariationWarning(String themethod,
AbstractScene.Platform platform)
Display a warning that the specified method is not available under the specified
platform.
|
static void |
showWarning(String msg)
Show warning, and keep track of it so that it's only shown once.
|
void |
toggleAxesVisualHint()
Toggles the state of
axesVisualHint() . |
void |
toggleBoundaryEquations()
Toggles automatic update of the camera frustum plane equations every frame.
|
void |
toggleCameraType()
Toggles the
eye() type between PERSPECTIVE and ORTHOGRAPHIC. |
void |
toggleGridVisualHint()
Toggles the state of
gridVisualHint() . |
void |
togglePathsVisualHint()
Toggles the state of
pathsVisualHint() . |
void |
togglePickingVisualhint()
Toggles the state of
pickingVisualHint() . |
void |
translate(float tx,
float ty)
Wrapper for
MatrixHelper.translate(float, float) |
void |
translate(float tx,
float ty,
float tz)
Wrapper for
MatrixHelper.translate(float, float, float) |
void |
traverseTree()
Traverse the frame hierarchy, successively applying the local transformation defined
by each traversed frame, and calling
GenericFrame.visit() on it. |
Vec |
unprojectedCoordinatesOf(Vec src)
If
MatrixHelper.isProjectionViewInverseCached()
(cache version) returns
Eye.unprojectedCoordinatesOf(Mat, Vec) (Mat is
MatrixHelper.projectionViewInverse() ). |
void |
unregisterAnimator(Animator object)
Convenience wrapper function that simply calls
timingHandler().unregisterAnimator(object) . |
void |
unregisterTimingTask(TimingTask task)
Convenience wrapper function that simply calls
timingHandler().unregisterTask(task) . |
int |
visualHints()
Returns the visual hints flag.
|
abstract int |
width() |
Window |
window()
If
is2D() returns the associated Window, never null . |
boolean |
zoomVisualHint()
Internal.
|
animate, animationPeriod, animationStarted, invokeAnimationHandler, restartAnimation, setAnimationPeriod, setAnimationPeriod, setTimingHandler, startAnimation, stopAnimation, timer, timingHandler, toggleAnimation
public static long frameCount
public static final int AXES
public static final int GRID
public static final int PICKING
public static final int PATHS
public static final int ZOOM
public static final int ROTATE
public AbstractScene()
MatrixStackHelper
. The constructor also instantiates
the inputHandler()
and the AnimatorObject.timingHandler()
, and sets the AXES and
GRID visual hint flags.
Third party (concrete) Scenes should additionally:
matrixHelper()
. Only if the target platform
(such as Processing) provides its own matrix handling.setEye(Eye)
to set the eye()
, once it's known if the Scene
is2D()
or is3D()
.motionAgent()
and the keyboardAgent()
and
enable them (register them at the inputHandler()
) and possibly some other
Agent
s as well and .isOffscreen()
.init()
at the end of the constructor.public List<GenericFrame> leadingFrames()
All leading frames are also reachable by the traverseTree()
algorithm for
which they are the seeds.
public void traverseTree()
GenericFrame.visit()
on it.
Note that only reachable frames are visited by this algorithm.
Attention: this method should be called after bindMatrices()
(i.e.,
eye update) and before any other transformation of the modelview takes place.
public void clearTree()
for(GenericFrame frame : leadingFrames()) pruneBranch(frame)
.pruneBranch(GenericFrame)
public ArrayList<GenericFrame> pruneBranch(GenericFrame frame)
frame
branch eligible for garbage collection.
A call to isFrameReachable(GenericFrame)
on all frame
descendants
(including frame
) will return false, after issuing this method. It also means
that all frames in the frame
branch will become unreachable by the
traverseTree()
algorithm.
Frames in the frame
branch will also be removed from all the agents currently
registered in the inputHandler()
.
To make all the frames in the branch reachable again, first cache the frames
belonging to the branch (i.e., branch=pruneBranch(frame)
) and then call
appendBranch(List)
on the cached branch. Note that calling
GenericFrame.setReferenceFrame(GenericFrame)
on a
frame belonging to the pruned branch will become reachable again by the traversal
algorithm. In this case, the frame should be manually added to some agents to
interactively handle it.
Note that if frame is not reachable (isFrameReachable(GenericFrame)
) this
method returns null
.
When collected, pruned frames behave like Frame
,
otherwise they are eligible for garbage collection.
public void appendBranch(List<GenericFrame> branch)
pruneBranch(GenericFrame)
.
All frames belonging to the branch are automatically added to all scene agents.
public boolean isFrameReachable(GenericFrame frame)
true
if the frame is reachable by the traverseTree()
algorithm and false
otherwise.
Frames are make unreachable with pruneBranch(GenericFrame)
and reachable
again with
GenericFrame.setReferenceFrame(GenericFrame)
.
traverseTree()
,
frames(boolean)
public ArrayList<GenericFrame> frames(boolean eyeframes)
traverseTree()
algorithm, including the EyeFrames (when eyeframes
is true
).public ArrayList<GenericFrame> branch(GenericFrame frame, boolean eyeframes)
frame
and all its descendant frames. When eyeframes
is
true
eye-frames will also be collected. Note that for a frame to be collected
it must be reachable.isFrameReachable(GenericFrame)
public void addKeyFrameToPath1()
eye().addKeyFrameToPath(1)
.Eye.addKeyFrameToPath(int)
public void addKeyFrameToPath2()
eye().addKeyFrameToPath(2)
.Eye.addKeyFrameToPath(int)
public void addKeyFrameToPath3()
eye().addKeyFrameToPath(1)
.Eye.addKeyFrameToPath(int)
public void deletePath1()
eye().deletePath(1)
.Eye.deletePath(int)
public void deletePath2()
eye().deletePath(2)
.Eye.deletePath(int)
public void deletePath3()
eye().deletePath(3)
.Eye.deletePath(int)
public void playPath1()
eye().playPath(1)
.Eye.playPath(int)
public void playPath2()
eye().playPath(2)
.Eye.playPath(int)
public void playPath3()
eye().playPath(3)
.Eye.playPath(int)
public void interpolateToFitScene()
eye().interpolateToFitScene()
.Eye.interpolateToFitScene()
public void resetAnchor()
eye().setAnchor(new Vec(0, 0, 0))
.Eye.setAnchor(Vec)
public boolean checkIfGrabsInput(BogusEvent event)
Grabber
checkIfGrabsInput
in interface Grabber
Agent.updateTrackedGrabber(BogusEvent)
,
Agent.inputGrabber()
public boolean checkIfGrabsInput(MotionEvent event)
Automatically called by agents handling this frame.
public boolean checkIfGrabsInput(ClickEvent event)
Automatically called by agents handling this frame.
public boolean checkIfGrabsInput(KeyboardEvent event)
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)
Override this method when you want the object to be picked from a DOF1Event
.
public boolean checkIfGrabsInput(DOF3Event event)
public boolean checkIfGrabsInput(DOF6Event event)
public void performInteraction(BogusEvent event)
Grabber
performInteraction
in interface Grabber
Agent.handle(BogusEvent)
public boolean grabsInput(Agent agent)
Agent.inputGrabber()
. Returns
true
if this object grabs the agent and false
otherwise.public boolean grabsInput()
public Point originCorner()
public static AbstractScene.Platform platform()
public Agent keyboardAgent()
Agent
keyboard agent.motionAgent()
public boolean isKeyboardAgentEnabled()
public void enableKeyboardAgent()
keyboardAgent()
.public Agent motionAgent()
keyboardAgent()
public boolean isMotionAgentEnabled()
public void enableMotionAgent()
motionAgent()
.public boolean disableKeyboardAgent()
Agent
and returns it.public boolean disableMotionAgent()
public long frameCount()
Use AbstractScene.frameCount
to retrieve the number of frames displayed since
the first scene was instantiated.
public void registerTimingTask(TimingTask task)
timingHandler().registerTask(task)
.TimingHandler.registerTask(TimingTask)
public void unregisterTimingTask(TimingTask task)
timingHandler().unregisterTask(task)
.public boolean isTimingTaskRegistered(TimingTask task)
timingHandler().isTaskRegistered(task)
.public void registerAnimator(Animator object)
timingHandler().registerAnimator(object)
.public void unregisterAnimator(Animator object)
timingHandler().unregisterAnimator(object)
.public boolean isAnimatorRegistered(Animator object)
timingHandler().isAnimatorRegistered(object)
.public InputHandler inputHandler()
InputHandler
.public abstract String info()
inputHandler().info()
.displayInfo(boolean)
public void displayInfo()
displayInfo(true)
.public void displayInfo(boolean onConsole)
info()
bindings.onConsole
- if this flag is true displays the help on console. Otherwise displays it on
the appletinfo()
public void setMatrixHelper(MatrixHelper r)
MatrixHelper
defining how dandelion matrices
are to be handled.matrixHelper()
public MatrixHelper matrixHelper()
MatrixHelper
.setMatrixHelper(MatrixHelper)
public void beginScreenDrawing()
MatrixHelper.beginScreenDrawing()
. Adds
exception when no properly closing the screen drawing with a call to
endScreenDrawing()
.MatrixHelper.beginScreenDrawing()
public void endScreenDrawing()
MatrixHelper.endScreenDrawing()
. Adds
exception if beginScreenDrawing()
wasn't properly called beforeMatrixHelper.endScreenDrawing()
public void pushModelView()
MatrixHelper.pushModelView()
public void popModelView()
MatrixHelper.popModelView()
public void pushProjection()
MatrixHelper.pushProjection()
public void popProjection()
MatrixHelper.popProjection()
public void translate(float tx, float ty)
MatrixHelper.translate(float, float)
public void translate(float tx, float ty, float tz)
MatrixHelper.translate(float, float, float)
public void rotate(float angle)
MatrixHelper.rotate(float)
public void rotateX(float angle)
MatrixHelper.rotateX(float)
public void rotateY(float angle)
MatrixHelper.rotateY(float)
public void rotateZ(float angle)
MatrixHelper.rotateZ(float)
public void rotate(float angle, float vx, float vy, float vz)
MatrixHelper.rotate(float, float, float, float)
public void scale(float s)
MatrixHelper.scale(float)
public void scale(float sx, float sy)
MatrixHelper.scale(float, float)
public void scale(float x, float y, float z)
MatrixHelper.scale(float, float, float)
public void resetModelView()
MatrixHelper.resetModelView()
public void resetProjection()
MatrixHelper.resetProjection()
public void applyModelView(Mat source)
MatrixHelper.applyModelView(Mat)
public void applyProjection(Mat source)
MatrixHelper.applyProjection(Mat)
public Mat modelView()
MatrixHelper.modelView()
public Mat projection()
MatrixHelper.projection()
public Mat getModelView(Mat target)
MatrixHelper.getModelView(Mat)
public Mat getProjection(Mat target)
MatrixHelper.getProjection(Mat)
public void setModelView(Mat source)
MatrixHelper.setModelView(Mat)
public void setProjection(Mat source)
MatrixHelper.setProjection(Mat)
public void printModelView()
MatrixHelper.printModelView()
public void printProjection()
MatrixHelper.printProjection()
public boolean isUnprojectedCoordinatesOfOptimized()
MatrixHelper.isProjectionViewInverseCached()
.
Use it only when continuously calling unprojectedCoordinatesOf(Vec)
.
public void optimizeUnprojectedCoordinatesOf(boolean optimise)
MatrixHelper.cacheProjectionViewInverse(boolean)
.
Use it only when continuously calling unprojectedCoordinatesOf(Vec)
.
public int visualHints()
public void setVisualHints(int flag)
setAxesVisualHint(boolean)
,
setGridVisualHint(boolean)
, setPathsVisualHint(boolean)
and
setPickingVisualHint(boolean)
, unless you want to set them all at once,
e.g., setVisualHints(Scene.AXES | Scene.GRID | Scene.PATHS | Scene.PICKING)
.public void toggleAxesVisualHint()
axesVisualHint()
.axesVisualHint()
,
setAxesVisualHint(boolean)
public void toggleGridVisualHint()
gridVisualHint()
.setGridVisualHint(boolean)
public void togglePickingVisualhint()
pickingVisualHint()
.setPickingVisualHint(boolean)
public void togglePathsVisualHint()
pathsVisualHint()
.setPathsVisualHint(boolean)
public boolean axesVisualHint()
true
if axes are currently being drawn and false
otherwise.public boolean gridVisualHint()
true
if grid is currently being drawn and false
otherwise.public boolean pickingVisualHint()
true
if the picking selection visual hint is currently being drawn
and false
otherwise.public boolean pathsVisualHint()
true
if the eye paths visual hints are currently being drawn and
false
otherwise.public boolean zoomVisualHint()
public boolean rotateVisualHint()
public void setAxesVisualHint(boolean draw)
draw
public void setGridVisualHint(boolean draw)
draw
public void setPickingVisualHint(boolean draw)
draw
public void setPathsVisualHint(boolean draw)
draw
public void setZoomVisualHint(boolean draw)
public void setRotateVisualHint(boolean draw)
public void preDraw()
avatar()
bindMatrices()
Eye.updateBoundaryEquations()
if
areBoundaryEquationsEnabled()
proscenium()
displayVisualHints()
.postDraw()
public void postDraw()
TimingHandler.handle()
and increments the the
frameCount()
frameCount()
InputHandler.handle()
preDraw()
public void drawPath(KeyFrameInterpolator kfi)
drawPath(kfi, 1, 6, 100)
.public void drawPath(KeyFrameInterpolator kfi, float scale)
drawPath(kfi, 1, 6, scale)
public void drawPath(KeyFrameInterpolator kfi, int mask, int nbFrames)
drawPath(kfi, mask, nbFrames, * 100)
public void drawAxes()
drawAxis(100)
.public void drawDottedGrid()
drawDottedGrid(100, 10)
.public void drawGrid()
drawGrid(100, 10)
drawGrid(float, int)
public void drawDottedGrid(float size)
drawDottedGrid(size, 10)
.public void drawGrid(float size)
drawGrid(size, 10)
drawGrid(float, int)
public void drawDottedGrid(int nbSubdivisions)
drawDottedGrid(100, nbSubdivisions)
.public void drawGrid(int nbSubdivisions)
drawGrid(100, nbSubdivisions)
drawGrid(float, int)
public void drawTorusSolenoid()
drawTorusSolenoid(6)
.public void drawTorusSolenoid(int faces)
drawTorusSolenoid(faces, 0.07f * radius())
.public void drawTorusSolenoid(float insideRadius)
drawTorusSolenoid(6, insideRadius)
.public void drawTorusSolenoid(int faces, float insideRadius)
drawTorusSolenoid(faces, 100, insideRadius, insideRadius * 1.3f)
.public abstract void drawTorusSolenoid(int faces, int detail, float insideRadius, float outsideRadius)
faces
- detail
- insideRadius
- outsideRadius
- public void drawCone(int det, float r, float h)
cone(det, 0, 0, r, h);
public void drawCone(float r, float h)
cone(12, 0, 0, r, h);
public void drawCone(int det, float r1, float r2, float h)
cone(det, 0, 0, r1, r2, h);
public void drawCone(float r1, float r2, float h)
cone(18, 0, 0, r1, r2, h);
public void drawArrow(float length)
drawArrow(length, 0.05f * length)
drawArrow(float, float)
public void drawArrow(float length, float radius)
length
and radius
define its geometry.
Use drawArrow(Vec, Vec, float)
to place the arrow in 3D.
public void drawArrow(Vec from, Vec to, float radius)
from
and the 3D point to
, both
defined in the current world coordinate system.drawArrow(float, float)
public void drawCross(float px, float py)
drawCross(pg3d.color(255, 255, 255), px, py, 15, 3)
.public void drawFilledCircle(Vec center, float radius)
drawFilledCircle(40, center, radius)
.drawFilledCircle(int, Vec, float)
public abstract void drawCylinder(float w, float h)
w
and height h
, along the positive
z
axis.public abstract void drawHollowCylinder(int detail, float w, float h, Vec m, Vec n)
m
and
n
), along the Camera positive z
axis.detail
- w
- radius of the cylinder and h is its heighth
- height of the cylinderm
- normal of the plane that intersects the cylinder at z=0n
- normal of the plane that intersects the cylinder at z=hdrawCylinder(float, float)
public abstract void drawCone(int detail, float x, float y, float r, float h)
z
axis, with its base centered at
(x,y)
, height h
, and radius r
.public abstract void drawCone(int detail, float x, float y, float r1, float r2, float h)
z
axis, with its base centered at
(x,y)
, height h
, and radii r1
and r2
(basis and
height respectively).public abstract void drawAxes(float length)
length
which origin correspond to the world coordinate
system origin.drawGrid(float, int)
public abstract void drawGrid(float size, int nbSubdivisions)
size
and nbSubdivisions
define its geometry.
drawAxes(float)
public abstract void drawDottedGrid(float size, int nbSubdivisions)
size
and nbSubdivisions
define its geometry.
drawAxes(float)
public abstract void drawPath(KeyFrameInterpolator kfi, int mask, int nbFrames, float scale)
KeyFrameInterpolator.frame()
mask
controls what is drawn: If ( (mask & 1) != 0 ), the position path is
drawn. If ( (mask & 2) != 0 ), a camera representation is regularly drawn and if
( (mask & 4) != 0 ), oriented axes are regularly drawn. Examples:
drawPath(); // Simply draws the interpolation path
drawPath(3); // Draws path and cameras
drawPath(5); // Draws path and axes
In the case where camera or axes are drawn, nbFrames
controls the number of
objects (axes or camera) drawn between two successive keyFrames. When
nbFrames = 1
, only the path KeyFrames are drawn. nbFrames = 2
also
draws the intermediate orientation, etc. The maximum value is 30. nbFrames
should divide 30 so that an object is drawn for each KeyFrame. Default value is 6.
scale
controls the scaling of the camera and axes drawing. A value of
radius()
should give good results.
public abstract void drawEye(Eye eye)
eye
in the scene.
The near and far planes are drawn as quads, the frustum is drawn using lines and the camera up vector is represented by an arrow to disambiguate the drawing.
Note: The drawing of a Scene's own Scene.camera() should not be visible, but may create artifacts due to numerical imprecisions.
public abstract void drawCross(float px, float py, float size)
(px, py)
, and edge of size
size
.drawAnchorHint()
public abstract void drawFilledCircle(int subdivisions, Vec center, float radius)
subdivisions
- Number of triangles approximating the circle.center
- Circle screen center.radius
- Circle screen radius.public abstract void drawFilledSquare(Vec center, float edge)
center
- Square screen center.edge
- Square edge length.public abstract void drawShooterTarget(Vec center, float length)
center
- Center of the target on the screenlength
- Length of the target in pixelspublic abstract void drawPickingTarget(GenericFrame gFrame)
GenericFrame.grabsInputThreshold()
pixels size.
Attention: the target is drawn either if the iFrame is part of camera path and
keyFrame is true
, or if the iFrame is not part of camera path and keyFrame is
false
.
public Trackable avatar()
Simply returns null
if no avatar has been set.
public void setAvatar(Trackable t)
resetAvatar()
public Trackable resetAvatar()
setAvatar(Trackable)
public Eye eye()
null
. This is the high level version of
window()
and camera()
which holds that which is common of the two.
2D applications should simply use window()
and 3D applications should simply
use camera()
. If you plan to implement two versions of the same application
one in 2D and the other in 3D, use this method.
Note that not all methods defined in the Camera class are available in the Eye class and that all methods defined in the Window class are.
public GenericFrame eyeFrame()
public void setEye(Eye vp)
eye()
with vp
.
The inputHandler()
will attempt to add the eyeFrame()
to all its
InputHandler.agents()
, such as the motionAgent()
and keyboardAgent()
.
public void flip()
public void setCamera(Camera cam)
setEye(Eye)
public void setWindow(Window win)
setEye(Eye)
public void setEyeConstraint(Constraint constraint)
eye().frame().setConstraint(constraint)
.Frame.setConstraint(Constraint)
public boolean isPointVisible(Vec point)
return eye().pointIsVisible(point)
.Eye.isPointVisible(Vec)
public Eye.Visibility ballVisibility(Vec center, float radius)
return eye().ballIsVisible(center, radius)
.Eye.ballVisibility(Vec, float)
public Eye.Visibility boxVisibility(Vec p1, Vec p2)
return eye().boxIsVisible(p1, p2)
.Eye.boxVisibility(Vec, Vec)
public boolean areBoundaryEquationsEnabled()
true
if automatic update of the camera frustum plane equations is
enabled and false
otherwise. Computation of the equations is expensive and
hence is disabled by default.public void toggleBoundaryEquations()
public void disableBoundaryEquations()
public void enableBoundaryEquations()
public void enableBoundaryEquations(boolean flag)
flag
. Computation of the equations is expensive and hence
is disabled by default.public void toggleCameraType()
eye()
type between PERSPECTIVE and ORTHOGRAPHIC.public boolean isFaceBackFacing(Vec a, Vec b, Vec c)
return camera().isFaceBackFacing(a, b, c)
.
This method is only available in 3D.
Camera.isFaceBackFacing(Vec, Vec, Vec)
public boolean isConeBackFacing(Vec vertex, Vec[] normals)
return camera().isConeBackFacing(vertex, normals)
.
This method is only available in 3D.
Camera.isConeBackFacing(Vec, Vec[])
public boolean isConeBackFacing(Vec vertex, Vec axis, float angle)
return camera().isConeBackFacing(vertex, axis, angle)
.
This method is only available in 3D.
Camera.isConeBackFacing(Vec, Vec, float)
public Vec pointUnderPixel(Point pixel)
pixel
(x,y) on
screen. May be null if no pixel is under pixel.public Vec pointUnderPixel(float x, float y)
return pointUnderPixel(new Point(x, y))
.pointUnderPixel(Point)
public abstract float pixelDepth(Point pixel)
pixel
.
The z-value ranges in [0..1] (near and far plane respectively). In 3D Note that this
value is not a linear interpolation between
Camera.zNear()
and
Camera.zFar()
;
z = zFar() / (zFar() - zNear()) * (1.0f - zNear() / z');
where z'
is
the distance from the point you project to the camera, along the
Camera.viewDirection()
. See the gluUnProject
man page for details.
public float pixelDepth(float x, float y)
public Vec projectedCoordinatesOf(Vec src)
Eye.projectedCoordinatesOf(Mat, Vec)
.public Vec unprojectedCoordinatesOf(Vec src)
MatrixHelper.isProjectionViewInverseCached()
(cache version) returns
Eye.unprojectedCoordinatesOf(Mat, Vec)
(Mat is
MatrixHelper.projectionViewInverse()
). Otherwise
(non-cache version) returns
Eye.unprojectedCoordinatesOf(Vec)
.public float radius()
Convenience wrapper function that simply calls camera().sceneRadius()
setRadius(float)
,
center()
public Vec center()
Convenience wrapper function that simply returns camera().sceneCenter()
{@link #radius()}
public Vec anchor()
Eye.anchor()
.
Convenience wrapper function that simply returns eye().anchor()
{@link #radius()}
public void setAnchor(Vec anchor)
Eye.setAnchor(Vec)
.public void setRadius(float radius)
radius()
of the Scene.
Convenience wrapper function that simply calls
camera().setSceneRadius(radius)
.
setCenter(Vec)
public void setCenter(Vec center)
center()
of the Scene.
Convenience wrapper function that simply calls
setRadius(float)
public void setBoundingBox(Vec min, Vec max)
center()
and radius()
of the Scene from the min
and max
vectors.
Convenience wrapper function that simply calls
camera().setSceneBoundingBox(min,max)
setRadius(float)
,
setCenter(Vec)
public void showAll()
camera().showEntireScene()
Eye.showEntireScene()
public boolean setAnchorFromPixel(Point pixel)
eye().setAnchorFromPixel(pixel)
.
Current implementation set no Eye.anchor()
. Override
Camera.pointUnderPixel(Point)
in your openGL based
camera for this to work.
public boolean setAnchorFromPixel(float x, float y)
public boolean setCenterFromPixel(Point pixel)
camera().setSceneCenterFromPixel(pixel)
Current implementation set no Eye.sceneCenter()
.
Override Camera.pointUnderPixel(Point)
in your openGL
based camera for this to work.
public boolean setCenterFromPixel(float x, float y)
public final Camera.Type cameraType()
eye()
type.public void setCameraType(Camera.Type type)
eye()
type.public static void showWarning(String msg)
msg
- the error message (which will be stored for later comparison)public static void showDepthWarning(String method)
method
- The method name (no parentheses)public static void showMissingImplementationWarning(String method, String theclass)
public static void showEventVariationWarning(String method)
public static void showOnlyEyeWarning(String method)
showOnlyEyeWarning(method, true)
.showOnlyEyeWarning(String, boolean)
public static void showOnlyEyeWarning(String method, boolean eye)
eye
is true
or a frame, different than an eye-frame, if eye
is false
.public static void showPlatformVariationWarning(String themethod, AbstractScene.Platform platform)
public static void showMinDOFsWarning(String themethod, int dofs)
public void applyTransformation(Frame frame)
frame
, i.e., respect to the frame
Frame.referenceFrame()
. The Frame is first translated
and then rotated around the new translated origin.
This method may be used to modify the modelview matrix from a Frame hierarchy. For example, with this Frame hierarchy:
Frame body = new Frame();
Frame leftArm = new Frame();
Frame rightArm = new Frame();
leftArm.setReferenceFrame(body);
rightArm.setReferenceFrame(body);
The associated drawing code should look like:
pushModelView();
applyTransformation(body);
drawBody();
pushModelView();
applyTransformation(leftArm);
drawArm();
popMatrix();
pushMatrix();
applyTransformation(rightArm);
drawArm();
popModelView();
popModelView();
Note the use of nested pushModelView()
and popModelView()
blocks to
represent the frame hierarchy: leftArm
and rightArm
are both
correctly drawn with respect to the body
coordinate system.
Attention: When drawing a frame hierarchy as above, this method should be used whenever possible.
applyWorldTransformation(Frame)
public void applyWorldTransformation(Frame frame)
applyTransformation(Frame)
but applies the global transformation
defined by the frame.public void init()
public void proscenium()
If you build a class that inherits from Scene, this is the method you should
overload, but no if you instantiate your own Scene object (for instance, in
Processing you should just overload PApplet.draw()
to define your scene).
The eye matrices set in bindMatrices()
converts from the world to the camera
coordinate systems. Thus vertices given here can then be considered as being given in
the world coordinate system. The eye is moved in this world using the mouse. This
representation is much more intuitive than a camera-centric system (which for
instance is the standard in OpenGL).
public boolean isLeftHanded()
setLeftHanded()
public boolean isRightHanded()
setRightHanded()
public void setRightHanded()
isRightHanded()
public void setLeftHanded()
isLeftHanded()
public boolean isOffscreen()
true
if this Scene is associated to an off-screen renderer and
false
otherwise.public boolean is2D()
public abstract boolean is3D()
public float aspectRatio()
public boolean gridIsDotted()
public void setDottedGrid(boolean dotted)
public abstract int width()
public abstract int height()
public abstract void disableDepthTest()
public abstract void enableDepthTest()
Processing Library proscene by Jean Pierre Charalambos. (c) 2014-2017 National University of Colombia