📄 tr_local.h
字号:
float timeOffset; // current time offset for this shader
int numStates; // if non-zero this is a state shader
struct shader_s *currentShader; // current state if this is a state shader
struct shader_s *parentShader; // current state if this is a state shader
int currentState; // current state index for cycle purposes
long expireTime; // time in milliseconds this expires
struct shader_s *remappedShader; // current shader this one is remapped too
int shaderStates[MAX_STATES_PER_SHADER]; // index to valid shader states
struct shader_s *next;
} shader_t;
typedef struct shaderState_s {
char shaderName[MAX_QPATH]; // name of shader this state belongs to
char name[MAX_STATE_NAME]; // name of this state
char stateShader[MAX_QPATH]; // shader this name invokes
int cycleTime; // time this cycle lasts, <= 0 is forever
shader_t *shader;
} shaderState_t;
// trRefdef_t holds everything that comes in refdef_t,
// as well as the locally generated scene information
typedef struct {
int x, y, width, height;
float fov_x, fov_y;
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
int time; // time in milliseconds for shader effects and other time dependent rendering issues
int rdflags; // RDF_NOWORLDMODEL, etc
// 1 bits will prevent the associated area from rendering at all
byte areamask[MAX_MAP_AREA_BYTES];
qboolean areamaskModified; // qtrue if areamask changed since last scene
float floatTime; // tr.refdef.time / 1000.0
// text messages for deform text shaders
char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];
int num_entities;
trRefEntity_t *entities;
int num_dlights;
struct dlight_s *dlights;
int numPolys;
struct srfPoly_s *polys;
int numDrawSurfs;
struct drawSurf_s *drawSurfs;
} trRefdef_t;
//=================================================================================
// skins allow models to be retextured without modifying the model file
typedef struct {
char name[MAX_QPATH];
shader_t *shader;
} skinSurface_t;
typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[MD3_MAX_SURFACES];
} skin_t;
typedef struct {
int originalBrushNumber;
vec3_t bounds[2];
unsigned colorInt; // in packed byte format
float tcScale; // texture coordinate vector scales
fogParms_t parms;
// for clipping distance in fog when outside
qboolean hasSurface;
float surface[4];
} fog_t;
typedef struct {
orientationr_t or;
orientationr_t world;
vec3_t pvsOrigin; // may be different than or.origin for portals
qboolean isPortal; // true if this view is through a portal
qboolean isMirror; // the portal is a mirror, invert the face culling
int frameSceneNum; // copied from tr.frameSceneNum
int frameCount; // copied from tr.frameCount
cplane_t portalPlane; // clip anything behind this if mirroring
int viewportX, viewportY, viewportWidth, viewportHeight;
float fovX, fovY;
float projectionMatrix[16];
cplane_t frustum[4];
vec3_t visBounds[2];
float zFar;
} viewParms_t;
/*
==============================================================================
SURFACES
==============================================================================
*/
// any changes in surfaceType must be mirrored in rb_surfaceTable[]
typedef enum {
SF_BAD,
SF_SKIP, // ignore
SF_FACE,
SF_GRID,
SF_TRIANGLES,
SF_POLY,
SF_MD3,
SF_MD4,
SF_FLARE,
SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity
SF_DISPLAY_LIST,
SF_NUM_SURFACE_TYPES,
SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int )
} surfaceType_t;
typedef struct drawSurf_s {
unsigned sort; // bit combination for fast compares
surfaceType_t *surface; // any of surface*_t
} drawSurf_t;
#define MAX_FACE_POINTS 64
#define MAX_PATCH_SIZE 32 // max dimensions of a patch mesh in map file
#define MAX_GRID_SIZE 65 // max dimensions of a grid mesh in memory
// when cgame directly specifies a polygon, it becomes a srfPoly_t
// as soon as it is called
typedef struct srfPoly_s {
surfaceType_t surfaceType;
qhandle_t hShader;
int fogIndex;
int numVerts;
polyVert_t *verts;
} srfPoly_t;
typedef struct srfDisplayList_s {
surfaceType_t surfaceType;
int listNum;
} srfDisplayList_t;
typedef struct srfFlare_s {
surfaceType_t surfaceType;
vec3_t origin;
vec3_t normal;
vec3_t color;
} srfFlare_t;
typedef struct srfGridMesh_s {
surfaceType_t surfaceType;
// dynamic lighting information
int dlightBits[SMP_FRAMES];
// culling information
vec3_t meshBounds[2];
vec3_t localOrigin;
float meshRadius;
// lod information, which may be different
// than the culling information to allow for
// groups of curves that LOD as a unit
vec3_t lodOrigin;
float lodRadius;
int lodFixed;
int lodStitched;
// vertexes
int width, height;
float *widthLodError;
float *heightLodError;
drawVert_t verts[1]; // variable sized
} srfGridMesh_t;
#define VERTEXSIZE 8
typedef struct {
surfaceType_t surfaceType;
cplane_t plane;
// dynamic lighting information
int dlightBits[SMP_FRAMES];
// triangle definitions (no normals at points)
int numPoints;
int numIndices;
int ofsIndices;
float points[1][VERTEXSIZE]; // variable sized
// there is a variable length list of indices here also
} srfSurfaceFace_t;
// misc_models in maps are turned into direct geometry by q3map
typedef struct {
surfaceType_t surfaceType;
// dynamic lighting information
int dlightBits[SMP_FRAMES];
// culling information (FIXME: use this!)
vec3_t bounds[2];
vec3_t localOrigin;
float radius;
// triangle definitions
int numIndexes;
int *indexes;
int numVerts;
drawVert_t *verts;
} srfTriangles_t;
extern void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])(void *);
/*
==============================================================================
BRUSH MODELS
==============================================================================
*/
//
// in memory representation
//
#define SIDE_FRONT 0
#define SIDE_BACK 1
#define SIDE_ON 2
typedef struct msurface_s {
int viewCount; // if == tr.viewCount, already added
struct shader_s *shader;
int fogIndex;
surfaceType_t *data; // any of srf*_t
} msurface_t;
#define CONTENTS_NODE -1
typedef struct mnode_s {
// common with leaf and node
int contents; // -1 for nodes, to differentiate from leafs
int visframe; // node needs to be traversed if current
vec3_t mins, maxs; // for bounding box culling
struct mnode_s *parent;
// node specific
cplane_t *plane;
struct mnode_s *children[2];
// leaf specific
int cluster;
int area;
msurface_t **firstmarksurface;
int nummarksurfaces;
} mnode_t;
typedef struct {
vec3_t bounds[2]; // for culling
msurface_t *firstSurface;
int numSurfaces;
} bmodel_t;
typedef struct {
char name[MAX_QPATH]; // ie: maps/tim_dm2.bsp
char baseName[MAX_QPATH]; // ie: tim_dm2
int dataSize;
int numShaders;
dshader_t *shaders;
bmodel_t *bmodels;
int numplanes;
cplane_t *planes;
int numnodes; // includes leafs
int numDecisionNodes;
mnode_t *nodes;
int numsurfaces;
msurface_t *surfaces;
int nummarksurfaces;
msurface_t **marksurfaces;
int numfogs;
fog_t *fogs;
vec3_t lightGridOrigin;
vec3_t lightGridSize;
vec3_t lightGridInverseSize;
int lightGridBounds[3];
byte *lightGridData;
int numClusters;
int clusterBytes;
const byte *vis; // may be passed in by CM_LoadMap to save space
byte *novis; // clusterBytes of 0xff
char *entityString;
char *entityParsePoint;
} world_t;
//======================================================================
typedef enum {
MOD_BAD,
MOD_BRUSH,
MOD_MESH,
MOD_MD4
} modtype_t;
typedef struct model_s {
char name[MAX_QPATH];
modtype_t type;
int index; // model = tr.models[model->index]
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
md4Header_t *md4; // only if type == MOD_MD4
int numLods;
} model_t;
#define MAX_MOD_KNOWN 1024
void R_ModelInit (void);
model_t *R_GetModelByHandle( qhandle_t hModel );
int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame,
float frac, const char *tagName );
void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs );
void R_Modellist_f (void);
//====================================================
extern refimport_t ri;
#define MAX_DRAWIMAGES 2048
#define MAX_LIGHTMAPS 256
#define MAX_SKINS 1024
#define MAX_DRAWSURFS 0x10000
#define DRAWSURF_MASK (MAX_DRAWSURFS-1)
/*
the drawsurf sort data is packed into a single 32 bit value so it can be
compared quickly during the qsorting process
the bits are allocated as follows:
21 - 31 : sorted shader index
11 - 20 : entity index
2 - 6 : fog index
//2 : used to be clipped flag REMOVED - 03.21.00 rad
0 - 1 : dlightmap index
TTimo - 1.32
17-31 : sorted shader index
7-16 : entity index
2-6 : fog index
0-1 : dlightmap index
*/
#define QSORT_SHADERNUM_SHIFT 17
#define QSORT_ENTITYNUM_SHIFT 7
#define QSORT_FOGNUM_SHIFT 2
extern int gl_filter_min, gl_filter_max;
/*
** performanceCounters_t
*/
typedef struct {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -