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; // for non-centered radar display
6 float teamradar_size; // 2D scale factor
7 float hud_panel_radar_scale; // window size = ...qu
10 float vlen2d(vector v)
12 return sqrt(v_x * v_x + v_y * v_y);
15 float vlen_maxnorm2d(vector v)
17 return max4(v_x, v_y, -v_x, -v_y);
20 float vlen_minnorm2d(vector v)
22 return min(max(v_x, -v_x), max(v_y, -v_y));
25 vector teamradar_3dcoord_to_texcoord(vector in)
28 out_x = (in_x - mi_picmin_x) / (mi_picmax_x - mi_picmin_x);
29 out_y = (in_y - mi_picmin_y) / (mi_picmax_y - mi_picmin_y);
34 vector teamradar_texcoord_to_2dcoord(vector in)
37 in -= teamradar_origin3d_in_texcoord;
39 out = rotate(in, teamradar_angle * DEG2RAD);
40 out_y = - out_y; // screen space is reversed
42 out = out * teamradar_size;
45 out += teamradar_origin2d;
49 vector yinvert(vector v)
55 void draw_teamradar_background(float fg)
60 if(fg > 0 && minimapname != "")
64 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP);
67 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
68 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
69 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
70 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
74 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
75 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
76 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
77 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
83 void(vector coord3d, vector pangles, vector rgb) draw_teamradar_player =
87 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord3d));
89 makevectors(pangles - '0 1 0' * teamradar_angle);
92 v_forward_x = -v_forward_x;
93 v_right_x = -v_right_x;
97 v_forward = normalize(v_forward);
99 v_right_x = -v_forward_y;
100 v_right_y = v_forward_x;
107 R_BeginPolygon("", 0);
108 R_PolygonVertex(coord+v_forward*3, '0 0 0', rgb2, panel_fg_alpha);
109 R_PolygonVertex(coord+v_right*4-v_forward*2.5, '0 1 0', rgb2, panel_fg_alpha);
110 R_PolygonVertex(coord-v_forward*2, '1 0 0', rgb2, panel_fg_alpha);
111 R_PolygonVertex(coord-v_right*4-v_forward*2.5, '1 1 0', rgb2, panel_fg_alpha);
114 R_BeginPolygon("", 0);
115 R_PolygonVertex(coord+v_forward*2, '0 0 0', rgb, panel_fg_alpha);
116 R_PolygonVertex(coord+v_right*3-v_forward*2, '0 1 0', rgb, panel_fg_alpha);
117 R_PolygonVertex(coord-v_forward, '1 0 0', rgb, panel_fg_alpha);
118 R_PolygonVertex(coord-v_right*3-v_forward*2, '1 1 0', rgb, panel_fg_alpha);
122 void draw_teamradar_icon(vector coord, float icon, entity pingdata, vector rgb, float a)
128 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
129 drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon)), '8 8 0', rgb, a, 0);
133 for(i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
135 dt = pingdata.(teamradar_times[i]);
139 if(dt >= 1 || dt <= 0)
141 v = '2 2 0' * teamradar_size * dt;
142 drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
147 void draw_teamradar_link(vector start, vector end, float colors)
151 start = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(start));
152 end = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(end));
153 norm = normalize(start - end);
159 c0 = colormapPaletteColor(colors & 0x0F, FALSE);
160 c1 = colormapPaletteColor((colors & 0xF0) / 0x10, FALSE);
162 R_BeginPolygon("", 0);
163 R_PolygonVertex(start - norm, '0 0 0', c0, panel_fg_alpha);
164 R_PolygonVertex(start + norm, '0 1 0', c0, panel_fg_alpha);
165 R_PolygonVertex(end + norm, '1 1 0', c1, panel_fg_alpha);
166 R_PolygonVertex(end - norm, '1 0 0', c1, panel_fg_alpha);
170 float hud_panel_radar_scale;
171 float hud_panel_radar_foreground_alpha;
172 float hud_panel_radar_rotation;
173 vector hud_panel_radar_size;
174 float hud_panel_radar_zoommode;
176 void teamradar_loadcvars()
178 v_flipped = autocvar_v_flipped;
179 hud_panel_radar_scale = autocvar_hud_panel_radar_scale;
180 hud_panel_radar_foreground_alpha = autocvar_hud_panel_radar_foreground_alpha * panel_fg_alpha;
181 hud_panel_radar_rotation = autocvar_hud_panel_radar_rotation;
182 hud_panel_radar_zoommode = autocvar_hud_panel_radar_zoommode;
184 // others default to 0
185 // match this to defaultXonotic.cfg!
186 if(!hud_panel_radar_scale) hud_panel_radar_scale = 4096;
187 if(!hud_panel_radar_foreground_alpha) hud_panel_radar_foreground_alpha = 0.8 * panel_fg_alpha;
188 if(!hud_panel_radar_size_x) hud_panel_radar_size_x = 128;
189 if(!hud_panel_radar_size_y) hud_panel_radar_size_y = hud_panel_radar_size_x;
197 sendflags = ReadByte();
199 InterpolateOrigin_Undo();
201 self.iflags = IFLAG_VELOCITY;
202 self.classname = "radarlink";
206 self.origin_x = ReadCoord();
207 self.origin_y = ReadCoord();
208 self.origin_z = ReadCoord();
213 self.velocity_x = ReadCoord();
214 self.velocity_y = ReadCoord();
215 self.velocity_z = ReadCoord();
220 self.team = ReadByte();
223 InterpolateOrigin_Note();