@ThreadSafe public class J3DDisplay extends Display3D
A Java3D implementation of Display3D
.
Due to the more severe of the issues below, this implementation is mostly
deprecated in favor of JOGLDisplay
.
The lock acquisition order for deadlock avoidance extends that of Display3D
: synchronize on environmentLock
before Display3D.projectionLock
.
GraphicsContext3D.flush()
is too buggy to useCopyright (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.
Display3D.Driver, Display3D.QueuedGeometry
Modifier and Type | Field and Description |
---|---|
protected javax.media.j3d.AmbientLight |
ambientLight
the Java3D ambient light
|
protected javax.media.j3d.Background |
background
the Java3D background light
|
protected javax.media.j3d.Canvas3D |
canvas3D
the Java3D canvas
|
protected double[] |
cmtMatrix
Matrix used to set
cmtT3D . |
protected javax.media.j3d.Transform3D |
cmtT3D
Java3D transform used to apply the CMT.
|
private static java.lang.String |
cvsid |
protected javax.media.j3d.DirectionalLight |
directionalLight
the Java3D directional light
|
protected java.lang.Object |
environmentLock
lock for
background and lights |
protected boolean |
flushEnabled
Whether to enable
GraphicsContext3D.flush() calls. |
protected javax.media.j3d.GraphicsContext3D |
gc3D
The Java3D immediatee mode graphics context.
|
protected javax.media.j3d.Transform3D |
projectionT3D
Java3D transform used to apply the projection
|
protected javax.media.j3d.View |
view
the Java3D View object
|
accumPass1Metrics, accumPass2Metrics, ALL_COMPONENTS, allExtendedRenderMetrics, ambientAlpha, applyProjectionPending, applyWidgetRX, blueBits, canvas, canvasMouseLock, canvasMouseX, canvasMouseY, canvasSize, clearMetrics, cmtRX, cmtScale, COORD_ONLY, dbgAppearance, dbgSceneExtentsEnabled, dbgSceneExtentsRect, DEF_AMBIENT_LIGHT_INTENSITY, DEF_DIRECTIONAL_LIGHT_DIRECTION, DEF_DIRECTIONAL_LIGHT_INTENSITY, DEF_HIGHLIGHT_COLOR, DEF_HIGHLIGHT_FACTOR, DEF_MASK_ALPHA, DEF_PICK_THRESHOLD_PIXELS, DEF_VIEW_SCALE, DEF_Z_CLIP, defaultHighlightedAppearance, defaultHighlightedMaterial, defaultRotationCenter, defaultTransparentAppearance, defaultViewScale, defaultViewTXEM, depthBits, depthOnlyAppearance, depthRenderMaskedQueueEnabled, depthSortTransparentEnabled, drawingEnabled, dumpRenderMetricsPending, dumpSceneMetricsPending, emissiveColorWas, ENABLE_EXTENDED_RENDER_METRICS, ensureWidgetBoundingSpheresInViewEnabled, fitPending, frameSaveCount, frameSaveDirectory, frameSaveFPS, frameSaveLastTime, frameSaveLock, frameSaveMetrics, frameSaveNextIndex, frameSaveNextTime, frameSavePrefix, frameSaveStartTime, frameSaveWithCursor, frameTime, freezeSceneMetrics, freezeTransparentQueue, freezeWidgetBounds, frustumCullEnabled, greenBits, highlightColor, highlightFactor, highlightingEnabled, indexAccessors, lastFrameEndTime, LOCAL_TO_WORLD_STACK_INITIAL_CAPACITY, localToWorldRX, localToWorldStack, localToWorldStackSize, longFrameWarningThreshold, maskAlpha, maskedQueue, maskedQueueSize, maskingEnabled, MAX, MIN, navigationEnabled, newEmissiveColor, NUM_RECENT_METRICS, numDisabledWidgetGeometries, numFrames, numHighlightedGeometries, numMaskedGeometries, numPickableGeometries, numPickBoundsHits, numPickedGeometries, numPickGeometryHits, numSamples, numSceneGeometries, numSceneWidgets, numTransparentGeometries, numVisibleGeometries, passAlpha, pickBoundsOnly, pickExtentInLocal, pickExtentInView, pickGeometryMetrics, pickingEnabled, pickSegmentInLocalDirty, pickSegmentIntersectionsOnly, pickSegmentInViewPerpCanvas, pickSegmentLock, pickStartInLocal, pickStartInView, pickThresholdPixels, pickVisibleBoundsOnly, postRenderMetrics, premultipliedHighlightColor, premultiplyPassAlpha, preRenderMetrics, primitiveIterators, projectionLock, QUEUE_INITIAL_CAPACITY, recentCycleTime, recentCycleTimeWriteIndex, recentFrameTime, recentFrameTimeWriteIndex, redBits, renderDepthOnlyMetrics, renderDepthOnlyQueueMetrics, renderGeometryMetrics, renderHighlightedMetrics, renderImplPostSceneMetrics, renderImplPreSceneMetrics, renderInViewMetrics, renderMaskedGeometry, renderMetricsLock, renderSceneMetrics, renderTransparentMetrics, renderTransparentQueue1Metrics, renderTransparentQueue2Metrics, renderWidgetGeometryMetrics, renderWidgetMetrics, resetPickMetricsEveryRender, resetRenderMetricsPending, rxsInteractor, rxsInterpolator, sceneAABBInView, sceneMetricsLock, SCREEN_METERS_PER_PIXEL, SQRT3F, stencilBits, swapMetrics, TRACE_GENERIC_EN, TRACE_PICKING_EN, traceFlags, traceStream, transformWidgetBounds, transparentQueue, transparentQueueSize, unsetPickSegmentAfterRender, unsetPickSegmentOnProjectionChange, unsetPickSegmentOnWorldToViewChange, updateNavMetrics, updateProjectionMetrics, vertexAccessors, viewAABB, viewToCanvasScale, worldToViewRX, worldToViewRXTemp, worldToViewScale
Constructor and Description |
---|
J3DDisplay(java.awt.GraphicsDevice device,
int width,
int height,
int minRedBits,
int minGreenBits,
int minBlueBits,
int minDepthBits,
int minStencilBits,
int minNumSamples)
Creates a new display.
|
Modifier and Type | Method and Description |
---|---|
protected void |
applyCMT()
|
protected void |
applyProjection()
This impl sets
projectionT3D and then does . |
protected void |
clearDrawingBuffer()
this impl does
|
protected void |
draw(RX cmt,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha)
This impl sets appearance and then draws geometry on
gc3D . |
void |
dumpCanvasProperties(java.io.PrintStream s)
Calls superclass impl, then
J3DUtils.dumpJ3DProperties(Canvas3D,
PrintStream) on canvas3D . |
static void |
main(java.lang.String[] arg)
runs the interactive test driver
|
protected java.awt.Canvas |
makeCanvas(java.awt.GraphicsDevice device,
int minRedBits,
int minGreenBits,
int minBlueBits,
int minDepthBits,
int minStencilBits,
int minNumSamples)
This impl makes a Java3D
Canvas3D . |
protected void |
preRender()
Sets
gc3D iff necessary. |
void |
setAmbientLightIntensity(float intensity)
this impl sets intensity of
ambientLight |
void |
setBackgroundColor(float... color)
this impl sets color of
background |
void |
setDirectionalLightDirection(float... direction)
this impl sets direction of
directionalLight |
void |
setDirectionalLightIntensity(float intensity)
this impl sets intensity of
directionalLight |
protected void |
swapBuffers()
this impl does
|
accumPass, addCanvasListeners, addToSceneMetrics, autoAddListenersToRXSInteractor, canvasToLocal, canvasToLocal, canvasToView, canvasToView, clearCMT, clearLocalToWorld, clearLocalToWorld, clearQueue, compareQueued, disableLongFrameWarningThreshold, doFit, draw, draw, draw, draw, draw, dump, dump, dumpAABB, dumpCanvasProperties, dumpCMT, dumpCMT, dumpHelp, dumpHelp, dumpHelp, dumpHelp, dumpInteractor, dumpInteractor, dumpLocalToWorld, dumpLocalToWorld, dumpPendingMetrics, dumpPickSegment, dumpPickSegment, dumpProjection, dumpProjection, dumpRenderMetrics, dumpRenderMetrics, dumpRenderMetricsImpl, dumpSceneMetrics, dumpSceneMetrics, dumpSceneMetricsImpl, dumpStats, dumpStats, dumpWorldToView, dumpWorldToView, enableDBGSceneExtents, enableDepthSortTransparent, enableDrawing, enableEnsureWidgetBoundingSpheresInView, enableFrustumCull, enableHighlighting, enableMasking, enableNavigation, enablePicking, enqueue, enqueueMaskedGeometry, enqueueTransparentGeometry, ensureDBGAppearance, fitView, getAllRenderTraceFlags, getAmbientAlpha, getAvgRecentFPS, getBlueBits, getCanvas, getCanvasMouseLocation, getCanvasMouseLocation, getDefaultRotationCenter, getDefaultViewScale, getDefaultViewTXEM, getDepthBits, getGreenBits, getHighlightColor, getHighlightColor, getHighlightFactor, getIndexAccessorFor, getInfo, getLocalTranslationRXToPixel, getLocalTranslationRXToPixel, getLocalTranslationRXToPixel, getLocalTranslationRXToPixel, getMaskAlpha, getNumFrames, getNumFramesSaved, getNumSamples, getPickCullFace, getPickThreshold, getPickThresholdPixels, getPrimitiveIteratorFor, getPrimitiveIteratorFor, getRedBits, getStencilBits, getTranslationRXToPixel, getTranslationRXToPixel, getTranslationRXToPixel, getTranslationRXToPixel, getVertexAccessorFor, getVertexAccessorFor, getViewToCanvasScale, getZCenterInView, grabAndSaveFrame, hasAccumBuffer, interpolateOnPickSegmentInLocal, interpolateOnPickSegmentInLocal, interpolateOnPickSegmentInView, interpolateOnPickSegmentInView, isDepthSortTransparentEnabled, isDrawingEnabled, isFrustumCullEnabled, isHighlighted, isHighlightingEnabled, isMasked, isMaskingEnabled, isNavigationEnabled, isPickable, isPickingEnabled, isPickSegmentSet, isSphereVisible, isTransparent, localToCanvas, localToCanvas, localToView, localToView, localToView, localToWorld, localToWorld, navigateToDefaultView, navigateToDefaultView, navigateToDefaultView, navigateToView, navigateToView, navigateToView, navigateToView, picked, pickGeometry, pickGeometry, pickGeometry, pickSphereInView, pickSphereInView, popLocalToWorld, popLocalToWorld, postMasking, postRender, postScene, postSwap, prependInverseLocalToWorld, prependInverseLocalToWorld, prependLocalToWorld, prependLocalToWorld, preSwap, projectionChanged, pushLocalToWorld, recenterZ, recenterZ, render, render, render, render, render, render, render, render, render, renderAccept, renderDepthOnly, renderDepthOnly, renderDepthOnly, renderHighlighted, renderImpl, renderInView, renderScene, renderTransparent, renderTransparent, renderTransparent, renderTransparent, rePicking, resetPendingMetrics, resetPickMetrics, resetRenderMetrics, resetRenderMetricsImpl, resetSceneMetrics, rotateAboutDefaultCenter, saveFrame, saveFrame, saveFrame, saveFrameFailed, saveFrameFinished, saveNextFrame, saveNextFrame, saveNextFrame, setAmbientAlpha, setCanvas, setCanvasSize, setCanvasSize, setCMT, setDefaultRotationCenter, setDefaultView, setDefaultViewScale, setDefaultViewTXEM, setDefaultViewTXEMS, setHighlightColor, setHighlightFactor, setLocalToWorld, setLocalToWorld, setLongFrameWarningThreshold, setMaskAlpha, setPickPointOnCanvas, setPickSegmentInView, setPickThresholdPixels, setSymmetricZClip, setTraceFlags, setTraceOptions, setTraceOptions, setViewInMeters, setViewInPixels, setViewToCanvasScale, setZClip, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, stopSavingFrames, traceNextFrame, traceNextFrame, traceNextPickingFrame, unsetPickSegment, updateCMT, updateHighlightedMaterial, updatePickSegmentInLocal, updateProjection, updateWorldToView, updateWorldToView, usingAccumBuffer, viewToCanvas, viewToCanvas, viewToLocal, viewToLocal, viewToLocal, viewToWorld, viewToWorld, viewToWorld, worldToLocal, worldToLocal, worldToView, worldToView, worldToView, worldToViewChanged, worldToViewDirty
private static final java.lang.String cvsid
protected volatile javax.media.j3d.Canvas3D canvas3D
protected javax.media.j3d.GraphicsContext3D gc3D
The Java3D immediatee mode graphics context.
This is sequentially thread confined to the thread that creates this
display (thus calling makeCanvas(java.awt.GraphicsDevice, int, int, int, int, int, int)
), then to the thread that calls
Display3D.render()
.
protected javax.media.j3d.View view
protected final java.lang.Object environmentLock
background
and lightsprotected javax.media.j3d.Background background
protected javax.media.j3d.AmbientLight ambientLight
protected javax.media.j3d.DirectionalLight directionalLight
protected javax.media.j3d.Transform3D projectionT3D
protected javax.media.j3d.Transform3D cmtT3D
Java3D transform used to apply the CMT.
Thread confined to the render thread.
protected double[] cmtMatrix
Matrix used to set cmtT3D
.
Thread confined to the render thread.
protected final boolean flushEnabled
Whether to enable GraphicsContext3D.flush()
calls.
These are needed for correct behavior of e.g. transparent render, but
unfortunately the Java3D flush()
implementation causes driver
segfaults on at least one platform.
public J3DDisplay(java.awt.GraphicsDevice device, int width, int height, int minRedBits, int minGreenBits, int minBlueBits, int minDepthBits, int minStencilBits, int minNumSamples)
Creates a new display.
Calls makeCanvas(java.awt.GraphicsDevice, int, int, int, int, int, int)
to actually make the Display3D.canvas
.
java.lang.IllegalArgumentException
- if a canvas could not be created with
the requested parameterspublic void setBackgroundColor(float... color)
background
setBackgroundColor
in class Display3D
public void setAmbientLightIntensity(float intensity)
ambientLight
setAmbientLightIntensity
in class Display3D
public void setDirectionalLightIntensity(float intensity)
directionalLight
setDirectionalLightIntensity
in class Display3D
public void setDirectionalLightDirection(float... direction)
directionalLight
setDirectionalLightDirection
in class Display3D
public void dumpCanvasProperties(java.io.PrintStream s)
Calls superclass impl, then J3DUtils.dumpJ3DProperties(Canvas3D,
PrintStream)
on canvas3D
.
dumpCanvasProperties
in class Display3D
protected java.awt.Canvas makeCanvas(java.awt.GraphicsDevice device, int minRedBits, int minGreenBits, int minBlueBits, int minDepthBits, int minStencilBits, int minNumSamples)
This impl makes a Java3D Canvas3D
.
It also makes the related Java3D objects including view
,
background
, etc.
protected void applyProjection()
This impl sets projectionT3D
and then does
.view
.setLeftProjection(projectionT3D
)
applyProjection
in class Display3D
protected void clearDrawingBuffer()
gc3D
.clear()
clearDrawingBuffer
in class Display3D
protected void swapBuffers()
canvas3D
.swap()
swapBuffers
in class Display3D
protected void draw(RX cmt, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha)
This impl sets appearance and then draws geometry on
gc3D
.
draw
in class Display3D
cmt
- 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 Display3D.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 preRender()
Sets gc3D
iff necessary.
On a multiprocessor system the thread that ran makeCanvas(java.awt.GraphicsDevice, int, int, int, int, int, int)
might have been on a different CPU than the the render thread, and thus
the value that was set to gc3D
might not be visible yet in the
render thread. Since gc3D
is a 32-bit variable that is
effectively final it is safe to just set it directly from within the
render thread iff necessary.
public static void main(java.lang.String[] arg)