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.
23 #define MAX_EFFECTS 256
25 typedef struct effect_s
34 // these are for interpolation
41 effect_t effect[MAX_EFFECTS];
43 cvar_t r_draweffects = {"r_draweffects", "1"};
45 void r_effects_start(void)
47 memset(effect, 0, sizeof(effect));
50 void r_effects_shutdown(void)
54 void r_effects_newmap(void)
56 memset(effect, 0, sizeof(effect));
59 void CL_Effects_Init(void)
61 Cvar_RegisterVariable(&r_draweffects);
63 R_RegisterModule("R_Effects", r_effects_start, r_effects_shutdown, r_effects_newmap);
66 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
70 if (!modelindex) // sanity check
72 for (i = 0, e = effect;i < MAX_EFFECTS;i++, e++)
77 VectorCopy(org, e->origin);
78 e->modelindex = modelindex;
79 e->starttime = cl.time;
80 e->startframe = startframe;
81 e->endframe = startframe + framecount;
82 e->framerate = framerate;
85 e->frame1start = cl.time;
86 e->frame2start = cl.time;
98 for (i = 0, e = effect;i < MAX_EFFECTS;i++, e++)
102 frame = (cl.time - e->starttime) * e->framerate + e->startframe;
104 if (intframe < 0 || intframe >= e->endframe)
107 memset(e, 0, sizeof(*e));
111 if (intframe != e->frame)
114 e->frame1start = e->frame2start;
115 e->frame2start = cl.time;
118 vis = CL_NewTempEntity();
121 VectorCopy(e->origin, vis->render.origin);
122 vis->render.lerp_model = vis->render.model = cl.model_precache[e->modelindex];
123 vis->render.frame1 = e->frame;
124 vis->render.frame2 = e->frame + 1;
125 if (vis->render.frame2 >= e->endframe)
126 vis->render.frame2 = -1; // disappear
127 vis->render.frame = vis->render.frame2;
128 vis->render.framelerp = frame - vis->render.frame1;
129 vis->render.frame1start = e->frame1start;
130 vis->render.frame2start = e->frame2start;
131 vis->render.lerp_starttime = -1;
132 vis->render.colormap = -1; // no special coloring
133 vis->render.scale = 1;
134 vis->render.alpha = 1;
135 vis->render.colormod[0] = vis->render.colormod[1] = vis->render.colormod[2] = 1;