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
477 // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
478 int qw_incoming_sequence;
479 int qw_outgoing_sequence;
481 // current file download buffer (only saved when file is completed)
482 char qw_downloadname[MAX_QPATH];
483 unsigned char *qw_downloadmemory;
484 int qw_downloadmemorycursize;
485 int qw_downloadmemorymaxsize;
486 int qw_downloadnumber;
487 int qw_downloadpercent;
488 qw_downloadtype_t qw_downloadtype;
490 // current file upload buffer (for uploading screenshots to server)
491 unsigned char *qw_uploaddata;
496 // this normally contains the following keys in quakeworld:
497 // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
498 char userinfo[MAX_USERINFO_STRING];
500 // video capture stuff
501 qboolean capturevideo_active;
502 capturevideoformat_t capturevideo_format;
503 double capturevideo_starttime;
504 double capturevideo_framerate;
505 int capturevideo_soundrate;
506 int capturevideo_frame;
507 unsigned char *capturevideo_buffer;
508 qfile_t *capturevideo_videofile;
509 qfile_t *capturevideo_soundfile;
510 short capturevideo_rgbtoyuvscaletable[3][3][256];
511 unsigned char capturevideo_yuvnormalizetable[3][256];
515 extern client_static_t cls;
517 typedef struct client_movementqueue_s
527 client_movementqueue_t;
533 qboolean drawenginesbar;
534 qboolean drawcrosshair;
537 typedef struct qw_usercmd_s
540 short forwardmove, sidemove, upmove;
541 unsigned char padding1[2];
543 unsigned char buttons;
544 unsigned char impulse;
545 unsigned char padding2;
551 PARTICLE_BILLBOARD = 0,
553 PARTICLE_ORIENTED_DOUBLESIDED = 2,
566 typedef struct particletype_s
569 porientation_t orientation;
576 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
580 typedef struct particle_s
582 particletype_t *type;
585 vec3_t vel; // velocity of particle, or orientation of decal, or end point of beam
587 float sizeincrease; // rate of size change per second
588 float alpha; // 0-255
589 float alphafade; // how much alpha reduces per second
590 float time2; // used for snow fluttering and decal fade
591 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)
592 float gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
593 float airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction)
594 float liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction)
595 unsigned char color[4];
596 unsigned short owner; // decal stuck to this entity
597 model_t *ownermodel; // model the decal is stuck to (used to make sure the entity is still alive)
598 vec3_t relativeorigin; // decal at this location in entity's coordinate space
599 vec3_t relativedirection; // decal oriented this way relative to entity's coordinate space
604 // the client_state_t structure is wiped completely at every
607 typedef struct client_state_s
609 // true if playing in a local game and no one else is connected
612 // when connecting to the server throw out the first couple move messages
613 // so the player doesn't accidentally do something the first frame
616 // send a clc_nop periodically until connected
619 // current input to send to the server
622 // information for local display
624 int stats[MAX_CL_STATS];
625 // last known inventory bit flags, for blinking
627 // cl.time of acquiring item, for blinking
628 float item_gettime[32];
629 // last known STAT_ACTIVEWEAPON
631 // cl.time of changing STAT_ACTIVEWEAPON
633 // use pain anim frame if cl.time < this
636 // color shifts for damage, powerups
637 cshift_t cshifts[NUM_CSHIFTS];
639 cshift_t prev_cshifts[NUM_CSHIFTS];
641 // the client maintains its own idea of view angles, which are
642 // sent to the server each frame. The server sets punchangle when
643 // the view is temporarily offset, and an angle reset commands at the start
644 // of each level and after teleporting.
646 // mviewangles is read from demo
647 // viewangles is either client controlled or lerped from mviewangles
648 vec3_t mviewangles[2], viewangles;
649 // update by server, used by qc to do weapon recoil
650 vec3_t mpunchangle[2], punchangle;
651 // update by server, can be used by mods to kick view around
652 vec3_t mpunchvector[2], punchvector;
653 // update by server, used for lean+bob (0 is newest)
654 vec3_t mvelocity[2], velocity;
655 // update by server, can be used by mods for zooming
656 vec_t mviewzoom[2], viewzoom;
657 // if true interpolation the mviewangles and other interpolation of the
658 // player is disabled until the next network packet
659 // this is used primarily by teleporters, and when spectating players
660 // special checking of the old fixangle[1] is used to differentiate
661 // between teleporting and spectating
662 qboolean fixangle[2];
664 // client movement simulation
665 // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
667 // this is set true by svc_time parsing and causes a new movement to be
668 // queued for prediction purposes
669 qboolean movement_needupdate;
670 // indicates the queue has been updated and should be replayed
671 qboolean movement_replay;
672 // timestamps of latest two predicted moves for interpolation
673 double movement_time[2];
674 // simulated data (this is valid even if cl.movement is false)
675 vec3_t movement_origin;
676 vec3_t movement_oldorigin;
677 vec3_t movement_velocity;
678 // queue of proposed moves
679 int movement_numqueue;
680 client_movementqueue_t movement_queue[64];
682 int servermovesequence;
683 // whether the replay should allow a jump at the first sequence
684 qboolean movement_replay_canjump;
686 // pitch drifting vars
693 //[515]: added for csqc purposes
694 float sensitivityscale;
695 csqc_vidvars_t csqc_vidvars; //[515]: these parms must be set to true by default
696 qboolean csqc_wantsmousemove;
697 struct model_s *csqc_model_precache[MAX_MODELS];
699 // local amount for smoothing stepups
708 qboolean oldonground;
709 double lastongroundtime;
710 double hitgroundtime;
712 // don't change view angle, full screen, etc
714 // latched at intermission start
715 double completed_time;
717 // the timestamp of the last two messages
720 // clients view of time, time should be between mtime[0] and mtime[1] to
721 // generate a lerp point for other data, oldtime is the previous frame's
722 // value of time, frametime is the difference between time and oldtime
723 double time, oldtime;
724 // how long it has been since the previous client frame in real time
725 // (not game time, for that use cl.time - cl.oldtime)
726 double realframetime;
728 // copy of realtime from last recieved message, for net trouble icon
729 float last_received_message;
731 // information that is static for the entire time connected to a server
732 struct model_s *model_precache[MAX_MODELS];
733 struct sfx_s *sound_precache[MAX_SOUNDS];
735 // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
736 char model_name[MAX_MODELS][MAX_QPATH];
737 char sound_name[MAX_SOUNDS][MAX_QPATH];
739 // for display on solo scoreboard
741 // cl_entitites[cl.viewentity] = player
743 // the real player entity (normally same as viewentity,
744 // different than viewentity if mod uses chasecam or other tricks)
746 // max players that can be in this game
748 // type of game (deathmatch, coop, singleplayer)
751 // models and sounds used by engine code (particularly cl_parse.c)
753 model_t *model_bolt2;
754 model_t *model_bolt3;
757 sfx_t *sfx_knighthit;
764 // refresh related state
766 // cl_entitites[0].model
767 struct model_s *worldmodel;
773 int cdtrack, looptrack;
778 scoreboard_t *scores;
780 // entity database stuff
781 // latest received entity frame numbers
782 #define LATESTFRAMENUMS 3
783 int latestframenums[LATESTFRAMENUMS];
784 entityframe_database_t *entitydatabase;
785 entityframe4_database_t *entitydatabase4;
786 entityframeqw_database_t *entitydatabaseqw;
788 // keep track of quake entities because they need to be killed if they get stale
790 unsigned char isquakeentity[MAX_EDICTS];
792 // bounding boxes for clientside movement
793 vec3_t playerstandmins;
794 vec3_t playerstandmaxs;
795 vec3_t playercrouchmins;
796 vec3_t playercrouchmaxs;
799 int max_csqcentities;
800 int max_static_entities;
801 int max_temp_entities;
806 int max_brushmodel_entities;
810 entity_t *csqcentities; //[515]: csqc
811 unsigned char *entities_active;
812 unsigned char *csqcentities_active; //[515]: csqc
813 entity_t *static_entities;
814 entity_t *temp_entities;
815 cl_effect_t *effects;
818 lightstyle_t *lightstyle;
819 int *brushmodel_entities;
820 particle_t *particles;
823 int num_csqcentities; //[515]: csqc
824 int num_static_entities;
825 int num_temp_entities;
826 int num_brushmodel_entities;
836 // local copy of the server infostring
837 char qw_serverinfo[MAX_SERVERINFO_STRING];
839 // time of last qw "pings" command sent to server while showing scores
840 double last_ping_request;
842 // used during connect
845 // updated from serverinfo
848 // indicates whether the player is spectating
849 qboolean qw_spectator;
851 // movement parameters for client prediction
852 float qw_movevars_gravity;
853 float qw_movevars_stopspeed;
854 float qw_movevars_maxspeed; // can change during play
855 float qw_movevars_spectatormaxspeed;
856 float qw_movevars_accelerate;
857 float qw_movevars_airaccelerate;
858 float qw_movevars_wateraccelerate;
859 float qw_movevars_friction;
860 float qw_movevars_waterfriction;
861 float qw_movevars_entgravity; // can change during play
863 // models used by qw protocol
864 int qw_modelindex_spike;
865 int qw_modelindex_player;
866 int qw_modelindex_flag;
867 int qw_modelindex_s_explod;
869 vec3_t qw_intermission_origin;
870 vec3_t qw_intermission_angles;
872 // 255 is the most nails the QW protocol could send
874 vec_t qw_nails[255][6];
878 int qw_validsequence;
880 qw_usercmd_t qw_moves[QW_UPDATE_BACKUP];
882 int qw_deltasequence[QW_UPDATE_BACKUP];
889 extern cvar_t cl_name;
890 extern cvar_t cl_color;
891 extern cvar_t cl_rate;
892 extern cvar_t cl_pmodel;
893 extern cvar_t cl_playermodel;
894 extern cvar_t cl_playerskin;
896 extern cvar_t rcon_password;
897 extern cvar_t rcon_address;
899 extern cvar_t cl_upspeed;
900 extern cvar_t cl_forwardspeed;
901 extern cvar_t cl_backspeed;
902 extern cvar_t cl_sidespeed;
904 extern cvar_t cl_movespeedkey;
906 extern cvar_t cl_yawspeed;
907 extern cvar_t cl_pitchspeed;
909 extern cvar_t cl_anglespeedkey;
911 extern cvar_t cl_autofire;
913 extern cvar_t csqc_progname; //[515]: csqc crc check and right csprogs name according to progs.dat
914 extern cvar_t csqc_progcrc;
916 extern cvar_t cl_shownet;
917 extern cvar_t cl_nolerp;
919 extern cvar_t cl_pitchdriftspeed;
920 extern cvar_t lookspring;
921 extern cvar_t lookstrafe;
922 extern cvar_t sensitivity;
924 extern cvar_t freelook;
926 extern cvar_t m_pitch;
928 extern cvar_t m_forward;
929 extern cvar_t m_side;
931 extern cvar_t cl_autodemo;
932 extern cvar_t cl_autodemo_nameformat;
934 extern cvar_t r_draweffects;
936 extern cvar_t cl_explosions_alpha_start;
937 extern cvar_t cl_explosions_alpha_end;
938 extern cvar_t cl_explosions_size_start;
939 extern cvar_t cl_explosions_size_end;
940 extern cvar_t cl_explosions_lifetime;
941 extern cvar_t cl_stainmaps;
942 extern cvar_t cl_stainmaps_clearonload;
944 extern cvar_t cl_prydoncursor;
946 extern client_state_t cl;
948 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);
950 //=============================================================================
956 void CL_Shutdown (void);
959 void CL_EstablishConnection(const char *host);
961 void CL_Disconnect (void);
962 void CL_Disconnect_f (void);
964 void CL_BoundingBoxForEntity(entity_render_t *ent);
966 extern cvar_t cl_beams_polygons;
967 extern cvar_t cl_beams_relative;
968 extern cvar_t cl_beams_lightatend;
973 typedef struct kbutton_s
975 int down[2]; // key nums holding it down
976 int state; // low bit is down state
980 extern kbutton_t in_mlook, in_klook;
981 extern kbutton_t in_strafe;
982 extern kbutton_t in_speed;
984 void CL_InitInput (void);
985 void CL_SendMove (void);
987 void CL_ValidateState(entity_state_t *s);
988 void CL_MoveLerpEntityStates(entity_t *ent);
989 void CL_LerpUpdate(entity_t *e);
990 void CL_ParseTEnt (void);
991 void CL_RelinkBeams (void);
993 void CL_ClearTempEntities (void);
994 entity_t *CL_NewTempEntity (void);
996 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
998 void CL_ClearState (void);
999 void CL_ExpandEntities(int num);
1000 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet);
1003 int CL_ReadFromServer (void);
1004 void CL_WriteToServer (void);
1005 void CL_Move (void);
1006 extern qboolean cl_ignoremousemove;
1009 float CL_KeyState (kbutton_t *key);
1010 const char *Key_KeynumToString (int keynum);
1011 int Key_StringToKeynum (const char *str);
1016 void CL_StopPlayback(void);
1017 void CL_ReadDemoMessage(void);
1018 void CL_WriteDemoMessage(void);
1020 void CL_NextDemo(void);
1021 void CL_Stop_f(void);
1022 void CL_Record_f(void);
1023 void CL_PlayDemo_f(void);
1024 void CL_TimeDemo_f(void);
1029 void CL_Parse_Init(void);
1030 void CL_Parse_Shutdown(void);
1031 void CL_ParseServerMessage(void);
1032 void CL_Parse_DumpPacket(void);
1033 void CL_Parse_ErrorCleanUp(void);
1034 void QW_CL_StartUpload(unsigned char *data, int size);
1035 extern cvar_t qport;
1040 void V_StartPitchDrift (void);
1041 void V_StopPitchDrift (void);
1044 float V_CalcRoll (vec3_t angles, vec3_t velocity);
1045 void V_UpdateBlends (void);
1046 void V_ParseDamage (void);
1052 extern cvar_t cl_particles;
1053 extern cvar_t cl_particles_quality;
1054 extern cvar_t cl_particles_size;
1055 extern cvar_t cl_particles_quake;
1056 extern cvar_t cl_particles_blood;
1057 extern cvar_t cl_particles_blood_alpha;
1058 extern cvar_t cl_particles_blood_bloodhack;
1059 extern cvar_t cl_particles_bulletimpacts;
1060 extern cvar_t cl_particles_explosions_bubbles;
1061 extern cvar_t cl_particles_explosions_smoke;
1062 extern cvar_t cl_particles_explosions_sparks;
1063 extern cvar_t cl_particles_explosions_shell;
1064 extern cvar_t cl_particles_smoke;
1065 extern cvar_t cl_particles_smoke_alpha;
1066 extern cvar_t cl_particles_smoke_alphafade;
1067 extern cvar_t cl_particles_sparks;
1068 extern cvar_t cl_particles_bubbles;
1069 extern cvar_t cl_decals;
1070 extern cvar_t cl_decals_time;
1071 extern cvar_t cl_decals_fadetime;
1073 void CL_Particles_Clear(void);
1074 void CL_Particles_Init(void);
1075 void CL_Particles_Shutdown(void);
1077 typedef enum effectnameindex_s
1081 EFFECT_TE_GUNSHOTQUAD,
1083 EFFECT_TE_SPIKEQUAD,
1084 EFFECT_TE_SUPERSPIKE,
1085 EFFECT_TE_SUPERSPIKEQUAD,
1087 EFFECT_TE_KNIGHTSPIKE,
1088 EFFECT_TE_VORESPIKE,
1089 EFFECT_TE_EXPLOSION,
1090 EFFECT_TE_EXPLOSIONQUAD,
1091 EFFECT_TE_TAREXPLOSION,
1093 EFFECT_TE_LAVASPLASH,
1094 EFFECT_TE_SMALLFLASH,
1099 EFFECT_TE_PLASMABURN,
1101 EFFECT_TE_TEI_SMOKE,
1102 EFFECT_TE_TEI_BIGEXPLOSION,
1103 EFFECT_TE_TEI_PLASMAHIT,
1109 EFFECT_TR_SLIGHTBLOOD,
1110 EFFECT_TR_KNIGHTSPIKE,
1111 EFFECT_TR_VORESPIKE,
1112 EFFECT_TR_NEHAHRASMOKE,
1113 EFFECT_TR_NEXUIZPLASMA,
1114 EFFECT_TR_GLOWTRAIL,
1115 EFFECT_SVC_PARTICLE,
1120 int CL_ParticleEffectIndexForName(const char *name);
1121 const char *CL_ParticleEffectNameForIndex(int i);
1122 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);
1123 void CL_ParseParticleEffect (void);
1124 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);
1125 void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type);
1126 void CL_EntityParticles (const entity_t *ent);
1127 void CL_ParticleExplosion (const vec3_t org);
1128 void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength);
1129 void CL_MoveParticles(void);
1130 void R_MoveExplosions(void);
1131 void R_NewExplosion(const vec3_t org);
1133 #include "cl_screen.h"
1135 #define NUMCROSSHAIRS 32
1136 extern cachepic_t *r_crosshairs[NUMCROSSHAIRS+1];
1138 #define FOGTABLEWIDTH 1024
1139 extern int fogtableindex;
1140 #define VERTEXFOGTABLE(dist) (fogtableindex = (int)((dist) * r_refdef.fogtabledistmultiplier), r_refdef.fogtable[bound(0, fogtableindex, FOGTABLEWIDTH - 1)])
1142 typedef struct r_refdef_stats_s
1145 int entities_surfaces;
1146 int entities_triangles;
1151 int meshes_elements;
1154 int lights_scissored;
1155 int lights_lighttriangles;
1156 int lights_shadowtriangles;
1157 int lights_dynamicshadowtriangles;
1159 int bloom_copypixels;
1160 int bloom_drawpixels;
1164 typedef struct r_refdef_s
1166 // these fields define the basic rendering information for the world
1167 // but not the view, which could change multiple times in one rendered
1168 // frame (for example when rendering textures for certain effects)
1170 // these are set for water warping before
1171 // frustum_x/frustum_y are calculated
1172 float frustumscale_x, frustumscale_y;
1174 // minimum visible distance (pixels closer than this disappear)
1176 // maximum visible distance (pixels further than this disappear in 16bpp modes,
1177 // in 32bpp an infinite-farclip matrix is used instead)
1180 // fullscreen color blend
1183 // whether to call S_ExtraUpdate during render to reduce sound chop
1184 qboolean extraupdate;
1186 // client gameworld time for rendering time based effects
1190 entity_render_t *worldentity;
1192 // same as worldentity->model
1193 model_t *worldmodel;
1195 // renderable entities (excluding world)
1196 entity_render_t **entities;
1200 // renderable dynamic lights
1201 dlight_t *lights[MAX_DLIGHTS];
1204 // 8.8bit fixed point intensities for light styles
1205 // controls intensity of dynamic lights and lightmap layers
1206 unsigned short lightstylevalue[256]; // 8.8 fraction of base light value
1210 vec_t fograngerecip;
1211 vec_t fogtabledistmultiplier;
1212 float fogtable[FOGTABLEWIDTH];
1217 qboolean fogenabled;
1218 qboolean oldgl_fogenable;
1220 qboolean draw2dstage;
1222 // true during envmap command capture
1225 // brightness of world lightmaps and related lighting
1226 // (often reduced when world rtlights are enabled)
1227 float lightmapintensity;
1228 // whether to draw world lights realtime, dlights realtime, and their shadows
1230 qboolean rtworldshadows;
1232 qboolean rtdlightshadows;
1233 float polygonfactor;
1234 float polygonoffset;
1235 float shadowpolygonfactor;
1236 float shadowpolygonoffset;
1238 // rendering stats for r_speeds display
1239 // (these are incremented in many places)
1240 r_refdef_stats_t stats;
1244 typedef struct r_view_s
1246 // view information (changes multiple times per frame)
1247 // if any of these variables change then r_viewcache must be regenerated
1248 // by calling R_View_Update
1249 // (which also updates viewport, scissor, colormask)
1251 // it is safe and expected to copy this into a structure on the stack and
1252 // call the renderer recursively, then restore from the stack afterward
1253 // (as long as R_View_Update is called)
1255 // eye position information
1262 mplane_t frustum[5];
1263 float frustum_x, frustum_y;
1265 // screen area to render in
1273 // which color components to allow (for anaglyph glasses)
1278 typedef struct r_viewcache_s
1280 // these properties are generated by R_View_Update()
1282 // which entities are currently visible for this viewpoint
1283 // (the used range is 0...r_refdef.numentities)
1284 unsigned char entityvisible[MAX_EDICTS];
1285 // flag arrays used for visibility checking on world model
1286 // (all other entities have no per-surface/per-leaf visibility checks)
1287 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
1288 unsigned char world_pvsbits[(32768+7)>>3];
1289 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
1290 unsigned char world_leafvisible[32768];
1291 // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
1292 unsigned char world_surfacevisible[262144];
1293 // if true, the view is currently in a leaf without pvs data
1294 qboolean world_novis;
1298 extern r_refdef_t r_refdef;
1299 extern r_view_t r_view;
1300 extern r_viewcache_t r_viewcache;