mr3d.visualization
Class ZBufferRenderer

java.lang.Object
  extended bymr3d.visualization.ZBufferRenderer
All Implemented Interfaces:
Debugable, Renderer

public class ZBufferRenderer
extends java.lang.Object
implements Renderer, Debugable

Renders an image of the 3D-scene using a scan-line based z-buffer algorithm.

Since:
MR3Dv1.0
Version:
12-2004
Author:
Manuel Ruelke

Nested Class Summary
private  class ZBufferRenderer.Edge
          Stores the information of an 2D-edge with additional information about the z-components.
 
Field Summary
(package private)  java.util.Vector[] scanlines
          Stores edges of the scanlines.
 
Fields inherited from interface mr3d.debug.Debugable
ERROR_INT, ERROR_STRING
 
Constructor Summary
ZBufferRenderer()
          Creates a new ZBufferRenderer.
 
Method Summary
private  void addTriangle(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int colorCode)
          Splits the triangle defined by the specified values into horizontal lines and creates Edge-objects with the calculated values.
 void render(Graphics g)
          This method starts the render process.
 void toConsole()
          Prints the contents of the object to the Java console.
 void toConsole(java.lang.String msgString)
          Prints the contents of the object to the Java console together with an information string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scanlines

java.util.Vector[] scanlines
Stores edges of the scanlines.

Constructor Detail

ZBufferRenderer

public ZBufferRenderer()
Creates a new ZBufferRenderer.

Method Detail

addTriangle

private void addTriangle(int x1,
                         int y1,
                         int z1,
                         int x2,
                         int y2,
                         int z2,
                         int x3,
                         int y3,
                         int z3,
                         int colorCode)
Splits the triangle defined by the specified values into horizontal lines and creates Edge-objects with the calculated values. The Edge-objects are stored in the vector of the scanline-Vector at the corresponding position.

Parameters:
x1 - x-coordinate of point 1
y1 - y-coordinate of point 1
x2 - x-coordinate of point 2
y2 - y-coordinate of point 2
x3 - x-coordinate of point 3
y3 - y-coordinate of point 3
colorCode - color the triangle should be drawn with

render

public void render(Graphics g)
Description copied from interface: Renderer
This method starts the render process. The image data is written to the specified graphics object.

Specified by:
render in interface Renderer
Parameters:
g - Graphics object the image should be rendered to

toConsole

public void toConsole()
Description copied from interface: Debugable
Prints the contents of the object to the Java console. How the information will be displayed depends on what data the object contains. Depending on structure and contents every implementation of this function produces a different result on the console.

Specified by:
toConsole in interface Debugable

toConsole

public void toConsole(java.lang.String msgString)
Description copied from interface: Debugable
Prints the contents of the object to the Java console together with an information string. How the information will be displayed depends on what data the object contains. Depending on structure and contents every implementation of this function produces a different result on the console.

Specified by:
toConsole in interface Debugable