Light
classMethod | Default |
---|---|
Light() |
enable flag : true |
Light(boolean lightOn, Color3f color) |
|
Light(Color3f color) |
|
void setEnable( boolean OnOff ) |
true |
void setColor( Color3f color ) |
1.0, 1.0, 1.0 |
AmbientLight
extends the Light class
TransformGroup group = new TransformGroup( );
. . .
AmbientLight light = new AmbientLight( );
light.setEnable( true );
light.setColor( new Color3f( 1.0f, 1.0f, 1.0f ) );
. . .
light.setInfluencingBounds( bounds );
group.addChild( light );
![]() |
![]() |
Ambient light + Headlight |
Ambient light only |
Light
class Method |
Default |
---|---|
|
|
TransformGroup group = new TransformGroup( );
. . .
DirectionalLight light = new DirectionalLight( );
light.setEnable( true );
light.setColor( new Color3f( 1.0f, 1.0f, 1.0f ) );
light.setDirection( new Vector3f( 1.0f, 0.0f, 0.0f ) );
. . .
light.setInfluencingBounds( bounds );
group.addChild( light );
PointLight
extends the Light
class
brightness = |
lightIntensity
|
Method | Default |
---|---|
void setPosition( Point3f pos ) |
0.0, 0.0, 0.0 |
void setAttenuation( Point3f atten ) |
1.0, 0.0, 0.0 |
TransformGroup group = new TransformGroup( );
. . .
PointLight light = new PointLight( );
light.setEnable( true );
light.setColor( new Color3f( 1.0f, 1.0f, 1.0f ) );
light.setPosition( new Point3f( 0.0f, 1.0f, 0.0f ) );
light.setAttenuation( new Point3f( 1.0f, 0.0f, 0.0f ) );
. . .
light.setInfluencingBounds( bounds );
group.addChild( light );
SpotLight
extends the Light
class Method | Default |
---|---|
void setDirection( Vector3f dir ) |
0.0, 0.0, -1.0 |
void setSpreadAngle( float angle ) |
PI |
void setConcentration( float concen ) |
0.0 |
Direction - The axis of the cone of light. The default
direction is (0.0, 0.0, -1.0). The spot light direction is significant only
when the spread angle is not PI radians (which it is by default).
* Spread angle - The angle in radians between the direction axis and a ray along
the edge of the cone. Note that the angle of the cone at the apex is then twice
this value. The range of values is [0.0,PI/2] radians, with a special value
of PI radians. Values lower than 0 are clamped to 0 and values over PI/2 are
clamped to PI. The default spread angle is PI radians.
* Concentration - Specifies how quickly the light intensity attenuates as a
function of the angle of radiation as measured from the direction of radiation.
The light's intensity is highest at the center of the cone and is attenuated
toward the edges of the cone by the cosine of the angle between the direction
of the light and the direction from the light to the object being lit, raised
to the power of the spot concentration exponent. The higher the concentration
value, the more focused the light source. The range of values is [0.0,128.0].
The default concentration is 0.0, which provides uniform light distribution.
TransformGroup group = new TransformGroup( );
. . .
SpotLight light = new SpotLight( );
light.setEnable( true );
light.setColor( new Color3f( 1.0f, 1.0f, 1.0f ) );
light.setPosition( new Point3f( 0.0f, 1.0f, 0.0f ) );
light.setAttenuation( new Point3f( 1.0f, 0.0f, 0.0f ) );
light.setDirection( new Vector3f( 1.0f, 0.0f, 0.0f ) );
light.setSpreadAngle( 0.785f ); // 45 degrees
light.setConcentration( 0.0f ); // Unfocused
. . .
light.setInfluencingBounds( bounds );
group.addChild( light );
Bounds
PointLight light = new PointLight( );
light.setInfluencingBounds( bounds );
TransformGroup group = new TransformGroup( );
BoundingLeaf leaf = new BoundingLeaf( bounds );
group.addChild( leaf );
. . .
PointLight light = new PointLight( );
light.setInfluencingBoundingLeaf( leaf );
![]() |
![]() |
Large bounds | Small bounds |
---|
TransformGroup lightable = new TransformGroup( );
. . .
DirectionalLight light = new DirectionalLight( );
light.addScope( lightable );
Class |
Attributes |
||
Light |
Enable, Color, Influencing bounds, Scope |
||
|
AmbientLight |
- |
|
|
DirectionalLight |
Direction |
|
|
PointLight |
Position, Attenuation |
|
|
SpotLight |
Direction, Spread Angle, Concentration |
Geometry
Appearance
class, and its components ![]() |
|
ColoringAttributes
node component controls:
Material
node component controls: ColoringAttributes
intrinsic color
LineAttributes
node component controls: PointAttributes
node component controls:
PolygonAttributes
node component controls: The PolygonAttributes object defines attributes for rendering
polygon primitives. The polygon attributes that can be defined are: * Rasterization
mode - defines how the polygon is drawn: as points, outlines, or filled.
* POLYGON_POINT - the polygon is rendered as points drawn at the vertices.
* POLYGON_LINE - the polygon is rendered as lines drawn between consecutive
vertices.
* POLYGON_FILL - the polygon is rendered by filling the interior between the
vertices. The default mode.* Face culling - defines which polygons are culled
(discarded) before they are converted to screen coordinates.
* CULL_NONE - disables face culling.
* CULL_BACK - culls all front-facing polygons. The default.
* CULL_FRONT - culls all back-facing polygons.* Back-face normal flip - specifies
whether vertex normals of back-facing polygons are flipped (negated) prior to
lighting. The setting is either true, meaning to flip back-facing normals, or
false. The default is false.
* Offset - the depth values of all pixels generated by polygon rasterization
can be offset by a value that is computed for that polygon. Two values are used
to specify the offset:* Offset bias - the constant polygon offset that is added
to the final device coordinate Z value of polygon primitives.
* Offset factor - the factor to be multiplied by the slope of the polygon and
then added to the final, device coordinate Z value of the polygon primitives.These
values can be either positive or negative. The default for both of these values
is 0.0.
RenderingAttributes
node component controls: The RenderingAttributes object defines common rendering
attributes for all primitive types. The rendering attributes are:* Alpha test
function - used to compare the alpha test value with each per-pixel alpha value.
If the test passes, the pixel is written, otherwise the pixel is not written.
The alpha test function is set with the setAlphaTestFunction method. The alpha
test function is one of the following:* ALWAYS - pixels are always drawn, irrespective
of the alpha value. This effectively disables alpha testing. This is the default
setting.
* NEVER - pixels are never drawn, irrespective of the alpha value.
* EQUAL - pixels are drawn if the pixel alpha value is equal to the alpha test
value.
* NOT_EQUAL - pixels are drawn if the pixel alpha value is not equal to the
alpha test value.
* LESS - pixels are drawn if the pixel alpha value is less than the alpha test
value.
* LESS_OR_EQUAL - pixels are drawn if the pixel alpha value is less than or
equal to the alpha test value.
* GREATER - pixels are drawn if the pixel alpha value is greater than the alpha
test value.
* GREATER_OR_EQUAL - pixels are drawn if the pixel alpha value is greater than
or equal to the alpha test value.* Alpha test value - the test value used by
the alpha test function. This value is compared to the alpha value of each rendered
pixel. The alpha test value is set with the setAlphaTestValue method. The default
alpha test value is 0.0.
* Raster operation - the raster operation function for this RenderingAttributes
component object. The raster operation is set with the setRasterOp method. The
raster operation is enabled or disabled with the setRasterOpEnable method. The
raster operation is one of the following:* ROP_COPY - DST = SRC. This is the
default operation.
* ROP_XOR - DST = SRC ^ DST.* Vertex colors - vertex colors can be ignored for
this RenderingAttributes object. This capability is set with the setIgnoreVertexColors
method. If ignoreVertexColors is false, per-vertex colors are used, when present
in the associated geometry objects, taking precedence over the ColoringAttributes
color and Material diffuse color. If ignoreVertexColors is true, per-vertex
colors are ignored. In this case, if lighting is enabled, the Material diffuse
color will be used as the object color. if lighting is disabled, the ColoringAttributes
color is used. The default value is false.
* Visibility flag - when set, invisible objects are not rendered (subject to
the visibility policy for the current view), but they can be picked or collided
with. This flag is set with the setVisible method. By default, the visibility
flag is true.
* Depth buffer - can be enabled or disabled for this RenderingAttributes component
object. The setDepthBufferEnable method enables or disabled the depth buffer.
The setDepthBufferWriteEnable method enables or disables writing the depth buffer
for this object. During the transparent rendering pass, this attribute can be
overridden by the depthBufferFreezeTransparent attribute in the View object.
Transparent objects include BLENDED transparent and antialiased lines and points.
Transparent objects do not include opaque objects or primitives rendered with
SCREEN_DOOR transparency. By default, the depth buffer is enabled and the depth
buffer write is enabled.
Method | Default |
---|---|
Appearance( ) |
Unlit white |
|
White, Gouraud |
void setMaterial( Material material ) |
None |
void setTransparencyAttributes( TransparencyAttributes transparencyAttributes ) |
Opaque |
void setLineAttributes( LineAttributes lineAttributes ) |
1 pixel wide |
|
1 pixel |
|
Fill |
|
Depth enable |
Appearance
node, then set one or more of its attribute
componentsAppearance app = new Appearance( ); // Coloring Attributes // Intrinsic color, Gouraud shading
ColoringAttributes ca = new ColoringAttributes( );
ca.setColor( 1.0f, 1.0f, 0.0f );
ca.setShadeModel( ColoringAttributes.SHADE_GOURAUD );
app.setColoringAttributes( ca ); //Material Attributes //Ambient, emissive, diffuse, and specular colors
Material mat = new Material( );
mat.setAmbientColor( 0.3f, 0.3f, 0.3f );
mat.setDiffuseColor( 1.0f, 0.0f, 0.0f );
mat.setEmissiveColor( 0.0f, 0.0f, 0.0f );
mat.setSpecularColor( 1.0f, 1.0f, 1.0f );
mat.setShininess( 80.0f );
app.setMaterial( mat ); // Transparency Attributes // Semi-transparent, alpha-blended
TransparencyAttributes ta = new TransparencyAttributes( );
ta.setTransparency( 0.5f );
ta.setTransparencyMode( TransparencyAttributes.BLENDED );
app.setTransparencyAttributes( ta ); // Point Attributes // 10 pixel points, not anti-aliased
PointAttributes pta = new PointAttributes( ); pta.setPointSize( 10.0f );
pta.setPointAntialiasingEnable( false );
app.setPointAttributes( pta ); // Line Attributes // 10 pixel lines, solid, not anti-aliased LineAttributes lta = new LineAttributes( ); lta.setLineWidth( 10.0f ); lta.setLineAntialiasingEnable( false ); lta.setLinePattern( LineAttributes.PATTERN_SOLID ); app.setLineAttributes( lta ); // Polygon Attributes // Filled polygons, front and back faces
PolygonAttributes pa = new PolygonAttributes( );
pa.setPolygonMode( PolygonAttributes.POLYGON_FILL );
pa.setCullFace( PolygonAttributes.CULL_NONE );
app.setPolygonAttributes( pa );
Class | Attributes |
---|---|
Appearance |
Multiple attribute components |
ColoringAttributes |
Intrinsic color, Shading model |
Material |
Ambient color, Emissive color, Diffuse color, Specular color, Shininess |
TransparencyAttributes |
Transparency, Mode |
PointAttributes |
Point size, Anti-aliasing |
LineAttributes |
Line width, Pattern, Anti-aliasing |
PolygonAttributes |
Culling, Polygon mode, Z offset |
RenderingAttributes |
Depth and Alpha modes |