qfiles.h File Reference

Header for various formats like pak, and model formats as well as bsp format. More...

#include "../shared/defines.h"
#include "unzip.h"
Include dependency graph for qfiles.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dMD2Coord_t
 These two shorts are used to map a vertex onto a skin The horizontal axis position is given by s, and the vertical axis position is given by t. The ranges for s and t are greater than or equal to 0 and less than skinWidth and skinHeight. More...
struct  dMD2Triangle_t
struct  dMD2TriangleVertex_t
struct  dAliasFrame_s
 is a variable sized structure, however all frame_t structures within the same file will have the same size (numVertices in the header) More...
struct  dMD2Model_t
 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. More...
struct  dMD2tag_t
 Tag file header structure - 32 byte A tag for a model must have the same amount of frames as the model. A tag is nothing more than a coordinate. It's used to e.g. determine the hand of a model when the walking animation is played. The renderer has to know where to place the weapon. More...
struct  dmd3coord_t
struct  dmd3vertex_t
struct  dmd3frame_t
struct  dorientation_t
struct  dmd3tag_t
struct  dmd3skin_t
struct  dmd3mesh_t
struct  dmd3_t
struct  dpmheader_s
 type 2 model (hierarchical skeletal pose) within this specification, int is assumed to be 32bit, float is assumed to be 32bit, char is assumed to be 8bit, text is assumed to be an array of chars with NULL termination all values are big endian (also known as network byte ordering), NOT x86 little endian More...
struct  dpmmesh_s
 there may be more than one of these More...
struct  dpmbone_s
 one per bone More...
struct  dpmbonepose_s
 a bonepose matrix is intended to be used like this: (n = output vertex, v = input vertex, m = matrix, f = influence) n[0] = v[0] * m[0][0] + v[1] * m[0][1] + v[2] * m[0][2] + f * m[0][3]; n[1] = v[0] * m[1][0] + v[1] * m[1][1] + v[2] * m[1][2] + f * m[1][3]; n[2] = v[0] * m[2][0] + v[1] * m[2][1] + v[2] * m[2][2] + f * m[2][3]; More...
struct  dpmframe_s
 immediately followed by bone positions for the frame More...
struct  dpmbonevert_s
 one or more of these per vertex More...
struct  dpmvertex_s
 variable size, parsed sequentially More...
struct  lump_t
 Directory of the different data blocks. More...
struct  dBspHeader_t
 The BSP header definition with the data block directory. More...

Defines

#define IDMDXHEADER   "UFOMDX"
#define MDX_VERSION   1
#define IDALIASHEADER   (('2'<<24)+('P'<<16)+('D'<<8)+'I')
#define IDTAGHEADER   (('2'<<24)+('P'<<16)+('D'<<8)+'J')
#define MD2_ALIAS_VERSION   8
#define TAG_VERSION   1
#define MD2_MAX_TRIANGLES   4096
#define MD2_MAX_VERTS   2048
#define MD2_MAX_FRAMES   512
#define MD2_MAX_SKINS   32
#define MD2_MAX_SKINNAME   64
#define MD2_MAX_TAGNAME   64
#define IDMD3HEADER   (('3'<<24)+('P'<<16)+('D'<<8)+'I')
#define MD3_ALIAS_VERSION   15
#define MD3_ALIAS_MAX_LODS   4
#define MD3_MAX_TRIANGLES   8192
#define MD3_MAX_VERTS   4096
#define MD3_MAX_SHADERS   256
#define MD3_MAX_FRAMES   1024
#define MD3_MAX_MESHES   32
#define MD3_MAX_TAGS   16
#define MD3_MAX_PATH   64
#define MD3_XYZ_SCALE   (1.0f/64.0f)
#define DPMHEADER   (('K'<<24)+('R'<<16)+('A'<<8)+'D')
#define DPMBONEFLAG_ATTACHMENT   1
 if set on a bone, it must be protected from removal
#define IDBSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'I')
#define BSPVERSION   78

Typedefs

typedef struct dAliasFrame_s dMD2Frame_t
 is a variable sized structure, however all frame_t structures within the same file will have the same size (numVertices in the header)
