This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/common/com_model.h

496 lines
12 KiB
C
Raw Normal View History

2011-05-09 22:00:00 +02:00
/*
com_model.h - cient model structures
Copyright (C) 2010 Uncle Mike
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 3 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.
*/
2010-08-07 22:00:00 +02:00
#ifndef COM_MODEL_H
#define COM_MODEL_H
2010-08-12 22:00:00 +02:00
#include "bspfile.h" // we need some declarations from it
2010-08-07 22:00:00 +02:00
2012-06-25 22:00:00 +02:00
typedef vec_t vec2_t[2];
typedef vec_t vec4_t[4];
2010-08-12 22:00:00 +02:00
/*
==============================================================================
ENGINE MODEL FORMAT
==============================================================================
*/
2010-11-15 22:00:00 +01:00
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2
#define ZISCALE ((float)0x8000)
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
#define MIPLEVELS 4
#define VERTEXSIZE 7
#define MAXLIGHTMAPS 4
#define NUM_AMBIENTS 4 // automatic ambient sounds
2010-10-23 22:00:00 +02:00
// model types
typedef enum
{
mod_bad = -1,
mod_brush,
mod_sprite,
mod_alias,
mod_studio
} modtype_t;
2010-08-12 22:00:00 +02:00
typedef struct mplane_s
{
vec3_t normal;
float dist;
2010-10-22 22:00:00 +02:00
byte type; // for fast side tests
byte signbits; // signx + (signy<<1) + (signz<<1)
byte pad[2];
2010-08-12 22:00:00 +02:00
} mplane_t;
2010-11-21 22:00:00 +01:00
typedef struct
2010-08-12 22:00:00 +02:00
{
2010-11-21 22:00:00 +01:00
vec3_t position;
} mvertex_t;
2010-08-12 22:00:00 +02:00
typedef struct
{
2017-07-24 23:00:00 +02:00
int planenum;
2017-07-31 23:00:00 +02:00
#ifdef SUPPORT_BSP2_FORMAT
2017-07-24 23:00:00 +02:00
int children[2]; // negative numbers are contents
2017-07-30 23:00:00 +02:00
#else
short children[2]; // negative numbers are contents
#endif
2017-07-31 23:00:00 +02:00
} mclipnode_t;
2017-07-24 23:00:00 +02:00
2017-07-31 23:00:00 +02:00
// size is matched but representation is not
2017-07-24 23:00:00 +02:00
typedef struct
{
2017-07-31 23:00:00 +02:00
#ifdef SUPPORT_BSP2_FORMAT
unsigned int v[2];
#else
unsigned short v[2];
2010-11-21 22:00:00 +01:00
unsigned int cachededgeoffset;
2017-07-31 23:00:00 +02:00
#endif
2010-11-21 22:00:00 +01:00
} medge_t;
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
typedef struct texture_s
{
char name[16];
unsigned int width, height;
int gl_texturenum;
struct msurface_s *texturechain; // for gl_texsort drawing
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
2012-05-21 22:00:00 +02:00
struct texture_s *alternate_anims; // bmodels in frame 1 use these
2013-11-03 21:00:00 +01:00
unsigned short fb_texturenum; // auto-luma texturenum
unsigned short dt_texturenum; // detail-texture binding
unsigned int unused[3]; // reserved
2010-11-21 22:00:00 +01:00
} texture_t;
2010-08-12 22:00:00 +02:00
2016-11-28 22:00:00 +01:00
typedef struct
{
char landname[16]; // name of decsription in mapname_land.txt
unsigned short texture_step; // default is 16, pixels\luxels ratio
unsigned short max_extent; // default is 16, subdivision step ((texture_step * max_extent) - texture_step)
short groupid; // to determine equal landscapes from various groups, -1 - no group
2017-03-14 22:00:00 +01:00
vec3_t mins, maxs; // terrain bounds (fill by user)
2016-11-28 22:00:00 +01:00
int reserved[32]; // just for future expansions or mod-makers
} mfaceinfo_t;
2010-08-12 22:00:00 +02:00
typedef struct
{
2010-11-21 22:00:00 +01:00
float vecs[2][4]; // [s/t] unit vectors in world space.
// [i][3] is the s/t offset relative to the origin.
2010-11-22 22:00:00 +01:00
// s or t = dot( 3Dpoint, vecs[i] ) + vecs[i][3]
2016-11-28 22:00:00 +01:00
mfaceinfo_t *faceinfo; // pointer to landscape info and lightmap resolution (may be NULL)
2010-11-21 22:00:00 +01:00
texture_t *texture;
2016-11-28 22:00:00 +01:00
int flags; // sky or slime, no lightmap or 256 subdivision
2010-08-12 22:00:00 +02:00
} mtexinfo_t;
2010-11-21 22:00:00 +01:00
typedef struct glpoly_s
2010-08-12 22:00:00 +02:00
{
2010-11-21 22:00:00 +01:00
struct glpoly_s *next;
struct glpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
typedef struct mnode_s
{
// common with leaf
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
// node specific
mplane_t *plane;
struct mnode_s *children[2];
2017-07-31 23:00:00 +02:00
#ifdef SUPPORT_BSP2_FORMAT
int firstsurface;
int numsurfaces;
#else
unsigned short firstsurface;
unsigned short numsurfaces;
#endif
2010-11-21 22:00:00 +01:00
} mnode_t;
typedef struct msurface_s msurface_t;
typedef struct decal_s decal_t;
// JAY: Compress this as much as possible
struct decal_s
{
decal_t *pnext; // linked list for each surface
msurface_t *psurface; // Surface id for persistence / unlinking
2013-10-23 22:00:00 +02:00
float dx; // local texture coordinates
float dy; //
float scale; // Pixel scale
2010-11-21 22:00:00 +01:00
short texture; // Decal texture
2017-03-14 22:00:00 +01:00
short flags; // Decal flags FDECAL_*
2010-11-21 22:00:00 +01:00
short entityIndex; // Entity this is attached to
2017-03-14 22:00:00 +01:00
// Xash3D specific
2010-12-23 22:00:00 +01:00
vec3_t position; // location of the decal center in world space.
2017-03-14 22:00:00 +01:00
glpoly_t *polys; // precomputed decal vertices
2010-12-23 22:00:00 +01:00
};
2010-08-12 22:00:00 +02:00
typedef struct mleaf_s
{
// common with node
int contents;
2010-11-21 22:00:00 +01:00
int visframe; // node needs to be traversed if current
float minmaxs[6]; // for bounding box culling
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
struct mnode_s *parent;
2010-08-12 22:00:00 +02:00
// leaf specific
2010-12-06 22:00:00 +01:00
byte *compressed_vis;
struct efrag_s *efrags;
2010-08-12 22:00:00 +02:00
msurface_t **firstmarksurface;
int nummarksurfaces;
2016-11-21 22:00:00 +01:00
int cluster; // helper to acess to uncompressed visdata
2010-11-21 22:00:00 +01:00
byte ambient_sound_level[NUM_AMBIENTS];
2010-08-12 22:00:00 +02:00
} mleaf_t;
2017-03-14 22:00:00 +01:00
// surface extradata
typedef struct mextrasurf_s
{
vec3_t mins, maxs;
vec3_t origin; // surface origin
struct msurface_s *surf; // upcast to surface
2018-02-06 22:00:00 +01:00
// extended light info
2017-03-14 22:00:00 +01:00
int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
2017-11-04 22:00:00 +01:00
short lightmapmins[2]; // lightmatrix
short lightextents[2];
float lmvecs[2][4];
2017-03-14 22:00:00 +01:00
color24 *deluxemap; // note: this is the actual deluxemap data for this surface
2017-12-31 22:00:00 +01:00
byte *shadowmap; // note: occlusion map for this surface
2017-03-14 22:00:00 +01:00
// begin userdata
2018-02-06 22:00:00 +01:00
struct msurface_s *lightmapchain; // lightmapped polys
struct mextrasurf_s *detailchain; // for detail textures drawing
struct mextrasurf_s *mirrorchain; // for gl_texsort drawing
struct cl_entity_s *parent; // upcast to owner entity
int mirrortexturenum; // gl texnum
float mirrormatrix[4][4];
2017-03-14 22:00:00 +01:00
struct grasshdr_s *grass; // grass that linked by this surface
unsigned short grasscount; // number of bushes per polygon (used to determine total VBO size)
unsigned short numverts; // world->vertexes[]
int firstvertex; // fisrt look up in tr.tbn_vectors[], then acess to world->vertexes[]
int reserved[32]; // just for future expansions or mod-makers
} mextrasurf_t;
2010-11-21 22:00:00 +01:00
typedef struct msurface_s
2010-08-12 22:00:00 +02:00
{
2010-11-21 22:00:00 +01:00
int visframe; // should be drawn when node is crossed
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
mplane_t *plane; // pointer to shared plane
int flags; // see SURF_ #defines
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
short texturemins[2];
short extents[2];
int light_s, light_t; // gl lightmap coordinates
glpoly_t *polys; // multiple if warped
struct msurface_s *texturechain;
mtexinfo_t *texinfo;
// lighting info
int dlightframe; // last frame the surface was checked by an animated light
int dlightbits; // dynamically generated. Indicates if the surface illumination
// is modified by an animated light.
int lightmaptexturenum;
byte styles[MAXLIGHTMAPS];
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
2017-03-14 22:00:00 +01:00
mextrasurf_t *info; // pointer to surface extradata (was cached_dlight)
2010-11-21 22:00:00 +01:00
color24 *samples; // note: this is the actual lightmap data for this surface
decal_t *pdecals;
} msurface_t;
typedef struct hull_s
{
2017-07-31 23:00:00 +02:00
mclipnode_t *clipnodes;
2010-11-21 22:00:00 +01:00
mplane_t *planes;
int firstclipnode;
int lastclipnode;
vec3_t clip_mins;
vec3_t clip_maxs;
} hull_t;
#ifndef CACHE_USER
#define CACHE_USER
typedef struct cache_user_s
{
void *data; // extradata
} cache_user_t;
#endif
2010-08-12 22:00:00 +02:00
typedef struct model_s
2010-08-07 22:00:00 +02:00
{
2010-08-12 22:00:00 +02:00
char name[64]; // model name
2010-12-06 22:00:00 +01:00
qboolean needload; // bmodels and sprites don't cache normally
2010-08-12 22:00:00 +02:00
// shared modelinfo
modtype_t type; // model type
2010-11-15 22:00:00 +01:00
int numframes; // sprite's framecount
byte *mempool; // private mempool (was synctype)
int flags; // hl compatibility
2010-08-12 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
//
// volume occupied by the model
//
vec3_t mins, maxs; // bounding box at angles '0 0 0'
float radius;
2010-08-12 22:00:00 +02:00
// brush model
int firstmodelsurface;
int nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels; // or studio animations
int numplanes;
mplane_t *planes;
int numleafs; // number of visible leafs, not counting 0
mleaf_t *leafs;
int numvertexes;
2010-11-21 22:00:00 +01:00
mvertex_t *vertexes;
2010-08-12 22:00:00 +02:00
int numedges;
2010-11-21 22:00:00 +01:00
medge_t *edges;
2010-08-12 22:00:00 +02:00
int numnodes;
mnode_t *nodes;
int numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
int numclipnodes;
2017-07-30 23:00:00 +02:00
mclipnode_t *clipnodes;
2010-08-12 22:00:00 +02:00
int nummarksurfaces;
msurface_t **marksurfaces;
2010-08-07 22:00:00 +02:00
2010-08-12 22:00:00 +02:00
hull_t hulls[MAX_MAP_HULLS];
2010-08-07 22:00:00 +02:00
2010-08-12 22:00:00 +02:00
int numtextures;
2010-11-21 22:00:00 +01:00
texture_t **textures;
2010-08-07 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
byte *visdata;
2010-08-07 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
color24 *lightdata;
2010-11-15 22:00:00 +01:00
char *entities;
2010-11-21 22:00:00 +01:00
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
2010-08-12 22:00:00 +02:00
} model_t;
2010-08-07 22:00:00 +02:00
2010-11-21 22:00:00 +01:00
typedef struct alight_s
{
int ambientlight; // clip at 128
int shadelight; // clip at 192 - ambientlight
vec3_t color;
float *plightvec;
} alight_t;
typedef struct auxvert_s
{
float fv[3]; // viewspace x, y
} auxvert_t;
2010-12-19 22:00:00 +01:00
#define MAX_SCOREBOARDNAME 32
#define MAX_INFO_STRING 256
2013-10-23 22:00:00 +02:00
#include "custom.h"
2010-12-19 22:00:00 +01:00
typedef struct player_info_s
{
int userid; // User id on server
char userinfo[MAX_INFO_STRING]; // User info string
char name[MAX_SCOREBOARDNAME]; // Name (extracted from userinfo)
int spectator; // Spectator or not, unused
int ping;
int packet_loss;
// skin information
char model[64];
int topcolor;
int bottomcolor;
// last frame rendered
int renderframe;
// Gait frame estimation
int gaitsequence;
float gaitframe;
float gaityaw;
vec3_t prevgaitorigin;
2013-10-23 22:00:00 +02:00
customization_t customdata;
2018-02-12 22:00:00 +01:00
// hashed cd key
char hashedcdkey[16];
2010-12-19 22:00:00 +01:00
} player_info_t;
2010-12-02 22:00:00 +01:00
//
// sprite representation in memory
//
typedef enum { SPR_SINGLE = 0, SPR_GROUP, SPR_ANGLED } spriteframetype_t;
typedef struct mspriteframe_s
{
int width;
int height;
float up, down, left, right;
int gl_texturenum;
} mspriteframe_t;
typedef struct
{
int numframes;
float *intervals;
mspriteframe_t *frames[1];
} mspritegroup_t;
typedef struct
{
spriteframetype_t type;
mspriteframe_t *frameptr;
} mspriteframedesc_t;
typedef struct
{
short type;
short texFormat;
int maxwidth;
int maxheight;
int numframes;
int radius;
int facecull;
int synctype;
mspriteframedesc_t frames[1];
} msprite_t;
2017-06-23 23:00:00 +02:00
/*
==============================================================================
ALIAS MODELS
Alias models are position independent, so the cache manager can move them.
==============================================================================
*/
#define MAXALIASVERTS 2048
#define MAXALIASFRAMES 256
#define MAXALIASTRIS 4096
#define MAX_SKINS 32
2017-07-12 23:00:00 +02:00
// This mirrors trivert_t in trilib.h, is present so Quake knows how to
// load this data
2017-06-23 23:00:00 +02:00
typedef struct
{
byte v[3];
byte lightnormalindex;
2017-07-12 23:00:00 +02:00
} trivertex_t;
2017-06-23 23:00:00 +02:00
typedef struct
{
int firstpose;
int numposes;
2017-07-12 23:00:00 +02:00
trivertex_t bboxmin;
trivertex_t bboxmax;
2017-06-23 23:00:00 +02:00
float interval;
char name[16];
} maliasframedesc_t;
typedef struct
{
int ident;
int version;
vec3_t scale;
vec3_t scale_origin;
float boundingradius;
vec3_t eyeposition;
int numskins;
int skinwidth;
int skinheight;
int numverts;
int numtris;
int numframes;
int synctype;
int flags;
float size;
2017-08-18 23:00:00 +02:00
int reserved[8]; // VBO offsets
2017-06-23 23:00:00 +02:00
int numposes;
int poseverts;
2017-07-12 23:00:00 +02:00
trivertex_t *posedata; // numposes * poseverts trivert_t
2017-06-23 23:00:00 +02:00
int *commands; // gl command list with embedded s/t
2017-07-12 23:00:00 +02:00
unsigned short gl_texturenum[MAX_SKINS][4];
unsigned short fb_texturenum[MAX_SKINS][4];
2017-08-18 23:00:00 +02:00
unsigned short gl_reserved0[MAX_SKINS][4]; // detail tex
unsigned short gl_reserved1[MAX_SKINS][4]; // normalmap
unsigned short gl_reserved2[MAX_SKINS][4]; // glossmap
2017-06-23 23:00:00 +02:00
maliasframedesc_t frames[1]; // variable sized
} aliashdr_t;
2010-08-07 22:00:00 +02:00
#endif//COM_MODEL_H