com.brackeen.javagamebook.graphics3D
Class SortedScanConverter

java.lang.Object
  extended bycom.brackeen.javagamebook.graphics3D.ScanConverter
      extended bycom.brackeen.javagamebook.graphics3D.SortedScanConverter

public class SortedScanConverter
extends ScanConverter

A ScanConverter used to draw sorted polygons from front-to-back with no overdraw. Polygons are added and clipped to a list of what's in the view window. Call clear() before drawing every frame.


Nested Class Summary
 
Nested classes inherited from class com.brackeen.javagamebook.graphics3D.ScanConverter
ScanConverter.Scan
 
Constructor Summary
SortedScanConverter(ViewWindow view)
          Creates a new SortedScanConverter for the specified ViewWindow.
 
Method Summary
 void clear()
          Clears the current view scan.
 boolean convert(Polygon3D polygon)
          Scan-converts a polygon, and if sortedMode is on, adds and clips it to a list of what's in the view window.
 int getNumScans(int y)
          Gets the number of scans for the specified row.
 ScanConverter.Scan getScan(int y, int index)
          Gets the nth scan for the specified row.
 boolean isFilled()
          Checks if the view is filled.
 void setSortedMode(boolean b)
          Sets sorted mode, so this scan converter can assume the polygons are drawn front-to-back, and should be clipped against polygons already scanned for this view.
 
Methods inherited from class com.brackeen.javagamebook.graphics3D.ScanConverter
getBottomBoundary, getScan, getTopBoundary
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedScanConverter

public SortedScanConverter(ViewWindow view)
Creates a new SortedScanConverter for the specified ViewWindow. The ViewWindow's properties can change in between scan conversions. By default, sorted mode is off, but can be turned on by calling setSortedMode().

Method Detail

clear

public void clear()
Clears the current view scan. Call this method every frame.


setSortedMode

public void setSortedMode(boolean b)
Sets sorted mode, so this scan converter can assume the polygons are drawn front-to-back, and should be clipped against polygons already scanned for this view.


getScan

public ScanConverter.Scan getScan(int y,
                                  int index)
Gets the nth scan for the specified row.


getNumScans

public int getNumScans(int y)
Gets the number of scans for the specified row.


isFilled

public boolean isFilled()
Checks if the view is filled.


convert

public boolean convert(Polygon3D polygon)
Scan-converts a polygon, and if sortedMode is on, adds and clips it to a list of what's in the view window.

Overrides:
convert in class ScanConverter