* Applied Thilo Schulz's MDR patch

This commit is contained in:
Tim Angus 2005-09-23 17:08:25 +00:00
parent 2b8395a4d0
commit 4c6f59c541
9 changed files with 1149 additions and 74 deletions

View file

@ -299,6 +299,130 @@ typedef struct {
int ofsEnd; // end of file
} md4Header_t;
/*
* Here are the definitions for Ravensoft's model format of md4. Raven stores their
* playermodels in .mdr files, in some games, which are pretty much like the md4
* format implemented by ID soft. It seems like ID's original md4 stuff is not used at all.
* MDR is being used in EliteForce, JediKnight2 and Soldiers of Fortune2 (I think).
* So this comes in handy for anyone who wants to make it possible to load player
* models from these games.
* This format has bone tags, which is similar to the thing you have in md3 I suppose.
* Raven has released their version of md3view under GPL enabling me to add support
* to this codebase. Thanks to Steven Howes aka Skinner for helping with example
* source code.
*
* - Thilo Schulz (arny@ats.s.bawue.de)
*/
// If you want to enable support for Raven's .mdr / md4 format, uncomment the next
// line.
//#define RAVENMD4
#ifdef RAVENMD4
#define MDR_IDENT (('5'<<24)+('M'<<16)+('D'<<8)+'R')
#define MDR_VERSION 2
#define MDR_MAX_BONES 128
typedef struct {
int boneIndex; // these are indexes into the boneReferences,
float boneWeight; // not the global per-frame bone list
vec3_t offset;
} mdrWeight_t;
typedef struct {
vec3_t normal;
vec2_t texCoords;
int numWeights;
mdrWeight_t weights[1]; // variable sized
} mdrVertex_t;
typedef struct {
int indexes[3];
} mdrTriangle_t;
typedef struct {
int ident;
char name[MAX_QPATH]; // polyset name
char shader[MAX_QPATH];
int shaderIndex; // for in-game use
int ofsHeader; // this will be a negative number
int numVerts;
int ofsVerts;
int numTriangles;
int ofsTriangles;
// Bone references are a set of ints representing all the bones
// present in any vertex weights for this surface. This is
// needed because a model may have surfaces that need to be
// drawn at different sort times, and we don't want to have
// to re-interpolate all the bones for each surface.
int numBoneReferences;
int ofsBoneReferences;
int ofsEnd; // next surface follows
} mdrSurface_t;
typedef struct {
float matrix[3][4];
} mdrBone_t;
typedef struct {
vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
vec3_t localOrigin; // midpoint of bounds, used for sphere cull
float radius; // dist from localOrigin to corner
char name[16];
mdrBone_t bones[1]; // [numBones]
} mdrFrame_t;
typedef struct {
unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
} mdrCompBone_t;
typedef struct {
vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
vec3_t localOrigin; // midpoint of bounds, used for sphere cull
float radius; // dist from localOrigin to corner
mdrCompBone_t bones[1]; // [numBones]
} mdrCompFrame_t;
typedef struct {
int numSurfaces;
int ofsSurfaces; // first surface, others follow
int ofsEnd; // next lod follows
} mdrLOD_t;
typedef struct {
int boneIndex;
char name[32];
} mdrTag_t;
typedef struct {
int ident;
int version;
char name[MAX_QPATH]; // model name
// frames and bones are shared by all levels of detail
int numFrames;
int numBones;
int ofsFrames; // mdrFrame_t[numFrames]
// each level of detail has completely separate sets of surfaces
int numLODs;
int ofsLODs;
int numTags;
int ofsTags;
int ofsEnd; // end of file
} mdrHeader_t;
#endif
/*
==============================================================================