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/engine/common/mod_local.h

181 lines
7.1 KiB
C
Raw Normal View History

2011-05-09 22:00:00 +02:00
/*
mod_local.h - model loader
Copyright (C) 2007 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.
*/
2011-04-06 22:00:00 +02:00
#ifndef MOD_LOCAL_H
#define MOD_LOCAL_H
2010-08-12 22:00:00 +02:00
#include "common.h"
2010-08-15 22:00:00 +02:00
#include "edict.h"
#include "eiface.h"
2010-08-12 22:00:00 +02:00
#include "com_model.h"
// 1/32 epsilon to keep floating point happy
2012-12-22 21:00:00 +01:00
#define DIST_EPSILON (1.0f / 32.0f)
#define FRAC_EPSILON (1.0f / 1024.0f)
#define BACKFACE_EPSILON 0.01f
#define MAX_BOX_LEAFS 256
#define ANIM_CYCLE 2
2017-03-02 22:00:00 +01:00
#define MOD_FRAMES 20
2010-08-12 22:00:00 +02:00
2011-07-22 22:00:00 +02:00
// remapping info
2012-12-22 21:00:00 +01:00
#define SUIT_HUE_START 192
#define SUIT_HUE_END 223
#define PLATE_HUE_START 160
#define PLATE_HUE_END 191
2011-07-22 22:00:00 +02:00
2017-07-28 23:00:00 +02:00
#define SHIRT_HUE_START 16
#define SHIRT_HUE_END 32
#define PANTS_HUE_START 96
#define PANTS_HUE_END 112
2018-02-02 22:00:00 +01:00
#define LM_SAMPLE_SIZE 16
#define LM_SAMPLE_EXTRASIZE 8
2012-12-12 21:00:00 +01:00
2016-11-21 22:00:00 +01:00
#define CHECKVISBIT( vis, b ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] & (1 << ((b) & 7))) : (byte)false )
#define SETVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] |= (1 << ((b) & 7))) : (byte)false )
#define CLEARVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] &= ~(1 << ((b) & 7))) : (byte)false )
#define REFPVS_RADIUS 2.0f // radius for rendering
#define FATPVS_RADIUS 8.0f // FatPVS use radius smaller than the FatPHS
#define FATPHS_RADIUS 16.0f
2010-12-15 22:00:00 +01:00
// model flags (stored in model_t->flags)
2012-12-22 21:00:00 +01:00
#define MODEL_CONVEYOR BIT( 0 )
#define MODEL_HAS_ORIGIN BIT( 1 )
#define MODEL_LIQUID BIT( 2 ) // model has only point hull
2017-07-20 23:00:00 +02:00
#define MODEL_TRANSPARENT BIT( 3 ) // have transparent surfaces
2017-07-31 23:00:00 +02:00
#define MODEL_COLORED_LIGHTING BIT( 4 ) // lightmaps stored as RGB
2010-12-15 22:00:00 +01:00
2017-03-02 22:00:00 +01:00
#define MODEL_CLIENT BIT( 30 ) // client sprite
2014-01-03 21:00:00 +01:00
typedef struct wadlist_s
{
char wadnames[256][32];
int count;
} wadlist_t;
2010-08-12 22:00:00 +02:00
typedef struct leaflist_s
{
int count;
int maxcount;
2010-10-26 22:00:00 +02:00
qboolean overflowed;
2010-08-12 22:00:00 +02:00
short *list;
vec3_t mins, maxs;
int topnode; // for overflows where each leaf can't be stored individually
} leaflist_t;
2010-12-08 22:00:00 +01:00
typedef struct
2010-08-12 22:00:00 +02:00
{
2013-02-19 21:00:00 +01:00
int mapversion; // map version (an key-value in worldspawn settings)
2010-12-27 22:00:00 +01:00
uint checksum; // current map checksum
2010-12-06 22:00:00 +01:00
int load_sequence; // increace each map change
2010-12-13 22:00:00 +01:00
msurface_t **draw_surfaces; // used for sorting translucent surfaces
int max_surfaces; // max surfaces per submodel (for all models)
2016-11-21 22:00:00 +01:00
2011-04-06 22:00:00 +02:00
qboolean loading; // true if worldmodel is loading
2011-09-03 22:00:00 +02:00
qboolean sky_sphere; // true when quake sky-sphere is used
2011-10-06 22:00:00 +02:00
qboolean has_mirrors; // one or more brush models contain reflective textures
2016-10-24 23:00:00 +02:00
qboolean custom_skybox; // if sky_sphere is active and custom skybox set
2016-11-21 22:00:00 +01:00
qboolean water_alpha; // allow translucency water
2012-12-21 21:00:00 +01:00
int block_size; // lightmap blocksize
2017-11-12 22:00:00 +01:00
int lightmap_samples; // samples per pixel
2013-12-19 21:00:00 +01:00
color24 *deluxedata; // deluxemap data pointer
2017-12-31 22:00:00 +01:00
byte *shadowdata; // occlusion data pointer
2014-05-17 22:00:00 +02:00
char message[2048]; // just for debug
2017-09-20 23:00:00 +02:00
char compiler[256]; // map compiler
2013-12-19 21:00:00 +01:00
2017-10-12 23:00:00 +02:00
dclipnode2_t *clipnodes; // temporary 32-bit array to hold clipnodes
int numclipnodes; // may be exceeds 32768
2017-10-31 22:00:00 +01:00
int numnodes; // worldcount of nodes
2017-10-12 23:00:00 +02:00
2016-11-21 22:00:00 +01:00
// visibility info
byte *visdata; // uncompressed visdata
size_t visbytes; // cluster size
size_t fatbytes; // fatpvs size
int visclusters; // num visclusters
// world stats
size_t visdatasize; // actual size of the visdata
size_t litdatasize; // actual size of the lightdata
size_t vecdatasize; // actual size of the deluxdata
2017-12-31 22:00:00 +01:00
size_t occdatasize; // actual size of the shadowdata
2016-11-21 22:00:00 +01:00
size_t entdatasize; // actual size of the entity string
size_t texdatasize; // actual size of the textures lump
2017-12-03 22:00:00 +01:00
size_t clipnodesize; // sizeof dclipnode_t struct
2016-11-21 22:00:00 +01:00
2011-08-21 22:00:00 +02:00
vec3_t mins; // real accuracy world bounds
vec3_t maxs;
vec3_t size;
2010-12-08 22:00:00 +01:00
} world_static_t;
2010-11-15 22:00:00 +01:00
2010-12-09 22:00:00 +01:00
extern world_static_t world;
extern byte *com_studiocache;
2010-08-12 22:00:00 +02:00
extern model_t *loadmodel;
2012-02-11 21:00:00 +01:00
extern convar_t *mod_studiocache;
2010-08-12 22:00:00 +02:00
//
2010-11-21 22:00:00 +01:00
// model.c
2010-08-12 22:00:00 +02:00
//
2010-11-21 22:00:00 +01:00
void Mod_Init( void );
2014-05-17 22:00:00 +02:00
void Mod_ClearAll( qboolean keep_playermodel );
2010-11-21 22:00:00 +01:00
void Mod_Shutdown( void );
2014-04-01 22:00:00 +02:00
void Mod_ClearUserData( void );
2012-06-26 22:00:00 +02:00
void Mod_PrintBSPFileSizes( void );
2010-08-12 22:00:00 +02:00
void Mod_GetBounds( int handle, vec3_t mins, vec3_t maxs );
void Mod_GetFrames( int handle, int *numFrames );
2016-02-26 22:00:00 +01:00
void Mod_LoadWorld( const char *name, uint *checksum, qboolean multiplayer );
2017-02-21 22:00:00 +01:00
int Mod_FrameCount( model_t *mod );
2010-12-08 22:00:00 +01:00
void Mod_FreeUnused( void );
2010-11-15 22:00:00 +01:00
void *Mod_Calloc( int number, size_t size );
void *Mod_CacheCheck( struct cache_user_s *c );
void Mod_LoadCacheFile( const char *path, struct cache_user_s *cu );
2017-07-02 23:00:00 +02:00
void *Mod_AliasExtradata( model_t *mod );
void *Mod_StudioExtradata( model_t *mod );
2010-12-08 22:00:00 +01:00
model_t *Mod_FindName( const char *name, qboolean create );
model_t *Mod_LoadModel( model_t *mod, qboolean world );
model_t *Mod_ForName( const char *name, qboolean world );
qboolean Mod_RegisterModel( const char *name, int index );
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
2018-02-02 22:00:00 +01:00
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf );
2010-12-08 22:00:00 +01:00
int Mod_BoxLeafnums( const vec3_t mins, const vec3_t maxs, short *list, int listsize, int *lastleaf );
2016-11-21 22:00:00 +01:00
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis );
2010-12-08 22:00:00 +01:00
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
2016-11-29 22:00:00 +01:00
int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );
int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize );
2010-12-08 22:00:00 +01:00
void Mod_AmbientLevels( const vec3_t p, byte *pvolumes );
2016-11-28 22:00:00 +01:00
int Mod_SampleSizeForFace( msurface_t *surf );
2016-11-21 22:00:00 +01:00
byte *Mod_GetPVSForPoint( const vec3_t p );
2010-12-08 22:00:00 +01:00
modtype_t Mod_GetType( int handle );
2011-02-20 22:00:00 +01:00
model_t *Mod_Handle( int handle );
2010-08-12 22:00:00 +02:00
2012-02-11 21:00:00 +01:00
//
// mod_studio.c
//
void Mod_InitStudioAPI( void );
void Mod_InitStudioHull( void );
2012-12-22 21:00:00 +01:00
void Mod_ResetStudioAPI( void );
2012-02-11 21:00:00 +01:00
qboolean Mod_GetStudioBounds( const char *name, vec3_t mins, vec3_t maxs );
void Mod_StudioGetAttachment( const edict_t *e, int iAttachment, float *org, float *ang );
void Mod_GetBonePosition( const edict_t *e, int iBone, float *org, float *ang );
hull_t *Mod_HullForStudio( model_t *m, float frame, int seq, vec3_t ang, vec3_t org, vec3_t size, byte *pcnt, byte *pbl, int *hitboxes, edict_t *ed );
2017-03-08 22:00:00 +01:00
void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
2017-03-06 22:00:00 +01:00
void R_StudioCalcBoneQuaternion( int frame, float s, void *pbone, void *panim, float *adj, vec4_t q );
void R_StudioCalcBonePosition( int frame, float s, void *pbone, void *panim, vec3_t adj, vec3_t pos );
2017-03-08 22:00:00 +01:00
void *R_StudioGetAnim( void *m_pStudioHeader, void *m_pSubModel, void *pseqdesc );
void Mod_StudioComputeBounds( void *buffer, vec3_t mins, vec3_t maxs, qboolean ignore_sequences );
2012-02-11 21:00:00 +01:00
int Mod_HitgroupForStudioHull( int index );
2011-04-06 22:00:00 +02:00
#endif//MOD_LOCAL_H