|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.media.j3d.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 | |
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. |
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. |
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. |
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. |
Sound |
getSound(int index)
Retrieves the index selected sound. |
int |
getStereoMode()
Returns the current stereo mode. |
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. |
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. |
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 ValuesMethod Detail |
public Canvas3D getCanvas3D()
public void setAppearance(Appearance appearance)
appearance
- the new Appearance objectpublic 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.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.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.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.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.public void removeLight(int index)
index
- which light to removepublic 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.public int numLights()
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 locationpublic 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.public void multiplyModelTransform(Transform3D t)
t
- the model transform to be concatenated with the
current model transform
BadTransformException
- if the transform is not affine.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.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.public void removeSound(int index)
index
- which sound to removepublic 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.public int numSounds()
public boolean isSoundPlaying(int index)
index
- which sound
public void setAuralAttributes(AuralAttributes attributes)
attributes
- the new AuralAttributes objectpublic AuralAttributes getAuralAttributes()
public void setBufferOverride(boolean bufferOverride)
frontBufferRendering
and stereoMode
attributes.
bufferOverride
- the new buffer override flagsetFrontBufferRendering(boolean)
,
setStereoMode(int)
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)
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)
public int getStereoMode()
STEREO_LEFT
,
STEREO_RIGHT
, or STEREO_BOTH
.public void clear()
public void draw(Geometry geometry)
geometry
- the Geometry object to draw.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.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 Raster's
ImageComponent2D is in by-reference mode and its RenderedImage
is not an instance of a BufferedImage.
IllegalSharingException
- if the Raster object
is part of a live scene graph.flush(boolean)
,
ImageComponent
,
DepthComponent
public void flush(boolean wait)
wait
- flag indicating whether or not to wait for the
rendering to be complete before returning from this call.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |