: Class GraphicsContext3D

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.media.j3d
Class GraphicsContext3D

    java.lang.Object
      |
      +--javax.media.j3d.GraphicsContext3D

public class GraphicsContext3D
extends java.lang.Object

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:

- Background object: null
- Fog object: null
- Appearance object: null
- List of Light objects: empty
- high-res coordinate: (0, 0, 0)
- modelTransform: identity
- AuralAttributes object: null
- List of Sound objects: empty

See Also:
  `Canvas3D.getGraphicsContext3D()`

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.
`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.
`Canvas3D` | `getCanvas3D()` Gets the Canvas3D that created this GraphicsContext3D.
`Fog` | `getFog()` Retrieves the current Fog leaf node object.
`void` | `getHiRes(HiResCoord hiRes)` Retrieves the current HiRes coordinate of this context.
`Light` | `getLight(int index)` Retrieves the index selected light.
`void` | `getModelTransform(Transform3D t)` Retrieves the current model transform.
`Sound` | `getSound(int index)` Retrieves the index selected sound.
`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` | `setFog(Fog fog)` Sets the current Fog to the specified Fog leaf node object.
`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` | `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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getCanvas3D

    public final Canvas3D getCanvas3D()

  Gets the Canvas3D that created this GraphicsContext3D.
  Returns:
    the Canvas3D that created this GraphicsContext3D

### setAppearance

    public final void setAppearance(Appearance appearance)

  Sets the current Appearance object to the specified Appearance component object.
  Parameters:
    `appearance` - the new Appearance object
  Throws:
    IllegalSharingException - if the Appearance object is part of or is subsequently made part of a live scene graph.

### getAppearance

    public final Appearance getAppearance()

  Retrieves the current Appearance component object.
  Returns:
    the current Appearance object

### setBackground

    public final void setBackground(Background background)

  Sets the current Background to the specified Background leaf node object.
  Parameters:
    `background` - the new Background object
  Throws:
    IllegalSharingException - if the Background object is part of or is subsequently made part of a live scene graph.

### getBackground

    public final Background getBackground()

  Retrieves the current Background leaf node object.
  Returns:
    the current Background object

### setFog

    public final void setFog(Fog fog)

  Sets the current Fog to the specified Fog leaf node object.
  Parameters:
    `fog` - the new Fog object
  Throws:
    IllegalSharingException - if the Fog object is part of or is subsequently made part of a live scene graph.

### getFog

    public final Fog getFog()

  Retrieves the current Fog leaf node object.
  Returns:
    the current Fog object

### setLight

    public final void setLight(Light light,
                               int index)

  Replaces the specified light with the light provided.
  Parameters:
    `light` - the new light
    `index` - which light to replace
  Throws:
    IllegalSharingException - if the Light object is part of or is subsequently made part of a live scene graph.
    NullPointerException - if the Light object is null.

### insertLight

    public final void insertLight(Light light,
                                  int index)

  Inserts the specified light at the specified index location.
  Parameters:
    `light` - the new light
    `index` - at which location to insert
  Throws:
    IllegalSharingException - if the Light object is part of or is subsequently made part of a live scene graph.
    NullPointerException - if the Light object is null.

### removeLight

    public final void removeLight(int index)

  Removes the light at the specified index location.
  Parameters:
    `index` - which light to remove

### getLight

    public final Light getLight(int index)

  Retrieves the index selected light.
  Parameters:
    `index` - which light to return
  Returns:
    the light at location index

### getAllLights

    public final java.util.Enumeration getAllLights()

  Retrieves the enumeration object of all the lights.
  Returns:
    the enumeration object of all the lights

### addLight

    public final void addLight(Light light)

  Appends the specified light to this graphics context's list of lights.
  Parameters:
    `light` - the light to add
  Throws:
    IllegalSharingException - if the Light object is part of or is subsequently made part of a live scene graph.
    NullPointerException - if the Light object is null.

### numLights

    public final int numLights()

  Retrieves the current number of lights in this graphics context.
  Returns:
    the current number of lights

### setHiRes

    public void setHiRes(int[] x,
                         int[] y,
                         int[] z)

  Sets the HiRes coordinate of this context to the location specified by the parameters provided.
  Parameters:
    `x` - an eight element array specifying the x position
    `y` - an eight element array specifying the y position
    `z` - an eight element array specifying the z position
  See Also:
    `HiResCoord`

