home games dev
Lewpen.com»Research & Development»3D Graphics»Java 3D Engine»3D Pillars»White Outline (Cartoon Shading)

White Outline (Cartoon Shading)

Using a postprocessing effect which finds outlines using discontinuities in the Z-buffer

/ Source / Shape.java

public class Shape
{
  //---- Data

  Scene scene = null;
  public Transform trans = null;

  int numPoints = 0;

  double[] px, py, pz;

  Vector shapes;

  //---- Main code

  public Shape(Scene sc)
  {
    scene = sc;
    shapes = new Vector();

    trans = new Transform();
    
    px = new double[64];
    py = new double[64];
    pz = new double[64];
  }

  //---- addPoint

  public void addPoint(double x, double y, double z)
  {
    px[numPoints] = x;
    py[numPoints] = y;
    pz[numPoints] = z;

    numPoints ++;
  }

  //---- addShape

  public void addShape(Shape s)
  {
    shapes.addElement(s);
  }

  //---- setTransform
  
  public void setTransform(Transform newtrans)
  {
    this.trans = null;
    this.trans = new Transform(newtrans);
  }

  //---- render

  public void render()
  {
    int i;

    //  Set up transformation

    scene.transform(trans);
        
    //  Render sub-shapes
    
    for(i=0; i<shapes.size(); i++) ((Shape)shapes.elementAt(i)).render();
    
    //  Render this shape
    
    for(i=0; i<numPoints; i++) scene.plotPoint(px[i], py[i], pz[i]);
    
    //  Revert transformation
    
    scene.untransform();
  }
  
}

Comments

Related Articles

Demonstration scene with reflection

Sponsored Links

Toys & Games:

Doggie Doo
Nerf Vortex
Monster High
Lagoona Hydration Station
Milky Bunny
Moshling Tree House
Lego Ninja Go Fire Temple
Fireman Sam Pontypandy Rescue
Rock Elmo
Star Wars Ultimate Force Lightsaber

Games

The Dodge Game
Flatspace

2-Player Games:

Quake 2D
Meteora

Puzzle Games:

Mini Tetris
Sudoku Solver

Development

3D Graphics:

3D Graphics Articles
WebGL Examples
Flash 3D Engine
Java 3D Engine

Development:

Programming Articles
Animation Demos
Game Development Examples

Links

iBuddy Social Network
Local Legends Football
PHP Charts & Graphs
CubeLogix Studios