home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch13 / quake / FrameGroup.java < prev    next >
Text File  |  1996-11-17  |  2KB  |  48 lines

  1. // Frame from an MDL file
  2.  
  3. // Written by Bernie Roehl, November 1996
  4.  
  5. package quake;
  6.  
  7. import java.io.*;
  8.  
  9. public class FrameGroup {
  10.         protected int nsubframes;
  11.         protected Trivertex min, max;
  12.         protected float[] times;
  13.         protected Frame[] subframes;
  14.  
  15.         public int getNumberOfSubFrames() { return nsubframes; }
  16.         public Trivertex getMin() { return min; }
  17.         public Trivertex getMax() { return max; }
  18.         public float getTime(int n) { return times[n]; }
  19.         public Frame getSubFrame(int n) { return subframes[n]; }
  20.  
  21.         public FrameGroup(ByteFlipInputStream input, int nverts)
  22.                 throws IOException {
  23.                 int type = input.readFlippedInt();
  24.                 if (type == 0) {
  25.                         nsubframes = 1;
  26.                         times = new float[1];
  27.                         times[0] = 0;
  28.                         subframes = new Frame[1];
  29.                         subframes[0] = new Frame(input, nverts);
  30.                         min = subframes[0].getMin();
  31.                         max = subframes[0].getMax();
  32.                 }
  33.                 else {
  34.                         nsubframes = input.readInt();
  35.                         min = new Trivertex(input);
  36.                         max = new Trivertex(input);
  37.                         times = new float[nsubframes];
  38.                         for (int i = 0; i < nsubframes; ++i)
  39.                                 times[i] = input.readFlippedFloat();
  40.                         subframes = new Frame[nsubframes];
  41.                         for (int i = 0; i < nsubframes; ++i)
  42.                                 subframes[i] = new Frame(input, nverts);
  43.                 }
  44.         }
  45.  
  46. }
  47.  
  48.