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 float teamradar_size; // 2D scale factor
6 float teamradar_scale; // window size = ...qu
8 vector teamradar_3dcoord_to_texcoord(vector in)
11 out_x = (in_x - mi_picmin_x) / (mi_picmax_x - mi_picmin_x);
12 out_y = (in_y - mi_picmin_y) / (mi_picmax_y - mi_picmin_y);
17 vector teamradar_texcoord_to_2dcoord(vector in)
20 in -= teamradar_origin3d_in_texcoord;
22 out = rotate(in, teamradar_angle * DEG2RAD);
23 out_y = - out_y; // screen space is reversed
25 out = out * teamradar_size;
26 out += teamradar_origin2d;
30 vector yinvert(vector v)
36 void draw_teamradar_background(float a)
38 R_BeginPolygon(minimapname, 0);
39 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x - teamradar_size2d_x * 0.5) + '0 1 0' * (teamradar_origin2d_y - teamradar_size2d_y * 0.5), '0 0 0', '0 0 0', a);
40 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x + teamradar_size2d_x * 0.5) + '0 1 0' * (teamradar_origin2d_y - teamradar_size2d_y * 0.5), '0 0 0', '0 0 0', a);
41 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x + teamradar_size2d_x * 0.5) + '0 1 0' * (teamradar_origin2d_y + teamradar_size2d_y * 0.5), '0 0 0', '0 0 0', a);
42 R_PolygonVertex('1 0 0' * (teamradar_origin2d_x - teamradar_size2d_x * 0.5) + '0 1 0' * (teamradar_origin2d_y + teamradar_size2d_y * 0.5), '0 0 0', '0 0 0', a);
44 R_BeginPolygon(minimapname, DRAWFLAG_ADDITIVE);
45 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), '1 1 1', 1);
46 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), '1 1 1', 1);
47 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), '1 1 1', 1);
48 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), '1 1 1', 1);
52 void(vector coord3d, vector pangles, vector rgb) draw_teamradar_player =
56 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord3d));
58 makevectors(pangles - '0 1 0' * teamradar_angle);
60 v_forward = normalize(v_forward);
62 v_right_x = -v_forward_y;
63 v_right_y = v_forward_x;
68 R_BeginPolygon("", 0);
69 R_PolygonVertex(coord+v_forward*3, '0 0 0', rgb2, 1);
70 R_PolygonVertex(coord+v_right*4-v_forward*2.5, '0 1 0', rgb2, 1);
71 R_PolygonVertex(coord-v_forward*2, '1 0 0', rgb2, 1);
72 R_PolygonVertex(coord-v_right*4-v_forward*2.5, '1 1 0', rgb2, 1);
76 R_BeginPolygon("", 0);
77 R_PolygonVertex(coord+v_forward*2, '0 0 0', rgb, 1);
78 R_PolygonVertex(coord+v_right*3-v_forward*2, '0 1 0', rgb, 1);
79 R_PolygonVertex(coord-v_forward, '1 0 0', rgb, 1);
80 R_PolygonVertex(coord-v_right*3-v_forward*2, '1 1 0', rgb, 1);
84 void draw_teamradar_icon(vector coord, float icon, float pingtime, vector rgb, float a)
89 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
90 drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon)), '8 8 0', rgb, a, 0);
96 v = '2 2 0' * teamradar_size * dt;
97 drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', 1 - dt, DRAWFLAG_ADDITIVE);
101 void() teamradar_view =
104 local vector coord, rgb;
106 float scale2d, normalsize, bigsize;
108 if(!cvar("cl_teamradar"))
111 color = GetPlayerColor(player_localentnum-1);
112 rgb = GetTeamRGB(color);
115 mi_picmax_x - mi_picmin_x,
116 mi_picmax_y - mi_picmin_y
119 teamradar_angle = cvar("cl_teamradar_rotation") * 4;
121 teamradar_angle = input_angles_y - 90;
122 teamradar_origin2d = '64 64 0';
123 teamradar_size2d = '128 128 0';
124 teamradar_scale = 2048;
126 normalsize = teamradar_size2d_x * scale2d / teamradar_scale;
127 bigsize = teamradar_size2d_x * scale2d / max(teamradar_scale, vlen(mi_min - mi_max));
129 current_zoomfraction * bigsize
130 + (1 - current_zoomfraction) * normalsize;
131 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
132 current_zoomfraction * (mi_min + mi_max) * 0.5
133 + (1 - current_zoomfraction) * pmove_org);
136 teamradar_origin2d_x - teamradar_size2d_x * 0.5,
137 teamradar_origin2d_y - teamradar_size2d_y * 0.5,
142 draw_teamradar_background(cvar("cl_teamradar_background_alpha"));
143 draw_teamradar_player(pmove_org, input_angles, '1 1 1');
144 for(tm = gps_start; tm != world; tm = tm.chain)
145 draw_teamradar_player(tm.origin, tm.angles, rgb);
146 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
147 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm.teamradar_time, tm.teamradar_color, tm.alpha);