Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class PolygonAttributes

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.PolygonAttributes
All Implemented Interfaces:
java.lang.Comparable, AppearanceAttributeRenderable, ObjectRenderable, Renderable

public class PolygonAttributes
extends NodeComponent
implements AppearanceAttributeRenderable

Describes attributes used when rendering a polygon.

Attributes control the visibility and some lighting calculations of the polygon. You can control which face to cull, which way to wind the polygons to calculate front and back faces, as well as some lighting control.

The default setup of this class mirrors the OpenGL defaults:

Internationalisation Resource Names

Version:
$Revision: 1.29 $
Author:
Justin Couch

Field Summary
static int CULL_BACK
          The cull mode says to draw back faces only
static int CULL_BOTH
          The cull mode says to not draw any faces
static int CULL_FRONT
          The cull mode says to draw front faces only
static int CULL_NONE
          The cull mode says to draw both front and back faces
static int DRAW_FILLED
          Draw the face filled as a solid object
static int DRAW_LINE
          Draw the face as outline lines only
static int DRAW_POINT
          Draw the face as the points of the vertices only
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount, parentList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.AppearanceAttributeRenderable
ALPHA_ATTRIBUTE, BLEND_ATTRIBUTE, DEPTH_ATTRIBUTE, LINE_ATTRIBUTE, POINT_ATTRIBUTE, POLYGON_ATTRIBUTE, STENCIL_ATTRIBUTE
 
Constructor Summary
PolygonAttributes()
          Constructs a attribute set with default values.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 int compareTo(PolygonAttributes pa)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 boolean equals(PolygonAttributes pa)
          Compares this object with the specified object to check for equivalence.
 int getAttributeType()
          Get the type this visual attribute represents.
 int getCulledFace()
          Get the current face culled flag.
 int getDrawMode(boolean front)
          Get the draw mode for the specified face.
 void getPolygonOffset(float[] values)
          Get the current polygon offset details.
 boolean isAntiAliased()
          Check the state of the antialiased flag setting for this geometry.
 boolean isCCW()
          Check the state of the CCW flag setting for this geometry.
 boolean isFlatShaded()
          Check the state of the separate specular lighting flag setting for this geometry.
 boolean isSeparateSpecular()
          Check the state of the separate specular lighting flag setting for this geometry.
 boolean isTwoSidedLighting()
          Check the state of the two-sided lighting flag setting for this geometry.
 void postRender(javax.media.opengl.GL gl)
          Restore all openGL state to the given drawable.
 void render(javax.media.opengl.GL gl)
          Issue ogl commands needed for this component
 void setAntiAliased(boolean state)
          Set the antialiased flag state.
 void setCCW(boolean state)
          Set the CCW flag.
 void setCulledFace(int face)
          Set which face is to be culled.
 void setDrawMode(boolean front, int mode)
          Set the draw mode for either the front or back face.
 void setFlatShaded(boolean state)
          Set the shading style to use either flat or smooth shading.
 void setPolygonOffset(float factor, float units)
          Set the polygon offset details.
 void setSeparateSpecular(boolean state)
          Set the separated specular lighting flag.
 void setStipplePattern(byte[] pattern)
          Set the stipple mask to be used on the polygon.
 void setTwoSidedLighting(boolean state)
          Set the two-sided lighting flag.
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CULL_NONE

public static final int CULL_NONE
The cull mode says to draw both front and back faces

See Also:
Constant Field Values

CULL_FRONT

public static final int CULL_FRONT
The cull mode says to draw front faces only

See Also:
Constant Field Values

CULL_BACK

public static final int CULL_BACK
The cull mode says to draw back faces only

See Also:
Constant Field Values

CULL_BOTH

public static final int CULL_BOTH
The cull mode says to not draw any faces

See Also:
Constant Field Values

DRAW_POINT

public static final int DRAW_POINT
Draw the face as the points of the vertices only

See Also:
Constant Field Values

DRAW_LINE

public static final int DRAW_LINE
Draw the face as outline lines only

See Also:
Constant Field Values

DRAW_FILLED

public static final int DRAW_FILLED
Draw the face filled as a solid object

See Also:
Constant Field Values
Constructor Detail

PolygonAttributes

public PolygonAttributes()
Constructs a attribute set with default values.

