forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradar.cpp
662 lines (588 loc) · 17.6 KB
/
radar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2019 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include "lib/framework/frame.h"
#include "lib/framework/fixedpoint.h"
#include "lib/framework/math_ext.h"
#include "lib/ivis_opengl/pieblitfunc.h"
// FIXME Direct iVis implementation include!
#include "lib/ivis_opengl/piematrix.h"
#include "lib/ivis_opengl/piepalette.h"
#include "lib/ivis_opengl/piestate.h"
#include "lib/ivis_opengl/piefunc.h"
#include "lib/ivis_opengl/bitimage.h"
#include "lib/gamelib/gtime.h"
#include "advvis.h"
#include "objects.h"
#include "display3d.h"
#include "map.h"
#include "component.h"
#include "console.h"
#include "radar.h"
#include "mapdisplay.h"
#include "hci.h"
#include "geometry.h"
#include "intimage.h"
#include "loop.h"
#include "warcam.h"
#include "display.h"
#include "mission.h"
#include "multiplay.h"
#include "intdisplay.h"
#include "texture.h"
#include "warzoneconfig.h"
#ifndef GLM_ENABLE_EXPERIMENTAL
#define GLM_ENABLE_EXPERIMENTAL
#endif
#include <glm/gtx/transform.hpp>
#define HIT_NOTIFICATION (GAME_TICKS_PER_SEC * 2)
#define RADAR_FRAME_SKIP 10
bool bEnemyAllyRadarColor = false; /**< Enemy/ally radar color. */
RADAR_DRAW_MODE radarDrawMode = RADAR_MODE_DEFAULT; /**< Current mini-map mode. */
bool rotateRadar; ///< Rotate the radar?
bool radarRotationArrow; ///< display arrow when radar rotation enabled?
static PIELIGHT colRadarAlly, colRadarMe, colRadarEnemy;
static PIELIGHT tileColours[MAX_TILES];
static UDWORD *radarBuffer = nullptr;
static Vector3i playerpos = {0, 0, 0};
PIELIGHT clanColours[] =
{
// see frontend2.png for team color order.
// [r,g,b,a]
{{0, 255, 0, 255}}, // green Player 0
{{255, 192, 40, 255}}, // orange Player 1
{{255, 255, 255, 255}}, // grey Player 2
{{0, 0, 0, 255}}, // black Player 3
{{255, 0, 0, 255}}, // red Player 4
{{20, 20, 255, 255}}, // blue Player 5
{{255, 0, 192, 255}}, // pink Player 6
{{0, 255, 255, 255}}, // cyan Player 7
{{255, 255, 0, 255}}, // yellow Player 8
{{144, 0, 255, 255}}, // purple Player 9
{{200, 255, 255, 255}}, // white Player A (Should be brighter than grey, but grey is already maximum.)
{{128, 128, 255, 255}}, // bright blue Player B
{{128, 255, 128, 255}}, // neon green Player C
{{128, 0, 0, 255}}, // infrared Player D
{{64, 0, 128, 255}}, // ultraviolet Player E
{{128, 128, 0, 255}}, // brown Player F
};
static PIELIGHT flashColours[] =
{
//right now the flash color is all bright red
{{254, 37, 37, 200}}, // Player 0
{{254, 37, 37, 200}}, // Player 1
{{254, 37, 37, 200}}, // Player 2
{{254, 37, 37, 200}}, // Player 3
{{254, 37, 37, 200}}, // Player 4 (notice, brighter red)
{{254, 37, 37, 200}}, // Player 5
{{254, 37, 37, 200}}, // Player 6
{{254, 37, 37, 200}}, // Player 7
{{254, 37, 37, 200}}, // Player 8
{{254, 37, 37, 200}}, // Player 9
{{254, 37, 37, 200}}, // Player A
{{254, 37, 37, 200}}, // Player B
{{254, 37, 37, 200}}, // Player C
{{254, 37, 37, 200}}, // Player D
{{254, 37, 37, 200}}, // Player E
{{254, 37, 37, 200}}, // Player F
};
static SDWORD radarWidth, radarHeight, radarCenterX, radarCenterY, radarTexWidth, radarTexHeight;
static uint8_t RadarZoom;
static UDWORD radarBufferSize = 0;
static int frameSkip = 0;
static void DrawRadarTiles();
static void DrawRadarObjects();
static void DrawRadarExtras(const glm::mat4 &modelViewProjectionMatrix);
static void DrawNorth(const glm::mat4 &modelViewProjectionMatrix);
static void setViewingWindow();
static void radarSize(int ZoomLevel)
{
float zoom = (float)ZoomLevel / 16.0;
radarWidth = radarTexWidth * zoom;
radarHeight = radarTexHeight * zoom;
radarCenterX = pie_GetVideoBufferWidth() - BASE_GAP * 4 - radarWidth / 2;
radarCenterY = pie_GetVideoBufferHeight() - BASE_GAP * 4 - radarHeight / 2;
debug(LOG_WZ, "radar=(%u,%u) tex=(%u,%u) size=(%u,%u)", radarCenterX, radarCenterY, radarTexWidth, radarTexHeight, radarWidth, radarHeight);
}
void radarInitVars()
{
radarTexWidth = 0;
radarTexHeight = 0;
RadarZoom = war_GetRadarZoom();
debug(LOG_WZ, "Resetting radar zoom to %u", RadarZoom);
radarSize(RadarZoom);
playerpos = Vector3i(-1, -1, -1);
frameSkip = 0;
}
bool InitRadar()
{
// Ally/enemy/me colors
colRadarAlly = WZCOL_YELLOW;
colRadarEnemy = WZCOL_RED;
colRadarMe = WZCOL_WHITE;
return true;
}
bool resizeRadar()
{
if (radarBuffer)
{
free(radarBuffer);
}
radarTexWidth = scrollMaxX - scrollMinX;
radarTexHeight = scrollMaxY - scrollMinY;
radarBufferSize = radarTexWidth * radarTexHeight * sizeof(UDWORD);
radarBuffer = (uint32_t *)malloc(radarBufferSize);
memset(radarBuffer, 0, radarBufferSize);
frameSkip = 0;
debug(LOG_WZ, "Setting radar zoom to %u", RadarZoom);
radarSize(RadarZoom);
pie_SetRadar(-radarWidth / 2.0 - 1, -radarHeight / 2.0 - 1, radarWidth, radarHeight, radarTexWidth, radarTexHeight);
setViewingWindow();
return true;
}
bool ShutdownRadar()
{
free(radarBuffer);
radarBuffer = nullptr;
frameSkip = 0;
return true;
}
void SetRadarZoom(uint8_t ZoomLevel)
{
if (ZoomLevel > MAX_RADARZOOM)
{
ZoomLevel = MAX_RADARZOOM;
}
if (ZoomLevel < MIN_RADARZOOM)
{
ZoomLevel = MIN_RADARZOOM;
}
debug(LOG_WZ, "Setting radar zoom to %u from %u", ZoomLevel, RadarZoom);
RadarZoom = ZoomLevel;
radarSize(RadarZoom);
frameSkip = 0;
resizeRadar();
}
uint8_t GetRadarZoom()
{
return RadarZoom;
}
/** Calculate the radar pixel sizes. Returns pixels per tile. */
static void CalcRadarPixelSize(float *SizeH, float *SizeV)
{
*SizeH = (float)radarHeight / std::max(radarTexHeight, 1);
*SizeV = (float)radarWidth / std::max(radarTexWidth, 1);
}
/** Given a position within the radar, return a world coordinate. */
void CalcRadarPosition(int mX, int mY, int *PosX, int *PosY)
{
int sPosX, sPosY;
float pixSizeH, pixSizeV;
Vector2f pos;
pos.x = mX - radarCenterX;
pos.y = mY - radarCenterY;
if (rotateRadar)
{
pos = Vector2f_Rotate2f(pos, -player.r.y);
}
pos.x += radarWidth / 2.0;
pos.y += radarHeight / 2.0;
CalcRadarPixelSize(&pixSizeH, &pixSizeV);
sPosX = pos.x / pixSizeH; // adjust for pixel size
sPosY = pos.y / pixSizeV;
sPosX += scrollMinX; // adjust for scroll limits
sPosY += scrollMinY;
#if REALLY_DEBUG_RADAR
debug(LOG_ERROR, "m=(%d,%d) radar=(%d,%d) pos(%d,%d), scroll=(%u-%u,%u-%u) sPos=(%d,%d), pixSize=(%f,%f)",
mX, mY, radarX, radarY, posX, posY, scrollMinX, scrollMaxX, scrollMinY, scrollMaxY, sPosX, sPosY, pixSizeH, pixSizeV);
#endif
// old safety code -- still necessary?
sPosX = clip(sPosX, scrollMinX, scrollMaxX -1);
sPosY = clip(sPosY, scrollMinY, scrollMaxY -1);
*PosX = sPosX;
*PosY = sPosY;
}
void drawRadar()
{
float pixSizeH, pixSizeV;
CalcRadarPixelSize(&pixSizeH, &pixSizeV);
ASSERT_OR_RETURN(, radarBuffer, "No radar buffer allocated");
setViewingWindow();
playerpos = player.p; // cache position
if (frameSkip <= 0)
{
DrawRadarTiles();
DrawRadarObjects();
pie_DownLoadRadar(radarBuffer);
frameSkip = RADAR_FRAME_SKIP;
}
frameSkip--;
pie_SetRendMode(REND_ALPHA);
glm::mat4 radarMatrix = glm::translate(glm::vec3(radarCenterX, radarCenterY, 0));
glm::mat4 orthoMatrix = glm::ortho(0.f, static_cast<float>(pie_GetVideoBufferWidth()), static_cast<float>(pie_GetVideoBufferHeight()), 0.f);
if (rotateRadar)
{
// rotate the map
radarMatrix *= glm::rotate(UNDEG(player.r.y), glm::vec3(0.f, 0.f, 1.f));
if (radarRotationArrow)
{
DrawNorth(orthoMatrix * radarMatrix);
}
}
pie_RenderRadar(orthoMatrix * radarMatrix);
DrawRadarExtras(orthoMatrix * radarMatrix * glm::translate(glm::vec3(-radarWidth / 2.f - 1.f, -radarHeight / 2.f - 1.f, 0.f)));
drawRadarBlips(-radarWidth / 2.0 - 1, -radarHeight / 2.0 - 1, pixSizeH, pixSizeV, orthoMatrix * radarMatrix);
}
static void DrawNorth(const glm::mat4 &modelViewProjectionMatrix)
{
iV_DrawImage(IntImages, RADAR_NORTH, -((radarWidth / 2.0) + iV_GetImageWidth(IntImages, RADAR_NORTH) + 1), -(radarHeight / 2.0), modelViewProjectionMatrix);
}
static PIELIGHT appliedRadarColour(RADAR_DRAW_MODE radarDrawMode, MAPTILE *WTile)
{
PIELIGHT WScr = WZCOL_BLACK; // squelch warning
// draw radar on/off feature
if (!getRevealStatus() && !TEST_TILE_VISIBLE(selectedPlayer, WTile))
{
return WZCOL_RADAR_BACKGROUND;
}
switch (radarDrawMode)
{
case RADAR_MODE_TERRAIN:
{
// draw radar terrain on/off feature
PIELIGHT col = tileColours[TileNumber_tile(WTile->texture)];
col.byte.r = sqrtf(col.byte.r * WTile->illumination);
col.byte.b = sqrtf(col.byte.b * WTile->illumination);
col.byte.g = sqrtf(col.byte.g * WTile->illumination);
if (terrainType(WTile) == TER_CLIFFFACE)
{
col.byte.r /= 2;
col.byte.g /= 2;
col.byte.b /= 2;
}
if (!hasSensorOnTile(WTile, selectedPlayer))
{
col.byte.r = col.byte.r * 2 / 3;
col.byte.g = col.byte.g * 2 / 3;
col.byte.b = col.byte.b * 2 / 3;
}
if (!TEST_TILE_VISIBLE(selectedPlayer, WTile))
{
col.byte.r /= 2;
col.byte.g /= 2;
col.byte.b /= 2;
}
WScr = col;
}
break;
case RADAR_MODE_COMBINED:
{
// draw radar terrain on/off feature
PIELIGHT col = tileColours[TileNumber_tile(WTile->texture)];
col.byte.r = sqrtf(col.byte.r * (WTile->illumination + WTile->height / ELEVATION_SCALE) / 2);
col.byte.b = sqrtf(col.byte.b * (WTile->illumination + WTile->height / ELEVATION_SCALE) / 2);
col.byte.g = sqrtf(col.byte.g * (WTile->illumination + WTile->height / ELEVATION_SCALE) / 2);
if (terrainType(WTile) == TER_CLIFFFACE)
{
col.byte.r /= 2;
col.byte.g /= 2;
col.byte.b /= 2;
}
if (!hasSensorOnTile(WTile, selectedPlayer))
{
col.byte.r = col.byte.r * 2 / 3;
col.byte.g = col.byte.g * 2 / 3;
col.byte.b = col.byte.b * 2 / 3;
}
if (!TEST_TILE_VISIBLE(selectedPlayer, WTile))
{
col.byte.r /= 2;
col.byte.g /= 2;
col.byte.b /= 2;
}
WScr = col;
}
break;
case RADAR_MODE_HEIGHT_MAP:
{
WScr.byte.r = WScr.byte.g = WScr.byte.b = WTile->height / ELEVATION_SCALE;
}
break;
case RADAR_MODE_NO_TERRAIN:
{
WScr = WZCOL_RADAR_BACKGROUND;
}
break;
case NUM_RADAR_MODES:
{
assert(false);
}
break;
}
return WScr;
}
/** Draw the map tiles on the radar. */
static void DrawRadarTiles()
{
SDWORD x, y;
for (x = scrollMinX; x < scrollMaxX; x++)
{
for (y = scrollMinY; y < scrollMaxY; y++)
{
MAPTILE *psTile = mapTile(x, y);
size_t pos = radarTexWidth * (y - scrollMinY) + (x - scrollMinX);
ASSERT(pos * sizeof(*radarBuffer) < radarBufferSize, "Buffer overrun");
if (y == scrollMinY || x == scrollMinX || y == scrollMaxY - 1 || x == scrollMaxX - 1)
{
radarBuffer[pos] = WZCOL_BLACK.rgba;
continue;
}
radarBuffer[pos] = appliedRadarColour(radarDrawMode, psTile).rgba;
}
}
}
/** Draw the droids and structure positions on the radar. */
static void DrawRadarObjects()
{
UBYTE clan;
PIELIGHT playerCol;
PIELIGHT flashCol;
int x, y;
/* Show droids on map - go through all players */
for (clan = 0; clan < MAX_PLAYERS; clan++)
{
DROID *psDroid;
//see if have to draw enemy/ally color
if (bEnemyAllyRadarColor)
{
if (clan == selectedPlayer)
{
playerCol = colRadarMe;
}
else
{
playerCol = (aiCheckAlliances(selectedPlayer, clan) ? colRadarAlly : colRadarEnemy);
}
}
else
{
//original 8-color mode
STATIC_ASSERT(MAX_PLAYERS <= ARRAY_SIZE(clanColours));
playerCol = clanColours[getPlayerColour(clan)];
}
STATIC_ASSERT(MAX_PLAYERS <= ARRAY_SIZE(flashColours));
flashCol = flashColours[getPlayerColour(clan)];
/* Go through all droids */
for (psDroid = apsDroidLists[clan]; psDroid != nullptr; psDroid = psDroid->psNext)
{
if (psDroid->pos.x < world_coord(scrollMinX) || psDroid->pos.y < world_coord(scrollMinY)
|| psDroid->pos.x >= world_coord(scrollMaxX) || psDroid->pos.y >= world_coord(scrollMaxY))
{
continue;
}
if (psDroid->visible[selectedPlayer]
|| (bMultiPlayer && alliancesSharedVision(game.alliance)
&& aiCheckAlliances(selectedPlayer, psDroid->player)))
{
int x = psDroid->pos.x / TILE_UNITS;
int y = psDroid->pos.y / TILE_UNITS;
size_t pos = (x - scrollMinX) + (y - scrollMinY) * radarTexWidth;
ASSERT(pos * sizeof(*radarBuffer) < radarBufferSize, "Buffer overrun");
if (clan == selectedPlayer && gameTime > HIT_NOTIFICATION && gameTime - psDroid->timeLastHit < HIT_NOTIFICATION)
{
radarBuffer[pos] = flashCol.rgba;
}
else
{
radarBuffer[pos] = playerCol.rgba;
}
}
}
}
/* Do the same for structures */
for (x = scrollMinX; x < scrollMaxX; x++)
{
for (y = scrollMinY; y < scrollMaxY; y++)
{
MAPTILE *psTile = mapTile(x, y);
STRUCTURE *psStruct;
size_t pos = (x - scrollMinX) + (y - scrollMinY) * radarTexWidth;
ASSERT(pos * sizeof(*radarBuffer) < radarBufferSize, "Buffer overrun");
if (!TileHasStructure(psTile))
{
continue;
}
psStruct = (STRUCTURE *)psTile->psObject;
clan = psStruct->player;
//see if have to draw enemy/ally color
if (bEnemyAllyRadarColor)
{
if (clan == selectedPlayer)
{
playerCol = colRadarMe;
}
else
{
playerCol = (aiCheckAlliances(selectedPlayer, clan) ? colRadarAlly : colRadarEnemy);
}
}
else
{
//original 8-color mode
playerCol = clanColours[getPlayerColour(clan)];
}
flashCol = flashColours[getPlayerColour(clan)];
if (psStruct->visible[selectedPlayer]
|| (bMultiPlayer && alliancesSharedVision(game.alliance)
&& aiCheckAlliances(selectedPlayer, psStruct->player)))
{
if (clan == selectedPlayer && gameTime > HIT_NOTIFICATION && gameTime - psStruct->timeLastHit < HIT_NOTIFICATION)
{
radarBuffer[pos] = flashCol.rgba;
}
else
{
radarBuffer[pos] = playerCol.rgba;
}
}
}
}
}
/** Rotate an array of 2d vectors about a given angle, also translates them after rotating. */
static void RotateVector2D(Vector3i *Vector, Vector3i *TVector, Vector3i *Pos, int Angle, int Count)
{
int64_t Cos = iCos(Angle);
int64_t Sin = iSin(Angle);
int ox = 0;
int oy = 0;
int i;
Vector3i *Vec = Vector;
Vector3i *TVec = TVector;
if (Pos)
{
ox = Pos->x;
oy = Pos->y;
}
for (i = 0; i < Count; i++)
{
TVec->x = ((Vec->x * Cos + Vec->y * Sin) >> 16) + ox;
TVec->y = ((Vec->y * Cos - Vec->x * Sin) >> 16) + oy;
Vec++;
TVec++;
}
}
static SDWORD getDistanceAdjust()
{
int dif = std::max<int>(MAXDISTANCE - getViewDistance(), 0);
return dif / 100;
}
static SDWORD getLengthAdjust()
{
const int pitch = 360 - (player.r.x / DEG_1);
// Max at
const int lookingDown = (0 - MIN_PLAYER_X_ANGLE);
const int lookingFar = (0 - MAX_PLAYER_X_ANGLE);
int dif = MAX(pitch - lookingFar, 0);
if (dif > (lookingDown - lookingFar))
{
dif = (lookingDown - lookingFar);
}
return dif / 2;
}
/** Draws a Myth/FF7 style viewing window */
static void setViewingWindow()
{
float pixSizeH, pixSizeV;
Vector3i v[4] = {{0, 0, 0}}, tv[4] = {{0, 0, 0}}, centre = {0, 0, 0};
int shortX, longX, yDrop, yDropVar;
int dif = getDistanceAdjust();
int dif2 = getLengthAdjust();
PIELIGHT colour;
CalcRadarPixelSize(&pixSizeH, &pixSizeV);
int x = player.p.x * pixSizeH / TILE_UNITS;
int y = player.p.z * pixSizeV / TILE_UNITS;
shortX = ((visibleTiles.x / 4) - (dif / 6)) * pixSizeH;
longX = ((visibleTiles.x / 2) - (dif / 4)) * pixSizeH;
yDropVar = ((visibleTiles.y / 2) - (dif2 / 3)) * pixSizeV;
yDrop = ((visibleTiles.y / 2) - dif2 / 3) * pixSizeV;
v[0].x = longX;
v[0].y = -yDropVar;
v[1].x = -longX;
v[1].y = -yDropVar;
v[2].x = shortX;
v[2].y = yDrop;
v[3].x = -shortX;
v[3].y = yDrop;
centre.x = x - scrollMinX * pixSizeH;
centre.y = y - scrollMinY * pixSizeV;
RotateVector2D(v, tv, ¢re, player.r.y, 4);
switch (getCampaignNumber())
{
case 1:
case 2:
// white
colour.byte.r = UBYTE_MAX;
colour.byte.g = UBYTE_MAX;
colour.byte.b = UBYTE_MAX;
colour.byte.a = 0x3f;
break;
case 3:
// greenish
colour.byte.r = 0x3f;
colour.byte.g = UBYTE_MAX;
colour.byte.b = 0x3f;
colour.byte.a = 0x3f;
break;
default:
// black
colour.rgba = 0;
colour.byte.a = 0x3f;
break;
}
/* Send the four points to the draw routine and the clip box params */
pie_SetViewingWindow(tv, colour);
}
static void DrawRadarExtras(const glm::mat4 &modelViewProjectionMatrix)
{
pie_DrawViewingWindow(modelViewProjectionMatrix);
RenderWindowFrame(FRAME_RADAR, -1, -1, radarWidth + 2, radarHeight + 2, modelViewProjectionMatrix);
}
/** Does a screen coordinate lie within the radar area? */
bool CoordInRadar(int x, int y)
{
Vector2f pos;
pos.x = x - radarCenterX;
pos.y = y - radarCenterY;
if (rotateRadar)
{
pos = Vector2f_Rotate2f(pos, -player.r.y);
}
pos.x += radarWidth / 2.0;
pos.y += radarHeight / 2.0;
if (pos.x < 0 || pos.y < 0 || pos.x >= radarWidth || pos.y >= radarHeight)
{
return false;
}
return true;
}
void radarColour(UDWORD tileNumber, uint8_t r, uint8_t g, uint8_t b)
{
tileColours[tileNumber].byte.r = r;
tileColours[tileNumber].byte.g = g;
tileColours[tileNumber].byte.b = b;
tileColours[tileNumber].byte.a = 255;
}