typedef struct dpmheader_s dpmheader_t
 type 2 model (hierarchical skeletal pose) within this specification, int is assumed to be 32bit, float is assumed to be 32bit, char is assumed to be 8bit, text is assumed to be an array of chars with NULL termination all values are big endian (also known as network byte ordering), NOT x86 little endian
typedef struct dpmmesh_s dpmmesh_t
 there may be more than one of these
typedef struct dpmbone_s dpmbone_t
 one per bone
typedef struct dpmbonepose_s dpmbonepose_t
 a bonepose matrix is intended to be used like this: (n = output vertex, v = input vertex, m = matrix, f = influence) n[0] = v[0] * m[0][0] + v[1] * m[0][1] + v[2] * m[0][2] + f * m[0][3]; n[1] = v[0] * m[1][0] + v[1] * m[1][1] + v[2] * m[1][2] + f * m[1][3]; n[2] = v[0] * m[2][0] + v[1] * m[2][1] + v[2] * m[2][2] + f * m[2][3];
typedef struct dpmframe_s dpmframe_t
 immediately followed by bone positions for the frame
typedef struct dpmbonevert_s dpmbonevert_t
 one or more of these per vertex
typedef struct dpmvertex_s dpmvertex_t
 variable size, parsed sequentially

Detailed Description

Header for various formats like pak, and model formats as well as bsp format.

Note:
This file must be identical in the quake and utils directories
The .pk3 files are just zip files
quake file formats: md2, md3, pk3, bsp

Definition in file qfiles.h.


Define Documentation

#define BSPVERSION   78

Definition at line 373 of file qfiles.h.

Referenced by CheckBSPFile(), CM_AddMapTile(), LoadBSPFile(), R_ModAddMapTile(), and WriteBSPFile().

#define DPMBONEFLAG_ATTACHMENT   1

if set on a bone, it must be protected from removal

Definition at line 317 of file qfiles.h.

#define DPMHEADER   (('K'<<24)+('R'<<16)+('A'<<8)+'D')

Definition at line 252 of file qfiles.h.

Referenced by LoadModel(), ModelWorker(), R_ModForName(), and SV_LoadModelMinsMaxs().

#define IDALIASHEADER   (('2'<<24)+('P'<<16)+('D'<<8)+'I')

Definition at line 42 of file qfiles.h.

Referenced by LoadModel(), ModelWorker(), R_ModForName(), and SV_LoadModelMinsMaxs().

#define IDBSPHEADER   (('P'<<24)+('S'<<16)+('B'<<8)+'I')

little-endian "IBSP"

Definition at line 371 of file qfiles.h.

Referenced by CheckBSPFile(), LoadBSPFile(), ModelWorker(), R_ModForName(), and WriteBSPFile().

#define IDMD3HEADER   (('3'<<24)+('P'<<16)+('D'<<8)+'I')
#define IDMDXHEADER   "UFOMDX"

Definition at line 35 of file qfiles.h.

Referenced by R_ModLoadMDX(), and WriteToFile().

#define IDTAGHEADER   (('2'<<24)+('P'<<16)+('D'<<8)+'J')

Definition at line 43 of file qfiles.h.

#define MD2_ALIAS_VERSION   8

Definition at line 44 of file qfiles.h.

Referenced by MD2HeaderCheck(), and R_ModLoadAliasMD2Mesh().

#define MD2_MAX_FRAMES   512

Definition at line 49 of file qfiles.h.

Referenced by R_ModLoadAliasMD2Model().

#define MD2_MAX_SKINNAME   64
#define MD2_MAX_SKINS   32
#define MD2_MAX_TAGNAME   64

Definition at line 52 of file qfiles.h.

Referenced by R_GetTagMatrix().

#define MD2_MAX_TRIANGLES   4096
#define MD2_MAX_VERTS   2048
#define MD3_ALIAS_MAX_LODS   4

Definition at line 164 of file qfiles.h.

#define MD3_ALIAS_VERSION   15

Definition at line 163 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_FRAMES   1024

Definition at line 169 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_MESHES   32

Definition at line 170 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_PATH   64

Definition at line 172 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_SHADERS   256

Definition at line 168 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_TAGS   16