Method Detail

getAttributeType

public int getAttributeType()
Get the type this visual attribute represents.

Specified by:
getAttributeType in interface AppearanceAttributeRenderable
Returns:
One of the _ATTRIBUTE constants

render

public void render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component

Specified by:
render in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

postRender

public void postRender(javax.media.opengl.GL gl)
Restore all openGL state to the given drawable.

Specified by:
postRender in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The object to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Specified by:
equals in interface Renderable
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setAntiAliased

public void setAntiAliased(boolean state)
                    throws InvalidWriteTimingException
Set the antialiased flag state. By antialiasing is off.

Parameters:
state - True to use antialiasing, false to turn it off
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isAntiAliased

public boolean isAntiAliased()
Check the state of the antialiased flag setting for this geometry.

Returns:
true if antialiasing is currently enabled

setCCW

public void setCCW(boolean state)
            throws InvalidWriteTimingException
Set the CCW flag. By default CCW is true.

Parameters:
state - True to use CCW triangles, false for CW
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isCCW

public boolean isCCW()
Check the state of the CCW flag setting for this geometry.

Returns:
true if the vertices are rendered counter clockwise

setTwoSidedLighting

public void setTwoSidedLighting(boolean state)
                         throws InvalidWriteTimingException
Set the two-sided lighting flag. By default only single sided lighting is in use.

Parameters:
state - True to use two sided lighting triangles, false for single sided
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isTwoSidedLighting

public boolean isTwoSidedLighting()
Check the state of the two-sided lighting flag setting for this geometry.

Returns:
true if the both sides should have lighting calcs done

setSeparateSpecular

public void setSeparateSpecular(boolean state)
                         throws InvalidWriteTimingException
Set the separated specular lighting flag. By default only single lighting color is calculated.

Parameters:
state - True to generate a separated specular component
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isSeparateSpecular

public boolean isSeparateSpecular()
Check the state of the separate specular lighting flag setting for this geometry.

Returns:
true if the a separate specular component should be computed

setFlatShaded

public void setFlatShaded(boolean state)
                   throws InvalidWriteTimingException
Set the shading style to use either flat or smooth shading. lighting flag. By default only single lighting color is calculated.

Parameters:
state - True to render as flat shaded polygons
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isFlatShaded

public boolean isFlatShaded()
Check the state of the separate specular lighting flag setting for this geometry.

Returns:
true if flat shading is used

setCulledFace

public void setCulledFace(int face)
                   throws InvalidWriteTimingException
Set which face is to be culled. It should be one of the base constants defined by this class.

Parameters:
face - The face that should be culled
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getCulledFace

public int getCulledFace()
Get the current face culled flag.

Returns:
one of the four CULL_X constants

setDrawMode

public void setDrawMode(boolean front,
                        int mode)
                 throws java.lang.IllegalArgumentException,
                        InvalidWriteTimingException
Set the draw mode for either the front or back face.

Parameters:
front - true if this is the front-face setting
mode - The mode to use for this face
Throws:
java.lang.IllegalArgumentException - Invalid mode supplied
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getDrawMode

public int getDrawMode(boolean front)
Get the draw mode for the specified face.

Parameters:
front - true if requesting the front-face setting

setPolygonOffset

public void setPolygonOffset(float factor,
                             float units)
                      throws InvalidWriteTimingException
Set the polygon offset details. Factor and unit applied as per the OpenGL specification.

Parameters:
factor - The offset factor mulitplier
units - The offset unit multiplier
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getPolygonOffset

public void getPolygonOffset(float[] values)
Get the current polygon offset details. The array is used to copy the current values into and therefore must be at least 2 items in length. Index 0 is the factor, index 1 is the units

Parameters:
values - The array to copy the current values into

setStipplePattern

public void setStipplePattern(byte[] pattern)
                       throws InvalidWriteTimingException
Set the stipple mask to be used on the polygon. If the stipple is null then it will clear the current stipple setup. If not null, it must be at least an array length 1024 (32x32). The value is used by reference

Parameters:
pattern - The bytes of the pattern or null
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

compareTo

public int compareTo(PolygonAttributes pa)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
pa - The attributes instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(PolygonAttributes pa)
Compares this object with the specified object to check for equivalence.

Parameters:
pa - The attributes instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org