2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "matrixlib.h"
27 // LordHavoc: 256 dynamic lights
28 #define MAX_DLIGHTS 256
30 // flags for rtlight rendering
31 #define LIGHTFLAG_NORMALMODE 1
32 #define LIGHTFLAG_REALTIMEMODE 2
34 typedef struct effect_s
43 // these are for interpolation
53 // draw this as lightning polygons, or a model?
55 struct model_s *model;
58 // if this beam is owned by an entity, this is the beam start relative to
59 // that entity's matrix for per frame start updates
62 // indicates whether relativestart is valid
63 int relativestartvalid;
67 typedef struct rtlight_s
69 // shadow volumes are done entirely in model space, so there are no matrices for dealing with them... they just use the origin
71 // note that the world to light matrices are inversely scaled (divided) by lightradius
74 // matrix for transforming world coordinates to light filter coordinates
75 matrix4x4_t matrix_worldtolight;
76 // typically 1 1 1, can be lower (dim) or higher (overbright)
78 // size of the light (remove?)
82 // light style to monitor for brightness
84 // whether light should render shadows
86 // intensity of corona to render
88 // radius scale of corona to render (1.0 means same as light radius)
89 vec_t coronasizescale;
90 // ambient intensity to render
92 // diffuse intensity to render
94 // specular intensity to render
99 // generated properties
100 // used only for shadow volumes
107 // squared cullradius
110 // rendering properties, updated each time a light is rendered
111 // this is rtlight->color * d_lightstylevalue
113 // this is R_Shadow_Cubemap(rtlight->cubemapname)
114 rtexture_t *currentcubemap;
117 // true if this light should be compiled as a static light
119 // true if this is a compiled world light, cleared if the light changes
121 // premade shadow volumes to render for world entity
122 shadowmesh_t *static_meshchain_shadow;
123 // used for visibility testing (more exact than bbox)
125 int static_numleafpvsbytes;
126 int *static_leaflist;
127 unsigned char *static_leafpvs;
128 // surfaces seen by light
129 int static_numsurfaces;
130 int *static_surfacelist;
134 typedef struct dlight_s
136 // destroy light after this time
139 // the entity that owns this light (can be NULL)
141 struct entity_render_s *ent;
143 // (worldlight: saved to .rtlights file)
145 // worldlight orientation
147 // (worldlight: saved to .rtlights file)
149 // dlight orientation/scaling/location
153 // (worldlight: saved to .rtlights file)
155 // cubemap number to use on this light
158 // cubemap name to use on this light
160 // (worldlight: saved to .rtlights file)
161 char cubemapname[64];
162 // make light flash while selected
165 // brightness (not really radius anymore)
166 // (worldlight: saved to .rtlights file)
168 // drop radius this much each second
171 // light style which controls intensity of this light
172 // (worldlight: saved to .rtlights file)
175 // (worldlight: saved to .rtlights file)
178 // (worldlight: saved to .rtlights file)
180 // radius scale of corona to render (1.0 means same as light radius)
181 // (worldlight: saved to .rtlights file)
182 vec_t coronasizescale;
183 // ambient intensity to render
184 // (worldlight: saved to .rtlights file)
186 // diffuse intensity to render
187 // (worldlight: saved to .rtlights file)
189 // specular intensity to render
190 // (worldlight: saved to .rtlights file)
193 // (worldlight: saved to .rtlights file)
195 // linked list of world lights
197 struct dlight_s *next;
198 // embedded rtlight struct for renderer
204 typedef struct frameblend_s
211 // LordHavoc: this struct is intended for the renderer but some fields are
212 // used by the client.
213 typedef struct entity_render_s
219 // transform matrix for model to world
221 // transform matrix for world to model
222 matrix4x4_t inversematrix;
223 // opacity (alpha) of the model
225 // size the model is shown
230 // current uninterpolated animation frame (for things which do not use interpolation)
232 // entity shirt and pants colors (-1 if not colormapped)
234 // literal colors for renderer
235 vec3_t colormap_pantscolor;
236 vec3_t colormap_shirtcolor;
237 // light, particles, etc
244 // colormod tinting of models
247 // interpolated animation
249 // frame that the model is interpolating from
251 // frame that the model is interpolating to
253 // interpolation factor, usually computed from frame2time
255 // time frame1 began playing (for framegroup animations)
257 // time frame2 began playing (for framegroup animations)
260 // calculated by the renderer (but not persistent)
262 // calculated during R_AddModelEntities
264 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
265 frameblend_t frameblend[4];
267 // current lighting from map
268 vec3_t modellight_ambient;
269 vec3_t modellight_diffuse; // q3bsp
270 vec3_t modellight_lightdir; // q3bsp
274 typedef struct entity_persistent_s
283 // muzzleflash fading
286 // interpolated movement
288 // start time of move
290 // time difference from start to end of move
292 // the move itself, start and end
300 typedef struct entity_s
303 // baseline state (default values)
304 entity_state_t state_baseline;
305 // previous state (interpolating from this)
306 entity_state_t state_previous;
307 // current state (interpolating to this)
308 entity_state_t state_current;
310 // used for regenerating parts of render
311 entity_persistent_t persistent;
313 // the only data the renderer should know about
314 entity_render_t render;
318 typedef struct usercmd_s
322 // intended velocities
327 vec3_t cursor_screen;
330 vec3_t cursor_impact;
331 vec3_t cursor_normal;
332 vec_t cursor_fraction;
333 int cursor_entitynumber;
340 qboolean applied; // if false we're still accumulating a move
343 typedef struct lightstyle_s
346 char map[MAX_STYLESTRING];
349 typedef struct scoreboard_s
351 char name[MAX_SCOREBOARDNAME];
353 int colors; // two 4 bit fields
356 char qw_userinfo[MAX_USERINFO_STRING];
362 char qw_skin[MAX_QPATH];
365 typedef struct cshift_s
368 float percent; // 0-256
371 #define CSHIFT_CONTENTS 0
372 #define CSHIFT_DAMAGE 1
373 #define CSHIFT_BONUS 2
374 #define CSHIFT_POWERUP 3
375 #define CSHIFT_VCSHIFT 4
376 #define NUM_CSHIFTS 5
378 #define NAME_LENGTH 64
382 // client_state_t should hold all pieces of the client state
385 #define SIGNONS 4 // signon messages to receive before connected
388 #define MAX_DEMONAME 16
390 typedef enum cactive_e
392 ca_dedicated, // a dedicated server with no ability to start a client
393 ca_disconnected, // full screen console with no connection
394 ca_connected // valid netcon, talking to a server
398 typedef enum qw_downloadtype_e
408 typedef enum capturevideoformat_e
410 CAPTUREVIDEOFORMAT_TARGA,
411 CAPTUREVIDEOFORMAT_JPEG,
412 CAPTUREVIDEOFORMAT_RAWRGB,
413 CAPTUREVIDEOFORMAT_RAWYV12
415 capturevideoformat_t;
418 // the client_static_t structure is persistent through an arbitrary number
419 // of server connections
421 typedef struct client_static_s
425 // all client memory allocations go in these pools
426 mempool_t *levelmempool;
427 mempool_t *permanentmempool;
430 // -1 = don't play demos
432 // list of demos in loop
433 char demos[MAX_DEMOS][MAX_DEMONAME];
434 // the actively playing demo (set by CL_PlayDemo_f)
437 // demo recording info must be here, because record is started before
438 // entering a map (and clearing client_state_t)
439 qboolean demorecording;
440 qboolean demoplayback;
442 // -1 = use normal cd track
445 // to meter out one message a frame
447 // host_framecount at start
449 // realtime at second frame of timedemo (LordHavoc: changed to double)
451 // LordHavoc: for measuring maxfps
452 double td_minframetime;
453 // LordHavoc: for measuring minfps
454 double td_maxframetime;
455 // LordHavoc: pausedemo
458 qboolean connect_trying;
459 int connect_remainingtries;
460 double connect_nextsendtime;
461 lhnetsocket_t *connect_mysocket;
462 lhnetaddress_t connect_address;
463 // protocol version of the server we're connected to
464 // (kept outside client_state_t because it's used between levels)
465 protocolversion_t protocol;
467 // connection information
470 // network connection
473 // quakeworld stuff below
475 // value of "qport" cvar at time of connection
478 // current file download buffer (only saved when file is completed)
479 char qw_downloadname[MAX_QPATH];
480 unsigned char *qw_downloadmemory;
481 int qw_downloadmemorycursize;
482 int qw_downloadmemorymaxsize;
483 int qw_downloadnumber;
484 int qw_downloadpercent;
485 qw_downloadtype_t qw_downloadtype;
487 // current file upload buffer (for uploading screenshots to server)
488 unsigned char *qw_uploaddata;
493 // this normally contains the following keys in quakeworld:
494 // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
495 char userinfo[MAX_USERINFO_STRING];
497 // video capture stuff
498 qboolean capturevideo_active;
499 capturevideoformat_t capturevideo_format;
500 double capturevideo_starttime;
501 double capturevideo_framerate;
502 int capturevideo_soundrate;
503 int capturevideo_frame;
504 unsigned char *capturevideo_buffer;
505 qfile_t *capturevideo_videofile;
506 qfile_t *capturevideo_soundfile;
507 short capturevideo_rgbtoyuvscaletable[3][3][256];
508 unsigned char capturevideo_yuvnormalizetable[3][256];
512 extern client_static_t cls;
514 typedef struct client_movementqueue_s
524 client_movementqueue_t;
530 qboolean drawenginesbar;
531 qboolean drawcrosshair;
534 typedef struct qw_usercmd_s
537 short forwardmove, sidemove, upmove;
538 unsigned char padding1[2];
540 unsigned char buttons;
541 unsigned char impulse;
542 unsigned char padding2;
548 PARTICLE_BILLBOARD = 0,
550 PARTICLE_ORIENTED_DOUBLESIDED = 2,
563 typedef struct particletype_s
566 porientation_t orientation;
573 pt_alphastatic, pt_static, pt_spark, pt_beam, pt_rain, pt_raindecal, pt_snow, pt_bubble, pt_blood, pt_smoke, pt_decal, pt_entityparticle, pt_total
577 typedef struct particle_s
579 particletype_t *type;
582 vec3_t vel; // velocity of particle, or orientation of decal, or end point of beam
584 float sizeincrease; // rate of size change per second
585 float alpha; // 0-255
586 float alphafade; // how much alpha reduces per second
587 float time2; // used for snow fluttering and decal fade
588 float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical)
589 float gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
590 float airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction)
591 float liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction)
592 unsigned char color[4];
593 unsigned short owner; // decal stuck to this entity
594 model_t *ownermodel; // model the decal is stuck to (used to make sure the entity is still alive)
595 vec3_t relativeorigin; // decal at this location in entity's coordinate space
596 vec3_t relativedirection; // decal oriented this way relative to entity's coordinate space
601 // the client_state_t structure is wiped completely at every
604 typedef struct client_state_s
606 // true if playing in a local game and no one else is connected
609 // when connecting to the server throw out the first couple move messages
610 // so the player doesn't accidentally do something the first frame
613 // send a clc_nop periodically until connected
616 // current input to send to the server
619 // information for local display
621 int stats[MAX_CL_STATS];
622 // last known inventory bit flags, for blinking
624 // cl.time of acquiring item, for blinking
625 float item_gettime[32];
626 // last known STAT_ACTIVEWEAPON
628 // cl.time of changing STAT_ACTIVEWEAPON
630 // use pain anim frame if cl.time < this
633 // color shifts for damage, powerups
634 cshift_t cshifts[NUM_CSHIFTS];
636 cshift_t prev_cshifts[NUM_CSHIFTS];
638 // the client maintains its own idea of view angles, which are
639 // sent to the server each frame. The server sets punchangle when
640 // the view is temporarily offset, and an angle reset commands at the start
641 // of each level and after teleporting.
643 // mviewangles is read from demo
644 // viewangles is either client controlled or lerped from mviewangles
645 vec3_t mviewangles[2], viewangles;
646 // update by server, used by qc to do weapon recoil
647 vec3_t mpunchangle[2], punchangle;
648 // update by server, can be used by mods to kick view around
649 vec3_t mpunchvector[2], punchvector;
650 // update by server, used for lean+bob (0 is newest)
651 vec3_t mvelocity[2], velocity;
652 // update by server, can be used by mods for zooming
653 vec_t mviewzoom[2], viewzoom;
654 // if true interpolation the mviewangles and other interpolation of the
655 // player is disabled until the next network packet
656 // this is used primarily by teleporters, and when spectating players
657 // special checking of the old fixangle[1] is used to differentiate
658 // between teleporting and spectating
659 qboolean fixangle[2];
661 // client movement simulation
662 // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
664 // this is set true by svc_time parsing and causes a new movement to be
665 // queued for prediction purposes
666 qboolean movement_needupdate;
667 // indicates the queue has been updated and should be replayed
668 qboolean movement_replay;
669 // timestamps of latest two predicted moves for interpolation
670 double movement_time[2];
671 // simulated data (this is valid even if cl.movement is false)
672 vec3_t movement_origin;
673 vec3_t movement_oldorigin;
674 vec3_t movement_velocity;
675 // queue of proposed moves
676 int movement_numqueue;
677 client_movementqueue_t movement_queue[64];
679 int servermovesequence;
681 // pitch drifting vars
688 //[515]: added for csqc purposes
689 float sensitivityscale;
690 csqc_vidvars_t csqc_vidvars; //[515]: these parms must be set to true by default
691 qboolean csqc_wantsmousemove;
692 struct model_s *csqc_model_precache[MAX_MODELS];
694 // local amount for smoothing stepups
703 qboolean oldonground;
704 double lastongroundtime;
705 double hitgroundtime;
707 // don't change view angle, full screen, etc
709 // latched at intermission start
710 double completed_time;
712 // the timestamp of the last two messages
715 // clients view of time, time should be between mtime[0] and mtime[1] to
716 // generate a lerp point for other data, oldtime is the previous frame's
717 // value of time, frametime is the difference between time and oldtime
718 double time, oldtime;
719 // how long it has been since the previous client frame in real time
720 // (not game time, for that use cl.time - cl.oldtime)
721 double realframetime;
723 // copy of realtime from last recieved message, for net trouble icon
724 float last_received_message;
726 // information that is static for the entire time connected to a server
727 struct model_s *model_precache[MAX_MODELS];
728 struct sfx_s *sound_precache[MAX_SOUNDS];
730 // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
731 char model_name[MAX_MODELS][MAX_QPATH];
732 char sound_name[MAX_SOUNDS][MAX_QPATH];
734 // for display on solo scoreboard
736 // cl_entitites[cl.viewentity] = player
738 // the real player entity (normally same as viewentity,
739 // different than viewentity if mod uses chasecam or other tricks)
741 // max players that can be in this game
743 // type of game (deathmatch, coop, singleplayer)
746 // models and sounds used by engine code (particularly cl_parse.c)
748 model_t *model_bolt2;
749 model_t *model_bolt3;
752 sfx_t *sfx_knighthit;
759 // refresh related state
761 // cl_entitites[0].model
762 struct model_s *worldmodel;
768 int cdtrack, looptrack;
773 scoreboard_t *scores;
775 // entity database stuff
776 // latest received entity frame numbers
777 #define LATESTFRAMENUMS 3
778 int latestframenums[LATESTFRAMENUMS];
779 entityframe_database_t *entitydatabase;
780 entityframe4_database_t *entitydatabase4;
781 entityframeqw_database_t *entitydatabaseqw;
783 // keep track of quake entities because they need to be killed if they get stale
785 unsigned char isquakeentity[MAX_EDICTS];
787 // bounding boxes for clientside movement
788 vec3_t playerstandmins;
789 vec3_t playerstandmaxs;
790 vec3_t playercrouchmins;
791 vec3_t playercrouchmaxs;
794 int max_csqcentities;
795 int max_static_entities;
796 int max_temp_entities;
801 int max_brushmodel_entities;
805 entity_t *csqcentities; //[515]: csqc
806 unsigned char *entities_active;
807 unsigned char *csqcentities_active; //[515]: csqc
808 entity_t *static_entities;
809 entity_t *temp_entities;
810 cl_effect_t *effects;
813 lightstyle_t *lightstyle;
814 int *brushmodel_entities;
815 particle_t *particles;
818 int num_csqcentities; //[515]: csqc
819 int num_static_entities;
820 int num_temp_entities;
821 int num_brushmodel_entities;
831 // local copy of the server infostring
832 char qw_serverinfo[MAX_SERVERINFO_STRING];
834 // time of last qw "pings" command sent to server while showing scores
835 double last_ping_request;
837 // used during connect
840 // updated from serverinfo
843 // indicates whether the player is spectating
844 qboolean qw_spectator;
846 // movement parameters for client prediction
847 float qw_movevars_gravity;
848 float qw_movevars_stopspeed;
849 float qw_movevars_maxspeed; // can change during play
850 float qw_movevars_spectatormaxspeed;
851 float qw_movevars_accelerate;
852 float qw_movevars_airaccelerate;
853 float qw_movevars_wateraccelerate;
854 float qw_movevars_friction;
855 float qw_movevars_waterfriction;
856 float qw_movevars_entgravity; // can change during play
858 // models used by qw protocol
859 int qw_modelindex_spike;
860 int qw_modelindex_player;
861 int qw_modelindex_flag;
862 int qw_modelindex_s_explod;
864 vec3_t qw_intermission_origin;
865 vec3_t qw_intermission_angles;
867 // 255 is the most nails the QW protocol could send
869 vec_t qw_nails[255][6];
873 int qw_validsequence;
875 qw_usercmd_t qw_moves[QW_UPDATE_BACKUP];
877 int qw_deltasequence[QW_UPDATE_BACKUP];
884 extern cvar_t cl_name;
885 extern cvar_t cl_color;
886 extern cvar_t cl_rate;
887 extern cvar_t cl_pmodel;
888 extern cvar_t cl_playermodel;
889 extern cvar_t cl_playerskin;
891 extern cvar_t rcon_password;
892 extern cvar_t rcon_address;
894 extern cvar_t cl_upspeed;
895 extern cvar_t cl_forwardspeed;
896 extern cvar_t cl_backspeed;
897 extern cvar_t cl_sidespeed;
899 extern cvar_t cl_movespeedkey;
901 extern cvar_t cl_yawspeed;
902 extern cvar_t cl_pitchspeed;
904 extern cvar_t cl_anglespeedkey;
906 extern cvar_t cl_autofire;
908 extern cvar_t csqc_progname; //[515]: csqc crc check and right csprogs name according to progs.dat
909 extern cvar_t csqc_progcrc;
911 extern cvar_t cl_shownet;
912 extern cvar_t cl_nolerp;
914 extern cvar_t cl_pitchdriftspeed;
915 extern cvar_t lookspring;
916 extern cvar_t lookstrafe;
917 extern cvar_t sensitivity;
919 extern cvar_t freelook;
921 extern cvar_t m_pitch;
923 extern cvar_t m_forward;
924 extern cvar_t m_side;
926 extern cvar_t cl_autodemo;
927 extern cvar_t cl_autodemo_nameformat;
929 extern cvar_t r_draweffects;
931 extern cvar_t cl_explosions_alpha_start;
932 extern cvar_t cl_explosions_alpha_end;
933 extern cvar_t cl_explosions_size_start;
934 extern cvar_t cl_explosions_size_end;
935 extern cvar_t cl_explosions_lifetime;
936 extern cvar_t cl_stainmaps;
937 extern cvar_t cl_stainmaps_clearonload;
939 extern cvar_t cl_prydoncursor;
941 extern client_state_t cl;
943 extern void CL_AllocDlight (entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, int cubemapnum, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags);
945 //=============================================================================
951 void CL_Shutdown (void);
954 void CL_EstablishConnection(const char *host);
956 void CL_Disconnect (void);
957 void CL_Disconnect_f (void);
959 void CL_BoundingBoxForEntity(entity_render_t *ent);
961 extern cvar_t cl_beams_polygons;
962 extern cvar_t cl_beams_relative;
963 extern cvar_t cl_beams_lightatend;
968 typedef struct kbutton_s
970 int down[2]; // key nums holding it down
971 int state; // low bit is down state
975 extern kbutton_t in_mlook, in_klook;
976 extern kbutton_t in_strafe;
977 extern kbutton_t in_speed;
979 void CL_InitInput (void);
980 void CL_SendMove (void);
982 void CL_ValidateState(entity_state_t *s);
983 void CL_MoveLerpEntityStates(entity_t *ent);
984 void CL_LerpUpdate(entity_t *e);
985 void CL_ParseTEnt (void);
986 void CL_RelinkBeams (void);
988 void CL_ClearTempEntities (void);
989 entity_t *CL_NewTempEntity (void);
991 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
993 void CL_ClearState (void);
994 void CL_ExpandEntities(int num);
995 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet);
998 int CL_ReadFromServer (void);
999 void CL_WriteToServer (void);
1000 void CL_Move (void);
1001 extern qboolean cl_ignoremousemove;
1004 float CL_KeyState (kbutton_t *key);
1005 const char *Key_KeynumToString (int keynum);
1006 int Key_StringToKeynum (const char *str);
1011 void CL_StopPlayback(void);
1012 void CL_ReadDemoMessage(void);
1013 void CL_WriteDemoMessage(void);
1015 void CL_NextDemo(void);
1016 void CL_Stop_f(void);
1017 void CL_Record_f(void);
1018 void CL_PlayDemo_f(void);
1019 void CL_TimeDemo_f(void);
1024 void CL_Parse_Init(void);
1025 void CL_Parse_Shutdown(void);
1026 void CL_ParseServerMessage(void);
1027 void CL_Parse_DumpPacket(void);
1028 void CL_Parse_ErrorCleanUp(void);
1029 void QW_CL_StartUpload(unsigned char *data, int size);
1030 extern cvar_t qport;
1035 void V_StartPitchDrift (void);
1036 void V_StopPitchDrift (void);
1039 float V_CalcRoll (vec3_t angles, vec3_t velocity);
1040 void V_UpdateBlends (void);
1041 void V_ParseDamage (void);
1047 extern cvar_t cl_particles;
1048 extern cvar_t cl_particles_quality;
1049 extern cvar_t cl_particles_size;
1050 extern cvar_t cl_particles_quake;
1051 extern cvar_t cl_particles_blood;
1052 extern cvar_t cl_particles_blood_alpha;
1053 extern cvar_t cl_particles_blood_bloodhack;
1054 extern cvar_t cl_particles_bulletimpacts;
1055 extern cvar_t cl_particles_explosions_bubbles;
1056 extern cvar_t cl_particles_explosions_smoke;
1057 extern cvar_t cl_particles_explosions_sparks;
1058 extern cvar_t cl_particles_explosions_shell;
1059 extern cvar_t cl_particles_smoke;
1060 extern cvar_t cl_particles_smoke_alpha;
1061 extern cvar_t cl_particles_smoke_alphafade;
1062 extern cvar_t cl_particles_sparks;
1063 extern cvar_t cl_particles_bubbles;
1064 extern cvar_t cl_decals;
1065 extern cvar_t cl_decals_time;
1066 extern cvar_t cl_decals_fadetime;
1068 void CL_Particles_Clear(void);
1069 void CL_Particles_Init(void);
1070 void CL_Particles_Shutdown(void);
1072 typedef enum effectnameindex_s
1076 EFFECT_TE_GUNSHOTQUAD,
1078 EFFECT_TE_SPIKEQUAD,
1079 EFFECT_TE_SUPERSPIKE,
1080 EFFECT_TE_SUPERSPIKEQUAD,
1082 EFFECT_TE_KNIGHTSPIKE,
1083 EFFECT_TE_VORESPIKE,
1084 EFFECT_TE_EXPLOSION,
1085 EFFECT_TE_EXPLOSIONQUAD,
1086 EFFECT_TE_TAREXPLOSION,
1088 EFFECT_TE_LAVASPLASH,
1089 EFFECT_TE_SMALLFLASH,
1094 EFFECT_TE_PLASMABURN,
1096 EFFECT_TE_TEI_SMOKE,
1097 EFFECT_TE_TEI_BIGEXPLOSION,
1098 EFFECT_TE_TEI_PLASMAHIT,
1104 EFFECT_TR_SLIGHTBLOOD,
1105 EFFECT_TR_KNIGHTSPIKE,
1106 EFFECT_TR_VORESPIKE,
1107 EFFECT_TR_NEHAHRASMOKE,
1108 EFFECT_TR_NEXUIZPLASMA,
1109 EFFECT_TR_GLOWTRAIL,
1110 EFFECT_SVC_PARTICLE,
1115 int CL_ParticleEffectIndexForName(const char *name);
1116 const char *CL_ParticleEffectNameForIndex(int i);
1117 void CL_ParticleEffect(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor);
1118 void CL_ParseParticleEffect (void);
1119 void CL_ParticleCube (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, vec_t gravity, vec_t randomvel);
1120 void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type);
1121 void CL_EntityParticles (const entity_t *ent);
1122 void CL_ParticleExplosion (const vec3_t org);
1123 void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength);
1124 void CL_MoveParticles(void);
1125 void R_MoveExplosions(void);
1126 void R_NewExplosion(const vec3_t org);
1128 #include "cl_screen.h"
1130 #define NUMCROSSHAIRS 32
1131 extern cachepic_t *r_crosshairs[NUMCROSSHAIRS+1];
1133 #define FOGTABLEWIDTH 1024
1134 extern int fogtableindex;
1135 #define VERTEXFOGTABLE(dist) (fogtableindex = (int)((dist) * r_refdef.fogtabledistmultiplier), r_refdef.fogtable[bound(0, fogtableindex, FOGTABLEWIDTH - 1)])
1137 typedef struct r_refdef_stats_s
1140 int entities_surfaces;
1141 int entities_triangles;
1146 int meshes_elements;
1149 int lights_scissored;
1150 int lights_lighttriangles;
1151 int lights_shadowtriangles;
1152 int lights_dynamicshadowtriangles;
1154 int bloom_copypixels;
1155 int bloom_drawpixels;
1159 typedef struct r_refdef_s
1161 // these fields define the basic rendering information for the world
1162 // but not the view, which could change multiple times in one rendered
1163 // frame (for example when rendering textures for certain effects)
1165 // these are set for water warping before
1166 // frustum_x/frustum_y are calculated
1167 float frustumscale_x, frustumscale_y;
1169 // minimum visible distance (pixels closer than this disappear)
1171 // maximum visible distance (pixels further than this disappear in 16bpp modes,
1172 // in 32bpp an infinite-farclip matrix is used instead)
1175 // fullscreen color blend
1178 // whether to call S_ExtraUpdate during render to reduce sound chop
1179 qboolean extraupdate;
1181 // client gameworld time for rendering time based effects
1185 entity_render_t *worldentity;
1187 // same as worldentity->model
1188 model_t *worldmodel;
1190 // renderable entities (excluding world)
1191 entity_render_t **entities;
1195 // renderable dynamic lights
1196 dlight_t *lights[MAX_DLIGHTS];
1199 // 8.8bit fixed point intensities for light styles
1200 // controls intensity of dynamic lights and lightmap layers
1201 unsigned short lightstylevalue[256]; // 8.8 fraction of base light value
1205 vec_t fograngerecip;
1206 vec_t fogtabledistmultiplier;
1207 float fogtable[FOGTABLEWIDTH];
1212 qboolean fogenabled;
1213 qboolean oldgl_fogenable;
1215 qboolean draw2dstage;
1217 // true during envmap command capture
1220 // brightness of world lightmaps and related lighting
1221 // (often reduced when world rtlights are enabled)
1222 float lightmapintensity;
1223 // whether to draw world lights realtime, dlights realtime, and their shadows
1225 qboolean rtworldshadows;
1227 qboolean rtdlightshadows;
1228 float polygonfactor;
1229 float polygonoffset;
1230 float shadowpolygonfactor;
1231 float shadowpolygonoffset;
1233 // rendering stats for r_speeds display
1234 // (these are incremented in many places)
1235 r_refdef_stats_t stats;
1239 typedef struct r_view_s
1241 // view information (changes multiple times per frame)
1242 // if any of these variables change then r_viewcache must be regenerated
1243 // by calling R_View_Update
1244 // (which also updates viewport, scissor, colormask)
1246 // it is safe and expected to copy this into a structure on the stack and
1247 // call the renderer recursively, then restore from the stack afterward
1248 // (as long as R_View_Update is called)
1250 // eye position information
1257 mplane_t frustum[5];
1258 float frustum_x, frustum_y;
1260 // screen area to render in
1268 // which color components to allow (for anaglyph glasses)
1273 typedef struct r_viewcache_s
1275 // these properties are generated by R_View_Update()
1277 // which entities are currently visible for this viewpoint
1278 // (the used range is 0...r_refdef.numentities)
1279 unsigned char entityvisible[MAX_EDICTS];
1280 // flag arrays used for visibility checking on world model
1281 // (all other entities have no per-surface/per-leaf visibility checks)
1282 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
1283 unsigned char world_pvsbits[(32768+7)>>3];
1284 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
1285 unsigned char world_leafvisible[32768];
1286 // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
1287 unsigned char world_surfacevisible[262144];
1288 // if true, the view is currently in a leaf without pvs data
1289 qboolean world_novis;
1293 extern r_refdef_t r_refdef;
1294 extern r_view_t r_view;
1295 extern r_viewcache_t r_viewcache;