2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-22 09:57:21 +01:00
hlsdk-xash3d/common/com_model.h

348 lines
7.0 KiB
C
Raw Normal View History

//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
2020-04-22 10:12:23 +02:00
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// com_model.h
#pragma once
2020-04-22 10:12:23 +02:00
#if !defined( COM_MODEL_H )
2016-06-04 15:24:23 +02:00
#define COM_MODEL_H
2020-04-22 10:12:23 +02:00
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2
#define MAX_CLIENTS 32
#define MAX_EDICTS 900
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
#define MAX_MODEL_NAME 64
#define MAX_MAP_HULLS 4
#define MIPLEVELS 4
#define NUM_AMBIENTS 4 // automatic ambient sounds
#define MAXLIGHTMAPS 4
#define PLANE_ANYZ 5
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
#define ALIAS_Z_CLIP_PLANE 5
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
// flags in finalvert_t.flags
#define ALIAS_LEFT_CLIP 0x0001
#define ALIAS_TOP_CLIP 0x0002
#define ALIAS_RIGHT_CLIP 0x0004
#define ALIAS_BOTTOM_CLIP 0x0008
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_ONSEAM 0x0020
#define ALIAS_XY_CLIP_MASK 0x000F
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
#define ZISCALE ((float)0x8000)
2016-06-04 15:24:23 +02:00
typedef enum
{
mod_brush,
mod_sprite,
mod_alias,
mod_studio
} modtype_t;
2020-04-22 10:12:23 +02:00
// must match definition in modelgen.h
2021-06-20 00:53:07 +02:00
#if !defined(SYNCTYPE_T)
2020-04-22 10:12:23 +02:00
#define SYNCTYPE_T
typedef enum
{
ST_SYNC=0,
ST_RAND
} synctype_t;
#endif
typedef struct
{
float mins[3], maxs[3];
float origin[3];
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
} dmodel_t;
// plane_t structure
2016-06-04 15:24:23 +02:00
typedef struct mplane_s
{
2020-04-22 10:12:23 +02:00
vec3_t normal; // surface normal
float dist; // closest appoach to origin
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
byte pad[2];
2016-06-04 15:24:23 +02:00
} mplane_t;
typedef struct
{
vec3_t position;
} mvertex_t;
typedef struct
{
unsigned short v[2];
unsigned int cachededgeoffset;
} medge_t;
typedef struct texture_s
{
char name[16];
2020-04-22 10:12:23 +02:00
unsigned width, height;
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
struct texture_s *alternate_anims; // bmodels in frame 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored
unsigned paloffset;
2016-06-04 15:24:23 +02:00
} texture_t;
typedef struct
{
2020-04-22 10:12:23 +02:00
float vecs[2][4]; // [s/t] unit vectors in world space.
// [i][3] is the s/t offset relative to the origin.
// s or t = dot(3Dpoint,vecs[i])+vecs[i][3]
float mipadjust; // ?? mipmap limits for very small surfaces
texture_t *texture;
int flags; // sky or slime, no lightmap or 256 subdivision
2016-06-04 15:24:23 +02:00
} mtexinfo_t;
typedef struct mnode_s
{
// common with leaf
2020-04-22 10:12:23 +02:00
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling
2016-06-04 15:24:23 +02:00
struct mnode_s *parent;
// node specific
2020-04-22 10:12:23 +02:00
mplane_t *plane;
2016-06-04 15:24:23 +02:00
struct mnode_s *children[2];
2020-04-22 10:12:23 +02:00
unsigned short firstsurface;
unsigned short numsurfaces;
2016-06-04 15:24:23 +02:00
} mnode_t;
typedef struct msurface_s msurface_t;
2020-04-22 10:12:23 +02:00
typedef struct decal_s decal_t;
2016-06-04 15:24:23 +02:00
// JAY: Compress this as much as possible
struct decal_s
{
2020-04-22 10:12:23 +02:00
decal_t *pnext; // linked list for each surface
msurface_t *psurface; // Surface id for persistence / unlinking
short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats)
short dy;
2016-06-04 15:24:23 +02:00
short texture; // Decal texture
2020-04-22 10:12:23 +02:00
byte scale; // Pixel scale
byte flags; // Decal flags
2016-06-04 15:24:23 +02:00
short entityIndex; // Entity this is attached to
};
typedef struct mleaf_s
{
// common with node
2020-04-22 10:12:23 +02:00
int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
short minmaxs[6]; // for bounding box culling
2016-06-04 15:24:23 +02:00
struct mnode_s *parent;
2020-04-22 10:12:23 +02:00
2016-06-04 15:24:23 +02:00
// leaf specific
byte *compressed_vis;
struct efrag_s *efrags;
msurface_t **firstmarksurface;
2020-04-22 10:12:23 +02:00
int nummarksurfaces;
int key; // BSP sequence number for leaf's contents
2016-06-04 15:24:23 +02:00
byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t;
2019-10-26 14:48:49 +02:00
struct msurface_s
2016-06-04 15:24:23 +02:00
{
2020-04-22 10:12:23 +02:00
int visframe; // should be drawn when node is crossed
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.
mplane_t *plane; // pointer to shared plane
int flags; // see SURF_ #defines
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
// surface generation data
struct surfcache_s *cachespots[MIPLEVELS];
short texturemins[2]; // smallest s/t position on the surface.
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces
mtexinfo_t *texinfo;
// lighting info
byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights
// no one surface can be effected by more than 4
// animated lights.
color24 *samples;
2016-06-04 15:24:23 +02:00
decal_t *pdecals;
2019-10-26 14:48:49 +02:00
};
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
typedef struct
2016-06-04 15:24:23 +02:00
{
2020-04-22 10:12:23 +02:00
int planenum;
short children[2]; // negative numbers are contents
} dclipnode_t;
2016-06-04 15:24:23 +02:00
typedef struct hull_s
{
dclipnode_t *clipnodes;
2020-04-22 10:12:23 +02:00
mplane_t *planes;
int firstclipnode;
int lastclipnode;
2016-06-04 15:24:23 +02:00
vec3_t clip_mins;
vec3_t clip_maxs;
} hull_t;
2020-04-22 10:12:23 +02:00
#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H )
2016-06-04 15:24:23 +02:00
#define CACHE_USER
typedef struct cache_user_s
{
2020-04-22 10:12:23 +02:00
void *data;
2016-06-04 15:24:23 +02:00
} cache_user_t;
#endif
typedef struct model_s
{
2020-04-22 10:12:23 +02:00
char name[ MAX_MODEL_NAME ];
qboolean needload; // bmodels and sprites don't cache normally
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
modtype_t type;
int numframes;
synctype_t synctype;
int flags;
2016-06-04 15:24:23 +02:00
//
// volume occupied by the model
2020-04-22 10:12:23 +02:00
//
vec3_t mins, maxs;
2016-06-04 15:24:23 +02:00
float radius;
2020-04-22 10:12:23 +02:00
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
int numsubmodels;
dmodel_t *submodels;
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
int numplanes;
mplane_t *planes;
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
int numleafs; // number of visible leafs, not counting 0
struct mleaf_s *leafs;
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
int numvertexes;
mvertex_t *vertexes;
int numedges;
2016-06-04 15:24:23 +02:00
medge_t *edges;
2020-04-22 10:12:23 +02:00
int numnodes;
2016-06-04 15:24:23 +02:00
mnode_t *nodes;
2020-04-22 10:12:23 +02:00
int numtexinfo;
2016-06-04 15:24:23 +02:00
mtexinfo_t *texinfo;
2020-04-22 10:12:23 +02:00
int numsurfaces;
2016-06-04 15:24:23 +02:00
msurface_t *surfaces;
2020-04-22 10:12:23 +02:00
int numsurfedges;
int *surfedges;
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
int numclipnodes;
2016-06-04 15:24:23 +02:00
dclipnode_t *clipnodes;
2020-04-22 10:12:23 +02:00
int nummarksurfaces;
2016-06-04 15:24:23 +02:00
msurface_t **marksurfaces;
hull_t hulls[MAX_MAP_HULLS];
2020-04-22 10:12:23 +02:00
int numtextures;
texture_t **textures;
2016-06-04 15:24:23 +02:00
byte *visdata;
color24 *lightdata;
2020-04-22 10:12:23 +02:00
2016-06-04 15:24:23 +02:00
char *entities;
2020-04-22 10:12:23 +02:00
2016-06-04 15:24:23 +02:00
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
2020-04-22 10:12:23 +02:00
2016-06-04 15:24:23 +02:00
} model_t;
2020-04-22 10:12:23 +02:00
typedef vec_t vec4_t[4];
2016-06-04 15:24:23 +02:00
typedef struct alight_s
{
2020-04-22 10:12:23 +02:00
int ambientlight; // clip at 128
int shadelight; // clip at 192 - ambientlight
2016-06-04 15:24:23 +02:00
vec3_t color;
float *plightvec;
} alight_t;
typedef struct auxvert_s
{
2020-04-22 10:12:23 +02:00
float fv[3]; // viewspace x, y
2016-06-04 15:24:23 +02:00
} auxvert_t;
#include "custom.h"
2020-04-22 10:12:23 +02:00
#define MAX_INFO_STRING 256
#define MAX_SCOREBOARDNAME 32
2016-06-04 15:24:23 +02:00
typedef struct player_info_s
{
2020-04-22 10:12:23 +02:00
// User id on server
int userid;
// User info string
char userinfo[ MAX_INFO_STRING ];
// Name
char name[ MAX_SCOREBOARDNAME ];
// Spectator or not, unused
int spectator;
2016-06-04 15:24:23 +02:00
int ping;
int packet_loss;
// skin information
2020-04-22 10:12:23 +02:00
char model[MAX_QPATH];
2016-06-04 15:24:23 +02:00
int topcolor;
int bottomcolor;
// last frame rendered
int renderframe;
// Gait frame estimation
int gaitsequence;
2020-04-22 10:12:23 +02:00
float gaitframe;
float gaityaw;
vec3_t prevgaitorigin;
2016-06-04 15:24:23 +02:00
2020-04-22 10:12:23 +02:00
customization_t customdata;
2016-06-04 15:24:23 +02:00
} player_info_t;
2020-04-22 10:12:23 +02:00
#endif // COM_MODEL_H
2016-06-04 15:24:23 +02:00