001/*
002
003*/
004
005package renderer.models;
006import  renderer.scene.*;
007
008import java.awt.Color;
009
010/**
011   Create a flat wireframe checkerboard panel in the xz-plane.
012*/
013public class Panel extends Model
014{
015   /**
016      Create a flat checkerboard panel in the xz-plane that runs
017      from -1 to 1 in the z-direction and -1 to 1 in the x-direction.
018   */
019   public Panel( )
020   {
021      this(-1, 1, -1, 1);
022   }
023
024
025   /**
026      Create a flat checkerboard panel in the xz-plane with the given dimensions.
027
028      @param xMin  location of left edge
029      @param xMax  location of right edge
030      @param zMin  location of back edge
031      @param zMax  location of front edge
032   */
033   public Panel(int xMin, int xMax, int zMin, int zMax)
034   {
035      super();
036
037      // Create the checkerboard panel's geometry.
038
039      // An array of vertices to be used to create line segments.
040      Vertex[][] v = new Vertex[(xMax-xMin)+1][(zMax-zMin)+1];
041
042      // Create the checkerboard of vertices.
043      for (int x = xMin; x <= xMax; x++)
044         for (int z = zMin; z <= zMax; z++)
045         {
046            v[x-xMin][z-zMin] = new Vertex(x, 0, z);
047         }
048
049      // Create the line segments that run in the z-direction.
050      for (int x = 0; x <= xMax-xMin; x++)
051      {
052         for (int z = 0; z < zMax-zMin; z++)
053         {
054            addLineSegment(new LineSegment(new Vertex(v[x][z]), new Vertex(v[x][z+1])));
055         }
056      }
057
058      // Create the line segments that run in the x-direction.
059      for (int z = 0; z <= zMax-zMin; z++)
060      {
061         for (int x = 0; x < xMax-xMin; x++)
062         {
063            addLineSegment(new LineSegment(new Vertex(v[x][z]), new Vertex(v[x+1][z])));
064         }
065      }
066   }
067}//Panel