Class GouraudRenderer

java.lang.Object
  |
  +--Renderer
        |
        +--FlatRenderer
              |
              +--GouraudRenderer
Direct Known Subclasses:
PhongRenderer

public class GouraudRenderer
extends FlatRenderer

Renders Gouraud; intensity-value interpolation proposed by Gouraud.

This class defines inner subclasses of EdgeEntry, EdgeTable, and PolygonInfo.

The EdgeEntryEx class, a subclass of EdgeEntry, contains the intensity values for the two vertices of the edge.

The EdgeTableEx class, a subclass of EdgeTable, is required in order to create instances of EdgeEntryEx containing intensity values gained from PolygonInfoEx.

The PolygonInfoEx class calculates the intensity values for each vertice in a polygon.

The MeshInfo class calculates and contains the normal vector for each vertice in a mesh.

Known Bugs:
When using parallel projection, the lights are not projected with the mesh, so rendering sometimes results with unlit objects because the lights are behind the objects.

Author:
Sasmito Adibowo - 1299000029.
See Also:
GouraudRenderer.EdgeEntryEx, GouraudRenderer.EdgeTableEx, GouraudRenderer.PolygonInfoEx, GouraudRenderer.MeshInfo

Inner Class Summary
protected static class GouraudRenderer.EdgeEntryEx
          Extended edge entry containing intensity information at each entry.
protected static class GouraudRenderer.EdgeTableEx
          Extended Edge Table containing intensity information at each edge entry.
protected static class GouraudRenderer.MeshInfo
          Information about rendering a mesh.
protected static class GouraudRenderer.PolygonInfoEx
          Extended polygon info containing information about the intensities of each vertices.
 
Inner classes inherited from class FlatRenderer
FlatRenderer.ActiveEdgeTable, FlatRenderer.EdgeBucket, FlatRenderer.EdgeEntry, FlatRenderer.EdgeTable, FlatRenderer.PolygonInfo
 
Field Summary
protected  Map meshTable
          A Set of (Mesh,MeshInfo objects) pairs describing the mesh.
 
Fields inherited from class FlatRenderer
colorBuffer, depthBuffer, lights, polygonTable, projectedMeshes, xmin
 
Fields inherited from class Renderer
AMBIENT_BLUE, AMBIENT_GREEN, AMBIENT_RED, backingStore, CS_REALWORLD, FATT_C1, FATT_C2, FATT_C3, metafile, owner, viewPlane
 
Constructor Summary
GouraudRenderer(Component owner)
           
 
Method Summary
protected  void fillPixels(FlatRenderer.PolygonInfo info, FlatRenderer.ActiveEdgeTable AET, int xmin, int y)
          Fills a line of pixels from the AET.
protected  void initPolygonTable()
          Initializes the polygon table with PolygonInfoEx instances using the current meshes in projectedMeshes.
protected  Mesh normalizeMesh(Mesh mesh)
          Normalize a mesh into vieplane coordinates.
protected  void normalizeMeshes()
          Normalizes all the mesh objects into viewplane coordinates
protected  void notifyDataChanged()
          Called when there are changes to the Renderer data.
protected  void paintLights(Graphics g)
          Paints the lights objects
 
Methods inherited from class FlatRenderer
getProjectionMatrix, initLineBuffers, makeCoorSysMatrices, paint, processPolygon, processScanLine, projectMatrix, projectMesh, projectMeshes, render, roundCoord, transformLights
 
Methods inherited from class Renderer
drawGrid, getMetafile, getSize, initBackingStore, makeParallelProjection, makePerspectiveProjection, moveCamera, overlaps, parallelProjection, rotateCameraX, rotateCameraY, rotateCameraZ, rotateCoorSysX, rotateCoorSysY, rotateCoorSysZ, setMetafile, setupCartesian, translateCoorSys
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

meshTable

protected Map meshTable
A Set of (Mesh,MeshInfo objects) pairs describing the mesh.
Constructor Detail

GouraudRenderer

public GouraudRenderer(Component owner)
Method Detail

notifyDataChanged

protected void notifyDataChanged()
Description copied from class: Renderer
Called when there are changes to the Renderer data. Derived classes should override this to receive the notification. The default implementation does nothing.
Overrides:
notifyDataChanged in class FlatRenderer

paintLights

protected void paintLights(Graphics g)
Paints the lights objects

normalizeMesh

protected Mesh normalizeMesh(Mesh mesh)
Normalize a mesh into vieplane coordinates.
Overrides:
normalizeMesh in class FlatRenderer
Parameters:
mesh - the source mesh to project.
Returns:
the new projected mesh.

normalizeMeshes

protected void normalizeMeshes()
Normalizes all the mesh objects into viewplane coordinates
Overrides:
normalizeMeshes in class FlatRenderer
See Also:
FlatRenderer.projectedMeshes

initPolygonTable

protected void initPolygonTable()
Initializes the polygon table with PolygonInfoEx instances using the current meshes in projectedMeshes.
Overrides:
initPolygonTable in class FlatRenderer
See Also:
FlatRenderer.projectedMeshes, FlatRenderer.polygonTable, FlatRenderer.PolygonInfo

fillPixels

protected void fillPixels(FlatRenderer.PolygonInfo info,
                          FlatRenderer.ActiveEdgeTable AET,
                          int xmin,
                          int y)
Fills a line of pixels from the AET. Updates depthBuffer and colorBuffer.
Overrides:
fillPixels in class FlatRenderer
Parameters:
AET - the current active-edge table.
g - the drawing surface.
xmin - the minimum x-coordinate.
y - the current y-coordinate of the line.
See Also:
FlatRenderer.depthBuffer, FlatRenderer.colorBuffer