### setHiRes

    public void setHiRes(HiResCoord hiRes)

  Sets the HiRes coordinate of this context to the location specified by the HiRes argument.
  Parameters:
    `hiRes` - the HiRes coordinate specifying the a new location

### getHiRes

    public void getHiRes(HiResCoord hiRes)

  Retrieves the current HiRes coordinate of this context.
  Parameters:
    `hiRes` - a HiResCoord object that will receive the HiRes coordinate of this context

### setModelTransform

    public void setModelTransform(Transform3D t)

  Sets the current model transform to a copy of the specified transform.
  Parameters:
    `t` - the new model transform
  Throws:
    BadTransformException - if the transform is not affine.

### multiplyModelTransform

    public void multiplyModelTransform(Transform3D t)

  Multiplies the current model transform by the specified transform and stores the result back into the current transform.
  Parameters:
    `t` - the model transform to be concatenated with the current model transform.
  Throws:
    BadTransformException - if the transform is not affine.

### getModelTransform

    public void getModelTransform(Transform3D t)

  Retrieves the current model transform.
  Parameters:
    `t` - the model transform that will receive the current model transform.

### setSound

    public final void setSound(Sound sound,
                               int index)

  Replaces the specified sound with the sound provided.
  Parameters:
    `sound` - the new sound
    `index` - which sound to replace
  Throws:
    IllegalSharingException - if the Sound object is part of or is subsequently made part of a live scene graph.
    NullPointerException - if the Sound object is null.

### insertSound

    public final void insertSound(Sound sound,
                                  int index)

  Inserts the specified sound at the specified index location.
  Parameters:
    `sound` - the new sound
    `index` - at which location to insert
  Throws:
    IllegalSharingException - if the Sound object is part or is subsequently made part of a live scene graph.
    NullPointerException - if the Sound object is null.

### removeSound

    public final void removeSound(int index)

  Removes the sound at the specified index location.
  Parameters:
    `index` - which sound to remove

### getSound

    public final Sound getSound(int index)

  Retrieves the index selected sound.
  Parameters:
    `index` - which sound to return
  Returns:
    the sound at location index

### getAllSounds

    public final java.util.Enumeration getAllSounds()

  Retrieves the enumeration object of all the sounds.
  Returns:
    the enumeration object of all the sounds

### addSound

    public final void addSound(Sound sound)

  Appends the specified sound to this graphics context's list of sounds.
  Parameters:
    `sound` - the sound to add
  Throws:
    IllegalSharingException - if the Sound object is part of or is subsequently made part of a live scene graph.
    NullPointerException - if the Sound object is null.

### numSounds

    public final int numSounds()

  Retrieves the current number of sounds in this graphics context.
  Returns:
    the current number of sounds

### isSoundPlaying

    public final boolean isSoundPlaying(int index)

  Retrieves the sound playing flag
  Returns:
    flag denoting if sound is currently playing

### setAuralAttributes

    public final void setAuralAttributes(AuralAttributes attributes)

  Sets the current AuralAttributes object to the specified AuralAttributes component object.
  Parameters:
    `attributes` - the new AuralAttributes object
  Throws:
    IllegalSharingException - if the AuralAttributes object is part of or is subsequently made part of a live scene graph.

### getAuralAttributes

    public final AuralAttributes getAuralAttributes()

  Retrieves the current AuralAttributes component object.
  Returns:
    the current AuralAttributes object

### clear

    public final void clear()

  Clear the Canvas3D to the color or image specified by the current background node.

### draw

    public final void draw(Geometry geometry)

  Draw the specified Geometry component object.
  Parameters:
    `geometry` - the Geometry object to draw.

### draw

    public final void draw(Shape3D shape)

  Draw the specified Shape3D leaf node object. This is a convenience method that is identical to calling the setAppearance(Appearance) and draw(Geometry) methods passing the appearance and geometry component objects of the specified shape node as arguments.
  Parameters:
    `shape` - the Shape3D node containing the Appearance component object to set and Geometry component object to draw.

### readRaster

    public final 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. All parameters of the Raster object and the component ImageComponent and/or DepthComponentmage objects must be set to the desired values prior to calling this method. These values determine the location, size, and format of the pixel data that is read.
  Parameters:
    `raster` - the Raster object used to read the contents of the frame buffer.
  See Also:
    `ImageComponent`, `DepthComponent`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD