2 #include "teamradar.qh"
9 return sqrt(v.x * v.x + v.y * v.y);
12 float vlen_maxnorm2d(vector v)
14 return max(v.x, v.y, -v.x, -v.y);
17 float vlen_minnorm2d(vector v)
19 return min(max(v.x, -v.x), max(v.y, -v.y));
22 vector teamradar_3dcoord_to_texcoord(vector in)
25 out.x = (in.x - mi_picmin.x) / (mi_picmax.x - mi_picmin.x);
26 out.y = (in.y - mi_picmin.y) / (mi_picmax.y - mi_picmin.y);
31 vector teamradar_texcoord_to_2dcoord(vector in)
34 in -= teamradar_origin3d_in_texcoord;
36 out = rotate(in, teamradar_angle * DEG2RAD);
37 out.y = - out.y; // screen space is reversed
39 out = out * teamradar_size;
42 out += teamradar_origin2d;
47 vector teamradar_2dcoord_to_texcoord(vector in)
52 out -= teamradar_origin2d;
55 out = out / teamradar_size;
57 out_y = - out_y; // screen space is reversed
58 out = rotate(out, -teamradar_angle * DEG2RAD);
60 out += teamradar_origin3d_in_texcoord;
65 vector teamradar_texcoord_to_3dcoord(vector in,float z)
68 out_x = in_x * (mi_picmax_x - mi_picmin_x) + mi_picmin_x;
69 out_y = in_y * (mi_picmax_y - mi_picmin_y) + mi_picmin_y;
74 vector yinvert(vector v)
80 void draw_teamradar_background(float fg)
85 if(fg > 0 && minimapname != "")
89 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP);
92 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
93 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
94 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
95 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
99 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
100 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
101 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
102 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
108 void draw_teamradar_player(vector coord3d, vector pangles, vector rgb)
112 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord3d));
114 makevectors(pangles - '0 1 0' * teamradar_angle);
117 v_forward.x = -v_forward.x;
118 v_right.x = -v_right.x;
122 v_forward = normalize(v_forward);
124 v_right.x = -v_forward.y;
125 v_right.y = v_forward.x;
132 R_BeginPolygon("", 0);
133 R_PolygonVertex(coord+v_forward*3, '0 0 0', rgb2, panel_fg_alpha);
134 R_PolygonVertex(coord+v_right*4-v_forward*2.5, '0 1 0', rgb2, panel_fg_alpha);
135 R_PolygonVertex(coord-v_forward*2, '1 0 0', rgb2, panel_fg_alpha);
136 R_PolygonVertex(coord-v_right*4-v_forward*2.5, '1 1 0', rgb2, panel_fg_alpha);
139 R_BeginPolygon("", 0);
140 R_PolygonVertex(coord+v_forward*2, '0 0 0', rgb, panel_fg_alpha);
141 R_PolygonVertex(coord+v_right*3-v_forward*2, '0 1 0', rgb, panel_fg_alpha);
142 R_PolygonVertex(coord-v_forward, '1 0 0', rgb, panel_fg_alpha);
143 R_PolygonVertex(coord-v_right*3-v_forward*2, '1 1 0', rgb, panel_fg_alpha);
147 void draw_teamradar_icon(vector coord, float icon, entity pingdata, vector rgb, float a)
149 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
150 drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon)), '8 8 0', rgb, a, 0);
154 for(int i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
156 float dt = pingdata.(teamradar_times[i]);
160 if(dt >= 1 || dt <= 0)
162 vector v = '2 2 0' * teamradar_size * dt;
163 drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
168 void draw_teamradar_link(vector start, vector end, int colors)
172 start = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(start));
173 end = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(end));
174 norm = normalize(start - end);
180 c0 = colormapPaletteColor(colors & 0x0F, false);
181 c1 = colormapPaletteColor((colors & 0xF0) / 0x10, false);
183 R_BeginPolygon("", 0);
184 R_PolygonVertex(start - norm, '0 0 0', c0, panel_fg_alpha);
185 R_PolygonVertex(start + norm, '0 1 0', c0, panel_fg_alpha);
186 R_PolygonVertex(end + norm, '1 1 0', c1, panel_fg_alpha);
187 R_PolygonVertex(end - norm, '1 0 0', c1, panel_fg_alpha);
191 void teamradar_loadcvars()
193 v_flipped = autocvar_v_flipped;
194 hud_panel_radar_scale = autocvar_hud_panel_radar_scale;
195 if (hud_panel_radar_maximized && !autocvar__hud_configure)
197 if (autocvar_hud_panel_radar_maximized_scale > 0)
198 hud_panel_radar_scale = autocvar_hud_panel_radar_maximized_scale;
200 hud_panel_radar_foreground_alpha = autocvar_hud_panel_radar_foreground_alpha * panel_fg_alpha;
201 hud_panel_radar_rotation = autocvar_hud_panel_radar_rotation;
202 hud_panel_radar_zoommode = autocvar_hud_panel_radar_zoommode;
203 hud_panel_radar_maximized_rotation = autocvar_hud_panel_radar_maximized_rotation;
204 hud_panel_radar_maximized_zoommode = autocvar_hud_panel_radar_maximized_zoommode;
206 // others default to 0
207 // match this to defaultXonotic.cfg!
208 if(!hud_panel_radar_scale) hud_panel_radar_scale = 4096;
209 if(!hud_panel_radar_foreground_alpha) hud_panel_radar_foreground_alpha = 0.8 * panel_fg_alpha;
210 if(!hud_panel_radar_size.x) hud_panel_radar_size.x = 128;
211 if(!hud_panel_radar_size.y) hud_panel_radar_size.y = hud_panel_radar_size.x;
218 int sendflags = ReadByte();
220 InterpolateOrigin_Undo();
222 self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
223 self.classname = "radarlink";
227 self.origin_x = ReadCoord();
228 self.origin_y = ReadCoord();
229 self.origin_z = ReadCoord();
230 setorigin(self, self.origin);
235 self.velocity_x = ReadCoord();
236 self.velocity_y = ReadCoord();
237 self.velocity_z = ReadCoord();
242 self.team = ReadByte();
245 InterpolateOrigin_Note();