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()
47 memset(effect, 0, sizeof(effect));
50 void r_effects_shutdown()
54 void CL_Effects_Init()
56 Cvar_RegisterVariable(&r_draweffects);
58 R_RegisterModule("R_Effects", r_effects_start, r_effects_shutdown);
61 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
65 if (!modelindex) // sanity check
67 for (i = 0, e = effect;i < MAX_EFFECTS;i++, e++)
72 VectorCopy(org, e->origin);
73 e->modelindex = modelindex;
74 e->starttime = cl.time;
75 e->startframe = startframe;
76 e->endframe = startframe + framecount;
77 e->framerate = framerate;
80 e->frame1start = cl.time;
81 e->frame2start = cl.time;
93 for (i = 0, e = effect;i < MAX_EFFECTS;i++, e++)
97 frame = (cl.time - e->starttime) * e->framerate + e->startframe;
99 if (intframe < 0 || intframe >= e->endframe)
102 memset(e, 0, sizeof(*e));
106 if (intframe != e->frame)
109 e->frame1start = e->frame2start;
110 e->frame2start = cl.time;
113 vis = CL_NewTempEntity();
116 VectorCopy(e->origin, vis->origin);
117 vis->lerp_model = vis->model = cl.model_precache[e->modelindex];
118 vis->frame1 = e->frame;
119 vis->frame2 = e->frame + 1;
120 if (vis->frame2 >= e->endframe)
121 vis->frame2 = -1; // disappear
122 vis->frame = vis->frame2;
123 vis->framelerp = frame - vis->frame1;
124 vis->frame1start = e->frame1start;
125 vis->frame2start = e->frame2start;
126 vis->lerp_starttime = -1;
127 vis->colormap = -1; // no special coloring
130 vis->colormod[0] = vis->colormod[1] = vis->colormod[2] = 1;