home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch13 / hash / Spline.java < prev    next >
Text File  |  1996-11-19  |  1KB  |  34 lines

  1. // An AnimationMaster Spline curve
  2.  
  3. // Written by Bernie Roehl, November 1996
  4.  
  5. package hash;
  6.  
  7. import java.io.*;
  8.  
  9. public class Spline {
  10.         protected int npoints;
  11.         protected ControlPoint[] points;
  12.  
  13.         public int getNumberOfControlPoints() { return npoints; }
  14.         public ControlPoint getControlPoint(int n) { return points[n]; }
  15.  
  16.         public void dump() {
  17.                 System.out.println("Spline: " + npoints + " points");
  18.                 for (int i = 0; i < npoints; ++i) {
  19.                         System.out.println("  Point " + i + ":");
  20.                         points[i].dump();
  21.                         System.out.println();
  22.                 }
  23.         }
  24.  
  25.         public Spline(DataInputStream input)
  26.                 throws IOException, HashSyntaxException {
  27.                 npoints = Integer.parseInt(input.readLine());
  28.                 points = new ControlPoint[npoints];
  29.                 for (int i = 0; i < npoints; ++i)
  30.                         points[i] = new ControlPoint(input);
  31.         }
  32. }
  33.  
  34.