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 static effect_t effect[MAX_EFFECTS];
43 static cvar_t r_draweffects = {0, "r_draweffects", "1"};
45 static void r_effects_start(void)
47 memset(effect, 0, sizeof(effect));
50 static void r_effects_shutdown(void)
54 static 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->frame1time = cl.time;
86 e->frame2time = cl.time;
91 extern void CL_LerpAnimation(entity_t *e);
100 for (i = 0, e = effect;i < MAX_EFFECTS;i++, e++)
104 frame = (cl.time - e->starttime) * e->framerate + e->startframe;
106 if (intframe < 0 || intframe >= e->endframe)
109 memset(e, 0, sizeof(*e));
113 if (intframe != e->frame)
116 e->frame1time = e->frame2time;
117 e->frame2time = cl.time;
120 if ((vis = CL_NewTempEntity()))
122 // interpolation stuff
123 vis->render.frame1 = intframe;
124 vis->render.frame2 = intframe + 1;
125 if (vis->render.frame2 >= e->endframe)
126 vis->render.frame2 = -1; // disappear
127 vis->render.framelerp = frame - intframe;
128 vis->render.frame1time = e->frame1time;
129 vis->render.frame2time = e->frame2time;
132 VectorCopy(e->origin, vis->render.origin);
133 vis->render.model = cl.model_precache[e->modelindex];
134 vis->render.frame = vis->render.frame2;
135 vis->render.colormap = -1; // no special coloring
136 vis->render.scale = 1;
137 vis->render.alpha = 1;
138 vis->render.colormod[0] = vis->render.colormod[1] = vis->render.colormod[2] = 1;