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

  1. // One part of an AnimationMaster Figure
  2.  
  3. // Written by Bernie Roehl, November 1996
  4.  
  5. package hash;
  6.  
  7. import java.io.*;
  8. import java.util.*;
  9.  
  10. public class Part {
  11.         protected String filename;
  12.         protected int drawmode;
  13.         protected Vec3f translation;
  14.         protected Vec3f scale;
  15.         protected Vec3f rotation;
  16.         protected Vec3f pivotRotation;
  17.         protected Float lonmin, lonmax, latmin, latmax;
  18.         protected boolean cutter;
  19.         protected Part child, sibling;
  20.  
  21.         public String getFilename() { return filename; }
  22.         public int getDrawmode() { return drawmode; }
  23.         public Vec3f getTranslation() { return translation; }
  24.         public Vec3f getScale() { return scale; }
  25.         public Vec3f getRotation() { return rotation; }
  26.         public Vec3f getPivotRotation() { return pivotRotation; }
  27.         public float getLongitudeMinimum() { return lonmin.floatValue(); }
  28.         public float getLongitudeMaximum() { return lonmax.floatValue(); }
  29.         public float getLatitudeMinimum() { return latmin.floatValue(); }
  30.         public float getLatitudeMaximum() { return latmax.floatValue(); }
  31.         public Part getChild() { return child; }
  32.         public Part getSibling() { return sibling; }
  33.  
  34.         public void dump(String indent) {
  35.                 System.out.println(indent + "Part '" + filename + "'");
  36.                 System.out.println(indent + "trans = " + translation);
  37.                 System.out.println(indent + "scale = " + scale);
  38.                 System.out.println(indent + "rot = " + rotation);
  39.                 System.out.println(indent + "pivotRotation = " + pivotRotation);
  40.                 System.out.println(indent + "longitude limits = " + lonmin + ", " + lonmax);
  41.                 System.out.println(indent + "latitude limits = " + latmin + ", " + latmax);
  42.                 System.out.println(indent + "cutter = " + cutter);
  43.                 if (child != null) child.dump(indent + "\t");
  44.                 if (sibling != null) sibling.dump(indent);
  45.         }
  46.  
  47.         public Part(DataInputStream input)
  48.                 throws IOException {
  49.                 StringTokenizer s;
  50.                 filename = input.readLine();
  51.                 drawmode = Integer.parseInt(input.readLine());
  52.                 translation = new Vec3f(input.readLine());
  53.                 scale = new Vec3f(input.readLine());
  54.                 rotation = new Vec3f(input.readLine());
  55.                 pivotRotation = new Vec3f(input.readLine());
  56.                 s = new StringTokenizer(input.readLine());
  57.                 lonmin = new Float(s.nextToken());
  58.                 lonmax = new Float(s.nextToken());
  59.                 latmin = new Float(s.nextToken());
  60.                 latmax = new Float(s.nextToken());
  61.                 s.nextToken();  // skip zero
  62.                 cutter = (Integer.parseInt(s.nextToken()) != 0) ? true : false;
  63.                 s = new StringTokenizer(input.readLine());
  64.                 boolean siblings = (Integer.parseInt(s.nextToken()) != 0) ? true: false;
  65.                 boolean children = (Integer.parseInt(s.nextToken()) != 0) ? true: false;
  66.                 if (children) child = new Part(input);
  67.                 if (siblings) sibling = new Part(input);
  68.         }
  69. }
  70.