@ThreadSafe
public abstract class Display3D
extends java.lang.Object
Base class for a 3D display.
Current implementation provides:
An implementation may optionally choose to use some or all of the
included generic render()
er. Minimally, the implementation would
override renderScene()
to do the desired drawing, and then call
render()
in a loop, possibly with some throttling. Actual drawing
code is left abstract; J3DDisplay
and JOGLDisplay
implement
back-ends via the respective libraries.
The generic renderer provides the following features:
setLocalToWorld(vona.math.RX, boolean)
and related APIs.updateWorldToView(boolean)
and related APIs.
This transform is used to implement spin/pan/zoom "object
manipulation"-style viewpoint navigation via rxsInteractor
when
navigationEnabled
.frustumCullEnabled
, for geometries with
specified bounding spheres.depthSortTransparentEnabled
, for geometries with specified bounding
spheres.highlightingEnabled
maskingEnabled
sceneAABBInView
, numVisibleGeometries
, numTransparentGeometries
, numHighlightedGeometries
, numMaskedGeometries
, numSceneGeometries
, numPickableGeometries
, numSceneWidgets
, and numDisabledWidgetGeometries
. The first
three are computed only for geometries for which bounding spheres are
specified. Set dbgSceneExtentsEnabled
to visualize the
corresponding view frame XY scene bounds rect.numFrames
, frameTime
, recentFrameTime
and recentCycleTime
.The pickSphereInView(float[], float[], float[], float, boolean)
and pickGeometry(...)
APIs provide
low-level picking functionality that can be used independent of the
renderer. Pick hits are reported to the picked(javax.media.j3d.Geometry, javax.media.j3d.Appearance, int, float)
callback. If
pickingEnabled
is set then the generic renderer also automatically
performs picking (using those APIs) whenever isPickSegmentSet()
,
further modified by pickBoundsOnly
and pickVisibleBoundsOnly
.
This class is designed to be thread-safe:
drawingEnabled
and other state flags affecting render()
are volatile and expected to be independentlocalToWorldRX
, transparentQueue
, and related are
expected to be thread confined, i.e., if they are used then it is expected
they will be accessed from only one thread, which effectively also means
that the generic render()
will be called only from that threadcanvasSize
and related projection state are guarded by projectionLock
worldToViewRX
and related navigation state are guarded by
rxsInteractor
sceneAABBInView
and related scene metrics are guareded by
sceneMetricsLock
numFrames
and related render metrics are guarded by renderMetricsLock
The lock acquisition order for deadlock avoidance is
environmentLock
frameSaveLock
projectionLock
rxsInteractor
rxsInterpolator
pickSegmentLock
sceneMetricsLock
renderMetricsLock
Copyright (C) 2007 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Class and Description |
---|---|
protected class |
Display3D.Driver
an interactive test driver
|
protected class |
Display3D.QueuedGeometry
Collects info to render a geometry.
|
Modifier and Type | Field and Description |
---|---|
protected TimeMetrics |
accumPass1Metrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
accumPass2Metrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected static boolean[] |
ALL_COMPONENTS
component enables for vertex accessors and primitive iterators
|
protected java.util.List<TimeMetrics> |
allExtendedRenderMetrics
all extended render metrics
|
protected float |
ambientAlpha
Ambient alpha.
|
protected boolean |
applyProjectionPending
whether a
applyProjection() is pending |
protected TimeMetrics |
applyWidgetRX
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected int |
blueBits
number of bits in the specified canvas component
|
protected java.awt.Canvas |
canvas
the canvas
|
protected java.lang.Object |
canvasMouseLock
synchronization object for canvas mouse location
|
protected int |
canvasMouseX
Most recent mouse location on canvas in canvas coords or negative if
mouse not on canvas.
|
protected int |
canvasMouseY
Most recent mouse location on canvas in canvas coords or negative if
mouse not on canvas.
|
protected float[] |
canvasSize
current cached size of
canvas in pixels |
protected TimeMetrics |
clearMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected RX |
cmtRX
current rigid part of the local-to-view composite model transform.
|
protected float |
cmtScale
Current scale part of the local-to-view composite model transform.
|
protected static boolean[] |
COORD_ONLY
component enables for vertex accessors and primitive iterators
|
private static java.lang.String |
cvsid |
protected javax.media.j3d.Appearance |
dbgAppearance
Appearance for dbg objects.
|
protected boolean |
dbgSceneExtentsEnabled
whether to enable dbg scene extents
|
protected RectangleWidget |
dbgSceneExtentsRect
widget for displaying dbg scene extents
|
static float |
DEF_AMBIENT_LIGHT_INTENSITY
default ambient light intensity
|
static float[] |
DEF_DIRECTIONAL_LIGHT_DIRECTION
default directional light direction
|
static float |
DEF_DIRECTIONAL_LIGHT_INTENSITY
default directional light intensity
|
static float[] |
DEF_HIGHLIGHT_COLOR
default
highlightColor |
static float |
DEF_HIGHLIGHT_FACTOR
default
highlightFactor |
static float |
DEF_MASK_ALPHA
default
maskAlpha |
static float |
DEF_PICK_THRESHOLD_PIXELS
default
pickThresholdPixels |
static double |
DEF_VIEW_SCALE
default
defaultViewScale |
static float |
DEF_Z_CLIP
default symmetric z clip, see
setSymmetricZClip(float) |
protected javax.media.j3d.Appearance |
defaultHighlightedAppearance
|
protected javax.media.j3d.Material |
defaultHighlightedMaterial
|
protected double[] |
defaultRotationCenter
Current default rotation center, used by
getDefaultRotationCenter() . |
protected javax.media.j3d.Appearance |
defaultTransparentAppearance
Default transparent appearance.
|
protected double |
defaultViewScale
Current default world-to-view scale, used by
getDefaultViewScale() . |
protected double[] |
defaultViewTXEM
Current default world-to-view TXEM, used by
getDefaultViewTXEM() . |
protected int |
depthBits
number of bits in the specified canvas component
|
protected javax.media.j3d.Appearance |
depthOnlyAppearance
Depth-only appearance.
|
protected boolean |
depthRenderMaskedQueueEnabled
enable for indicated feature in generic
render() code |
protected boolean |
depthSortTransparentEnabled
enable for indicated feature in generic
render() code |
protected boolean |
drawingEnabled
enable for indicated feature in generic
render() code |
protected java.io.PrintStream |
dumpRenderMetricsPending
|
protected java.io.PrintStream |
dumpSceneMetricsPending
|
protected javax.vecmath.Color3f |
emissiveColorWas
|
protected boolean |
ENABLE_EXTENDED_RENDER_METRICS
whether to enable extended render metrics (compile time constant)
|
protected boolean |
ensureWidgetBoundingSpheresInViewEnabled
Whether
render(Widget, RX) calls Widget.ensureBoundingSpheresInView() . |
protected java.lang.Object |
environmentLock
lock for bg, light, and highlight params
|
protected boolean |
fitPending
whether a
doFit() is pending |
protected int |
frameSaveCount
total count of frames saved in current sequence, including errors
|
protected java.io.File |
frameSaveDirectory
frame save destination directory or null for current dir
|
protected double |
frameSaveFPS
maximum rate for regular frame save.
|
protected double |
frameSaveLastTime
last frame save wall-clock time in seconds, if any, else NaN
|
protected java.lang.Object |
frameSaveLock
lock object for frame save state
|
protected TimeMetrics |
frameSaveMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected int |
frameSaveNextIndex
next index for regular-rate frame save
|
protected double |
frameSaveNextTime
next frame save wall-clock time in seconds, if any, else NaN
|
protected java.lang.String |
frameSavePrefix
frame save filename prefix or null for none
|
protected double |
frameSaveStartTime
Regular-rate frame save sequence start time in wall-clock time in
seconds, if any, else NaN.
|
boolean |
frameSaveWithCursor
Whether to include the cursor in frame saves.
|
protected double[] |
frameTime
Min and max generic
render() time [s] since last resetRenderMetrics() . |
protected boolean |
freezeSceneMetrics
Whether to short circuit in
addToSceneMetrics(float[], float, boolean, boolean, boolean, boolean, boolean) . |
protected boolean |
freezeTransparentQueue
Whether to short circuit in
enqueueTransparentGeometry(vona.math.RX, float, javax.media.j3d.Geometry, javax.media.j3d.Appearance, float, float) . |
protected boolean |
freezeWidgetBounds
Whether to skip updating
Widget bounds in view render(Widget, RX) . |
protected boolean |
frustumCullEnabled
enable for indicated feature in generic
render() code |
protected int |
greenBits
number of bits in the specified canvas component
|
protected float[] |
highlightColor
highlight modulation color, see
highlightFactor |
protected float |
highlightFactor
This is the multiplicative factor by which
renderHighlighted(vona.math.RX, float, javax.media.j3d.Geometry, javax.media.j3d.Appearance)
increases the emissive color of highlighted geometry, modulated by highlightColor . |
protected boolean |
highlightingEnabled
enable for indicated feature in generic
render() code |
protected J3DIndexAccessor[] |
indexAccessors
Set of available index accessors, consed lazily.
|
protected double |
lastFrameEndTime
end time [s] of previous generic
render() , NaN if none |
static int |
LOCAL_TO_WORLD_STACK_INITIAL_CAPACITY
defailt initial capacity of
localToWorldStack |
protected RX |
localToWorldRX
Local-to-world
RX . |
protected RX[] |
localToWorldStack
Stack for saving
localToWorldRX . |
protected int |
localToWorldStackSize
Current number of transforms saved in
localToWorldStack . |
protected float |
longFrameWarningThreshold
Iif non-NaN this is the threshold in ms above which a warning will be
issued for long frame render times.
|
protected float |
maskAlpha
alpha factor for masked geometry
|
protected Display3D.QueuedGeometry[] |
maskedQueue
Queue for masked geometry.
|
protected int |
maskedQueueSize
Current number of objects in
maskedQueue |
protected boolean |
maskingEnabled
enable for indicated feature in generic
render() code |
static int |
MAX
index of component in a two-element extents vector
|
static int |
MIN
index of component in a two-element extents vector
|
protected boolean |
navigationEnabled
enable for indicated feature in generic
render() code |
protected javax.vecmath.Color3f |
newEmissiveColor
|
static int |
NUM_RECENT_METRICS
length of
recentFrameTime and recentCycleTime |
protected int |
numDisabledWidgetGeometries
Total number of disabled
Widget geometries seen by generic
render(Widget, RX) since last resetSceneMetrics(boolean) . |
protected int |
numFrames
Total num generic
render() calls since last resetRenderMetrics() . |
protected int |
numHighlightedGeometries
Total number of visible (not frustum cull) geometries rendered as
highlighted by generic
render(Geometry, Appearance, float[],
float) since last resetSceneMetrics(boolean) . |
protected int |
numMaskedGeometries
Total number of visible (not frustum cull) geometries rendered as
masked by generic
render(Geometry, Appearance, float[],
float) since last resetSceneMetrics(boolean) . |
protected int |
numPickableGeometries
Total number of visible pickable geometries iff
pickingEnabled
since last resetSceneMetrics(boolean) . |
protected int |
numPickBoundsHits
Total number of geometries picked by bounds in generic render since
last
resetSceneMetrics(boolean) on a frame with picking (or if resetPickMetricsEveryRender ). |
protected int |
numPickedGeometries
Total number of geometries picked either by bounds only or by geometry
since last
resetSceneMetrics(boolean) on a frame with picking (or if
resetPickMetricsEveryRender ). |
protected int |
numPickGeometryHits
Total number of geometries with at least one pick hit in
pickGeometry(Geometry, Appearance, J3DPrimitiveIterator, float[],
float[], float, int) since last resetSceneMetrics(boolean) on a frame
with picking (or if resetPickMetricsEveryRender ). |
protected int |
numSamples
number antialiasing samples
|
protected int |
numSceneGeometries
Total number of geometries (including those that would be frustum
culled) seen by generic
render(Geometry, Appearance, float[],
float) since last resetSceneMetrics(boolean) . |
protected int |
numSceneWidgets
Total number of
Widget s (including those with zero enabled
geometries, and those that would be frustum culled) seen by generic render(Widget, RX) since last resetSceneMetrics(boolean) . |
protected int |
numTransparentGeometries
Total number of visible (not frustum cull) geometries rendered as
transparent by generic
render(Geometry, Appearance, float[],
float) since last resetSceneMetrics(boolean) . |
protected int |
numVisibleGeometries
Total number of visible (not frustum cull) geometries seen by generic
render(Geometry, Appearance, float[], float) since last resetSceneMetrics(boolean) . |
protected float |
passAlpha
Alpha factor for current rendering pass.
|
protected boolean |
pickBoundsOnly
whether picking should be done only on bounding spheres
|
protected float[] |
pickExtentInLocal
Extent of the pick segment in local frame, or NaN if un-set.
|
protected float[] |
pickExtentInView
Extent of the pick segment in view frame, or NaN if un-set.
|
protected TimeMetrics |
pickGeometryMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
pickingEnabled
enable for indicated feature in generic
render() code |
protected boolean |
pickSegmentInLocalDirty
Dirty flag for
pickStartInLocal and pickExtentInLocal . |
protected boolean |
pickSegmentIntersectionsOnly
Whether picks should only be reported for pick intersections that
actually lie on the pick segment defined by
pickStartInView ,
pickExtentInView . |
protected boolean |
pickSegmentInViewPerpCanvas
whether the pick segment in view frame is perpendicular to the canvas
|
protected java.lang.Object |
pickSegmentLock
lock object for pick segment state
|
protected float[] |
pickStartInLocal
Start point of the pick segment in local frame, or NaN if un-set.
|
protected float[] |
pickStartInView
Start point of the pick segment in view frame, or NaN if un-set.
|
protected float |
pickThresholdPixels
Pick threshold in canvas pixels.
|
protected boolean |
pickVisibleBoundsOnly
whether picking should be done only on non-culled geometry
|
protected TimeMetrics |
postRenderMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected javax.vecmath.Color3f |
premultipliedHighlightColor
|
protected boolean |
premultiplyPassAlpha
Whether the default renderer will use the extraAlpha
draw(...) parameter to implement passAlpha . |
protected TimeMetrics |
preRenderMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected J3DPrimitiveIterator[] |
primitiveIterators
Set of available primitive iterators, consed lazily.
|
protected java.lang.Object |
projectionLock
synchronization lock for projection state
|
static int |
QUEUE_INITIAL_CAPACITY
defailt initial capacity of the queues
|
protected double[] |
recentCycleTime
Cycle time [s] for up to
NUM_RECENT_METRICS most
recent generic render() frames. |
protected int |
recentCycleTimeWriteIndex
next write index in
recentCycleTime |
protected double[] |
recentFrameTime
Rendering time [s] for up to
NUM_RECENT_METRICS most
recent generic render() frames. |
protected int |
recentFrameTimeWriteIndex
next write index in
recentFrameTime |
protected int |
redBits
number of bits in the specified canvas component
|
protected TimeMetrics |
renderDepthOnlyMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderDepthOnlyQueueMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderGeometryMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderHighlightedMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderImplPostSceneMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderImplPreSceneMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderInViewMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
renderMaskedGeometry
Whether to render masked geometry in the current pass.
|
protected java.lang.Object |
renderMetricsLock
synchronization lock for render metrics
|
protected TimeMetrics |
renderSceneMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderTransparentMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderTransparentQueue1Metrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderTransparentQueue2Metrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderWidgetGeometryMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderWidgetMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
resetPickMetricsEveryRender
Whether to reset pick metrics at the beginning of every frame or just
at the beginning of frames for pick will be performed.
|
protected boolean |
resetRenderMetricsPending
|
RXSInteractor |
rxsInteractor
The interactor.
|
RXSInterpolator |
rxsInterpolator
the
RXSInterpolator in rxsInteractor |
protected float[][] |
sceneAABBInView
AABB of enclosing union of bounding spheres (including those that would
be frustum culled) seen by generic
render(Geometry, Appearance,
float[], float) since last resetSceneMetrics(boolean) . |
protected java.lang.Object |
sceneMetricsLock
synchronization lock for scene metrics
|
static float |
SCREEN_METERS_PER_PIXEL
physical screen resolution
|
static float |
SQRT3F
square root of 3.0f
|
protected int |
stencilBits
number of bits in the specified canvas component
|
protected TimeMetrics |
swapMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
static int |
TRACE_GENERIC_EN
trace flags
|
static int |
TRACE_PICKING_EN
trace flags
|
protected int |
traceFlags
trace flags for generic
render() |
protected java.io.PrintStream |
traceStream
trace stream for generic
render() |
protected TimeMetrics |
transformWidgetBounds
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected Display3D.QueuedGeometry[] |
transparentQueue
Queue for depth sort transparency.
|
protected int |
transparentQueueSize
Current number of objects in
transparentQueue |
protected boolean |
unsetPickSegmentAfterRender
Whether to automatically un-set the pick segment on the given
event.
|
protected boolean |
unsetPickSegmentOnProjectionChange
Whether to automatically un-set the pick segment on the given
event.
|
protected boolean |
unsetPickSegmentOnWorldToViewChange
Whether to automatically un-set the pick segment on the given
event.
|
protected TimeMetrics |
updateNavMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
updateProjectionMetrics
Extended render metrics, iff compiled with
ENABLE_EXTENDED_RENDER_METRICS . |
protected J3DVertexAccessor[] |
vertexAccessors
Set of available vertex accessors, consed lazily.
|
protected float[][] |
viewAABB
view volume AABB in view frame
|
protected float |
viewToCanvasScale
current view-to-canvas scale
|
protected RX |
worldToViewRX
world-to-view
RX |
protected RX |
worldToViewRXTemp
temporary world-to-view
RX |
protected float |
worldToViewScale
world-to-view scale, updated by
updateWorldToView(boolean) |
Constructor and Description |
---|
Display3D()
make a new Display3D
|
Modifier and Type | Method and Description |
---|---|
protected void |
accumPass()
Hook called from generic
render() to accumulate a rendering
pass. |
protected void |
addCanvasListeners()
Adds all necessary event listeners to
canvas . |
protected void |
addToSceneMetrics(float[] boundingSphereCenterInView,
float boundingSphereRadiusInView,
boolean culled,
boolean transparent,
boolean highlighted,
boolean masked,
boolean pickable)
Add the information for a geometry to the scene metrics.
|
protected abstract void |
applyCMT()
|
protected abstract void |
applyProjection()
Subclasses must implement this to engage
viewAABB so that it
is applied to subsequent drawing. |
protected boolean |
autoAddListenersToRXSInteractor()
Whether to call
RXSInteractor.addListeners(java.awt.Component) on rxsInteractor in addCanvasListeners() . |
protected float[] |
canvasToLocal(float... point)
Applies projection^{-1} and cmt^{-1} transforms.
|
protected float |
canvasToLocal(float length)
Applies projection^{-1} and cmt^{-1} transforms.
|
float[] |
canvasToView(float... point)
Transform a point in canvas frame to view frame by applying the
projection transform.
|
float |
canvasToView(float length)
applies the projection transform
|
protected void |
clearCMT()
|
protected abstract void |
clearDrawingBuffer()
subclasses must implement this to clear the render buffer
|
protected boolean |
clearLocalToWorld()
clearLocalToWorld(boolean) not alwaysUpdate |
protected boolean |
clearLocalToWorld(boolean alwaysUpdate)
Set identity
localToWorldRX , then updateCMT() iff
changed or alwaysUpdate. |
protected void |
clearQueue(Display3D.QueuedGeometry[] queue,
int queueSize)
clears the geometry and appearance refs in a queue
|
protected int |
compareQueued(Display3D.QueuedGeometry a,
Display3D.QueuedGeometry b)
Implementation of
Display3D.QueuedGeometry.compareTo(vona.ui.Display3D.QueuedGeometry) . |
void |
disableLongFrameWarningThreshold()
Disable the long-frame warning threshold, see
setLongFrameWarningThreshold(float) . |
protected void |
doFit()
Calls
RXSInteractor.fit(double, double, double, double) on the
curent sceneAABBInView . |
protected void |
draw(javax.media.j3d.Geometry geometry)
|
protected void |
draw(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
|
protected void |
draw(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha)
|
protected void |
draw(javax.media.j3d.Geometry geometry,
float extraAlpha)
|
protected void |
draw(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
|
protected abstract void |
draw(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha)
Concrete subclasses must implement this to draw geometry.
|
void |
dump()
dump(PrintStream) to System.out |
void |
dump(java.io.PrintStream s)
dump everything
|
protected void |
dumpAABB(float[][] aabb,
java.lang.String msg,
java.io.PrintStream s)
dump the coords of an axis aligned bounding box
|
void |
dumpCanvasProperties()
dumpCanvasProperties(PrintStream) to System.out |
void |
dumpCanvasProperties(java.io.PrintStream s)
dumps properties of
canvas |
void |
dumpCMT()
dumpCMT(PrintStream) to System.out |
void |
dumpCMT(java.io.PrintStream s)
Dumps the current composite model transform taking local coordinates to
view coordinates.
|
void |
dumpHelp()
dumpHelp(PrintStream, String) to System.out using "meters" |
void |
dumpHelp(java.io.PrintStream s)
dumpHelp(PrintStream, String) using "meters" |
void |
dumpHelp(java.io.PrintStream s,
java.lang.String meters)
|
void |
dumpHelp(java.lang.String meters)
dumpHelp(PrintStream, String) to System.out |
void |
dumpInteractor()
dumpInteractor(PrintStream) to System.out |
void |
dumpInteractor(java.io.PrintStream s)
dumps
rxsInteractor and its RXSInterpolator |
protected void |
dumpLocalToWorld()
dumpLocalToWorld(PrintStream) to System.out |
protected void |
dumpLocalToWorld(java.io.PrintStream s)
Dump the current local-to-world transform.
|
protected boolean |
dumpPendingMetrics()
Dump any metrics that need it.
|
void |
dumpPickSegment()
dumpPickSegment(PrintStream) to System.out |
void |
dumpPickSegment(java.io.PrintStream s)
dump pick segment in view
|
void |
dumpProjection()
dumpProjection(PrintStream) to System.out |
void |
dumpProjection(java.io.PrintStream s)
dump the current projection parameters
|
void |
dumpRenderMetrics()
dumpRenderMetrics(PrintStream) to System.out |
void |
dumpRenderMetrics(java.io.PrintStream s)
Dumps the
*FrameTime* fields and related. |
protected void |
dumpRenderMetricsImpl(java.io.PrintStream s)
Impl of
dumpRenderMetrics(java.io.PrintStream) , run at end of generic render
when dumpRenderMetricsPending is set. |
void |
dumpSceneMetrics()
dumpSceneMetrics(PrintStream) to System.out |
void |
dumpSceneMetrics(java.io.PrintStream s)
Dumps scene metrics.
|
protected void |
dumpSceneMetricsImpl(java.io.PrintStream s)
Impl of
dumpSceneMetrics(java.io.PrintStream) , run at end of generic render
when dumpSceneMetricsPending is set. |
void |
dumpStats()
dumpStats(PrintStream) to System.out |
void |
dumpStats(java.io.PrintStream s)
|
void |
dumpWorldToView()
dumpWorldToView(PrintStream) to System.out |
void |
dumpWorldToView(java.io.PrintStream s)
dumps the current world-to-view transform
|
void |
enableDBGSceneExtents(boolean enable)
|
void |
enableDepthSortTransparent(boolean enable)
|
void |
enableDrawing(boolean enable)
|
void |
enableEnsureWidgetBoundingSpheresInView(boolean enable)
|
void |
enableFrustumCull(boolean enable)
|
void |
enableHighlighting(boolean enable)
|
void |
enableMasking(boolean enable)
|
void |
enableNavigation(boolean enable)
|
void |
enablePicking(boolean enable)
|
protected Display3D.QueuedGeometry[] |
enqueue(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float maxViewZ,
float ambientAlpha,
Display3D.QueuedGeometry[] queue,
int queueSize)
|
protected void |
enqueueMaskedGeometry(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float maxViewZ)
Add an item to the
maskedQueue . |
protected void |
enqueueTransparentGeometry(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float maxViewZ,
float ambientAlpha)
Add an item to the
transparentQueue , unless freezeTransparentQueue is set. |
protected void |
ensureDBGAppearance()
makes sure that
dbgAppearance has been consed |
void |
fitView()
Request a
doFit() . |
protected int |
getAllRenderTraceFlags()
Hook to get combination of all trace flags that apply to the render
algorithm.
|
float |
getAmbientAlpha()
get
ambientAlpha |
double |
getAvgRecentFPS()
Get the avg recent FPS according to the
recentCycleTime
metrics, which are maintained by the generic render() er. |
int |
getBlueBits()
get the bit width of the blue buffer
|
java.awt.Canvas |
getCanvas()
get
canvas , thread safe |
java.awt.Point |
getCanvasMouseLocation()
getCanvasMouseLocation(Point) , conses |
java.awt.Point |
getCanvasMouseLocation(java.awt.Point point)
Get the most recent mouse location on canvas in canvas coords.
|
double[] |
getDefaultRotationCenter()
Get the default rotation center in world frame, defaul impl returns
defaultRotationCenter . |
double |
getDefaultViewScale()
Get default world-to-view scale, used by
navigateToDefaultView(boolean, boolean) , default impl returns defaultViewScale if not NaN, else DEF_VIEW_SCALE . |
double[] |
getDefaultViewTXEM()
Get the default world-to-view TXEM vector.
|
int |
getDepthBits()
get the bit width of the depth buffer
|
int |
getGreenBits()
get the bit width of the green buffer
|
float[] |
getHighlightColor()
covers
getHighlightColor(float[]) , always conses |
float[] |
getHighlightColor(float[] color)
get
highlightColor |
float |
getHighlightFactor()
get
highlightFactor |
protected J3DIndexAccessor |
getIndexAccessorFor(javax.media.j3d.Geometry g)
Get an index accessor for a geometry.
|
protected java.lang.String |
getInfo(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Get an identifying string for geometry and appearance for
use in tracing and dbg.
|
protected RX |
getLocalTranslationRXToPixel()
getLocalTranslationRXToPixel(Point, RX) , uses current mouse
position or (0, 0) if mouse not on canvas, conses. |
protected RX |
getLocalTranslationRXToPixel(java.awt.Point pixel)
|
protected RX |
getLocalTranslationRXToPixel(java.awt.Point pixel,
RX ret)
getTranslationRXToPixel(RX, Point) using the current localToWorldRX . |
protected RX |
getLocalTranslationRXToPixel(RX ret)
getLocalTranslationRXToPixel(Point, RX) , uses current mouse
position or (0, 0) if mouse not on canvas. |
float |
getMaskAlpha()
get
maskAlpha |
int |
getNumFrames()
get
numFrames |
int |
getNumFramesSaved()
Get the total number of frames saved in the current or previous
regular-rate save sequence.
|
int |
getNumSamples()
get the number of antialiasing samples
|
protected int |
getPickCullFace(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook called by the smaller
pickGeometry(...) APIs to get the
pick cull face for the given geometry. |
protected float |
getPickThreshold(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook called by the smaller
pickGeometry(...) APIs to get the
pick threshold for the given geometry in local frame. |
float |
getPickThresholdPixels()
|
protected J3DPrimitiveIterator |
getPrimitiveIteratorFor(javax.media.j3d.Geometry g)
Covers
getPrimitiveIteratorFor(Geometry, boolean...) , enables
all components. |
protected J3DPrimitiveIterator |
getPrimitiveIteratorFor(javax.media.j3d.Geometry g,
boolean... enableComponent)
Get a primitive iterator for a geometry.
|
int |
getRedBits()
get the bit width of the red buffer
|
int |
getStencilBits()
get the bit width of the stencil buffer
|
RX |
getTranslationRXToPixel(RX localFrameCMT)
getTranslationRXToPixel(RX, Point, RX) , uses current mouse
position or (0, 0) if mouse not on canvas, conses. |
RX |
getTranslationRXToPixel(RX localFrameCMT,
java.awt.Point pixel)
|
RX |
getTranslationRXToPixel(RX localFrameCMT,
java.awt.Point pixel,
RX ret)
Compute translation which takes (0, 0, 0) to the nearest point on the
ray through pixel to the origin of a local frame.
|
RX |
getTranslationRXToPixel(RX localFrameCMT,
RX ret)
getTranslationRXToPixel(RX, Point, RX) , uses current mouse
position or (0, 0) if mouse not on canvas. |
protected J3DVertexAccessor |
getVertexAccessorFor(javax.media.j3d.Geometry g)
Covers
getVertexAccessorFor(Geometry, boolean...) , enables all
components. |
protected J3DVertexAccessor |
getVertexAccessorFor(javax.media.j3d.Geometry g,
boolean... enableComponent)
Get a vertex accessor for a geometry.
|
float |
getViewToCanvasScale()
get current
viewToCanvasScale |
float |
getZCenterInView()
Get the z coordinate of the center of
viewAABB in view
frame. |
protected java.io.File |
grabAndSaveFrame(java.io.File directory,
java.lang.String basename,
int index,
boolean withCursor)
Implementation hook to grab and save a frame.
|
boolean |
hasAccumBuffer()
check whether an accumulation buffer is available
|
float[] |
interpolateOnPickSegmentInLocal(float u)
|
float[] |
interpolateOnPickSegmentInLocal(float u,
float[] p)
|
float[] |
interpolateOnPickSegmentInView(float u)
|
float[] |
interpolateOnPickSegmentInView(float u,
float[] p)
Compute the coordinates of a point on the pick segment in view frame,
or NaN if un-set.
|
boolean |
isDepthSortTransparentEnabled()
|
boolean |
isDrawingEnabled()
|
boolean |
isFrustumCullEnabled()
|
protected boolean |
isHighlighted(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook that generic renderer uses to determine whether a
geometry/appearance combination should be categorized as
highlighted, if
highlightingEnabled . |
boolean |
isHighlightingEnabled()
|
protected boolean |
isMasked(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook that generic renderer uses to determine whether a
geometry/appearance combination should be categorized as
masked, if
maskingEnabled . |
boolean |
isMaskingEnabled()
|
boolean |
isNavigationEnabled()
|
protected boolean |
isPickable(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Check if the given geometry should be considered pickable.
|
boolean |
isPickingEnabled()
|
boolean |
isPickSegmentSet()
check if the pick segment is set
|
boolean |
isSphereVisible(float[] centerInView,
float radiusInView)
Check if a view-frame sphere intersects the view volume.
|
protected boolean |
isTransparent(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook that
render(Geometry, Appearance, float[], float) uses to
determine whether a geometry/appearance combination should
be categorized as transparent. |
protected float[] |
localToCanvas(float... point)
Applies cmt and projection transforms.
|
protected float |
localToCanvas(float length)
Applies cmt and projection transforms.
|
protected float[] |
localToView(boolean doScale,
boolean doRotate,
boolean doTranslate,
float... v)
Transform a 3D vector v from local frame to view frame, i.e.
|
protected float[] |
localToView(float... v)
Covers
localToView(boolean, boolean, boolean, float...) , does all three transformations |
protected float |
localToView(float length)
Applies
cmtScale . |
protected float[] |
localToWorld(boolean doRotate,
boolean doTranslate,
float... v)
Transform a 3D vector v from local frame to world frame by
applying
localToWorldRX . |
protected float[] |
localToWorld(float... v)
covers
localToWorld(boolean, boolean, float...) , does both transformations |
void |
navigateToDefaultView()
Covers
navigateToDefaultView(boolean, boolean) , never resets
rotaion center and always interpolates. |
void |
navigateToDefaultView(boolean resetRotationCenter)
Covers
navigateToDefaultView(boolean, boolean) , always
interpolates. |
void |
navigateToDefaultView(boolean resetRotationCenter,
boolean jump)
Navigate to
getDefaultViewTXEM() , getDefaultViewScale() . |
void |
navigateToView(RX localToWorld)
navigateToView(RX, boolean, boolean, boolean, boolean) , always
interpolates, does not set rotation center or defaults. |
void |
navigateToView(RX localToWorld,
boolean setRotationCenter)
navigateToView(RX, boolean, boolean, boolean, boolean) , always
interpolates, does not set defaults. |
void |
navigateToView(RX localToWorld,
boolean setRotationCenter,
boolean setDefaultView,
boolean setDefaultRotationCenter)
navigateToView(RX, boolean, boolean, boolean, boolean) , always
interpolates. |
void |
navigateToView(RX localToWorld,
boolean setRotationCenter,
boolean setDefaultView,
boolean setDefaultRotationCenter,
boolean jump)
Navigate to a viewpoint that aligns the coordinate frame identified by
cmt with the view frame.
|
protected boolean |
picked(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
int prim,
float u)
Picking callback.
|
protected int |
pickGeometry(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Covers
pickGeometry(Geometry, Appearance, J3DPrimitiveIterator,
float[], float[], float, int) using getPrimitiveIteratorFor(javax.media.j3d.Geometry, boolean...) ,
getPickThreshold(javax.media.j3d.Geometry, javax.media.j3d.Appearance) , and getPickCullFace(javax.media.j3d.Geometry, javax.media.j3d.Appearance) , pickStartInLocal , and pickExtentInLocal . |
protected int |
pickGeometry(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float[] pickStart,
float[] pickExtent)
Covers
pickGeometry(Geometry, Appearance, J3DPrimitiveIterator,
float[], float[], float, int) using getPrimitiveIteratorFor(javax.media.j3d.Geometry, boolean...) ,
getPickThreshold(javax.media.j3d.Geometry, javax.media.j3d.Appearance) , and getPickCullFace(javax.media.j3d.Geometry, javax.media.j3d.Appearance) . |
protected int |
pickGeometry(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
J3DPrimitiveIterator primitiveIterator,
float[] pickStart,
float[] pickExtent,
float pickThreshold,
int cullFace)
Perform a geometry pick.
|
float |
pickSphereInView(float[] pickStart,
float[] pickExtent,
float[] center,
float radius,
boolean checkOnly)
Check if a view-frame sphere and pick segment intersect.
|
float |
pickSphereInView(float[] center,
float radius,
boolean checkOnly)
Covers
pickSphereInView(float[], float[], float[], float,
boolean) using current pickStartInView and pickExtentInView . |
protected boolean |
popLocalToWorld()
popLocalToWorld(boolean) not alwaysUpdate |
protected boolean |
popLocalToWorld(boolean alwaysUpdate)
Pop the top transform off
localToWorldStack and set it by copy
to localToWorldRX , then updateCMT() iff changed or
alwaysUpdate. |
protected void |
postMasking(int numMaskedGeometries)
Hook called from generic
render() after masking pass. |
protected void |
postRender(double frameTimeSoFar)
Hook called at end of generic
render() . |
protected void |
postScene()
Hook called from generic
render() after renderScene() . |
protected void |
postSwap()
Hook called from generic
render() after swapBuffers() . |
protected boolean |
prependInverseLocalToWorld(RX rx)
prependInverseLocalToWorld(RX, boolean) not
alwaysUpdate. |
protected boolean |
prependInverseLocalToWorld(RX rx,
boolean alwaysUpdate)
Prepend rx^{-1} to
localToWorldRX , then updateCMT() iff changed. |
protected boolean |
prependLocalToWorld(RX rx)
prependLocalToWorld(RX, boolean) not alwaysUpdate |
protected boolean |
prependLocalToWorld(RX rx,
boolean alwaysUpdate)
Prepend rx to
localToWorldRX , then updateCMT() iff changed or alwayUpdate. |
protected void |
preRender()
Hook called at beginning of generic
render() . |
protected void |
preSwap()
Hook called from generic
render() before swapBuffers() . |
protected void |
projectionChanged()
Hook called when the projection transform has changed, default impl
does nothing.
|
protected void |
pushLocalToWorld()
Push
localToWorldRX by copy onto the top of localToWorldStack . |
float |
recenterZ()
covers
recenterZ(boolean) , always interpolates |
float |
recenterZ(boolean jump)
Move the viewpoint so that the current rotation center is on the
z plane midway between the front and rear clip planes.
|
void |
render()
The generic renderer.
|
protected void |
render(Display3D.QueuedGeometry[] queue,
int queueSize)
Render a queue of geometry.
|
protected void |
render(javax.media.j3d.Geometry geometry)
Covers
render(Geometry, Appearance, float[], float) , no
bounding sphere and default appearance. |
protected void |
render(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Covers
render(Geometry, Appearance, float[], float) , no
bounding sphere. |
protected void |
render(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float[] boundingSphereCenterInView,
float boundingSphereRadiusInView)
Render geometry in local frame.
|
protected void |
render(java.util.List<Widget> widgets)
Render a list of
Widget s. |
protected void |
render(javax.media.j3d.Shape3D shape)
renders all geometries of shape
|
protected void |
render(Widget w)
covers
render(Widget, RX) , no extra local-to-world transform |
protected void |
render(Widget w,
RX extraLocalToWorld)
Render a
Widget . |
protected boolean |
renderAccept(Widget widget)
Filter hook for
render(List) . |
protected void |
renderDepthOnly(Display3D.QueuedGeometry queuedGeometry)
|
protected void |
renderDepthOnly(Display3D.QueuedGeometry[] queue,
int queueSize)
Hook called from generic
render() to render a queue of
geometry depth-only. |
protected void |
renderDepthOnly(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Render only the depth component of a geometry.
|
protected void |
renderHighlighted(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook called from generic
render() to render a highlighted
geometry. |
protected void |
renderImpl()
actual implementation of
render() |
protected void |
renderInView()
Hook called from generic
render() to render geometry in view
frame. |
protected void |
renderScene()
Hook called from generic
render() to actually render the
scene. |
protected void |
renderTransparent(Display3D.QueuedGeometry queuedGeometry)
|
protected void |
renderTransparent(Display3D.QueuedGeometry[] queue,
int queueSize)
Hook called from generic
render() to render a queue of
transparent geometry. |
protected void |
renderTransparent(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha)
Covers
renderTransparent(RX, float, Geometry, Appearance,
float) , always disables depth write. |
protected void |
renderTransparent(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha,
boolean disableDepthWrite)
Render a transparent geometry.
|
protected void |
rePicking()
Hook called from generic render when pick will be performed for a
render.
|
protected boolean |
resetPendingMetrics()
Reset any metrics that need it.
|
protected void |
resetPickMetrics()
resets pick metrics
|
void |
resetRenderMetrics()
Resets the render metrics.
|
protected void |
resetRenderMetricsImpl()
Impl of
resetRenderMetrics() , run at beginning of generic render
when resetRenderMetricsPending is set. |
protected void |
resetSceneMetrics(boolean resetPickMetrics)
Resets scene metrics, the generic render implementation does this at
the beginning of each render.
|
void |
rotateAboutDefaultCenter()
Set the navigation rotation center to
defaultRotationCenter . |
void |
saveFrame(java.io.File directory,
java.lang.String basename,
double time)
Save the first frame whose rendering completes at or after time
to file.
|
void |
saveFrame(java.lang.String basename,
double time)
saveFrame(File, String, double) to current dir |
void |
saveFrame(java.lang.String directory,
java.lang.String basename,
double time)
|
protected boolean |
saveFrameFailed(java.lang.Exception exception)
Called when any frame save fails.
|
protected boolean |
saveFrameFinished(java.io.File file)
Called after any frame save is completed or fails.
|
void |
saveNextFrame(java.io.File directory,
java.lang.String basename)
|
void |
saveNextFrame(java.lang.String basename)
saveFrame(File, String, double) asap to current dir |
void |
saveNextFrame(java.lang.String directory,
java.lang.String basename)
covers
saveNextFrame(File, String) |
void |
setAmbientAlpha(float alpha)
set
ambientAlpha |
abstract void |
setAmbientLightIntensity(float intensity)
concrete subclasses must implement to set ambient light intensity
|
abstract void |
setBackgroundColor(float... color)
concrete subclasses must implement this to set the background color
|
protected void |
setCanvas(java.awt.Canvas canvas,
int width,
int height)
Concrete subclasses call this to set
canvas , thread safe. |
void |
setCanvasSize(int width,
int height)
setCanvasSize(int, int, boolean) and re-pack |
void |
setCanvasSize(int width,
int height,
boolean rePack)
set the canvas preferred size
|
protected void |
setCMT(RX cmtRX,
float cmtScale)
|
void |
setDefaultRotationCenter(double... rc)
Set the default rotation center in world frame as returned by the
default impl of
getDefaultRotationCenter() . |
void |
setDefaultView(RX rx,
double scale)
Set the default world-to-view transform as returned by the
default impl of
getDefaultViewTXEM() . |
void |
setDefaultViewScale(double scale)
Set
defaultViewScale . |
void |
setDefaultViewTXEM(double... txem)
Set the default world-to-view TXEM vector as returned by the
default impl of
getDefaultViewTXEM() . |
void |
setDefaultViewTXEMS(double... txems)
|
abstract void |
setDirectionalLightDirection(float... direction)
concrete subclasses must implement to set directional light direction
|
abstract void |
setDirectionalLightIntensity(float intensity)
concrete subclasses must implement to set directional light intensity
|
void |
setHighlightColor(float... color)
set
highlightColor |
void |
setHighlightFactor(float factor)
set
highlightFactor |
protected boolean |
setLocalToWorld(RX rx)
setLocalToWorld(RX, boolean) not alwaysUpdate |
protected boolean |
setLocalToWorld(RX rx,
boolean alwaysUpdate)
Set identity
localToWorldRX by copy, then updateCMT() iff changed or alwaysUpdate. |
void |
setLongFrameWarningThreshold(float threshold)
Set the threshold in ms above whidh a warning will be issued for long
frame render times.
|
void |
setMaskAlpha(float alpha)
set
maskAlpha |
void |
setPickPointOnCanvas(float x,
float y)
Convenience to
setPickSegmentInView(float[], float[]) given a location on the
canvas in pixels. |
void |
setPickSegmentInView(float[] start,
float[] extent)
Set the pick segment in view frame.
|
void |
setPickThresholdPixels(float threshold)
|
boolean |
setSymmetricZClip(float depth)
setZClip(float, float) symmetrically for a total span of depth |
protected void |
setTraceFlags(int flags)
hook to set
traceFlags |
protected void |
setTraceOptions(boolean... options)
covers
setTraceOptions(int, boolean...) , no base flags |
protected void |
setTraceOptions(int baseFlags,
boolean... options)
Accumulate options as a bitfield, in order starting with LSB, on
top of baseFlags, and then
setTraceFlags(int) . |
boolean |
setViewInMeters()
|
boolean |
setViewInPixels()
setViewToCanvasScale(float) to 1.0f |
boolean |
setViewToCanvasScale(float viewToCanvasScale)
Set
viewToCanvasScale . |
boolean |
setZClip(float near,
float far)
Set the near and far planes of the view volume in view frame.
|
void |
startSavingFrames(java.io.File directory,
java.lang.String prefix)
startSavingFrames(File, String, double, int) with start index
0, saving every render. |
void |
startSavingFrames(java.io.File directory,
java.lang.String prefix,
double fps)
startSavingFrames(File, String, double, int) with start index
0. |
void |
startSavingFrames(java.io.File directory,
java.lang.String prefix,
double fps,
int startIndex)
Save frames at a regular rate, starting with with the next render.
|
void |
startSavingFrames(java.lang.String prefix)
startSavingFrames(File, String, double, int) with start index
0, saving every render to current dir. |
void |
startSavingFrames(java.lang.String prefix,
double fps)
startSavingFrames(File, String, double, int) with start index
0, to current dir. |
void |
startSavingFrames(java.lang.String directory,
java.lang.String prefix)
Covers
startSavingFrames(File, String) . |
void |
startSavingFrames(java.lang.String directory,
java.lang.String prefix,
double fps)
|
void |
startSavingFrames(java.lang.String directory,
java.lang.String prefix,
double fps,
int startIndex)
|
double |
stopSavingFrames()
Abort any pending one-shot or regular-rate frame save.
|
protected abstract void |
swapBuffers()
subclasses must implement this to swap display buffers
|
void |
traceNextFrame()
Like
traceNextFrame(boolean, boolean) but only traces
renderer. |
void |
traceNextFrame(boolean tracePicking,
boolean traceRenderer)
Enable tracing for next frame with given options.
|
void |
traceNextPickingFrame()
Like
traceNextFrame(boolean, boolean) but only traces
picking. |
void |
unsetPickSegment()
un-set the pick segment
|
protected void |
updateCMT()
Set
cmtRX and cmtScale as the concatenation of localToWorldRX , worldToViewScale , and worldToViewRX ,
in that order, then applyCMT() . |
protected void |
updateHighlightedMaterial()
|
protected void |
updatePickSegmentInLocal()
|
protected boolean |
updateProjection(float canvasWidth,
float canvasHeight,
float viewToCanvasScale)
Recomputes
viewAABB from canvasWidth,
canvasHeight, and viewToCanvasScale . |
protected boolean |
updateWorldToView()
covers
updateWorldToView(boolean) , always to current |
protected boolean |
updateWorldToView(boolean toWaypoint)
|
boolean |
usingAccumBuffer()
Check if the accum buffer is currently considered usable.
|
float[] |
viewToCanvas(float... point)
opposite of
canvasToView(float...) |
float |
viewToCanvas(float length)
applies the projection transform
|
protected float[] |
viewToLocal(boolean doScale,
boolean doRotate,
boolean doTranslate,
float... v)
|
protected float[] |
viewToLocal(float... v)
covers
viewToLocal(boolean, boolean, boolean, float...) , does all three transformations |
protected float |
viewToLocal(float length)
Applies
cmtScale ^{-1}. |
float[] |
viewToWorld(boolean doScale,
boolean doRotate,
boolean doTranslate,
float... v)
|
float[] |
viewToWorld(float... v)
covers
viewToWorld(boolean, boolean, boolean, float...) , does all three transformations |
float |
viewToWorld(float length)
applies
worldToViewScale ^{-1} |
protected float[] |
worldToLocal(boolean doRotate,
boolean doTranslate,
float... v)
inverse of
localToWorld(boolean, boolean, float...) |
protected float[] |
worldToLocal(float... v)
covers
worldToLocal(boolean, boolean, float...) , does both transformations |
float[] |
worldToView(boolean doScale,
boolean doRotate,
boolean doTranslate,
float... v)
Transform a 3D vector v from world frame to view frame by
applying
worldToViewScale and worldToViewRX . |
float[] |
worldToView(float... v)
covers
worldToView(boolean, boolean, boolean, float...) , does all three transformations |
float |
worldToView(float length)
applies
worldToViewScale |
protected void |
worldToViewChanged()
Hook called when the world-to-view transform has changed (e.g.
|
boolean |
worldToViewDirty()
check if a navigation update is waiting to be applied
|
private static final java.lang.String cvsid
public static final int MIN
public static final int MAX
public static final int TRACE_PICKING_EN
public static final int TRACE_GENERIC_EN
public static final float DEF_Z_CLIP
setSymmetricZClip(float)
public static final double DEF_VIEW_SCALE
defaultViewScale
public static final float DEF_AMBIENT_LIGHT_INTENSITY
public static final float DEF_DIRECTIONAL_LIGHT_INTENSITY
public static final float SQRT3F
public static final float[] DEF_DIRECTIONAL_LIGHT_DIRECTION
public static final int NUM_RECENT_METRICS
recentFrameTime
and recentCycleTime
public static final int QUEUE_INITIAL_CAPACITY
public static final int LOCAL_TO_WORLD_STACK_INITIAL_CAPACITY
localToWorldStack
public static final float DEF_HIGHLIGHT_FACTOR
highlightFactor
public static final float[] DEF_HIGHLIGHT_COLOR
highlightColor
public static final float DEF_MASK_ALPHA
maskAlpha
public static final float DEF_PICK_THRESHOLD_PIXELS
pickThresholdPixels
protected static final boolean[] COORD_ONLY
protected static final boolean[] ALL_COMPONENTS
public static final float SCREEN_METERS_PER_PIXEL
protected volatile java.awt.Canvas canvas
protected volatile int redBits
protected volatile int greenBits
protected volatile int blueBits
protected volatile int depthBits
protected volatile int stencilBits
protected volatile int numSamples
protected final java.lang.Object projectionLock
protected final float[] canvasSize
canvas
in pixelsprotected final float[][] viewAABB
protected float viewToCanvasScale
protected boolean applyProjectionPending
applyProjection()
is pendingprotected final java.lang.Object canvasMouseLock
protected int canvasMouseX
Most recent mouse location on canvas in canvas coords or negative if mouse not on canvas.
protected int canvasMouseY
Most recent mouse location on canvas in canvas coords or negative if mouse not on canvas.
public final RXSInteractor rxsInteractor
The interactor.
Users of this class may configure this directly, e.g. to set factors or
enable/disable motion types (while synchronized on it). However, note
that the world-to-canvas transform parameters of this interactor are
automatically set by updateProjection(float, float, float)
.
public final RXSInterpolator rxsInterpolator
RXSInterpolator
in rxsInteractor
protected double[] defaultRotationCenter
Current default rotation center, used by getDefaultRotationCenter()
.
protected double[] defaultViewTXEM
Current default world-to-view TXEM, used by getDefaultViewTXEM()
.
protected double defaultViewScale
Current default world-to-view scale, used by getDefaultViewScale()
.
protected final RX localToWorldRX
Local-to-world RX
.
If used, this is designed to be confined to the render thread.
protected RX[] localToWorldStack
Stack for saving localToWorldRX
.
If used, this is designed to be confined to the render thread.
protected int localToWorldStackSize
Current number of transforms saved in localToWorldStack
.
If used, this is designed to be confined to the render thread.
protected float worldToViewScale
updateWorldToView(boolean)
protected final RX cmtRX
current rigid part of the local-to-view composite model transform.
Confined to the render thread.
protected float cmtScale
Current scale part of the local-to-view composite model transform.
Confined to the render thread.
protected boolean fitPending
doFit()
is pendingprotected java.lang.Object frameSaveLock
protected double frameSaveNextTime
protected double frameSaveLastTime
protected double frameSaveStartTime
Regular-rate frame save sequence start time in wall-clock time in seconds, if any, else NaN.
protected java.io.File frameSaveDirectory
protected java.lang.String frameSavePrefix
protected int frameSaveNextIndex
protected int frameSaveCount
protected double frameSaveFPS
maximum rate for regular frame save.
Zero to save every render.
Negative indicates not regularly saving frames.
public volatile boolean frameSaveWithCursor
Whether to include the cursor in frame saves.
Default false.
protected final java.lang.Object sceneMetricsLock
protected final float[][] sceneAABBInView
AABB of enclosing union of bounding spheres (including those that would
be frustum culled) seen by generic render(Geometry, Appearance,
float[], float)
since last resetSceneMetrics(boolean)
.
protected int numSceneWidgets
Total number of Widget
s (including those with zero enabled
geometries, and those that would be frustum culled) seen by generic render(Widget, RX)
since last resetSceneMetrics(boolean)
.
protected int numDisabledWidgetGeometries
Total number of disabled Widget
geometries seen by generic
render(Widget, RX)
since last resetSceneMetrics(boolean)
.
protected int numSceneGeometries
Total number of geometries (including those that would be frustum
culled) seen by generic render(Geometry, Appearance, float[],
float)
since last resetSceneMetrics(boolean)
.
protected int numVisibleGeometries
Total number of visible (not frustum cull) geometries seen by generic
render(Geometry, Appearance, float[], float)
since last resetSceneMetrics(boolean)
.
protected int numTransparentGeometries
Total number of visible (not frustum cull) geometries rendered as
transparent by generic render(Geometry, Appearance, float[],
float)
since last resetSceneMetrics(boolean)
.
protected int numHighlightedGeometries
Total number of visible (not frustum cull) geometries rendered as
highlighted by generic render(Geometry, Appearance, float[],
float)
since last resetSceneMetrics(boolean)
.
protected int numMaskedGeometries
Total number of visible (not frustum cull) geometries rendered as
masked by generic render(Geometry, Appearance, float[],
float)
since last resetSceneMetrics(boolean)
.
protected int numPickableGeometries
Total number of visible pickable geometries iff pickingEnabled
since last resetSceneMetrics(boolean)
.
protected final java.lang.Object renderMetricsLock
protected volatile boolean resetRenderMetricsPending
protected volatile java.io.PrintStream dumpRenderMetricsPending
protected volatile java.io.PrintStream dumpSceneMetricsPending
protected final double[] frameTime
Min and max generic render()
time [s] since last resetRenderMetrics()
.
protected int numPickGeometryHits
Total number of geometries with at least one pick hit in pickGeometry(Geometry, Appearance, J3DPrimitiveIterator, float[],
float[], float, int)
since last resetSceneMetrics(boolean)
on a frame
with picking (or if resetPickMetricsEveryRender
).
protected int numPickBoundsHits
Total number of geometries picked by bounds in generic render since
last resetSceneMetrics(boolean)
on a frame with picking (or if resetPickMetricsEveryRender
).
protected int numPickedGeometries
Total number of geometries picked either by bounds only or by geometry
since last resetSceneMetrics(boolean)
on a frame with picking (or if
resetPickMetricsEveryRender
).
protected final double[] recentFrameTime
Rendering time [s] for up to NUM_RECENT_METRICS
most
recent generic render()
frames.
protected int recentFrameTimeWriteIndex
recentFrameTime
protected final double[] recentCycleTime
Cycle time [s] for up to NUM_RECENT_METRICS
most
recent generic render()
frames.
A frame cycle is defined here as beginning at the end of frame n render and ending at the end of frame n+1 render.
protected int recentCycleTimeWriteIndex
recentCycleTime
protected double lastFrameEndTime
render()
, NaN if noneprotected int numFrames
Total num generic render()
calls since last resetRenderMetrics()
.
protected TimeMetrics renderImplPreSceneMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics updateProjectionMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics preRenderMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics updateNavMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics clearMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderSceneMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderImplPostSceneMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderTransparentQueue1Metrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics accumPass1Metrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderDepthOnlyQueueMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderTransparentQueue2Metrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics accumPass2Metrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderInViewMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics swapMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics postRenderMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderWidgetMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics applyWidgetRX
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics transformWidgetBounds
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderWidgetGeometryMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderGeometryMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderTransparentMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderHighlightedMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderDepthOnlyMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics pickGeometryMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics frameSaveMetrics
Extended render metrics, iff compiled with ENABLE_EXTENDED_RENDER_METRICS
.
protected java.util.List<TimeMetrics> allExtendedRenderMetrics
protected final boolean ENABLE_EXTENDED_RENDER_METRICS
protected volatile boolean drawingEnabled
render()
codeprotected volatile boolean pickingEnabled
render()
codeprotected volatile boolean depthSortTransparentEnabled
render()
codeprotected volatile boolean depthRenderMaskedQueueEnabled
render()
codeprotected volatile boolean highlightingEnabled
render()
codeprotected volatile boolean maskingEnabled
render()
codeprotected volatile boolean frustumCullEnabled
render()
codeprotected volatile boolean navigationEnabled
render()
codeprotected volatile boolean pickBoundsOnly
protected volatile boolean pickVisibleBoundsOnly
protected volatile boolean pickSegmentIntersectionsOnly
Whether picks should only be reported for pick intersections that
actually lie on the pick segment defined by pickStartInView
,
pickExtentInView
.
Otherwise, all intersections with the line through the pick segment will be reported.
protected volatile boolean unsetPickSegmentOnWorldToViewChange
Whether to automatically un-set the pick segment on the given event.
protected volatile boolean unsetPickSegmentOnProjectionChange
Whether to automatically un-set the pick segment on the given event.
protected volatile boolean unsetPickSegmentAfterRender
Whether to automatically un-set the pick segment on the given event.
protected volatile boolean resetPickMetricsEveryRender
Whether to reset pick metrics at the beginning of every frame or just at the beginning of frames for pick will be performed.
protected volatile boolean ensureWidgetBoundingSpheresInViewEnabled
Whether render(Widget, RX)
calls Widget.ensureBoundingSpheresInView()
.
protected volatile boolean dbgSceneExtentsEnabled
protected RectangleWidget dbgSceneExtentsRect
protected volatile float longFrameWarningThreshold
Iif non-NaN this is the threshold in ms above which a warning will be issued for long frame render times.
protected volatile int traceFlags
render()
protected volatile java.io.PrintStream traceStream
render()
protected javax.media.j3d.Appearance dbgAppearance
Appearance for dbg objects.
If used, this is designed to be confined to the render thread.
protected javax.media.j3d.Appearance defaultTransparentAppearance
Default transparent appearance.
If used, this is designed to be confined to the render thread.
protected javax.media.j3d.Appearance depthOnlyAppearance
Depth-only appearance.
If used, this is designed to be confined to the render thread.
protected final java.lang.Object environmentLock
protected float highlightFactor
This is the multiplicative factor by which renderHighlighted(vona.math.RX, float, javax.media.j3d.Geometry, javax.media.j3d.Appearance)
increases the emissive color of highlighted geometry, modulated by highlightColor
.
This must be in the range [0, 1]. The modulation is computed as n =
o+c*f where n is the new color component, o is the
original color component, c is the corresponding highlightColor
component, and f is the highlight factor. If the
resulting n is greater than 1 then the alternate formulat n =
c*f is used.
protected final float[] highlightColor
highlightFactor
protected final javax.vecmath.Color3f emissiveColorWas
protected final javax.vecmath.Color3f newEmissiveColor
protected final javax.vecmath.Color3f premultipliedHighlightColor
protected final javax.media.j3d.Material defaultHighlightedMaterial
protected final javax.media.j3d.Appearance defaultHighlightedAppearance
protected volatile float ambientAlpha
Ambient alpha.
Ignored if outside the range [0, 1). Otherwise, ambientAlpha is
considered to multiply the original alpha in render(Geometry,
Appearance, float[], float)
.
protected volatile float maskAlpha
protected float passAlpha
Alpha factor for current rendering pass.
If used, this is designed to be confined to the render thread.
protected boolean premultiplyPassAlpha
Whether the default renderer will use the extraAlpha draw(...)
parameter to implement passAlpha
.
If used, this is designed to be confined to the render thread.
protected boolean renderMaskedGeometry
Whether to render masked geometry in the current pass.
If used, this is designed to be confined to the render thread.
protected boolean freezeTransparentQueue
Whether to short circuit in enqueueTransparentGeometry(vona.math.RX, float, javax.media.j3d.Geometry, javax.media.j3d.Appearance, float, float)
.
If used, this is designed to be confined to the render thread.
protected boolean freezeSceneMetrics
Whether to short circuit in addToSceneMetrics(float[], float, boolean, boolean, boolean, boolean, boolean)
.
If used, this is designed to be confined to the render thread.
protected boolean freezeWidgetBounds
Whether to skip updating Widget
bounds in view render(Widget, RX)
.
If used, this is designed to be confined to the render thread.
protected Display3D.QueuedGeometry[] transparentQueue
Queue for depth sort transparency.
Consed lazily iff depthSortTransparentEnabled
.
If used, this is designed to be confined to the render thread.
protected int transparentQueueSize
Current number of objects in transparentQueue
If used, this is designed to be confined to the render thread.
protected Display3D.QueuedGeometry[] maskedQueue
Queue for masked geometry.
Consed lazily iff maskingEnabled
.
If used, this is designed to be confined to the render thread.
protected int maskedQueueSize
Current number of objects in maskedQueue
If used, this is designed to be confined to the render thread.
protected J3DVertexAccessor[] vertexAccessors
Set of available vertex accessors, consed lazily.
If used, this is designed to be confined to the render thread.
protected J3DIndexAccessor[] indexAccessors
Set of available index accessors, consed lazily.
If used, this is designed to be confined to the render thread.
protected J3DPrimitiveIterator[] primitiveIterators
Set of available primitive iterators, consed lazily.
If used, this is designed to be confined to the render thread.
protected final float[] pickStartInView
Start point of the pick segment in view frame, or NaN if un-set.
protected final float[] pickExtentInView
Extent of the pick segment in view frame, or NaN if un-set.
protected final float[] pickStartInLocal
Start point of the pick segment in local frame, or NaN if un-set.
protected final float[] pickExtentInLocal
Extent of the pick segment in local frame, or NaN if un-set.
protected boolean pickSegmentInLocalDirty
Dirty flag for pickStartInLocal
and pickExtentInLocal
.
protected boolean pickSegmentInViewPerpCanvas
protected java.lang.Object pickSegmentLock
protected volatile float pickThresholdPixels
Pick threshold in canvas pixels.
public java.awt.Canvas getCanvas()
canvas
, thread safepublic void setCanvasSize(int width, int height, boolean rePack)
public void setCanvasSize(int width, int height)
setCanvasSize(int, int, boolean)
and re-packpublic java.awt.Point getCanvasMouseLocation(java.awt.Point point)
Get the most recent mouse location on canvas in canvas coords.
Returns negative coords if mouse is not on canvas.
public java.awt.Point getCanvasMouseLocation()
getCanvasMouseLocation(Point)
, consespublic int getRedBits()
public int getGreenBits()
public int getBlueBits()
public int getDepthBits()
public int getStencilBits()
public int getNumSamples()
public boolean usingAccumBuffer()
Check if the accum buffer is currently considered usable.
Default impl chains to hasAccumBuffer()
.
public boolean hasAccumBuffer()
public void saveFrame(java.io.File directory, java.lang.String basename, double time)
Save the first frame whose rendering completes at or after time to file.
The file format is implementation dependent.
saveFrameFailed(java.lang.Exception)
will be called if the save fails for any
reason, and saveFrameFinished(java.io.File)
will be called after the save is
completed (or failed).
directory
- the destination directory, null for current dirbasename
- the name of the destination file without directory or
extensiontime
- the system time in seconds after which to save a framejava.lang.IllegalStateException
- if currently saving frames (see startSavingFrames(java.io.File, java.lang.String, double, int)
)public void saveFrame(java.lang.String directory, java.lang.String basename, double time)
public void saveFrame(java.lang.String basename, double time)
saveFrame(File, String, double)
to current dirpublic void saveNextFrame(java.io.File directory, java.lang.String basename)
public void saveNextFrame(java.lang.String directory, java.lang.String basename)
saveNextFrame(File, String)
public void saveNextFrame(java.lang.String basename)
saveFrame(File, String, double)
asap to current dirpublic void startSavingFrames(java.io.File directory, java.lang.String prefix, double fps, int startIndex)
Save frames at a regular rate, starting with with the next render.
The file format is implementation dependent.
saveFrameFailed(java.lang.Exception)
will be called if any save fails for any
reason, and saveFrameFinished(java.io.File)
will be called after each save is
completed (or fails).
The frames will be saved no faster than the requested fps. The actual
save rate will be limited to the rate at which render()
is called
by higher level code. The average of this actual rate across all frames
will be returned when stopSavingFrames()
is called.
Will not overwrite existing files.
directory
- the directory in which to save, null for current dirprefix
- filename prefix, null for nonefps
- target frames per second, not negative, zero to save every
renderstartIndex
- initial index, not negativepublic void startSavingFrames(java.lang.String directory, java.lang.String prefix, double fps, int startIndex)
public void startSavingFrames(java.io.File directory, java.lang.String prefix, double fps)
startSavingFrames(File, String, double, int)
with start index
0.
public void startSavingFrames(java.lang.String directory, java.lang.String prefix, double fps)
public void startSavingFrames(java.io.File directory, java.lang.String prefix)
startSavingFrames(File, String, double, int)
with start index
0, saving every render.
public void startSavingFrames(java.lang.String directory, java.lang.String prefix)
Covers startSavingFrames(File, String)
.
public void startSavingFrames(java.lang.String prefix, double fps)
startSavingFrames(File, String, double, int)
with start index
0, to current dir.
public void startSavingFrames(java.lang.String prefix)
startSavingFrames(File, String, double, int)
with start index
0, saving every render to current dir.
public double stopSavingFrames()
Abort any pending one-shot or regular-rate frame save.
public int getNumFramesSaved()
Get the total number of frames saved in the current or previous regular-rate save sequence.
This count includes error frames.
protected java.io.File grabAndSaveFrame(java.io.File directory, java.lang.String basename, int index, boolean withCursor) throws java.io.IOException
Implementation hook to grab and save a frame.
The file format is implementation dependent; the implementation should generate the full name of the save destination file as directory/basenameindex.ext where ext is appropriate for the frame save format.
If the destination file exists it should not be overridden.
Default impl throws an IOException wrapping an UnsupportedOperationException.
directory
- the destination directory or null for current dirbasename
- the file basenameindex
- the frame index, or negative if nonejava.io.IOException
- (possibly wrapping another exception) if the save
fails for any reason, including would overwriteprotected boolean saveFrameFailed(java.lang.Exception exception)
Called when any frame save fails.
Default impl prints error message to System.err and returns true.
exception
- the errorprotected boolean saveFrameFinished(java.io.File file)
Called after any frame save is completed or fails.
Default impl returns true.
file
- the attempted save fileprotected void pushLocalToWorld()
Push localToWorldRX
by copy onto the top of localToWorldStack
.
Grows localToWorldStack
as necessary, conses then and only
then.
If used, this is designed to be confined to the render thread.
protected boolean popLocalToWorld(boolean alwaysUpdate)
Pop the top transform off localToWorldStack
and set it by copy
to localToWorldRX
, then updateCMT()
iff changed or
alwaysUpdate.
If used, this is designed to be confined to the render thread.
alwaysUpdate
- whether to always updateCMT()
even if localToWorldRX
unchangedjava.lang.IllegalStateException
- if localToWorldStack
is
currently emptyprotected boolean popLocalToWorld()
popLocalToWorld(boolean)
not alwaysUpdateprotected boolean prependLocalToWorld(RX rx, boolean alwaysUpdate)
Prepend rx to localToWorldRX
, then updateCMT()
iff changed or alwayUpdate.
If used, this is designed to be confined to the render thread.
alwaysUpdate
- whether to always updateCMT()
even if localToWorldRX
unchangedprotected boolean prependLocalToWorld(RX rx)
prependLocalToWorld(RX, boolean)
not alwaysUpdateprotected boolean prependInverseLocalToWorld(RX rx, boolean alwaysUpdate)
Prepend rx^{-1} to localToWorldRX
, then updateCMT()
iff changed.
If used, this is designed to be confined to the render thread.
alwaysUpdate
- whether to always updateCMT()
even if localToWorldRX
unchangedprotected boolean prependInverseLocalToWorld(RX rx)
prependInverseLocalToWorld(RX, boolean)
not
alwaysUpdate.
protected boolean setLocalToWorld(RX rx, boolean alwaysUpdate)
Set identity localToWorldRX
by copy, then updateCMT()
iff changed or alwaysUpdate.
If used, this is designed to be confined to the render thread.
alwaysUpdate
- whether to always updateCMT()
even if localToWorldRX
unchangedprotected boolean setLocalToWorld(RX rx)
setLocalToWorld(RX, boolean)
not alwaysUpdateprotected boolean clearLocalToWorld(boolean alwaysUpdate)
Set identity localToWorldRX
, then updateCMT()
iff
changed or alwaysUpdate.
If used, this is designed to be confined to the render thread.
alwaysUpdate
- whether to always updateCMT()
even if localToWorldRX
unchangedprotected boolean clearLocalToWorld()
clearLocalToWorld(boolean)
not alwaysUpdateprotected boolean updateWorldToView(boolean toWaypoint)
Updates worldToViewRX
and worldToViewScale
from
rxsInteractor
, then updateCMT()
iff changed.
If used, this is designed to be confined to the render thread.
Calls worldToViewChanged()
iff the transform changed.
toWaypoint
- if true then the acquired world-to-view transform
will be that of the next view waypoint, which may be different than the
current effective transform if an interpolation is ongoing. If false then
the current effective transform is acquired.protected boolean updateWorldToView()
updateWorldToView(boolean)
, always to currentprotected void updateCMT()
Set cmtRX
and cmtScale
as the concatenation of localToWorldRX
, worldToViewScale
, and worldToViewRX
,
in that order, then applyCMT()
.
If used, this is designed to be confined to the render thread.
protected void setCMT(RX cmtRX, float cmtScale)
Set cmtRX
and cmtScale
by copy, then applyCMT()
.
Note that this is a low-level method; if you are making use of localToWorldRX
, worldToViewRX
, and worldToViewScale
then normally you would call updateCMT()
instead.
protected void clearCMT()
Set cmtRX
and cmtScale
to identity, then applyCMT()
.
Subsequent drawing will thus be in view frame.
protected boolean updateProjection(float canvasWidth, float canvasHeight, float viewToCanvasScale)
Recomputes viewAABB
from canvasWidth,
canvasHeight, and viewToCanvasScale
.
Also updates the cached canvasSize
and flags applyProjectionPending
, which will trigger an applyProjection()
at th next generic render()
.
Calls projectionChanged()
iff the transform changed.
canvasWidth
- the new canvas width, or non-positive to use the
current cached valuecanvasHeight
- the new canvas height, or non-positive to use the
current cached valueviewToCanvasScale
- the new view to canvas scale, or non-positive to
use the current valuepublic float recenterZ(boolean jump)
Move the viewpoint so that the current rotation center is on the z plane midway between the front and rear clip planes.
Note that the next waypoint will not be engaged till rxsInteractor
is jumped or interpolated.
jump
- if true then jump to the new viewpoint, otherwise interpolatepublic float recenterZ()
recenterZ(boolean)
, always interpolatespublic float getZCenterInView()
Get the z coordinate of the center of viewAABB
in view
frame.
public void navigateToView(RX localToWorld, boolean setRotationCenter, boolean setDefaultView, boolean setDefaultRotationCenter, boolean jump)
Navigate to a viewpoint that aligns the coordinate frame identified by cmt with the view frame.
localToWorld
- transform taking object coordinates to world
coordinatessetRotationCenter
- whether to also set the navigation rotation
center to the origin of the coordinate frame identified by
localToWorldsetDefaultView
- whether to also make the new view the default viewsetDefaultRotationCenter
- whether to also make the origin of the
frame identified by localToWorld the default rotation centerjump
- if true then jump to the new viewpoint, otherwise interpolatepublic void navigateToView(RX localToWorld, boolean setRotationCenter, boolean setDefaultView, boolean setDefaultRotationCenter)
navigateToView(RX, boolean, boolean, boolean, boolean)
, always
interpolates.
public void navigateToView(RX localToWorld, boolean setRotationCenter)
navigateToView(RX, boolean, boolean, boolean, boolean)
, always
interpolates, does not set defaults.
public void navigateToView(RX localToWorld)
navigateToView(RX, boolean, boolean, boolean, boolean)
, always
interpolates, does not set rotation center or defaults.
public void navigateToDefaultView(boolean resetRotationCenter, boolean jump)
Navigate to getDefaultViewTXEM()
, getDefaultViewScale()
.
resetRotationCenter
- if true then the rotation center is set to
getDefaultRotationCenter()
jump
- if true then jump to the new viewpoint, otherwise interpolatepublic void navigateToDefaultView(boolean resetRotationCenter)
Covers navigateToDefaultView(boolean, boolean)
, always
interpolates.
public void navigateToDefaultView()
Covers navigateToDefaultView(boolean, boolean)
, never resets
rotaion center and always interpolates.
public void rotateAboutDefaultCenter()
Set the navigation rotation center to defaultRotationCenter
.
public double[] getDefaultRotationCenter()
Get the default rotation center in world frame, defaul impl returns
defaultRotationCenter
.
public void setDefaultRotationCenter(double... rc)
Set the default rotation center in world frame as returned by the
default impl of getDefaultRotationCenter()
.
rc
- the new default rotation center in world frame or null for originpublic double[] getDefaultViewTXEM()
Get the default world-to-view TXEM vector.
Default impl returns defaultViewTXEM
if not null, otherwise
identity except that z is backed off so that the world frame origin
is at the center of the view volume.
public void setDefaultViewTXEM(double... txem)
Set the default world-to-view TXEM vector as returned by the
default impl of getDefaultViewTXEM()
.
txem
- the new default view-to-world TXEM vector or null to use
default as described in getDefaultViewTXEM()
public void setDefaultViewTXEMS(double... txems)
public void setDefaultViewScale(double scale)
Set defaultViewScale
.
scale
- the new default world-to-view scale or null to use default as
described in getDefaultViewScale()
public double getDefaultViewScale()
Get default world-to-view scale, used by navigateToDefaultView(boolean, boolean)
, default impl returns defaultViewScale
if not NaN, else DEF_VIEW_SCALE
.
public void setDefaultView(RX rx, double scale)
Set the default world-to-view transform as returned by the
default impl of getDefaultViewTXEM()
.
rx
- the new default view-to-world transform or null to use default
as described in getDefaultViewTXEM()
scale
- the new default world-to-view scale or null to use default as
described in getDefaultViewScale()
public void fitView()
Request a doFit()
.
This sets fitPending
. The generic render()
implementation will then do a doFit()
with at its next call.
public boolean worldToViewDirty()
public boolean setZClip(float near, float far)
Set the near and far planes of the view volume in view frame.
Calls projectionChanged()
iff the new values differ from the
old.
public boolean setSymmetricZClip(float depth)
setZClip(float, float)
symmetrically for a total span of depthpublic boolean setViewToCanvasScale(float viewToCanvasScale)
Set viewToCanvasScale
.
Calls projectionChanged()
iff the new values differ from the
old.
viewToCanvasScale
- the new scale, must be positivepublic float getViewToCanvasScale()
viewToCanvasScale
public boolean setViewInMeters()
public boolean setViewInPixels()
setViewToCanvasScale(float)
to 1.0fpublic boolean isSphereVisible(float[] centerInView, float radiusInView)
Check if a view-frame sphere intersects the view volume.
centerInView
- the center of the sphere in view frameradiusInView
- the radius of the sphere in view frame, non-negativepublic float pickSphereInView(float[] pickStart, float[] pickExtent, float[] center, float radius, boolean checkOnly)
Check if a view-frame sphere and pick segment intersect.
Note that the intersection may be outside the view volume.
pickStart
- the view frame coordinates of the start of the pick
segmentpickExtent
- the extent of the pick segment relative to
pickStart in view framecenter
- the center of the sphere in view frameradius
- the radius of the sphere in view frame, non-negativepublic float pickSphereInView(float[] center, float radius, boolean checkOnly)
Covers pickSphereInView(float[], float[], float[], float,
boolean)
using current pickStartInView
and pickExtentInView
.
public void setPickSegmentInView(float[] start, float[] extent)
Set the pick segment in view frame.
The pick segment is considered un-set if any of it is NaN.
start
- the start point of the pick segment, if any element is NaN
then all should be NaNextent
- the extent of the pick segment, nonzero, if any element is
NaN then all elements of both extent and start should be NaNpublic void setPickPointOnCanvas(float x, float y)
Convenience to setPickSegmentInView(float[], float[])
given a location on the
canvas in pixels.
The pick segment will span the view frustum in Z and will pierce the indicated canvas pixel.
public void unsetPickSegment()
public boolean isPickSegmentSet()
public float[] interpolateOnPickSegmentInView(float u, float[] p)
Compute the coordinates of a point on the pick segment in view frame, or NaN if un-set.
public float[] interpolateOnPickSegmentInView(float u)
public float[] interpolateOnPickSegmentInLocal(float u, float[] p)
public float[] interpolateOnPickSegmentInLocal(float u)
protected float[] localToWorld(boolean doRotate, boolean doTranslate, float... v)
Transform a 3D vector v from local frame to world frame by
applying localToWorldRX
.
If used, this is designed to be confined to the render thread.
doRotate
- whether to apply the rotationdoTranslate
- whether to apply the translationprotected float[] localToWorld(float... v)
localToWorld(boolean, boolean, float...)
, does both transformationsprotected float[] worldToLocal(boolean doRotate, boolean doTranslate, float... v)
localToWorld(boolean, boolean, float...)
protected float[] worldToLocal(float... v)
worldToLocal(boolean, boolean, float...)
, does both transformationspublic float[] worldToView(boolean doScale, boolean doRotate, boolean doTranslate, float... v)
Transform a 3D vector v from world frame to view frame by
applying worldToViewScale
and worldToViewRX
.
doScale
- whether to apply the scalingdoRotate
- whether to apply the rotationdoTranslate
- whether to apply the translationpublic float[] worldToView(float... v)
worldToView(boolean, boolean, boolean, float...)
, does all three transformationspublic float worldToView(float length)
worldToViewScale
public float[] viewToWorld(boolean doScale, boolean doRotate, boolean doTranslate, float... v)
public float[] viewToWorld(float... v)
viewToWorld(boolean, boolean, boolean, float...)
, does all three transformationspublic float viewToWorld(float length)
worldToViewScale
^{-1}protected float[] localToView(boolean doScale, boolean doRotate, boolean doTranslate, float... v)
Transform a 3D vector v from local frame to view frame, i.e. by
applying localToWorldRX
, worldToViewScale
, and worldToViewRX
, in that order.
If used, this is designed to be confined to the render thread.
doScale
- whether to apply the scalingdoRotate
- whether to apply the rotationdoTranslate
- whether to apply the translationprotected float[] localToView(float... v)
localToView(boolean, boolean, boolean, float...)
, does all three transformationsprotected float localToView(float length)
Applies cmtScale
.
If used, this is designed to be confined to the render thread.
protected float[] viewToLocal(boolean doScale, boolean doRotate, boolean doTranslate, float... v)
protected float[] viewToLocal(float... v)
viewToLocal(boolean, boolean, boolean, float...)
, does all three transformationsprotected float viewToLocal(float length)
Applies cmtScale
^{-1}.
If used, this is designed to be confined to the render thread.
public float[] canvasToView(float... point)
Transform a point in canvas frame to view frame by applying the projection transform.
See class header doc for the definition of camera frame.
point
- a 2D or 3D point in canvas frame, will be transformed
in-placepublic float canvasToView(float length)
public float[] viewToCanvas(float... point)
canvasToView(float...)
public float viewToCanvas(float length)
protected float[] localToCanvas(float... point)
Applies cmt and projection transforms.
If used, this is designed to be confined to the render thread.
protected float localToCanvas(float length)
Applies cmt and projection transforms.
If used, this is designed to be confined to the render thread.
protected float[] canvasToLocal(float... point)
Applies projection^{-1} and cmt^{-1} transforms.
If used, this is designed to be confined to the render thread.
protected float canvasToLocal(float length)
Applies projection^{-1} and cmt^{-1} transforms.
If used, this is designed to be confined to the render thread.
public RX getTranslationRXToPixel(RX localFrameCMT, java.awt.Point pixel, RX ret)
Compute translation which takes (0, 0, 0) to the nearest point on the ray through pixel to the origin of a local frame.
localFrameCMT
- transform taking local frame coordinates to world
frame, or null to use identitypixel
- the canvas pixel coordinates or null to use (0, 0)ret
- the computed translation is set as the translation part of this
transform. The rotation part is not modified. If null a new identity
transform is consed.public RX getTranslationRXToPixel(RX localFrameCMT, RX ret)
getTranslationRXToPixel(RX, Point, RX)
, uses current mouse
position or (0, 0) if mouse not on canvas.
public RX getTranslationRXToPixel(RX localFrameCMT)
getTranslationRXToPixel(RX, Point, RX)
, uses current mouse
position or (0, 0) if mouse not on canvas, conses.
protected RX getLocalTranslationRXToPixel(java.awt.Point pixel, RX ret)
getTranslationRXToPixel(RX, Point)
using the current localToWorldRX
.
If used, this is designed to be confined to the render thread.
protected RX getLocalTranslationRXToPixel(RX ret)
getLocalTranslationRXToPixel(Point, RX)
, uses current mouse
position or (0, 0) if mouse not on canvas.
protected RX getLocalTranslationRXToPixel(java.awt.Point pixel)
protected RX getLocalTranslationRXToPixel()
getLocalTranslationRXToPixel(Point, RX)
, uses current mouse
position or (0, 0) if mouse not on canvas, conses.
public abstract void setBackgroundColor(float... color)
public abstract void setAmbientLightIntensity(float intensity)
public abstract void setDirectionalLightIntensity(float intensity)
public abstract void setDirectionalLightDirection(float... direction)
public void setHighlightFactor(float factor)
highlightFactor
protected void updateHighlightedMaterial()
Update defaultHighlightedMaterial
from highlightFactor
and highlightColor
.
public float getHighlightFactor()
highlightFactor
public void setHighlightColor(float... color)
highlightColor
public float[] getHighlightColor(float[] color)
highlightColor
public float[] getHighlightColor()
getHighlightColor(float[])
, always consespublic void setAmbientAlpha(float alpha)
ambientAlpha
public float getAmbientAlpha()
ambientAlpha
public void setMaskAlpha(float alpha)
maskAlpha
public float getMaskAlpha()
maskAlpha
public void setPickThresholdPixels(float threshold)
public float getPickThresholdPixels()
public int getNumFrames()
numFrames
public void enableDrawing(boolean enable)
public boolean isDrawingEnabled()
public void enablePicking(boolean enable)
public boolean isPickingEnabled()
public void enableDepthSortTransparent(boolean enable)
public boolean isDepthSortTransparentEnabled()
public void enableHighlighting(boolean enable)
public boolean isHighlightingEnabled()
public void enableMasking(boolean enable)
public boolean isMaskingEnabled()
public void enableFrustumCull(boolean enable)
public boolean isFrustumCullEnabled()
public void enableNavigation(boolean enable)
public boolean isNavigationEnabled()
public void enableDBGSceneExtents(boolean enable)
public void enableEnsureWidgetBoundingSpheresInView(boolean enable)
public void dumpPickSegment(java.io.PrintStream s)
public void dumpPickSegment()
dumpPickSegment(PrintStream)
to System.outpublic void dumpSceneMetrics(java.io.PrintStream s)
Dumps scene metrics.
Note that this API is asynchronous; the dump will be produced at the end of the next generic render cycle.
protected void dumpSceneMetricsImpl(java.io.PrintStream s)
Impl of dumpSceneMetrics(java.io.PrintStream)
, run at end of generic render
when dumpSceneMetricsPending
is set.
public void dumpSceneMetrics()
dumpSceneMetrics(PrintStream)
to System.outprotected void dumpAABB(float[][] aabb, java.lang.String msg, java.io.PrintStream s)
public void dumpRenderMetrics(java.io.PrintStream s)
Dumps the *FrameTime*
fields and related.
Note that this API is asynchronous; the dump will be produced at the end of the next generic render cycle.
protected void dumpRenderMetricsImpl(java.io.PrintStream s)
Impl of dumpRenderMetrics(java.io.PrintStream)
, run at end of generic render
when dumpRenderMetricsPending
is set.
public void dumpRenderMetrics()
dumpRenderMetrics(PrintStream)
to System.outpublic void resetRenderMetrics()
Resets the render metrics.
Note that this API is asynchronous; the metrics will be reset at the beginning of the next generic render cycle.
protected void resetRenderMetricsImpl()
Impl of resetRenderMetrics()
, run at beginning of generic render
when resetRenderMetricsPending
is set.
public double getAvgRecentFPS()
Get the avg recent FPS according to the recentCycleTime
metrics, which are maintained by the generic render()
er.
public void dumpProjection(java.io.PrintStream s)
public void dumpProjection()
dumpProjection(PrintStream)
to System.outpublic void dumpWorldToView(java.io.PrintStream s)
public void dumpWorldToView()
dumpWorldToView(PrintStream)
to System.outpublic void dumpCMT(java.io.PrintStream s)
Dumps the current composite model transform taking local coordinates to view coordinates.
public void dumpCMT()
dumpCMT(PrintStream)
to System.outprotected void dumpLocalToWorld(java.io.PrintStream s)
Dump the current local-to-world transform.
If used, this is designed to be confined to the render thread.
protected void dumpLocalToWorld()
dumpLocalToWorld(PrintStream)
to System.outpublic void dumpCanvasProperties(java.io.PrintStream s)
canvas
public void dumpCanvasProperties()
dumpCanvasProperties(PrintStream)
to System.outpublic void dumpInteractor(java.io.PrintStream s)
rxsInteractor
and its RXSInterpolator
public void dumpHelp(java.io.PrintStream s, java.lang.String meters)
public void dumpHelp(java.lang.String meters)
dumpHelp(PrintStream, String)
to System.outpublic void dumpHelp(java.io.PrintStream s)
dumpHelp(PrintStream, String)
using "meters"public void dumpHelp()
dumpHelp(PrintStream, String)
to System.out using "meters"public void dumpInteractor()
dumpInteractor(PrintStream)
to System.outpublic void dumpStats(java.io.PrintStream s)
public void dumpStats()
dumpStats(PrintStream)
to System.outpublic void dump(java.io.PrintStream s)
public void dump()
dump(PrintStream)
to System.outpublic void setLongFrameWarningThreshold(float threshold)
Set the threshold in ms above whidh a warning will be issued for long frame render times.
threshold
- the threshold in ms or NaN to disablepublic void disableLongFrameWarningThreshold()
Disable the long-frame warning threshold, see setLongFrameWarningThreshold(float)
.
public void traceNextFrame(boolean tracePicking, boolean traceRenderer)
Enable tracing for next frame with given options.
Note: if tracePicking is set then the trace will be deferred until the next frame with picking.
traceRenderer
- whether to emit render algorithm dbgtracePicking
- whether to emit pick algorithm dbgprotected void setTraceOptions(int baseFlags, boolean... options)
Accumulate options as a bitfield, in order starting with LSB, on
top of baseFlags, and then setTraceFlags(int)
.
protected void setTraceOptions(boolean... options)
setTraceOptions(int, boolean...)
, no base flagsprotected void setTraceFlags(int flags)
traceFlags
protected int getAllRenderTraceFlags()
Hook to get combination of all trace flags that apply to the render algorithm.
public void traceNextFrame()
Like traceNextFrame(boolean, boolean)
but only traces
renderer.
public void traceNextPickingFrame()
Like traceNextFrame(boolean, boolean)
but only traces
picking.
public void render()
The generic renderer.
See class header doc for features and details.
Default impl does resetPendingMetrics()
, renderImpl()
,
dumpPendingMetrics()
.
protected boolean resetPendingMetrics()
Reset any metrics that need it.
protected boolean dumpPendingMetrics()
Dump any metrics that need it.
protected void renderImpl()
render()
protected void addToSceneMetrics(float[] boundingSphereCenterInView, float boundingSphereRadiusInView, boolean culled, boolean transparent, boolean highlighted, boolean masked, boolean pickable)
Add the information for a geometry to the scene metrics.
boundingSphereCenterInView
- the view frame center of the geometry or
null if not knownprotected void resetSceneMetrics(boolean resetPickMetrics)
Resets scene metrics, the generic render implementation does this at the beginning of each render.
protected void resetPickMetrics()
protected abstract void applyProjection()
Subclasses must implement this to engage viewAABB
so that it
is applied to subsequent drawing.
The default render()
impl calls this while holding projectionLock
.
protected abstract void applyCMT()
Subclasses must implement this to engage cmtRX
and cmtScale
so that they are applied to subsequent drawing.
Implementations may choose to short circuit unless drawingEnabled
.
Remember to synchronize on rxsInteractor
while accessing
cmtRX
and cmtScale
.
protected abstract void clearDrawingBuffer()
protected abstract void swapBuffers()
protected void renderScene()
Hook called from generic render()
to actually render the
scene.
The CMT at time of call will be the world-to-view transform; local-to-world is initialized to identity.
No Display3D
locks are held at time of call.
Default impl does nothing.
protected void renderInView()
Hook called from generic render()
to render geometry in view
frame.
Default impl does nothing.
protected void preRender()
Hook called at beginning of generic render()
.
Default impl does nothing.
protected void postScene()
Hook called from generic render()
after renderScene()
.
Default impl does nothing.
protected void postMasking(int numMaskedGeometries)
Hook called from generic render()
after masking pass.
Default impl does nothing.
protected void preSwap()
Hook called from generic render()
before swapBuffers()
.
Default impl does nothing.
protected void postSwap()
Hook called from generic render()
after swapBuffers()
.
Default impl does nothing.
protected void postRender(double frameTimeSoFar)
Hook called at end of generic render()
.
Default impl does nothing.
protected void doFit()
Calls RXSInteractor.fit(double, double, double, double)
on the
curent sceneAABBInView
.
protected void render(Widget w, RX extraLocalToWorld)
Render a Widget
.
Calls Widget.ensureBoundingSpheresInView()
iff ensureWidgetBoundingSpheresInViewEnabled
, and updates the widget's
bounding spheres in view frame (if present) for each enabled geometry
with a valid bounding sphere.
If used, this is designed to be confined to the render thread.
If w.rx it not null and not identity, it is prepended to localToWorldRX
and the result is applied as a temporary CMT for
rendering w.
extraLocalToWorld
- if not null and not identity, then this is
appended to the value of w.rx (which itself is not mutated) before
that is prepended to localToWorldRX
protected void render(Widget w)
render(Widget, RX)
, no extra local-to-world transformprotected void render(java.util.List<Widget> widgets)
Render a list of Widget
s.
Each Widget
that passes renderAccept(Widget)
is
rendered.
protected boolean renderAccept(Widget widget)
Filter hook for render(List)
.
Default impl returns true.
protected void render(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float[] boundingSphereCenterInView, float boundingSphereRadiusInView)
Render geometry in local frame.
Bounding sphere is optional, but frustum cull and depth sort transparent do not apply if there is no bounding sphere.
Applies ambientAlpha
, if any.
If used, this is designed to be confined to the render thread.
geometry
- the geometry in local frameappearance
- the appearance to set, null to use defaultboundingSphereCenterInView
- the center of a bounding sphere for
geometry in view frame, or null if noneboundingSphereRadiusInView
- the radius of a bounding sphere for
geometry centered at boundingSphereCenterInView or
negative if noneprotected java.lang.String getInfo(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Get an identifying string for geometry and appearance for use in tracing and dbg.
Default impl calls J3DUtils.getInfo(Geometry)
.
protected void render(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Covers render(Geometry, Appearance, float[], float)
, no
bounding sphere.
protected void render(javax.media.j3d.Shape3D shape)
protected void render(javax.media.j3d.Geometry geometry)
Covers render(Geometry, Appearance, float[], float)
, no
bounding sphere and default appearance.
protected void renderTransparent(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha, boolean disableDepthWrite)
Render a transparent geometry.
If used, this is designed to be confined to the render thread.
extraAlpha
- if in the range [0.0, 1.0) then this multiplies the
alpha used for renderingdisableDepthWrite
- if true then temporarily disable depth buffer
writeprotected void renderTransparent(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha)
Covers renderTransparent(RX, float, Geometry, Appearance,
float)
, always disables depth write.
protected void renderTransparent(Display3D.QueuedGeometry queuedGeometry)
protected void renderTransparent(Display3D.QueuedGeometry[] queue, int queueSize)
Hook called from generic render()
to render a queue of
transparent geometry.
The queue has already been sorted and local-to-world set identity before this hook is called.
Default impl calls renderTransparent(QueuedGeometry)
for each
geometry in the queue.
protected boolean isTransparent(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook that render(Geometry, Appearance, float[], float)
uses to
determine whether a geometry/appearance combination should
be categorized as transparent.
Default impl returns true iff
JOGLGeometry
that JOGLGeometry.hasAlpha()
.GeometryArray
including COLOR_4 and/or TEXTURE_COORDINATE_4 in its vertex
format.protected void enqueueTransparentGeometry(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float maxViewZ, float ambientAlpha)
Add an item to the transparentQueue
, unless freezeTransparentQueue
is set.
If used, this is designed to be confined to the render thread.
protected Display3D.QueuedGeometry[] enqueue(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float maxViewZ, float ambientAlpha, Display3D.QueuedGeometry[] queue, int queueSize)
Implmentation of enqueueTransparentGeometry(vona.math.RX, float, javax.media.j3d.Geometry, javax.media.j3d.Appearance, float, float)
and enqueueMaskedGeometry(javax.media.j3d.Geometry, javax.media.j3d.Appearance, float)
.
Automatically conses or grows the queue as necessary. The implementation only does heap allocations when the queue capacity needs to change.
If used, this is designed to be confined to the render thread.
protected void clearQueue(Display3D.QueuedGeometry[] queue, int queueSize)
protected int compareQueued(Display3D.QueuedGeometry a, Display3D.QueuedGeometry b)
Implementation of Display3D.QueuedGeometry.compareTo(vona.ui.Display3D.QueuedGeometry)
.
Default impl is the sort order of the Display3D.QueuedGeometry.maxViewZ
.
Subclasses can override this to implement other orderings.
protected void render(Display3D.QueuedGeometry[] queue, int queueSize)
Render a queue of geometry.
The queue is rendered in order. Picking, frustum cull, and scene
metrics collection are not performed; typically these steps would have
been done before the geometry was enqueued, e.g. in render(Geometry, Appearance, float[], float)
.
Any transparent geometry is not rendered immediately, but rather
re-enqueued to transparentQueue
. Highlighed geometry is passed
to renderHighlighted(vona.math.RX, float, javax.media.j3d.Geometry, javax.media.j3d.Appearance)
.
protected boolean isHighlighted(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook that generic renderer uses to determine whether a
geometry/appearance combination should be categorized as
highlighted, if highlightingEnabled
.
Default impl returns false.
protected void renderHighlighted(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook called from generic render()
to render a highlighted
geometry.
Default impl temporarily changes emissive color and then renders geometry.
If used, this is designed to be confined to the render thread.
protected boolean isMasked(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook that generic renderer uses to determine whether a
geometry/appearance combination should be categorized as
masked, if maskingEnabled
.
Default impl returns false.
protected void enqueueMaskedGeometry(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float maxViewZ)
Add an item to the maskedQueue
.
If used, this is designed to be confined to the render thread.
protected void renderDepthOnly(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Render only the depth component of a geometry.
Default impl temporarily sets NOOP raster op and then renders geometry.
If used, this is designed to be confined to the render thread.
protected void renderDepthOnly(Display3D.QueuedGeometry queuedGeometry)
protected void renderDepthOnly(Display3D.QueuedGeometry[] queue, int queueSize)
Hook called from generic render()
to render a queue of
geometry depth-only.
Default impl calls renderDepthOnly(QueuedGeometry)
for each
geometry in the queue.
protected void accumPass()
protected abstract void draw(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha)
Concrete subclasses must implement this to draw geometry.
cmtRX
- the rigid part of the CMT to set prior to drawing, or null to
leave the current CMT in effectcmtScale
- the scale part of the CMT to set prior to drawing, ignored
if cmtRX
is nullgeometry
- the geometry to drawappearance
- the appearance to set, or null to set the default
appearanceextraAlpha
- if in the range [0.0, 1.0) then this multiplies the
alpha used for renderingprotected void draw(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
protected void draw(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha)
protected void draw(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
protected void draw(javax.media.j3d.Geometry geometry, float extraAlpha)
protected void draw(javax.media.j3d.Geometry geometry)
protected J3DVertexAccessor getVertexAccessorFor(javax.media.j3d.Geometry g, boolean... enableComponent)
Get a vertex accessor for a geometry.
If used, this is designed to be confined to the render thread.
protected J3DVertexAccessor getVertexAccessorFor(javax.media.j3d.Geometry g)
Covers getVertexAccessorFor(Geometry, boolean...)
, enables all
components.
protected J3DIndexAccessor getIndexAccessorFor(javax.media.j3d.Geometry g)
Get an index accessor for a geometry.
If used, this is designed to be confined to the render thread.
protected J3DPrimitiveIterator getPrimitiveIteratorFor(javax.media.j3d.Geometry g, boolean... enableComponent)
Get a primitive iterator for a geometry.
If used, this is designed to be confined to the render thread.
protected J3DPrimitiveIterator getPrimitiveIteratorFor(javax.media.j3d.Geometry g)
Covers getPrimitiveIteratorFor(Geometry, boolean...)
, enables
all components.
protected boolean isPickable(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Check if the given geometry should be considered pickable.
Default impl returns true.
protected int getPickCullFace(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook called by the smaller pickGeometry(...)
APIs to get the
pick cull face for the given geometry.
Default impl returns the cull face of the PolygonAttributes
of
appearance, if any, else PolygonAttributes.CULL_BACK
.
protected float getPickThreshold(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook called by the smaller pickGeometry(...)
APIs to get the
pick threshold for the given geometry in local frame.
If used, this is designed to be confined to the render thread.
Default impl returns canvasToLocal(float...)
of pickThresholdPixels
.
protected void updatePickSegmentInLocal()
Update pickStartInLocal
and pickExtentInLocal
from
pickStartInView
and pickExtentInView
.
Clears pickSegmentInLocalDirty
.
protected int pickGeometry(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, J3DPrimitiveIterator primitiveIterator, float[] pickStart, float[] pickExtent, float pickThreshold, int cullFace)
Perform a geometry pick.
Calls picked(javax.media.j3d.Geometry, javax.media.j3d.Appearance, int, float)
for each hit, stopping on the first call that
returns false.
The corresponding pick metrics numPickGeometryHits
and numPickedGeometries
are updated.
primitiveIterator
- the iterator to use, if null then no hits are
registered; the iterator is not internally reset at any timepickStart
- the start of the pick segment in the same frame as the
geometrypickExtent
- the end of the pick segment in the same frame as the
geometrypickThreshold
- the pick threshold distance in the same frame as the
geometrycullFace
- one of PolygonAttributes.CULL_BACK
, PolygonAttributes.CULL_FRONT
, or PolygonAttributes.CULL_NONE
protected int pickGeometry(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float[] pickStart, float[] pickExtent)
Covers pickGeometry(Geometry, Appearance, J3DPrimitiveIterator,
float[], float[], float, int)
using getPrimitiveIteratorFor(javax.media.j3d.Geometry, boolean...)
,
getPickThreshold(javax.media.j3d.Geometry, javax.media.j3d.Appearance)
, and getPickCullFace(javax.media.j3d.Geometry, javax.media.j3d.Appearance)
.
protected int pickGeometry(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Covers pickGeometry(Geometry, Appearance, J3DPrimitiveIterator,
float[], float[], float, int)
using getPrimitiveIteratorFor(javax.media.j3d.Geometry, boolean...)
,
getPickThreshold(javax.media.j3d.Geometry, javax.media.j3d.Appearance)
, and getPickCullFace(javax.media.j3d.Geometry, javax.media.j3d.Appearance)
, pickStartInLocal
, and pickExtentInLocal
.
First does updatePickSegmentInLocal()
iff pickSegmentInLocalDirty
.
protected boolean picked(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, int prim, float u)
Picking callback.
This is called for every pick intersection detected in render(Geometry, Appearance, float[], float)
.
Default impl returns false.
prim
- the prim index of the intersection, or negative if picked by
bounds onlyu
- the signed distance along the pick segment (pickStartInView
, pickExtentInView
) of the intersection
normalized to the pick segment length. Note that this may imply a pick
intersection outside the view frustum, however, as long as frustumCullEnabled
and pickVisibleBoundsOnly
are set, then the
bounding sphere of geometry is known to intersect the view frustum.
Also, if the pick segment is itself known to be within the view frustum
(as it will be, e.g., when set by setPickPointOnCanvas(float, float)
), and
pickSegmentIntersectionsOnly
is set, then reported pick
intersections will always be within the view frustum.protected void worldToViewChanged()
Hook called when the world-to-view transform has changed (e.g. due to navigation, default impl does nothing.
Note that this may be called after worldToViewScale
and worldToViewRX
have been updated but before the CMT has been updated or
applied.
Default impl does nothing.
protected void projectionChanged()
Hook called when the projection transform has changed, default impl does nothing.
Note that this may be called after viewToCanvasScale
and
viewAABB
have been updated but before applyProjection()
has happened.
Default impl does nothing.
protected void rePicking()
Hook called from generic render when pick will be performed for a render.
Default impl does nothing.
protected void ensureDBGAppearance()
dbgAppearance
has been consedprotected void setCanvas(java.awt.Canvas canvas, int width, int height)
Concrete subclasses call this to set canvas
, thread safe.
This should be called exactly once. It does addCanvasListeners()
, configures the canvas sizes, and sets the initial
background color, light properties, and projection.
canvas
- the canvas to set, not nullwidth
- if both this and height are positive then they are set
as the preferred size of canvasprotected void addCanvasListeners()
Adds all necessary event listeners to canvas
.
Automatically called from setCanvas(java.awt.Canvas, int, int)
.
Calls RXSInteractor.addListeners(java.awt.Component)
on rxsInteractor
iff
autoAddListenersToRXSInteractor()
.
protected boolean autoAddListenersToRXSInteractor()
Whether to call RXSInteractor.addListeners(java.awt.Component)
on rxsInteractor
in addCanvasListeners()
.
Default impl returns true. Subclasses can override if they don't want
to use rxsInteractor
or if they want to add its listeners in
order after other listeners.