2014-11-22 12:32:56 +00:00
|
|
|
#ifndef mdsprite_h_
|
|
|
|
# define mdsprite_h_
|
2008-05-05 09:05:07 +00:00
|
|
|
|
2013-02-07 21:01:24 +00:00
|
|
|
#ifdef USE_OPENGL
|
2009-08-09 05:32:17 +00:00
|
|
|
#include "hightile.h"
|
2020-05-24 17:12:22 +00:00
|
|
|
#include "glbackend/gl_hwtexture.h"
|
2009-08-09 05:32:17 +00:00
|
|
|
|
2019-10-19 23:42:51 +00:00
|
|
|
#if defined(_M_IX86) || defined(_M_AMD64) || defined(__i386) || defined(__x86_64)
|
|
|
|
#define SHIFTMOD32(a) (a)
|
|
|
|
#else
|
2008-05-05 09:05:07 +00:00
|
|
|
#define SHIFTMOD32(a) ((a)&31)
|
2019-10-19 23:42:51 +00:00
|
|
|
#endif
|
2008-05-05 09:05:07 +00:00
|
|
|
|
2014-09-30 04:18:43 +00:00
|
|
|
#define IDP2_MAGIC 0x32504449
|
|
|
|
#define IDP3_MAGIC 0x33504449
|
|
|
|
|
2020-05-25 21:59:07 +00:00
|
|
|
class FGameTexture;
|
2020-05-24 19:19:33 +00:00
|
|
|
class FHardwareTexture;
|
2019-09-18 18:44:21 +00:00
|
|
|
|
2019-10-18 12:04:32 +00:00
|
|
|
struct mdmodel_t
|
2008-05-05 09:05:07 +00:00
|
|
|
{
|
2019-10-18 12:04:32 +00:00
|
|
|
int32_t mdnum, shadeoff;
|
|
|
|
float scale, bscale, zadd, yoffset;
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture *texture;
|
2019-10-18 12:04:32 +00:00
|
|
|
|
|
|
|
int32_t flags;
|
|
|
|
};
|
|
|
|
|
2019-10-18 17:06:57 +00:00
|
|
|
struct mdanim_t
|
|
|
|
{
|
|
|
|
int32_t startframe, endframe;
|
|
|
|
int32_t fpssc, flags;
|
|
|
|
mdanim_t* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mdskinmap_t
|
|
|
|
{
|
|
|
|
uint8_t palette, flags, filler[2]; // Build palette number, flags the same as hightiles
|
|
|
|
int32_t skinnum, surfnum; // Skin identifier, surface number
|
2020-05-24 19:19:33 +00:00
|
|
|
FTextureID texture;
|
2019-10-18 17:06:57 +00:00
|
|
|
mdskinmap_t* next;
|
|
|
|
float param, specpower, specfactor;
|
|
|
|
};
|
|
|
|
|
2019-10-18 12:04:32 +00:00
|
|
|
struct idmodel_t : public mdmodel_t
|
|
|
|
{
|
|
|
|
int32_t numframes, cframe, nframe, fpssc, usesalpha;
|
|
|
|
float oldtime, curtime, interpol;
|
|
|
|
mdanim_t *animations;
|
|
|
|
mdskinmap_t *skinmap;
|
|
|
|
int32_t numskins, skinloaded;
|
|
|
|
};
|
2008-05-05 09:05:07 +00:00
|
|
|
|
|
|
|
#define MDANIM_LOOP 0
|
|
|
|
#define MDANIM_ONESHOT 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//This MD2 code is based on the source code from David Henry (tfc_duke(at)hotmail.com)
|
|
|
|
// Was at http://tfc.duke.free.fr/us/tutorials/models/md2.htm
|
|
|
|
// Available from http://web.archive.org/web/20030816010242/http://tfc.duke.free.fr/us/tutorials/models/md2.htm
|
|
|
|
// Now at http://tfc.duke.free.fr/coding/md2.html (in French)
|
|
|
|
//He probably wouldn't recognize it if he looked at it though :)
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8
|
|
|
|
int32_t numskins, numverts, numuv, numtris, numglcmds, numframes;
|
|
|
|
int32_t ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each)
|
2008-05-05 09:05:07 +00:00
|
|
|
} md2head_t;
|
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
typedef struct { uint8_t v[3], ni; } md2vert_t; //compressed vertex coords (x,y,z)
|
2008-05-05 09:05:07 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2014-09-30 04:18:43 +00:00
|
|
|
vec3f_t mul, add; //scale&translation vector
|
2008-05-05 09:05:07 +00:00
|
|
|
char name[16]; //frame name
|
|
|
|
md2vert_t verts[1]; //first vertex of this frame
|
|
|
|
} md2frame_t;
|
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
typedef struct { int16_t u, v; } md2uv_t;
|
2008-05-05 09:05:07 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-01-10 07:38:50 +00:00
|
|
|
uint16_t v[3];
|
|
|
|
uint16_t u[3];
|
2008-05-05 09:05:07 +00:00
|
|
|
} md2tri_t;
|
|
|
|
|
2019-10-18 12:04:32 +00:00
|
|
|
struct md2model_t : public idmodel_t
|
2008-05-05 09:05:07 +00:00
|
|
|
{
|
|
|
|
//MD2 specific stuff:
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t numverts, numglcmds, framebytes, *glcmds;
|
2008-05-05 09:05:07 +00:00
|
|
|
char *frames;
|
|
|
|
char *basepath; // pointer to string of base path
|
|
|
|
char *skinfn; // pointer to first of numskins 64-char strings
|
|
|
|
md2uv_t *uv;
|
|
|
|
md2tri_t* tris;
|
2019-10-18 12:04:32 +00:00
|
|
|
};
|
2008-05-05 09:05:07 +00:00
|
|
|
|
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
typedef struct { char nam[64]; int32_t i; } md3shader_t; //ascz path of shader, shader index
|
|
|
|
typedef struct { int32_t i[3]; } md3tri_t; //indices of tri
|
2008-05-05 09:05:07 +00:00
|
|
|
typedef struct { float u, v; } md3uv_t;
|
2009-04-26 05:57:42 +00:00
|
|
|
typedef struct { int16_t x, y, z; uint8_t nlat, nlng; } md3xyzn_t; //xyz are [10:6] ints
|
2008-05-05 09:05:07 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2014-09-30 04:18:43 +00:00
|
|
|
vec3f_t min, max, cen; //bounding box&origin
|
2008-05-05 09:05:07 +00:00
|
|
|
float r; //radius of bounding sphere
|
|
|
|
char nam[16]; //ascz frame name
|
|
|
|
} md3frame_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char nam[64]; //ascz tag name
|
2014-09-30 04:18:43 +00:00
|
|
|
vec3f_t p, x, y, z; //tag object pos&orient
|
2008-05-05 09:05:07 +00:00
|
|
|
} md3tag_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t id; //IDP3(0x33806873)
|
2008-05-05 09:05:07 +00:00
|
|
|
char nam[64]; //ascz surface name
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t flags; //?
|
|
|
|
int32_t numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192
|
|
|
|
int32_t ofstris;
|
|
|
|
int32_t ofsshaders;
|
|
|
|
int32_t ofsuv;
|
|
|
|
int32_t ofsxyzn;
|
|
|
|
int32_t ofsend;
|
2008-05-24 06:53:56 +00:00
|
|
|
// DO NOT read directly to this structure
|
|
|
|
// the following block is NOT in the file format
|
|
|
|
// be sure to use the SIZEOF_MD3SURF_T macro
|
|
|
|
md3tri_t *tris;
|
|
|
|
md3shader_t *shaders;
|
|
|
|
md3uv_t *uv;
|
|
|
|
md3xyzn_t *xyzn;
|
2011-06-19 18:30:32 +00:00
|
|
|
float *geometry; // used by Polymer
|
2008-05-05 09:05:07 +00:00
|
|
|
} md3surf_t;
|
|
|
|
|
2009-03-10 12:08:33 +00:00
|
|
|
#define SIZEOF_MD3SURF_T (11*sizeof(int32_t) + 64*sizeof(char))
|
2008-05-24 06:53:56 +00:00
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t id, vers; //id=IDP3(0x33806873), vers=15
|
2008-05-05 09:05:07 +00:00
|
|
|
char nam[64]; //ascz path in PK3
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t flags; //?
|
|
|
|
int32_t numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead
|
|
|
|
int32_t ofsframes;
|
|
|
|
int32_t ofstags;
|
|
|
|
int32_t ofssurfs;
|
|
|
|
int32_t eof;
|
2008-05-24 06:53:56 +00:00
|
|
|
// DO NOT read directly to this structure
|
|
|
|
// the following block is NOT in the file format
|
|
|
|
// be sure to use the SIZEOF_MD3HEAD_T macro
|
|
|
|
md3frame_t *frames;
|
|
|
|
md3tag_t *tags;
|
|
|
|
md3surf_t *surfs;
|
2008-05-05 09:05:07 +00:00
|
|
|
} md3head_t;
|
|
|
|
|
2008-05-24 06:53:56 +00:00
|
|
|
#define SIZEOF_MD3HEAD_T (sizeof(md3head_t)-3*sizeof(void*))
|
|
|
|
|
2019-10-18 12:04:32 +00:00
|
|
|
struct md3model_t : public idmodel_t
|
2008-05-05 09:05:07 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
//MD3 specific
|
|
|
|
md3head_t head;
|
2014-09-30 04:18:43 +00:00
|
|
|
vec3f_t *muladdframes;
|
2014-12-26 17:29:48 +00:00
|
|
|
|
|
|
|
uint16_t *indexes;
|
|
|
|
uint16_t *vindexes;
|
|
|
|
|
|
|
|
float *maxdepths;
|
2008-06-01 08:58:06 +00:00
|
|
|
// polymer VBO names after that, allocated per surface
|
2019-09-16 19:08:42 +00:00
|
|
|
/*
|
2014-12-26 17:29:48 +00:00
|
|
|
GLuint *indices;
|
|
|
|
GLuint *texcoords;
|
|
|
|
GLuint *geometry;
|
2019-09-16 19:08:42 +00:00
|
|
|
*/
|
2019-10-18 12:04:32 +00:00
|
|
|
};
|
2008-05-05 09:05:07 +00:00
|
|
|
|
|
|
|
#define VOXBORDWIDTH 1 //use 0 to save memory, but has texture artifacts; 1 looks better...
|
|
|
|
#define VOXUSECHAR 0
|
2014-12-26 17:29:48 +00:00
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
#if (VOXUSECHAR != 0)
|
2009-04-26 05:57:42 +00:00
|
|
|
typedef struct { uint8_t x, y, z, u, v; } vert_t;
|
2008-05-05 09:05:07 +00:00
|
|
|
#else
|
2009-01-10 07:38:50 +00:00
|
|
|
typedef struct { uint16_t x, y, z, u, v; } vert_t;
|
2008-05-05 09:05:07 +00:00
|
|
|
#endif
|
2014-12-26 17:29:48 +00:00
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
typedef struct { vert_t v[4]; } voxrect_t;
|
2014-12-26 17:29:48 +00:00
|
|
|
|
2019-10-18 12:04:32 +00:00
|
|
|
struct voxmodel_t : public mdmodel_t
|
2008-05-05 09:05:07 +00:00
|
|
|
{
|
|
|
|
//VOX specific stuff:
|
2009-01-10 07:38:50 +00:00
|
|
|
voxrect_t *quad; int32_t qcnt, qfacind[7];
|
|
|
|
int32_t *mytex, mytexx, mytexy;
|
2014-09-30 04:18:43 +00:00
|
|
|
vec3_t siz;
|
|
|
|
vec3f_t piv;
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t is8bit;
|
2020-02-09 19:14:26 +00:00
|
|
|
TMap<int, FHardwareTexture*> *texIds;
|
2019-10-18 17:06:57 +00:00
|
|
|
};
|
2008-05-05 09:05:07 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
EXTERN mdmodel_t **models;
|
2008-05-05 09:05:07 +00:00
|
|
|
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture* mdloadskin(idmodel_t* m, int32_t number, int32_t pal, int32_t surf, bool* exact);
|
2008-12-02 10:44:39 +00:00
|
|
|
void mdinit(void);
|
|
|
|
void freeallmodels(void);
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t polymost_mddraw(tspriteptr_t tspr);
|
2019-09-30 06:35:33 +00:00
|
|
|
EXTERN void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16]);
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
EXTERN int32_t mdpause;
|
2012-01-19 21:57:22 +00:00
|
|
|
EXTERN int32_t nextmodelid;
|
2009-01-10 07:38:50 +00:00
|
|
|
EXTERN voxmodel_t *voxmodels[MAXVOXELS];
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
void voxfree(voxmodel_t *m);
|
|
|
|
voxmodel_t *voxload(const char *filnam);
|
2019-09-19 20:02:45 +00:00
|
|
|
voxmodel_t *loadkvxfrombuf(const char *buffer, int32_t length);
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr);
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2010-12-24 15:44:37 +00:00
|
|
|
int md3postload_polymer(md3model_t* m);
|
2012-01-12 20:48:38 +00:00
|
|
|
//int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap);
|
2014-09-30 04:18:43 +00:00
|
|
|
EXTERN void md_freevbos(void);
|
2010-12-24 15:44:37 +00:00
|
|
|
|
2013-02-07 21:01:24 +00:00
|
|
|
#endif // defined USE_OPENGL
|
2014-01-02 17:08:08 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
HUDFLAG_HIDE = 1,
|
|
|
|
HUDFLAG_NOBOB = 2,
|
|
|
|
HUDFLAG_FLIPPED = 4,
|
|
|
|
HUDFLAG_NODEPTH = 8,
|
|
|
|
};
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // !mdsprite_h_
|