Class FlatRenderer.EdgeTable

java.lang.Object
  |
  +--FlatRenderer.EdgeTable
Direct Known Subclasses:
GouraudRenderer.EdgeTableEx
Enclosing class:
FlatRenderer

protected static class FlatRenderer.EdgeTable
extends Object

The global Edge Table for each polygon.


Field Summary
protected  FlatRenderer.EdgeBucket[] buckets
          The entries in the edge table.
protected  int ymax
          The maximum value of the scan lines.
protected  int ymin
          The minimum value of the scan lines.
 
Constructor Summary
protected FlatRenderer.EdgeTable()
          Constructs a null edge table.
  FlatRenderer.EdgeTable(int ymin, int ymax)
          Constructs an empty edge table.
  FlatRenderer.EdgeTable(Mesh.Polygon p)
          Constructs an edge table from a polygon object.
 
Method Summary
protected  void addEdge(Mesh.Polygon owner, int xlow, int ylow, int xhigh, int yhigh, int yComp)
          Adds an edge to the edge table, ignoring horizontal edges.
 void addMesh(Mesh mesh)
          Adds a mesh into the edge table.
protected  void addPolygon(Mesh.Polygon poly)
          Adds a polygon into the edge table.
 FlatRenderer.EdgeBucket getBucket(int y)
          Returns the bucket with the specified y coordinate.
protected  int getIndex(int y)
          Calculates the index in the bucket array, given a y coordinate.
protected  void initBucket(int ymin, int ymax)
          Initializes the bucket.
 boolean inside(int y)
          Returns true if the specified coordinate is within the bounds of the edge table.
 FlatRenderer.EdgeBucket removeBucket(int y)
          Returns the bucket with the specified y coordinate, and removes it from the edge table.
 void setBucket(int y, FlatRenderer.EdgeBucket b)
          Sets the bucket at the specified y coordinate.
 String toString()
          Creates a human-readable String that displays the contents of this object, for debugging purposes.
protected static int yNext(int k, Point3D[] vertices, int[] indexes)
          Given an index, returns the next y value of the first nonhorizontal polygon.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

ymin

protected int ymin
The minimum value of the scan lines.

ymax

protected int ymax
The maximum value of the scan lines.

buckets

protected FlatRenderer.EdgeBucket[] buckets
The entries in the edge table.
Constructor Detail

FlatRenderer.EdgeTable

protected FlatRenderer.EdgeTable()
Constructs a null edge table. Derived classes must initialize all data members.

FlatRenderer.EdgeTable

public FlatRenderer.EdgeTable(Mesh.Polygon p)
Constructs an edge table from a polygon object.
Parameters:
p - the polygon from which to extract edges.

FlatRenderer.EdgeTable

public FlatRenderer.EdgeTable(int ymin,
                              int ymax)
Constructs an empty edge table.
Parameters:
ymin - the minimum value of the scan lines.
ymax - the maximum value of the scan lines.
Method Detail

initBucket

protected void initBucket(int ymin,
                          int ymax)
Initializes the bucket.
Parameters:
ymin - the minimum value of the scan lines.
ymax - the maximum value of the scan lines.

addMesh

public void addMesh(Mesh mesh)
Adds a mesh into the edge table.
Parameters:
mesh - the mesh to add.

inside

public boolean inside(int y)
Returns true if the specified coordinate is within the bounds of the edge table.

addPolygon

protected void addPolygon(Mesh.Polygon poly)
Adds a polygon into the edge table.
Parameters:
poly - the polygon to add.

yNext

protected static int yNext(int k,
                           Point3D[] vertices,
                           int[] indexes)
Given an index, returns the next y value of the first nonhorizontal polygon.
Parameters:
k - the current index.
vertices - the vertices to search.
indexes - an array to index vertices.

addEdge

protected void addEdge(Mesh.Polygon owner,
                       int xlow,
                       int ylow,
                       int xhigh,
                       int yhigh,
                       int yComp)
Adds an edge to the edge table, ignoring horizontal edges.
Parameters:
owner - the owner of the edge.
xlow - the x coordinate of the lower point in the edge.
ylow - the y coordinate of the lower point in the edge.
xhigh - the x coordinate of the higher point in the edge.
yhigh - the y coordinate of the higher point in the edge.
yComp - the next nonhorizontal y

removeBucket

public FlatRenderer.EdgeBucket removeBucket(int y)
Returns the bucket with the specified y coordinate, and removes it from the edge table.
Parameters:
y - the y coordinate of the bucket.
Returns:
the bucket at y, null if no bucket at y.

getBucket

public FlatRenderer.EdgeBucket getBucket(int y)
Returns the bucket with the specified y coordinate.
Parameters:
y - the y coordinate of the bucket.
Returns:
the bucket at y, null if no bucket at y.

setBucket

public void setBucket(int y,
                      FlatRenderer.EdgeBucket b)
Sets the bucket at the specified y coordinate.
Parameters:
y - the y coordinate of the bucket.
b - the bucket to set to the table.

toString

public String toString()
Creates a human-readable String that displays the contents of this object, for debugging purposes. It returns a string in the following format:
ET[ y-coordinate:EdgeBucket values ... ]
Overrides:
toString in class Object

getIndex

protected int getIndex(int y)
Calculates the index in the bucket array, given a y coordinate.
Parameters:
y - the y coordinate
Returns:
index to the buckets array.