|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.media.j3d.GraphicsContext3D
public class GraphicsContext3D
A GraphicsContext3D object is used for immediate mode rendering into a 3D canvas. It is created by, and associated with, a specific Canvas3D object. A GraphicsContext3D defines methods to set 3D graphics state and draw 3D geometric primitives. There are no public constructors of GraphicsContext3D. An application obtains a 3D graphics context object from the Canvas3D object that the application wishes to render into by using the getGraphicsContext3D method. A new graphics context is created if one does not already exist. A new GraphicsContext3D initializes its state variables to the following defaults:
STEREO_BOTH
Note that the drawing methods in this class are not necessarily
executed immediately. They may be buffered up for future
execution. Applications must call the
flush(boolean)
method to ensure that the rendering actually happens. The flush
method is implicitly called in the following cases:
readRaster
method calls
flush(true)
Canvas3D.swap
method calls
flush(true)
flush(true)
prior to
swapping the buffer for a double buffered on-screen Canvas3Dflush(true)
prior to
copying into the off-screen buffer of an off-screen Canvas3Dflush(false)
after
calling the preRender, renderField, postRender, and postSwap
Canvas3D callback methods.A single-buffered, pure-immediate mode application must explicitly call flush to ensure that the graphics will be rendered to the Canvas3D.
Canvas3D.getGraphicsContext3D()
Field Summary | |
---|---|
(package private) static int |
ADD_LIGHT
|
(package private) static int |
ADD_SOUND
|
(package private) float |
alpha
The cached TransparencyAttributes transparency value. |
(package private) Appearance |
appearance
|
(package private) AuralAttributes |
auralAttributes
|
(package private) Background |
background
|
(package private) BackgroundRetained |
black
|
(package private) float |
blue
|
private static int |
BUFFER_MODE
|
(package private) boolean |
bufferOverride
|
(package private) byte[] |
byteBuffer
|
(package private) Canvas3D |
canvas3d
Canvas3D in which this GraphicsContext3D will render. |
(package private) static int |
CLEAR
|
private static java.lang.Integer[] |
commands
|
(package private) Transform3D |
compTransform
|
(package private) float |
dBlue
|
private Appearance |
defaultAppearance
|
(package private) AppearanceRetained |
defaultAppearanceRetained
|
(package private) float |
dGreen
|
private int |
dirtyMask
|
(package private) static int |
DISPOSE2D
|
(package private) static int |
DRAW
|
(package private) static int |
DRAWANDFLUSH2D
|
(package private) Transform3D |
drawTransform
|
(package private) float |
dRed
Cached diffuse color value |
(package private) boolean |
enableLighting
/** A boolean indicating whether or not lighting should be on. |
(package private) float[] |
floatBuffer
|
(package private) static int |
FLUSH
|
(package private) static int |
FLUSH2D
|
(package private) Fog |
fog
|
(package private) boolean |
frontBufferRendering
|
private boolean |
gcReady
|
private boolean |
geometryIsLocked
|
(package private) float |
green
|
(package private) HiResCoord |
hiRes
|
(package private) Transform3D |
identityTransform
|
private boolean |
ignoreVertexColors
|
(package private) static int |
INSERT_LIGHT
|
(package private) static int |
INSERT_SOUND
|
(package private) int[] |
intBuffer
|
private int |
lastActiveTexUnitIndex
|
(package private) LightRetained[] |
lightlist
|
(package private) java.util.Vector |
lights
|
(package private) boolean |
lightsChanged
|
(package private) boolean |
lineAA
|
(package private) LightSet |
ls
|
(package private) ModelClip |
modelClip
|
(package private) Transform3D |
modelClipTransform
|
(package private) Transform3D |
modelTransform
|
(package private) static int |
MULTIPLY_MODEL_TRANSFORM
|
(package private) static int |
NCOMMANDS
|
(package private) Transform3D |
normalTransform
|
(package private) boolean |
normalTransformNeedToUpdate
|
private int |
numActiveTexUnit
|
(package private) int |
numLights
|
(package private) boolean |
pointAA
|
(package private) int |
polygonMode
Cached values for polygonMode, line antialiasing, and point antialiasing |
(package private) static int |
READ_RASTER
|
private boolean |
readRasterReady
|
(package private) float |
red
The cached ColoringAttributes color value. |
(package private) static int |
REMOVE_LIGHT
|
(package private) static int |
REMOVE_SOUND
|
(package private) Color3f |
sceneAmbient
|
(package private) static int |
SET_APPEARANCE
|
(package private) static int |
SET_AURAL_ATTRIBUTES
|
(package private) static int |
SET_BACKGROUND
|
(package private) static int |
SET_BUFFER_OVERRIDE
|
(package private) static int |
SET_FOG
|
(package private) static int |
SET_FRONT_BUFFER_RENDERING
|
(package private) static int |
SET_HI_RES
|
(package private) static int |
SET_LIGHT
|
(package private) static int |
SET_MODEL_TRANSFORM
|
(package private) static int |
SET_MODELCLIP
|
(package private) static int |
SET_SOUND
|
(package private) static int |
SET_STEREO_MODE
|
(package private) java.util.Vector |
sounds
|
(package private) boolean |
soundsChanged
|
static int |
STEREO_BOTH
Specifies that rendering is done to both eyes. |
static int |
STEREO_LEFT
Specifies that rendering is done to the left eye. |
static int |
STEREO_RIGHT
Specifies that rendering is done to the right eye. |
(package private) int |
stereoMode
|
private static java.lang.Integer[] |
stereoModes
|
(package private) static int |
SWAP
|
private Appearance |
uAppearance
|
private AuralAttributes |
uAuralAttributes
|
private Background |
uBackground
|
private boolean |
uBufferOverride
|
private Fog |
uFog
|
private boolean |
uFrontBufferRendering
|
private HiResCoord |
uHiRes
|
private java.util.Vector |
uLights
|
private ModelClip |
uModelClip
|
private java.util.Vector |
uSounds
|
private int |
uStereoMode
|
(package private) boolean |
visible
The cached visible flag for geometry. |
(package private) Transform3D |
vpcToEc
|
private int |
waiting
|
Constructor Summary | |
---|---|
GraphicsContext3D(Canvas3D canvas3d)
Constructs and creates a GraphicsContext3D object with default values. |
Method Summary | |
---|---|
void |
addLight(Light light)
Appends the specified light to this graphics context's list of lights. |
void |
addSound(Sound sound)
Appends the specified sound to this graphics context's list of sounds. |
void |
clear()
Clear the Canvas3D to the color or image specified by the current background node. |
private void |
computeCompositeTransform()
|
(package private) void |
doAddLight(Light light)
|
(package private) void |
doAddSound(Sound sound)
|
(package private) void |
doClear()
|
(package private) void |
doDraw(Geometry geometry)
|
(package private) void |
doFlush(boolean wait)
|
(package private) void |
doInsertLight(Light light,
int index)
|
(package private) void |
doInsertSound(Sound sound,
int index)
|
(package private) void |
doMultiplyModelTransform(Transform3D t)
|
(package private) void |
doReadRaster(Raster raster)
|
(package private) void |
doRemoveLight(int index)
|
(package private) void |
doRemoveSound(int index)
|
(package private) void |
doSetAppearance(Appearance appearance)
|
(package private) void |
doSetAuralAttributes(AuralAttributes attributes)
|
(package private) void |
doSetBackground(Background background)
|
(package private) void |
doSetBufferOverride(boolean bufferOverride)
|
(package private) void |
doSetFog(Fog fog)
|
(package private) void |
doSetFrontBufferRendering(boolean frontBufferRendering)
|
(package private) void |
doSetHiRes(HiResCoord hiRes)
|
(package private) void |
doSetLight(Light light,
int index)
|
(package private) void |
doSetModelClip(ModelClip modelClip)
|
(package private) void |
doSetModelTransform(Transform3D t)
|
(package private) void |
doSetSound(Sound sound,
int index)
|
(package private) void |
doSetStereoMode(int stereoMode)
|
void |
draw(Geometry geometry)
Draw the specified Geometry component object. |
void |
draw(Shape3D shape)
Draw the specified Shape3D leaf node object. |
void |
flush(boolean wait)
Flushes all previously executed rendering operations to the drawing buffer for this 3D graphics context. |
java.util.Enumeration |
getAllLights()
Retrieves the enumeration object of all the lights. |
java.util.Enumeration |
getAllSounds()
Retrieves the enumeration object of all the sounds. |
Appearance |
getAppearance()
Retrieves the current Appearance component object. |
AuralAttributes |
getAuralAttributes()
Retrieves the current AuralAttributes component object. |
Background |
getBackground()
Retrieves the current Background leaf node object. |
boolean |
getBufferOverride()
Returns the current buffer override flag. |
Canvas3D |
getCanvas3D()
Gets the Canvas3D that created this GraphicsContext3D. |
Fog |
getFog()
Retrieves the current Fog leaf node object. |
boolean |
getFrontBufferRendering()
Returns the current front buffer rendering flag. |
void |
getHiRes(HiResCoord hiRes)
Retrieves the current HiRes coordinate of this context. |
(package private) static java.lang.Integer |
getImmCommand(int command)
|
Light |
getLight(int index)
Retrieves the index selected light. |
ModelClip |
getModelClip()
Retrieves the current ModelClip leaf node object. |
void |
getModelTransform(Transform3D t)
Retrieves the current model transform. |
private Transform3D |
getNormalTransform()
|
Sound |
getSound(int index)
Retrieves the index selected sound. |
(package private) SoundScheduler |
getSoundScheduler()
|
int |
getStereoMode()
Returns the current stereo mode. |
(package private) void |
initializeState()
|
void |
insertLight(Light light,
int index)
Inserts the specified light at the specified index location. |
void |
insertSound(Sound sound,
int index)
Inserts the specified sound at the specified index location. |
boolean |
isSoundPlaying(int index)
Retrieves the sound playing flag. |
void |
multiplyModelTransform(Transform3D t)
Multiplies the current model transform by the specified transform and stores the result back into the current transform. |
int |
numLights()
Retrieves the current number of lights in this graphics context. |
int |
numSounds()
Retrieves the current number of sounds in this graphics context. |
void |
readRaster(Raster raster)
Read an image from the frame buffer and copy it into the ImageComponent and/or DepthComponent objects referenced by the specified Raster object. |
void |
removeLight(int index)
Removes the light at the specified index location. |
void |
removeSound(int index)
Removes the sound at the specified index location. |
(package private) void |
resetAppearance()
|
(package private) void |
runMonitor(int action)
|
(package private) void |
sendRenderMessage(boolean renderRun,
int command,
java.lang.Object arg1,
java.lang.Object arg2)
|
(package private) void |
sendSoundMessage(int command,
java.lang.Object arg1,
java.lang.Object arg2)
|
void |
setAppearance(Appearance appearance)
Sets the current Appearance object to the specified Appearance component object. |
void |
setAuralAttributes(AuralAttributes attributes)
Sets the current AuralAttributes object to the specified AuralAttributes component object. |
void |
setBackground(Background background)
Sets the current Background to the specified Background leaf node object. |
void |
setBufferOverride(boolean bufferOverride)
Sets a flag that specifies whether the double buffering and stereo mode from the Canvas3D are overridden. |
void |
setFog(Fog fog)
Sets the current Fog to the specified Fog leaf node object. |
void |
setFrontBufferRendering(boolean frontBufferRendering)
Sets a flag that enables or disables immediate mode rendering into the front buffer of a double buffered Canvas3D. |
void |
setHiRes(HiResCoord hiRes)
Sets the HiRes coordinate of this context to the location specified by the HiRes argument. |
void |
setHiRes(int[] x,
int[] y,
int[] z)
Sets the HiRes coordinate of this context to the location specified by the parameters provided. |
void |
setLight(Light light,
int index)
Replaces the specified light with the light provided. |
void |
setModelClip(ModelClip modelClip)
Sets the current ModelClip leaf node to the specified object. |
void |
setModelTransform(Transform3D t)
Sets the current model transform to a copy of the specified transform. |
void |
setSound(Sound sound,
int index)
Replaces the specified sound with the sound provided. |
void |
setStereoMode(int stereoMode)
Sets the stereo mode for immediate mode rendering. |
(package private) void |
updateFogState(FogRetained fogRet)
|
(package private) void |
updateLightAndFog()
|
(package private) void |
updateLightState(LightRetained light)
|
(package private) void |
updateModelClip(Transform3D vworldToVpc)
|
(package private) void |
updateSoundState(SoundRetained sound)
|
(package private) boolean |
updateState(RenderBin rb,
int geometryType)
|
private void |
updateViewCache(RenderBin rb)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STEREO_LEFT
setStereoMode(int)
,
Constant Field Valuespublic static final int STEREO_RIGHT
setStereoMode(int)
,
Constant Field Valuespublic static final int STEREO_BOTH
setStereoMode(int)
,
Constant Field ValuesCanvas3D canvas3d
private Background uBackground
private Fog uFog
private Appearance uAppearance
private java.util.Vector uLights
private HiResCoord uHiRes
private java.util.Vector uSounds
private AuralAttributes uAuralAttributes
private boolean uBufferOverride
private boolean uFrontBufferRendering
private int uStereoMode
private ModelClip uModelClip
Background background
BackgroundRetained black
Fog fog
ModelClip modelClip
Appearance appearance
AppearanceRetained defaultAppearanceRetained
java.util.Vector lights
HiResCoord hiRes
Transform3D modelTransform
Transform3D identityTransform
Transform3D modelClipTransform
Transform3D normalTransform
boolean normalTransformNeedToUpdate
java.util.Vector sounds
AuralAttributes auralAttributes
LightSet ls
LightRetained[] lightlist
Color3f sceneAmbient
int numLights
Transform3D compTransform
Transform3D drawTransform
Transform3D vpcToEc
boolean lightsChanged
boolean soundsChanged
boolean bufferOverride
boolean frontBufferRendering
int stereoMode
byte[] byteBuffer
float[] floatBuffer
int[] intBuffer
float red
float green
float blue
float dRed
float dGreen
float dBlue
float alpha
boolean visible
int polygonMode
boolean lineAA
boolean pointAA
boolean enableLighting
private Appearance defaultAppearance
private boolean geometryIsLocked
private boolean ignoreVertexColors
static final int CLEAR
static final int DRAW
static final int SWAP
static final int READ_RASTER
static final int SET_APPEARANCE
static final int SET_BACKGROUND
static final int SET_FOG
static final int SET_LIGHT
static final int INSERT_LIGHT
static final int REMOVE_LIGHT
static final int ADD_LIGHT
static final int SET_HI_RES
static final int SET_MODEL_TRANSFORM
static final int MULTIPLY_MODEL_TRANSFORM
static final int SET_SOUND
static final int INSERT_SOUND
static final int REMOVE_SOUND
static final int ADD_SOUND
static final int SET_AURAL_ATTRIBUTES
static final int SET_BUFFER_OVERRIDE
static final int SET_FRONT_BUFFER_RENDERING
static final int SET_STEREO_MODE
static final int FLUSH
static final int FLUSH2D
static final int DRAWANDFLUSH2D
static final int SET_MODELCLIP
static final int DISPOSE2D
static final int NCOMMANDS
private static java.lang.Integer[] commands
private static java.lang.Integer[] stereoModes
private static final int BUFFER_MODE
private int dirtyMask
private int numActiveTexUnit
private int lastActiveTexUnitIndex
private volatile boolean readRasterReady
private boolean gcReady
private int waiting
Constructor Detail |
---|
GraphicsContext3D(Canvas3D canvas3d)
Method Detail |
---|
public Canvas3D getCanvas3D()
public void setAppearance(Appearance appearance)
appearance
- the new Appearance object
IllegalSharingException
- if the specified appearance refers
to an ImageComponent2D that is being used by a Canvas3D as
an off-screen buffer.void doSetAppearance(Appearance appearance)
public Appearance getAppearance()
public void setBackground(Background background)
background
- the new Background object
IllegalSharingException
- if the Background node
is part of or is subsequently made part of a live scene graph.
IllegalSharingException
- if the specified background node
refers to an ImageComponent2D that is being used by a Canvas3D as
an off-screen buffer.void doSetBackground(Background background)
public Background getBackground()
public void setFog(Fog fog)
fog
- the new Fog object
IllegalSharingException
- if the Fog node
is part of or is subsequently made part of a live scene graph.void doSetFog(Fog fog)
public Fog getFog()
public void setModelClip(ModelClip modelClip)
modelClip
- the new ModelClip node
IllegalSharingException
- if the ModelClip node
is part of or is subsequently made part of a live scene graph.void doSetModelClip(ModelClip modelClip)
public ModelClip getModelClip()
public void setLight(Light light, int index)
light
- the new lightindex
- which light to replace
IllegalSharingException
- if the Light node
is part of or is subsequently made part of a live scene graph.
java.lang.NullPointerException
- if the Light object is null.void doSetLight(Light light, int index)
public void insertLight(Light light, int index)
light
- the new lightindex
- at which location to insert
IllegalSharingException
- if the Light node
is part of or is subsequently made part of a live scene graph.
java.lang.NullPointerException
- if the Light object is null.void doInsertLight(Light light, int index)
public void removeLight(int index)
index
- which light to removevoid doRemoveLight(int index)
public Light getLight(int index)
index
- which light to return
public java.util.Enumeration getAllLights()
public void addLight(Light light)
light
- the light to add
IllegalSharingException
- if the Light node
is part of or is subsequently made part of a live scene graph.
java.lang.NullPointerException
- if the Light object is null.void doAddLight(Light light)
public int numLights()
private Transform3D getNormalTransform()
void updateFogState(FogRetained fogRet)
void updateLightState(LightRetained light)
public void setHiRes(int[] x, int[] y, int[] z)
x
- an eight element array specifying the x positiony
- an eight element array specifying the y positionz
- an eight element array specifying the z positionHiResCoord
public void setHiRes(HiResCoord hiRes)
hiRes
- the HiRes coordinate specifying the a new locationvoid doSetHiRes(HiResCoord hiRes)
public void getHiRes(HiResCoord hiRes)
hiRes
- a HiResCoord object that will receive the
HiRes coordinate of this contextpublic void setModelTransform(Transform3D t)
t
- the new model transform
BadTransformException
- if the transform is not affine.void doSetModelTransform(Transform3D t)
public void multiplyModelTransform(Transform3D t)
t
- the model transform to be concatenated with the
current model transform
BadTransformException
- if the transform is not affine.void doMultiplyModelTransform(Transform3D t)
public void getModelTransform(Transform3D t)
t
- the model transform that will receive the current
model transformpublic void setSound(Sound sound, int index)
sound
- the new soundindex
- which sound to replace
IllegalSharingException
- if the Sound node
is part of or is subsequently made part of a live scene graph.
java.lang.NullPointerException
- if the Sound object is null.void doSetSound(Sound sound, int index)
public void insertSound(Sound sound, int index)
sound
- the new soundindex
- at which location to insert
IllegalSharingException
- if the Sound node
is part or is subsequently made part of a live scene graph.
java.lang.NullPointerException
- if the Sound object is null.void doInsertSound(Sound sound, int index)
public void removeSound(int index)
index
- which sound to removevoid doRemoveSound(int index)
public Sound getSound(int index)
index
- which sound to return
public java.util.Enumeration getAllSounds()
public void addSound(Sound sound)
sound
- the sound to add
IllegalSharingException
- if the Sound node
is part of or is subsequently made part of a live scene graph.
java.lang.NullPointerException
- if the Sound object is null.void doAddSound(Sound sound)
public int numSounds()
SoundScheduler getSoundScheduler()
void updateSoundState(SoundRetained sound)
public boolean isSoundPlaying(int index)
index
- which sound
public void setAuralAttributes(AuralAttributes attributes)
attributes
- the new AuralAttributes objectvoid doSetAuralAttributes(AuralAttributes attributes)
public AuralAttributes getAuralAttributes()
public void setBufferOverride(boolean bufferOverride)
frontBufferRendering
and stereoMode
attributes.
bufferOverride
- the new buffer override flagsetFrontBufferRendering(boolean)
,
setStereoMode(int)
void doSetBufferOverride(boolean bufferOverride)
public boolean getBufferOverride()
public void setFrontBufferRendering(boolean frontBufferRendering)
bufferOverride
flag is enabled.
Note that this attribute has no effect if double buffering is disabled or is not available on the Canvas3D.
frontBufferRendering
- the new front buffer rendering flagsetBufferOverride(boolean)
void doSetFrontBufferRendering(boolean frontBufferRendering)
public boolean getFrontBufferRendering()
public void setStereoMode(int stereoMode)
bufferOverride
flag is enabled.
STEREO_LEFT
specifies that rendering is done into
the left eye.
STEREO_RIGHT
specifies that rendering is done into
the right eye.
STEREO_BOTH
specifies that rendering is done into
both eyes. This is the default.
Note that this attribute has no effect if stereo is disabled or is not available on the Canvas3D.
stereoMode
- the new stereo modesetBufferOverride(boolean)
void doSetStereoMode(int stereoMode)
public int getStereoMode()
STEREO_LEFT
,
STEREO_RIGHT
, or STEREO_BOTH
.public void clear()
void doClear()
private void computeCompositeTransform()
private void updateViewCache(RenderBin rb)
void doDraw(Geometry geometry)
public void draw(Geometry geometry)
geometry
- the Geometry object to draw.
IllegalSharingException
- if the specified geometry is a
Raster that refers to an ImageComponent2D that is being used by a
Canvas3D as an off-screen buffer.public void draw(Shape3D shape)
shape
- the Shape3D node containing the Appearance component
object to set and Geometry component object to draw
IllegalSharingException
- if the Shape3D node
is part of or is subsequently made part of a live scene graph.
IllegalSharingException
- if the Shape3D node's Appearance
refers to an ImageComponent2D that is being used by a
Canvas3D as an off-screen buffer.public void readRaster(Raster raster)
flush(true)
prior to reading the
frame buffer.
raster
- the Raster object used to read the
contents of the frame buffer
java.lang.IllegalArgumentException
- if the image class of the specified
Raster's ImageComponent2D is not ImageClass.BUFFERED_IMAGE.
java.lang.IllegalArgumentException
- if the specified Raster's
ImageComponent2D is in by-reference mode and its
RenderedImage is null.
java.lang.IllegalArgumentException
- if the the Raster's
ImageComponent2D format
is not a 3-component format (e.g., FORMAT_RGB)
or a 4-component format (e.g., FORMAT_RGBA).
IllegalSharingException
- if the Raster object is
part of a live scene graph, or if the Raster's ImageComponent2D is
part of a live scene graph.
IllegalSharingException
- if the Raster's ImageComponent2D is
being used by an immediate mode context, or by a Canvas3D as
an off-screen buffer.flush(boolean)
,
ImageComponent
,
DepthComponent
void doReadRaster(Raster raster)
public void flush(boolean wait)
wait
- flag indicating whether or not to wait for the
rendering to be complete before returning from this call.void doFlush(boolean wait)
void updateLightAndFog()
void updateModelClip(Transform3D vworldToVpc)
boolean updateState(RenderBin rb, int geometryType)
void initializeState()
void resetAppearance()
void sendRenderMessage(boolean renderRun, int command, java.lang.Object arg1, java.lang.Object arg2)
void sendSoundMessage(int command, java.lang.Object arg1, java.lang.Object arg2)
static java.lang.Integer getImmCommand(int command)
void runMonitor(int action)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |