27 #include "../../cl_shared.h"
93 const float radarHeightPerDegree = height / 180.0f;
95 if (pos[1] + radius > 90) {
97 *yMax = round((90 - pos[1] + radius) * radarHeightPerDegree);
98 }
else if (pos[1] - radius < -90) {
99 *yMin = ceil((90 - pos[1] - radius) * radarHeightPerDegree);
102 *yMin = ceil((90 - pos[1] - radius) * radarHeightPerDegree);
103 *yMax = round((90 - pos[1] + radius) * radarHeightPerDegree);
108 assert(*yMin <= *yMax);
109 assert(*yMax <= height);
124 const float angle = (cos(radius *
torad) - sin(centerPos[1] * torad) * sin(yLat)) / (cos(centerPos[1] * torad) * cos(yLat));
125 return fabs(angle) > 1.0f ? 180.0f :
todeg * acos(angle);
143 currentPos[1] = yLat;
145 for (x = xMin; x < xMax; x++) {
150 currentPos[0] = 180.0f - 360.0f * x / ((float)
XVI_WIDTH);
152 newLevel = ceil((xviLevel * (radius - distance)) / radius);
153 if (newLevel > previousLevel)
170 const float xviWidthPerDegree =
XVI_WIDTH / 360.0f;
176 if (latMin < -180.0
f) {
178 int xMax = ceil((latMax + 180.0
f) * xviWidthPerDegree);
180 xMin = floor((latMin + 540.0
f) * xviWidthPerDegree);
183 }
else if (latMax > 180.0
f) {
185 int xMax = ceil((latMax - 180.0
f) * xviWidthPerDegree);
187 xMin = floor((latMin + 180.0
f) * xviWidthPerDegree);
191 const int xMin = floor((latMin + 180.0
f) * xviWidthPerDegree);
192 const int xMax = ceil((latMax + 180.0
f) * xviWidthPerDegree);
219 radius = sqrt(factor * xviLevel);
224 for (y = yMin; y < yMax; y++) {
225 const float yLat = 90.0f - 180.0f * y / ((float)
XVI_HEIGHT);
259 const int xCenter = round((180 - pos[0]) *
XVI_WIDTH / 360.0
f);
260 const int yCenter = round((90 - pos[1]) *
XVI_HEIGHT / 180.0
f);
311 const float radarWidthPerDegree =
RADAR_WIDTH / 360.0f;
318 if (latMin < -180.0
f) {
320 int xMax = ceil((latMax + 180.0
f) * radarWidthPerDegree);
321 for (x = xMin; x < xMax; x++) {
326 xMin = floor((latMin + 540.0
f) * radarWidthPerDegree);
328 for (x = xMin; x < xMax; x++) {
333 }
else if (latMax > 180.0
f) {
335 int xMax = ceil((latMax - 180.0
f) * radarWidthPerDegree);
336 for (x = xMin; x < xMax; x++) {
341 xMin = floor((latMin + 180.0
f) * radarWidthPerDegree);
343 for (x = xMin; x < xMax; x++) {
349 const int xMin = floor((latMin + 180.0
f) * radarWidthPerDegree);
350 const int xMax = ceil((latMax + 180.0
f) * radarWidthPerDegree);
351 for (x = xMin; x < xMax; x++) {
369 const byte innerAlpha = 0;
370 const byte outerAlpha = 60;
371 const float radarHeightPerDegree =
RADAR_HEIGHT / 180.0f;
374 int outeryMax, outeryMin;
377 assert(outerRadius < 180.0
f);
378 assert(outerRadius > innerRadius);
385 for (y = outeryMin; y < yMin; y++) {
387 const float yLat =
torad * (90.0f - y / radarHeightPerDegree);
395 for (y = yMin; y < yMax; y++) {
397 const float yLat =
torad * (90.0f - y / radarHeightPerDegree);
408 for (y = yMax; y < outeryMax; y++) {
410 const float yLat =
torad * (90.0f - y / radarHeightPerDegree);
void CP_InitializeRadarOverlay(bool source)
Initialize radar overlay on geoscape.
void CP_SetXVILevel(int x, int y, int value)
void CP_DecreaseXVILevelEverywhere(void)
void CP_UploadRadarCoverage(void)
Smooth radar coverage.
Functions to generate and render overlay for geoscape.
static void CP_DrawXVIOverlayPixel(int xMin, int xMax, const vec2_t centerPos, int y, const float yLat, int xviLevel, float radius)
Change the value of 1 pixel in XVI overlay, the new value is higher than old one. ...
static byte * CP_XVIGetAlpha(int x, int y)
static void CP_SetMinMaxOverlayRows(const vec2_t pos, float radius, const int height, int *yMin, int *yMax)
Set lower and upper value of an overlay (radar, xvi) row that can be modified when tracing a circle...
void CP_GetXVIMapDimensions(int *width, int *height)
static float CP_GetCircleDeltaLongitude(const vec2_t centerPos, float radius, const float yLat)
Return the half longitude affected when tracing a circle at a given latitude.
const cgame_import_t * cgi
static void CP_DrawRadarOverlayRow(float latMin, float latMax, int y, byte alpha, bool source)
Draw radar overlay for a given latitude between 2 longitudes.
QGL_EXTERN GLenum GLuint * dest
int CP_GetXVILevel(int x, int y)
void CP_AddRadarCoverage(const vec2_t pos, float innerRadius, float outerRadius, bool source)
Add a radar coverage (base or aircraft) to radar overlay.
static void CP_IncreaseXVILevel(const vec2_t pos, int xCenter, int yCenter, float factor)
Applies spreading on xvi transparency channel centered on a given pos.
void CP_InitializeXVIOverlay(void)
Initialize XVI overlay on geoscape.
Header file for single player campaign control.
static void CP_DrawXVIOverlayRow(float latMin, float latMax, const vec2_t center, int y, float yLat, int xviLevel, float radius)
Draw XVI overlay for a given latitude between 2 longitudes.
static const int INITIAL_ALPHA_VALUE
static void CP_UploadXVI(void)
void CP_ChangeXVILevel(const vec2_t pos, float factor)
Convert the pos into degrees and increase XVI there.
static byte * CP_RadarGet(int x, int y, bool source)
static const int MAX_ALPHA_VALUE
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.