1 float teamradar_angle; // player yaw angle
2 vector teamradar_origin3d_in_texcoord; // player origin
3 vector teamradar_origin2d; // 2D origin
4 vector teamradar_size2d; // 2D size
5 vector teamradar_extraclip_mins, teamradar_extraclip_maxs; // don't even ask
6 float teamradar_size; // 2D scale factor
7 float cl_teamradar_scale; // window size = ...qu
8 float cl_teamradar_nohudhack;
11 float vlen2d(vector v)
13 return sqrt(v_x * v_x + v_y * v_y);
16 float vlen_maxnorm2d(vector v)
18 return max4(v_x, v_y, -v_x, -v_y);
21 float vlen_minnorm2d(vector v)
23 return min(max(v_x, -v_x), max(v_y, -v_y));
26 vector teamradar_3dcoord_to_texcoord(vector in)
29 out_x = (in_x - mi_picmin_x) / (mi_picmax_x - mi_picmin_x);
30 out_y = (in_y - mi_picmin_y) / (mi_picmax_y - mi_picmin_y);
35 vector teamradar_texcoord_to_2dcoord(vector in)
38 in -= teamradar_origin3d_in_texcoord;
40 out = rotate(in, teamradar_angle * DEG2RAD);
41 out_y = - out_y; // screen space is reversed
43 out = out * teamradar_size;
46 out += teamradar_origin2d;
50 vector yinvert(vector v)
56 void draw_teamradar_background(float bg, float fg)
62 R_BeginPolygon("", 0);
63 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x - teamradar_size2d_x * 0.5 + teamradar_extraclip_mins_x) + '0 1 0' * (teamradar_origin2d_y - teamradar_size2d_y * 0.5 + teamradar_extraclip_mins_y), '0 0 0', '0 0 0', bg);
64 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x + teamradar_size2d_x * 0.5 + teamradar_extraclip_maxs_x) + '0 1 0' * (teamradar_origin2d_y - teamradar_size2d_y * 0.5 + teamradar_extraclip_mins_y), '0 0 0', '0 0 0', bg);
65 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x + teamradar_size2d_x * 0.5 + teamradar_extraclip_maxs_x) + '0 1 0' * (teamradar_origin2d_y + teamradar_size2d_y * 0.5 + teamradar_extraclip_maxs_y), '0 0 0', '0 0 0', bg);
66 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x - teamradar_size2d_x * 0.5 + teamradar_extraclip_mins_x) + '0 1 0' * (teamradar_origin2d_y + teamradar_size2d_y * 0.5 + teamradar_extraclip_maxs_y), '0 0 0', '0 0 0', bg);
70 if(fg > 0 && minimapname != "")
74 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP);
77 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
78 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
79 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
80 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
84 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
85 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
86 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
87 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
93 void(vector coord3d, vector pangles, vector rgb) draw_teamradar_player =
97 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord3d));
99 makevectors(pangles - '0 1 0' * teamradar_angle);
102 v_forward_x = -v_forward_x;
103 v_right_x = -v_right_x;
107 v_forward = normalize(v_forward);
109 v_right_x = -v_forward_y;
110 v_right_y = v_forward_x;
117 R_BeginPolygon("", 0);
118 R_PolygonVertex(coord+v_forward*3, '0 0 0', rgb2, hud_alpha_fg);
119 R_PolygonVertex(coord+v_right*4-v_forward*2.5, '0 1 0', rgb2, hud_alpha_fg);
120 R_PolygonVertex(coord-v_forward*2, '1 0 0', rgb2, hud_alpha_fg);
121 R_PolygonVertex(coord-v_right*4-v_forward*2.5, '1 1 0', rgb2, hud_alpha_fg);
124 R_BeginPolygon("", 0);
125 R_PolygonVertex(coord+v_forward*2, '0 0 0', rgb, hud_alpha_fg);
126 R_PolygonVertex(coord+v_right*3-v_forward*2, '0 1 0', rgb, hud_alpha_fg);
127 R_PolygonVertex(coord-v_forward, '1 0 0', rgb, hud_alpha_fg);
128 R_PolygonVertex(coord-v_right*3-v_forward*2, '1 1 0', rgb, hud_alpha_fg);
132 void draw_teamradar_icon(vector coord, float icon, entity pingdata, vector rgb, float a)
138 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
139 drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon)), '8 8 0', rgb, a, 0);
143 for(i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
145 dt = pingdata.(teamradar_times[i]);
149 if(dt >= 1 || dt <= 0)
151 v = '2 2 0' * teamradar_size * dt;
152 drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
157 void draw_teamradar_link(vector start, vector end, float colors)
161 start = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(start));
162 end = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(end));
163 norm = normalize(start - end);
169 c0 = colormapPaletteColor(colors & 0x0F, FALSE);
170 c1 = colormapPaletteColor((colors & 0xF0) / 0x10, FALSE);
172 R_BeginPolygon("", 0);
173 R_PolygonVertex(start - norm, '0 0 0', c0, hud_alpha_fg);
174 R_PolygonVertex(start + norm, '0 1 0', c0, hud_alpha_fg);
175 R_PolygonVertex(end + norm, '1 1 0', c1, hud_alpha_fg);
176 R_PolygonVertex(end - norm, '1 0 0', c1, hud_alpha_fg);
180 float cl_teamradar_scale;
181 float cl_teamradar_background_alpha;
182 float cl_teamradar_foreground_alpha;
183 float cl_teamradar_rotation;
184 vector cl_teamradar_size;
185 vector cl_teamradar_position;
186 float cl_teamradar_zoommode;
188 void teamradar_loadcvars()
190 v_flipped = cvar("v_flipped");
193 cl_teamradar_scale = 42; // dummy, not used (see zoommode)
194 cl_teamradar_background_alpha = 1 * (1 - cvar("_menu_alpha"));
195 cl_teamradar_foreground_alpha = 1 * (1 - cvar("_menu_alpha"));
196 cl_teamradar_rotation = cvar("cl_teamradar_rotation");
197 if(!cl_teamradar_rotation)
198 cl_teamradar_rotation = 4;
199 cl_teamradar_zoommode = 3;
200 cl_teamradar_nohudhack = 0;
204 cl_teamradar_scale = cvar("cl_teamradar_scale");
205 cl_teamradar_background_alpha = cvar("cl_teamradar_background_alpha") * hud_alpha_fg;
206 cl_teamradar_foreground_alpha = cvar("cl_teamradar_foreground_alpha") * hud_alpha_fg;
207 cl_teamradar_rotation = cvar("cl_teamradar_rotation");
208 cl_teamradar_zoommode = cvar("cl_teamradar_zoommode");
210 // others default to 0
211 // match this to defaultXonotic.cfg!
212 if(!cl_teamradar_scale) cl_teamradar_scale = 4096;
213 if(!cl_teamradar_background_alpha) cl_teamradar_background_alpha = 0.4 * hud_alpha_fg;
214 if(!cl_teamradar_foreground_alpha) cl_teamradar_foreground_alpha = 0.8 * hud_alpha_fg;
215 if(!cl_teamradar_size_x) cl_teamradar_size_x = 128;
216 if(!cl_teamradar_size_y) cl_teamradar_size_y = cl_teamradar_size_x;
218 cl_teamradar_size_z = 0;
219 cl_teamradar_nohudhack = cl_teamradar_position_z;
220 cl_teamradar_position_z = 0;
229 sendflags = ReadByte();
231 InterpolateOrigin_Undo();
233 self.iflags = IFLAG_VELOCITY;
234 self.classname = "radarlink";
238 self.origin_x = ReadCoord();
239 self.origin_y = ReadCoord();
240 self.origin_z = ReadCoord();
245 self.velocity_x = ReadCoord();
246 self.velocity_y = ReadCoord();
247 self.velocity_z = ReadCoord();
252 self.team = ReadByte();
255 InterpolateOrigin_Note();