- Add Inter-Quake Model (IQM) Format support, patch by gimhael with minor modifications by myself (#4965)

- Changed model_t::md4 to model_t::modelData
- Fix R_ModelBounds for MD4, MDR and IQM models (#4966)
- Support Model format fallback similar to image formats in tr_image.c, patch by Zack Middleton (#4967)
This commit is contained in:
Thilo Schulz 2011-05-02 15:50:19 +00:00
parent d34c6b7e0b
commit c5e2654b54
8 changed files with 1299 additions and 140 deletions

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/qcommon.h"
#include "tr_public.h"
#include "qgl.h"
#include "iqm.h"
#define GL_INDEX_TYPE GL_UNSIGNED_INT
typedef unsigned int glIndex_t;
@ -533,6 +534,7 @@ typedef enum {
#ifdef RAVENMD4
SF_MDR,
#endif
SF_IQM,
SF_FLARE,
SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity
SF_DISPLAY_LIST,
@ -639,6 +641,39 @@ typedef struct {
drawVert_t *verts;
} srfTriangles_t;
// inter-quake-model
typedef struct {
int num_vertexes;
int num_triangles;
int num_frames;
int num_surfaces;
int num_joints;
struct srfIQModel_s *surfaces;
float *positions;
float *texcoords;
float *normals;
float *tangents;
byte *blendIndexes;
byte *blendWeights;
byte *colors;
int *triangles;
int *jointParents;
float *poseMats;
float *bounds;
char *names;
} iqmData_t;
// inter-quake-model surface
typedef struct srfIQModel_s {
surfaceType_t surfaceType;
shader_t *shader;
iqmData_t *data;
int first_vertex, num_vertexes;
int first_triangle, num_triangles;
} srfIQModel_t;
extern void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])(void *);
@ -747,19 +782,20 @@ typedef enum {
MOD_MESH,
MOD_MD4,
#ifdef RAVENMD4
MOD_MDR
MOD_MDR,
#endif
MOD_IQM
} modtype_t;
typedef struct model_s {
char name[MAX_QPATH];
modtype_t type;
int index; // model = tr.models[model->index]
int index; // model = tr.models[model->index]
int dataSize; // just for listing purposes
bmodel_t *bmodel; // only if type == MOD_BRUSH
int dataSize; // just for listing purposes
bmodel_t *bmodel; // only if type == MOD_BRUSH
md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH
void *md4; // only if type == (MOD_MD4 | MOD_MDR)
void *modelData; // only if type == (MOD_MD4 | MOD_MDR | MOD_IQM)
int numLods;
} model_t;
@ -1491,6 +1527,12 @@ void RB_SurfaceAnim( md4Surface_t *surfType );
void R_MDRAddAnimSurfaces( trRefEntity_t *ent );
void RB_MDRSurfaceAnim( md4Surface_t *surface );
#endif
qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name );
void R_AddIQMSurfaces( trRefEntity_t *ent );
void RB_IQMSurfaceAnim( surfaceType_t *surface );
int R_IQMLerpTag( orientation_t *tag, iqmData_t *data,
int startFrame, int endFrame,
float frac, const char *tagName );
/*
=============================================================