28 while (
vdist(c - b, >, 1))
47 if (n > 200)
LOG_TRACE(
"HOLY SHIT! FullTraceFraction: ",
ftos(n),
" total traces, ",
ftos(m),
" iterations");
49 return white / (black + white);
51 float RadarMapAtPoint_Trace(
float e,
float f,
float w,
float h,
float zmin,
float zsize,
float q)
56 ma =
'1 0 0' * w +
'0 1 0' * h;
57 a =
'1 0 0' * e +
'0 1 0' * f +
'0 0 1' * zmin;
58 b =
'1 0 0' * e +
'0 1 0' * f +
'0 0 1' * (zsize + zmin);
60 return FullTraceFraction(a, mi, ma, b);
62 float RadarMapAtPoint_LineBlock(
float e,
float f,
float w,
float h,
float zmin,
float zsize,
float q)
72 dz = (zsize / q) *
'0 0 1';
73 ma =
'1 0 0' * w +
'0 1 0' * h + dz;
74 o =
'1 0 0' * e +
'0 1 0' * f +
'0 0 1' * zmin;
76 if (e <
world.absmin.x - w)
return 0;
77 if (f <
world.absmin.y - h)
return 0;
78 if (e >
world.absmax.x)
return 0;
79 if (f >
world.absmax.y)
return 0;
82 for (i = 0; i < q; ++i)
85 v1 = v2 = o + dz * i + mi;
86 v1_x +=
random() * (ma.x - mi.x);
87 v1_y +=
random() * (ma.y - mi.y);
88 v1_z +=
random() * (ma.z - mi.z);
89 v2_x +=
random() * (ma.x - mi.x);
90 v2_y +=
random() * (ma.y - mi.y);
91 v2_z +=
random() * (ma.z - mi.z);
97 float RadarMapAtPoint_Block(
float e,
float f,
float w,
float h,
float zmin,
float zsize,
float q)
107 dz = (zsize / q) *
'0 0 1';
108 ma =
'1 0 0' * w +
'0 1 0' * h + dz;
109 o =
'1 0 0' * e +
'0 1 0' * f +
'0 0 1' * zmin;
111 if (e <
world.absmin.x - w)
return 0;
112 if (f <
world.absmin.y - h)
return 0;
113 if (e >
world.absmax.x)
return 0;
114 if (f >
world.absmax.y)
return 0;
117 for (i = 0; i < q; ++i)
124 float RadarMapAtPoint_Sample(
float e,
float f,
float w,
float h,
float zmin,
float zsize,
float q)
134 ma =
'1 0 0' * w +
'0 1 0' * h;
135 a =
'1 0 0' * e +
'0 1 0' * f +
'0 0 1' * zmin;
136 b =
'1 0 0' * w +
'0 1 0' * h +
'0 0 1' * zsize;
141 for (i = 0; i < q; ++i)
144 v.x = a.x +
random() * b.x;
145 v.y = a.y +
random() * b.y;
146 v.z = a.z +
random() * b.z;
153 void sharpen_set(
int b,
float v)
155 sharpen_buffer[b + 2 * RADAR_WIDTH_MAX] =
v;
157 float sharpen_getpixel(
int b,
int c)
160 if (b >= RADAR_WIDTH_MAX)
return 0;
163 return sharpen_buffer[b + c * RADAR_WIDTH_MAX];
165 float sharpen_get(
float b,
float a)
167 float sum = sharpen_getpixel(b, 1);
168 if (a == 0)
return sum;
170 sum -= sharpen_getpixel(b - 1, 0);
171 sum -= sharpen_getpixel(b - 1, 1);
172 sum -= sharpen_getpixel(b - 1, 2);
173 sum -= sharpen_getpixel(b + 1, 0);
174 sum -= sharpen_getpixel(b + 1, 1);
175 sum -= sharpen_getpixel(b + 1, 2);
176 sum -= sharpen_getpixel(b, 0);
177 sum -= sharpen_getpixel(b, 2);
178 return bound(0, sum * a, 1);
180 void sharpen_shift(
int w)
182 for (
int i = 0; i < w; ++i)
184 sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX];
185 sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX];
186 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
189 void sharpen_init(
int w)
191 for (
int i = 0; i < w; ++i)
193 sharpen_buffer[i] = 0;
194 sharpen_buffer[i + RADAR_WIDTH_MAX] = 0;
195 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
200 if (radarmapper.count & 4)
204 else if (radarmapper.count & 2)
206 localcmd(
strcat(
"defer 1 \"sv_cmd radarmap --flags ",
ftos(radarmapper.count),
strcat(
" --res ",
ftos(radarmapper.size.x),
" ",
ftos(radarmapper.size.y),
" --sharpen ",
ftos(radarmapper.ltime),
" --qual ",
ftos(radarmapper.size.z)),
"\"\n"));
212 void RadarMap_Think(
entity this)
226 get_mi_min_max_texcoords(1);
227 this.
mins = mi_picmin;
228 this.maxs_x = (mi_picmax.x - mi_picmin.x) / this.
size.x;
229 this.maxs_y = (mi_picmax.y - mi_picmin.y) / this.
size.y;
230 this.maxs_z = mi_max.z - mi_min.z;
233 if (!(this.
count & 1))
246 LOG_INFO(this.
netname,
" already exists, aborting (you may want to specify --force)");
261 fputs(this.
cnt,
"static char *RadarMap[] = {\n");
262 fputs(this.
cnt,
"/* columns rows colors chars-per-pixel */\n");
264 for (i = 0; i < 256; ++i)
271 sharpen_init(this.
size.x);
276 sharpen_shift(this.
size.x);
283 for (x = 0; x < this.
size.x; ++x)
285 l = RadarMapAtPoint_Block(this.
mins.x + x *
this.maxs.x,
this.mins.y + (
this.size.y -
this.frame) *
this.maxs.y,
this.maxs.x,
this.maxs.y,
this.mins.z,
this.maxs.z,
this.size.z);
290 for (x = 0; x < this.
size.x; ++x)
292 l = RadarMapAtPoint_Trace(this.
mins.x + x *
this.maxs.x,
this.mins.y + (
this.size.y -
this.frame) *
this.maxs.y,
this.maxs.x,
this.maxs.y,
this.mins.z,
this.maxs.z,
this.size.z);
297 for (x = 0; x < this.
size.x; ++x)
299 l = RadarMapAtPoint_Sample(this.
mins.x + x *
this.maxs.x,
this.mins.y + (
this.size.y -
this.frame) *
this.maxs.y,
this.maxs.x,
this.maxs.y,
this.mins.z,
this.maxs.z,
this.size.z);
304 for (x = 0; x < this.
size.x; ++x)
306 l = RadarMapAtPoint_LineBlock(this.
mins.x + x *
this.maxs.x,
this.mins.y + (
this.size.y -
this.frame) *
this.maxs.y,
this.maxs.x,
this.maxs.y,
this.mins.z,
this.maxs.z,
this.size.z);
317 for (x = 0; x < this.
size.x; ++x)
319 l = sharpen_get(x, this.
ltime);
336 sharpen_shift(this.
size.x);
339 for (x = 0; x < this.
size.x; ++x)
341 l = sharpen_get(x, this.
ltime);
363 LOG_INFO(
"Finished. Please edit data/", this.
netname,
" with an image editing application and place it in the TGA format in the gfx folder.");
374 radarmapper =
new(radarmapper);
375 setthink(radarmapper, RadarMap_Think);
376 radarmapper.nextthink =
time;
377 radarmapper.count = 8;
378 radarmapper.ltime = 1;
379 radarmapper.size =
'512 512 1';
380 for (i = 1; i < argc; ++i)
385 { radarmapper.count |= 1;
389 { radarmapper.count |= 2;
393 { radarmapper.count |= 4;
397 { radarmapper.count &= ~24;
401 { radarmapper.count &= ~24;
402 radarmapper.count |= 8;
406 { radarmapper.count &= ~24;
407 radarmapper.count |= 16;
411 { radarmapper.count |= 24;
449 LOG_INFO(
"Radarmap entity spawned.");
void GotoNextMap(float reinit)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
bool RadarMap_Make(int argc)