Definition at line 171 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_TRIANGLES   8192

Definition at line 166 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_MAX_VERTS   4096

Definition at line 167 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MD3_XYZ_SCALE   (1.0f/64.0f)

vertex scales

Definition at line 175 of file qfiles.h.

Referenced by R_ModLoadAliasMD3Model().

#define MDX_VERSION   1

Definition at line 36 of file qfiles.h.

Referenced by R_ModLoadMDX(), and WriteToFile().

#define TAG_VERSION   1

Definition at line 45 of file qfiles.h.

Referenced by R_ModLoadTags().


Typedef Documentation

typedef struct dAliasFrame_s dMD2Frame_t

is a variable sized structure, however all frame_t structures within the same file will have the same size (numVertices in the header)

typedef struct dpmbone_s dpmbone_t

one per bone

typedef struct dpmbonepose_s dpmbonepose_t

a bonepose matrix is intended to be used like this: (n = output vertex, v = input vertex, m = matrix, f = influence) n[0] = v[0] * m[0][0] + v[1] * m[0][1] + v[2] * m[0][2] + f * m[0][3]; n[1] = v[0] * m[1][0] + v[1] * m[1][1] + v[2] * m[1][2] + f * m[1][3]; n[2] = v[0] * m[2][0] + v[1] * m[2][1] + v[2] * m[2][2] + f * m[2][3];

typedef struct dpmbonevert_s dpmbonevert_t

one or more of these per vertex

typedef struct dpmframe_s dpmframe_t

immediately followed by bone positions for the frame

typedef struct dpmheader_s dpmheader_t

type 2 model (hierarchical skeletal pose) within this specification, int is assumed to be 32bit, float is assumed to be 32bit, char is assumed to be 8bit, text is assumed to be an array of chars with NULL termination all values are big endian (also known as network byte ordering), NOT x86 little endian

Note:
general notes: a pose is a 3x4 matrix (rotation matrix, and translate vector) parent bones must always be lower in number than their children, models will be rejected if this is not obeyed (can be fixed by modelling utilities)
utility notes: if a hard edge is desired (faceted lighting, or a jump to another set of skin coordinates), vertices must be duplicated ability to visually edit groupids of triangles is highly recommended bones should be markable as 'attach' somehow (up to the utility) and thus protected from culling of unused resources frame 0 is always the base pose (the one the skeleton was built for)
game notes: the loader should be very thorough about error checking, all vertex and bone indices should be validated, etc the gamecode can look up bone numbers by name using a builtin function, for use in attachment situations (the client should have the same model as the host of the gamecode in question - that is to say if the server gamecode is setting the bone number, the client and server must have vaguely compatible models so the client understands, and if the client gamecode is setting the bone number, the server could have a completely different model with no harm done) the triangle groupid values are up to the gamecode, it is recommended that gamecode process this in an object-oriented fashion (I.E. bullet hits entity, call that entity's function for getting properties of that groupid) frame 0 should be usable, not skipped speed optimizations for the saver to do: remove all unused data (unused bones, vertices, etc, be sure to check if bones are used for attachments however) sort triangles into strips sort vertices according to first use in a triangle (caching benefits) after sorting triangles speed optimizations for the loader to do: if the model only has one frame, process it at load time to create a simple static vertex mesh to render (this is a hassle, but it is rewarding to optimize all such models)
rendering process: 1*. one or two poses are looked up by number 2*. boneposes (matrices) are interpolated, building bone matrix array 3. bones are parsed sequentially, each bone's matrix is transformed by it's parent bone (which can be -1; the model to world matrix) 4. meshs are parsed sequentially, as follows: 1. vertices are parsed sequentially and may be influenced by more than one bone (the results of the 3x4 matrix transform will be added together - weighting is already built into these) 2. shader is looked up and called, passing vertex buffer (temporary) and triangle indices (which are stored in the mesh) 5. rendering is complete
  • these stages can be replaced with completely dynamic animation instead of pose animations. header for the entire file
typedef struct dpmmesh_s dpmmesh_t

there may be more than one of these

typedef struct dpmvertex_s dpmvertex_t

variable size, parsed sequentially


Generated by  doxygen 1.6.2