public class GraphicsContext3D extends Object
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()
Modifier and Type | Field and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Enumeration<Light> |
getAllLights()
Retrieves the enumeration object of all the lights.
|
Enumeration<Sound> |
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.
|
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 Valuespublic Canvas3D getCanvas3D()
public void setAppearance(Appearance appearance)
appearance
- the new Appearance objectIllegalSharingException
- if the specified appearance refers
to an ImageComponent2D that is being used by a Canvas3D as
an off-screen buffer.public Appearance getAppearance()
public void setBackground(Background background)
background
- the new Background objectIllegalSharingException
- 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.public Background getBackground()
public void setFog(Fog fog)
fog
- the new Fog objectIllegalSharingException
- 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 nodeIllegalSharingException
- 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 replaceIllegalSharingException
- if the Light node
is part of or is subsequently made part of a live scene graph.NullPointerException
- if the Light object is null.public void insertLight(Light light, int index)
light
- the new lightindex
- at which location to insertIllegalSharingException
- if the Light node
is part of or is subsequently made part of a live scene graph.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 returnpublic Enumeration<Light> getAllLights()
public void addLight(Light light)
light
- the light to addIllegalSharingException
- if the Light node
is part of or is subsequently made part of a live scene graph.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 transformBadTransformException
- if the transform is not affine.public void multiplyModelTransform(Transform3D t)
t
- the model transform to be concatenated with the
current model transformBadTransformException
- 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 replaceIllegalSharingException
- if the Sound node
is part of or is subsequently made part of a live scene graph.NullPointerException
- if the Sound object is null.public void insertSound(Sound sound, int index)
sound
- the new soundindex
- at which location to insertIllegalSharingException
- if the Sound node
is part or is subsequently made part of a live scene graph.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 returnpublic Enumeration<Sound> getAllSounds()
public void addSound(Sound sound)
sound
- the sound to addIllegalSharingException
- if the Sound node
is part of or is subsequently made part of a live scene graph.NullPointerException
- if the Sound object is null.public int numSounds()
public boolean isSoundPlaying(int index)
index
- which soundpublic 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.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 drawIllegalSharingException
- 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 bufferIllegalArgumentException
- if the image class of the specified
Raster's ImageComponent2D is not ImageClass.BUFFERED_IMAGE.IllegalArgumentException
- if the specified Raster's
ImageComponent2D is in by-reference mode and its
RenderedImage is null.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
public void flush(boolean wait)
wait
- flag indicating whether or not to wait for the
rendering to be complete before returning from this call.Copyright © 2016–2022 SciJava. All rights reserved.