home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-11-17 | 1.6 KB | 48 lines |
- // Skin for an MDL file from Quake
-
- // Written by Bernie Roehl, November 1996
-
- package quake;
-
- import java.io.*;
-
- public class Skin {
- protected int height, width;
- protected int npictures;
- protected float[] times;
- protected byte[][] pixels;
-
- public int getHeight() { return height; }
- public int getWidth() { return width; }
- public int getNumberOfPictures() { return npictures; }
- public float getTime(int n) { return times[n]; }
- public byte[] getPicture(int n) { return pixels[n]; }
-
- public byte getPixel(int picture, int horiz, int vert) {
- return pixels[picture][vert * width + horiz];
- }
-
- public Skin(ByteFlipInputStream input, int w, int h) throws IOException {
- height = h;
- width = w;
- if (input.readFlippedInt() == 0) {
- npictures = 1;
- times = new float[1];
- times[0] = 0;
- pixels = new byte[1][height*width];
- input.read(pixels[0]);
- }
- else {
- npictures = input.readFlippedInt();
- times = new float[npictures];
- for (int i = 0; i < npictures; ++i)
- times[i] = input.readFlippedFloat();
- pixels = new byte[npictures][height*width];
- for (int i = 0; i < npictures; ++i)
- input.read(pixels[i]);
- }
- }
- }
-
-
-