/* =========================================================================== maya2q3 - export .md3 files from maya Copyright (C) 2005 HermitWorks Entertainment Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of 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 of MERCHANTABILITY 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 License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. =========================================================================== */ #ifndef INC__q3types_h_ #define INC__q3types_h_ //this file mirrors the types used in the q3 engine... //keep these in sync!! namespace q3 { //============================================================================= // // Snipped out of qfiles.h - KEEP IN SYNC // Note: defines turned into static const *** to minimize namespace pollution // q3 types changed to exporter util equivalents where appropriate. // // All the types that support regular Quake 3 go here. Types for our extensions // to the Quake 3 engine have a home further down (look for the big block comment). // //============================================================================= // surface geometry should not exceed these limits const size_t SHADER_MAX_VERTEXES = 2500; const size_t SHADER_MAX_INDEXES = SHADER_MAX_VERTEXES * 6; // the maximum size of game relative pathnames const size_t MAX_QPATH = 64; typedef sstr< MAX_QPATH > qname; /* * MD3 types and constants... * */ const int MD3_IDENT = ('3' << 24) | ('P' << 16) | ('D' << 8) | 'I'; const int MD3_VERSION = 15; // limits const size_t MD3_MAX_LODS = 3; const size_t MD3_MAX_TRIANGLES = 8192; // per surface const size_t MD3_MAX_VERTS = 4096; // per surface const size_t MD3_MAX_SHADERS = 256; // per surface const size_t MD3_MAX_FRAMES = 1024; // per model const size_t MD3_MAX_SURFACES = 32; // per model const size_t MD3_MAX_TAGS = 16; // per frame // vertex scales const float MD3_XYZ_INVSCALE = 64.0F; const float MD3_XYZ_SCALE = (1.0f / MD3_XYZ_INVSCALE); typedef vec_s16sb< 3, 64 > md3vec3_t; //keep the 64 here sync'd with MD3_XYZ_INVSCALE! typedef float vec_t; typedef vec2 vec2_t; typedef vec3 vec3_t; typedef vec4 vec4_t; struct affine_t { vec3_t axis[3]; vec3_t origin; }; struct md3Frame_t { vec3_t bounds[2]; vec3_t localOrigin; float radius; sstr< 16 > name; }; struct md3Tag_t { qname name; // tag name vec3_t origin; vec3_t axis[3]; }; /* ** md3Surface_t ** ** CHUNK SIZE ** header sizeof( md3Surface_t ) ** shaders sizeof( md3Shader_t ) * numShaders ** triangles[0] sizeof( md3Triangle_t ) * numTriangles ** st sizeof( md3St_t ) * numVerts ** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames */ struct md3Surface_t { int ident; // qname name; // polyset name int flags; int numFrames; // all surfaces in a model should have the same int numShaders; // all surfaces in a model should have the same int numVerts; int numTriangles; int ofsTriangles; int ofsShaders; // offset from start of md3Surface_t int ofsSt; // texture coords are common for all frames int ofsXyzNormals; // numVerts * numFrames int ofsEnd; // next surface follows }; struct md3Shader_t { qname name; int shaderIndex; // for in-game use }; struct md3Triangle_t { int indexes[3]; }; struct md3St_t { vec2_t st; }; struct md3XyzNormal_t { md3vec3_t xyz; short normal; }; struct md3Header_t { int ident; int version; qname name; // model name int flags; int numFrames; int numTags; int numSurfaces; int numSkins; int ofsFrames; // offset for first frame int ofsTags; // numFrames * numTags int ofsSurfaces; // first surface, others follow int ofsEnd; // end of file }; /* * BSP types and constants... * */ const int BSP_IDENT = ('P' << 24) | ('S' << 16) | ('B' << 8) | 'I'; const int BSP_VERSION = 46; const int LUMP_ENTITIES = 0; const int LUMP_SHADERS = 1; const int LUMP_PLANES = 2; const int LUMP_NODES = 3; const int LUMP_LEAFS = 4; const int LUMP_LEAFSURFACES = 5; const int LUMP_LEAFBRUSHES = 6; const int LUMP_MODELS = 7; const int LUMP_BRUSHES = 8; const int LUMP_BRUSHSIDES = 9; const int LUMP_DRAWVERTS = 10; const int LUMP_DRAWINDEXES = 11; const int LUMP_FOGS = 12; const int LUMP_SURFACES = 13; const int LUMP_LIGHTMAPS = 14; const int LUMP_LIGHTGRID = 15; const int LUMP_VISIBILITY = 16; const int HEADER_LUMPS = 17; const int MAX_MAP_MODELS = 0x400; const int MAX_MAP_BRUSHES = 0x8000; const int MAX_MAP_ENTITIES = 0x800; const int MAX_MAP_ENTSTRING = 0x40000; const int MAX_MAP_SHADERS = 0x400; const int MAX_MAP_AREAS = 0x100; const int MAX_MAP_FOGS = 0x100; const int MAX_MAP_PLANES = 0x20000; const int MAX_MAP_NODES = 0x20000; const int MAX_MAP_BRUSHSIDES = 0x20000; const int MAX_MAP_LEAFS = 0x20000; const int MAX_MAP_LEAFFACES = 0x20000; const int MAX_MAP_LEAFBRUSHES = 0x40000; const int MAX_MAP_PORTALS = 0x20000; const int MAX_MAP_LIGHTING = 0x800000; const int MAX_MAP_LIGHTGRID = 0x800000; const int MAX_MAP_VISIBILITY = 0x200000; const int MAX_MAP_DRAW_SURFS = 0x20000; const int MAX_MAP_DRAW_VERTS = 0x80000; const int MAX_MAP_DRAW_INDEXES = 0x80000; // key / value pair sizes in the entities lump const int MAX_KEY = 32; const int MAX_VALUE = 1024; // the editor uses these predefined yaw angles to orient entities up or down const int ANGLE_UP = -1; const int ANGLE_DOWN = -2; const int LIGHTMAP_WIDTH = 128; const int LIGHTMAP_HEIGHT = 128; const int MAX_WORLD_COORD = 128 * 1024; const int MIN_WORLD_COORD = -128 * 1024; const int WORLD_SIZE = MAX_WORLD_COORD - MIN_WORLD_COORD; struct lump_t { int fileofs; int filelen; }; struct dheader_t { int ident; int version; lump_t lumps[HEADER_LUMPS]; }; struct dmodel_t { vec3_t mins, maxs; int firstSurface, numSurfaces; int firstBrush, numBrushes; }; struct dshader_t { qname shader; int surfaceFlags; int contentFlags; }; // planes x^1 is allways the opposite of plane x struct dplane_t { vec3 normal; float dist; }; struct dnode_t { int planeNum; int children[2]; // negative numbers are -(leafs+1), not nodes int mins[3]; // for frustom culling int maxs[3]; }; struct dleaf_t { int cluster; // -1 = opaque cluster (do I still store these?) int area; int mins[3]; // for frustum culling int maxs[3]; int firstLeafSurface; int numLeafSurfaces; int firstLeafBrush; int numLeafBrushes; }; struct dbrushside_t { int planeNum; // positive plane side faces out of the leaf int shaderNum; }; struct dbrush_t { int firstSide; int numSides; int shaderNum; // the shader that determines the contents flags }; struct dfog_t { char shader[MAX_QPATH]; int brushNum; int visibleSide; // the brush side that ray tests need to clip against (-1 == none) }; struct drawVert_t { vec3_t xyz; vec2_t st; vec2_t lightmap; vec3_t normal; byte color[4]; }; enum mapSurfaceType_t { MST_BAD, MST_PLANAR, MST_PATCH, MST_TRIANGLE_SOUP, MST_FLARE }; struct dsurface_t { int shaderNum; int fogNum; int surfaceType; int firstVert; int numVerts; int firstIndex; int numIndexes; int lightmapNum; int lightmapX, lightmapY; int lightmapWidth, lightmapHeight; vec3_t lightmapOrigin; vec3_t lightmapVecs[3]; // for patches, [0] and [1] are lodbounds int patchWidth; int patchHeight; }; //============================================================================= // // Here be Dragons! // // The following code is for Hermitworks extensions to the // standard Quake 3 engine release. // // Everything beyond this point is an extension to the released Quake 3 engine // code. None of it is standard Quake 3. You will not find this stuff in the // Quake 3 release from ID. Have I repeated this enough? If you want the runtime // for this stuff you'll have to wait until we release our engine code. // // You have been warned! // //============================================================================= //tangent basis info for extended MD3 struct md3TangentBasis_t { vec3_t tangent; vec3_t binormal; }; #include "../common/x42_file.h" }; #endif