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
8 float hud_panel_radar_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 fg)
61 if(fg > 0 && minimapname != "")
65 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP);
68 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
69 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
70 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
71 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
75 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
76 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
77 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
78 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
84 void(vector coord3d, vector pangles, vector rgb) draw_teamradar_player =
88 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord3d));
90 makevectors(pangles - '0 1 0' * teamradar_angle);
93 v_forward_x = -v_forward_x;
94 v_right_x = -v_right_x;
98 v_forward = normalize(v_forward);
100 v_right_x = -v_forward_y;
101 v_right_y = v_forward_x;
108 R_BeginPolygon("", 0);
109 R_PolygonVertex(coord+v_forward*3, '0 0 0', rgb2, panel_fg_alpha);
110 R_PolygonVertex(coord+v_right*4-v_forward*2.5, '0 1 0', rgb2, panel_fg_alpha);
111 R_PolygonVertex(coord-v_forward*2, '1 0 0', rgb2, panel_fg_alpha);
112 R_PolygonVertex(coord-v_right*4-v_forward*2.5, '1 1 0', rgb2, panel_fg_alpha);
115 R_BeginPolygon("", 0);
116 R_PolygonVertex(coord+v_forward*2, '0 0 0', rgb, panel_fg_alpha);
117 R_PolygonVertex(coord+v_right*3-v_forward*2, '0 1 0', rgb, panel_fg_alpha);
118 R_PolygonVertex(coord-v_forward, '1 0 0', rgb, panel_fg_alpha);
119 R_PolygonVertex(coord-v_right*3-v_forward*2, '1 1 0', rgb, panel_fg_alpha);
123 void draw_teamradar_icon(vector coord, float icon, entity pingdata, vector rgb, float a)
129 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
130 drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon)), '8 8 0', rgb, a, 0);
134 for(i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
136 dt = pingdata.(teamradar_times[i]);
140 if(dt >= 1 || dt <= 0)
142 v = '2 2 0' * teamradar_size * dt;
143 drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
148 void draw_teamradar_link(vector start, vector end, float colors)
152 start = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(start));
153 end = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(end));
154 norm = normalize(start - end);
160 c0 = colormapPaletteColor(colors & 0x0F, FALSE);
161 c1 = colormapPaletteColor((colors & 0xF0) / 0x10, FALSE);
163 R_BeginPolygon("", 0);
164 R_PolygonVertex(start - norm, '0 0 0', c0, panel_fg_alpha);
165 R_PolygonVertex(start + norm, '0 1 0', c0, panel_fg_alpha);
166 R_PolygonVertex(end + norm, '1 1 0', c1, panel_fg_alpha);
167 R_PolygonVertex(end - norm, '1 0 0', c1, panel_fg_alpha);
171 float hud_panel_radar_scale;
172 float hud_panel_radar_foreground_alpha;
173 float hud_panel_radar_rotation;
174 vector hud_panel_radar_size;
175 vector hud_panel_radar_position;
176 float hud_panel_radar_zoommode;
178 void teamradar_loadcvars()
180 v_flipped = cvar("v_flipped");
181 hud_panel_radar_scale = cvar("hud_panel_radar_scale");
182 hud_panel_radar_foreground_alpha = cvar("hud_panel_radar_foreground_alpha") * panel_fg_alpha;
183 hud_panel_radar_rotation = cvar("hud_panel_radar_rotation");
184 hud_panel_radar_zoommode = cvar("hud_panel_radar_zoommode");
186 // others default to 0
187 // match this to defaultXonotic.cfg!
188 if(!hud_panel_radar_scale) hud_panel_radar_scale = 4096;
189 if(!hud_panel_radar_foreground_alpha) hud_panel_radar_foreground_alpha = 0.8 * panel_fg_alpha;
190 if(!hud_panel_radar_size_x) hud_panel_radar_size_x = 128;
191 if(!hud_panel_radar_size_y) hud_panel_radar_size_y = hud_panel_radar_size_x;
193 hud_panel_radar_size_z = 0;
194 hud_panel_radar_nohudhack = hud_panel_radar_position_z;
195 hud_panel_radar_position_z = 0;
203 sendflags = ReadByte();
205 InterpolateOrigin_Undo();
207 self.iflags = IFLAG_VELOCITY;
208 self.classname = "radarlink";
212 self.origin_x = ReadCoord();
213 self.origin_y = ReadCoord();
214 self.origin_z = ReadCoord();
219 self.velocity_x = ReadCoord();
220 self.velocity_y = ReadCoord();
221 self.velocity_z = ReadCoord();
226 self.team = ReadByte();
229 InterpolateOrigin_Note();