⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qfiles.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * qfiles.java * Copyright (C) 2003 * * $Id: qfiles.java,v 1.6 2005/05/07 23:40:49 cawe Exp $ *//*Copyright (C) 1997-2001 Id Software, Inc.This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*/package jake2.qcommon;import jake2.Defines;import java.nio.*;/** * qfiles *  * @author cwei */public class qfiles {	//	// qfiles.h: quake file formats	// This file must be identical in the quake and utils directories	//	/*	========================================================================		The .pak files are just a linear collapse of a directory tree		========================================================================	*/	/*	========================================================================		PCX files are used for as many images as possible		========================================================================	*/	public static class pcx_t {		// size of byte arrays		static final int PALETTE_SIZE = 48;		static final int FILLER_SIZE = 58;		public byte manufacturer;		public byte version;		public byte encoding;		public byte bits_per_pixel;		public int xmin, ymin, xmax, ymax; // unsigned short		public int hres, vres; // unsigned short		public byte[] palette; //unsigned byte; size 48		public byte reserved;		public byte color_planes;		public int bytes_per_line; // unsigned short		public int palette_type; // unsigned short		public byte[] filler; // size 58		public ByteBuffer data; //unbounded data		public pcx_t(byte[] dataBytes) {			this(ByteBuffer.wrap(dataBytes));		}		public pcx_t(ByteBuffer b) {			// is stored as little endian			b.order(ByteOrder.LITTLE_ENDIAN);			// fill header			manufacturer = b.get();			version = b.get();			encoding = b.get();			bits_per_pixel = b.get();			xmin = b.getShort() & 0xffff;			ymin = b.getShort() & 0xffff;			xmax = b.getShort() & 0xffff;			ymax = b.getShort() & 0xffff;			hres = b.getShort() & 0xffff;			vres = b.getShort() & 0xffff;			b.get(palette = new byte[PALETTE_SIZE]);			reserved = b.get();			color_planes = b.get();			bytes_per_line = b.getShort() & 0xffff;			palette_type = b.getShort() & 0xffff;			b.get(filler = new byte[FILLER_SIZE]);			// fill data			data = b.slice();		}	}	/*	========================================================================		TGA files are used for sky planes		========================================================================	*/	public static class tga_t {				// targa header		public int id_length, colormap_type, image_type; // unsigned char		public int colormap_index, colormap_length; // unsigned short		public int colormap_size; // unsigned char		public int x_origin, y_origin, width, height; // unsigned short		public int pixel_size, attributes; // unsigned char		public ByteBuffer data; // (un)compressed data		public tga_t(byte[] dataBytes) {			this(ByteBuffer.wrap(dataBytes));		}		public tga_t(ByteBuffer b) {			// is stored as little endian			b.order(ByteOrder.LITTLE_ENDIAN);			// fill header			id_length = b.get() & 0xFF;			colormap_type = b.get() & 0xFF;			image_type = b.get() & 0xFF;			colormap_index = b.getShort() & 0xFFFF;			colormap_length = b.getShort() & 0xFFFF;			colormap_size = b.get() & 0xFF;			x_origin = b.getShort() & 0xFFFF;			y_origin = b.getShort() & 0xFFFF;			width = b.getShort() & 0xFFFF;			height = b.getShort() & 0xFFFF;			pixel_size = b.get() & 0xFF;			attributes = b.get() & 0xFF;			// fill data			data = b.slice();		}				}		/*	========================================================================		.MD2 triangle model file format		========================================================================	*/		public static final int IDALIASHEADER =	(('2'<<24)+('P'<<16)+('D'<<8)+'I');	public static final int ALIAS_VERSION = 8;		public static final int MAX_TRIANGLES = 4096;	public static final int MAX_VERTS = 2048;	public static final int MAX_FRAMES = 512;	public static final int MAX_MD2SKINS = 32;	public static final int MAX_SKINNAME = 64;		public static class dstvert_t {		public short s;		public short t;				public dstvert_t(ByteBuffer b) {			s = b.getShort();			t = b.getShort();		}	}	public static class dtriangle_t {		public short index_xyz[] = { 0, 0, 0 };		public short index_st[] = { 0, 0, 0 };				public dtriangle_t(ByteBuffer b) {			index_xyz[0] = b.getShort();			index_xyz[1] = b.getShort();			index_xyz[2] = b.getShort();						index_st[0] = b.getShort();			index_st[1] = b.getShort();			index_st[2] = b.getShort();		}	}	public static final int DTRIVERTX_V0 =  0;	public static final int DTRIVERTX_V1 = 1;	public static final int DTRIVERTX_V2 = 2;	public static final int DTRIVERTX_LNI = 3;	public static final int DTRIVERTX_SIZE = 4;		public static class  daliasframe_t {		public float[] scale = {0, 0, 0}; // multiply byte verts by this		public float[] translate = {0, 0, 0};	// then add this		public String name; // frame name from grabbing (size 16)		public int[] verts;	// variable sized				public daliasframe_t(ByteBuffer b) {			scale[0] = b.getFloat();	scale[1] = b.getFloat();	scale[2] = b.getFloat();			translate[0] = b.getFloat(); translate[1] = b.getFloat(); translate[2] = b.getFloat();			byte[] nameBuf = new byte[16];			b.get(nameBuf);			name = new String(nameBuf).trim();		}	}		//	   the glcmd format:	//	   a positive integer starts a tristrip command, followed by that many	//	   vertex structures.	//	   a negative integer starts a trifan command, followed by -x vertexes	//	   a zero indicates the end of the command list.	//	   a vertex consists of a floating point s, a floating point t,	//	   and an integer vertex index.		public static class dmdl_t {		public int ident;		public int version;		public int skinwidth;		public int skinheight;		public int framesize; // byte size of each frame		public int num_skins;		public int num_xyz;		public int num_st; // greater than num_xyz for seams		public int num_tris;		public int num_glcmds; // dwords in strip/fan command list		public int num_frames;		public int ofs_skins; // each skin is a MAX_SKINNAME string		public int ofs_st; // byte offset from start for stverts		public int ofs_tris; // offset for dtriangles		public int ofs_frames; // offset for first frame		public int ofs_glcmds;		public int ofs_end; // end of file				// wird extra gebraucht		public String[] skinNames;		public dstvert_t[] stVerts;		public dtriangle_t[] triAngles;		public int[] glCmds;		public daliasframe_t[] aliasFrames;						public dmdl_t(ByteBuffer b) {			ident = b.getInt();			version = b.getInt();			skinwidth = b.getInt();			skinheight = b.getInt();			framesize = b.getInt(); // byte size of each frame			num_skins = b.getInt();			num_xyz = b.getInt();			num_st = b.getInt(); // greater than num_xyz for seams			num_tris = b.getInt();			num_glcmds = b.getInt(); // dwords in strip/fan command list			num_frames = b.getInt();			ofs_skins = b.getInt(); // each skin is a MAX_SKINNAME string			ofs_st = b.getInt(); // byte offset from start for stverts			ofs_tris = b.getInt(); // offset for dtriangles			ofs_frames = b.getInt(); // offset for first frame			ofs_glcmds = b.getInt();			ofs_end = b.getInt(); // end of file		}		/*		 * new members for vertex array handling		 */		public FloatBuffer textureCoordBuf = null;		public IntBuffer vertexIndexBuf = null;		public int[] counts = null;		public IntBuffer[] indexElements = null;	}		/*	========================================================================		.SP2 sprite file format		========================================================================	*/	// little-endian "IDS2"	public static final int IDSPRITEHEADER = (('2'<<24)+('S'<<16)+('D'<<8)+'I');	public static final int SPRITE_VERSION = 2;	public static class dsprframe_t {		public int width, height;		public int origin_x, origin_y; // raster coordinates inside pic		public String name; // name of pcx file (MAX_SKINNAME)				public dsprframe_t(ByteBuffer b) {			width = b.getInt();			height = b.getInt();			origin_x = b.getInt();			origin_y = b.getInt();						byte[] nameBuf = new byte[MAX_SKINNAME];			b.get(nameBuf);			name = new String(nameBuf).trim();		}	}	public static class dsprite_t {		public int ident;		public int version;		public int numframes;		public dsprframe_t frames[]; // variable sized				public dsprite_t(ByteBuffer b) {			ident = b.getInt();			version = b.getInt();			numframes = b.getInt();						frames = new dsprframe_t[numframes];			for (int i=0; i < numframes; i++) {				frames[i] = new dsprframe_t(b);				}		}	}		/*	==============================================================================		  .WAL texture file format		==============================================================================	*/	public static class miptex_t {		static final int MIPLEVELS = 4;		static final int NAME_SIZE = 32;		public String name; // char name[32];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -