Functions to generate and render overlay for geoscape. More...
#include "../cl_shared.h"
#include "../renderer/r_image.h"
#include "cp_campaign.h"
#include "cp_overlay.h"
Go to the source code of this file.
Defines | |
#define | XVI_WIDTH 512 |
#define | XVI_HEIGHT 256 |
#define | RADAR_WIDTH 512 |
#define | RADAR_HEIGHT 256 |
#define | DAN_WIDTH 512 |
#define | DAN_HEIGHT 256 |
#define | DAWN 0.03 |
Functions | |
void | CP_CalcAndUploadDayAndNightTexture (float q) |
Applies alpha values to the night overlay image for 2d geoscape. | |
void | CP_GetXVIMapDimensions (int *width, int *height) |
void | CP_SetXVILevel (int x, int y, int value) |
int | CP_GetXVILevel (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. | |
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. | |
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 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 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_DecreaseXVILevelEverywhere (void) |
void | CP_ChangeXVILevel (const vec2_t pos, float factor) |
void | CP_InitializeXVIOverlay (const byte *data) |
Initialize XVI overlay on geoscape. | |
void | CP_InitializeRadarOverlay (qboolean source) |
Radar overlay code description The radar overlay is handled in 2 times : bases radar range and aircraft radar range. Bases radar range needs to be updated only when a radar facilities is built or destroyed. The base radar overlay is stored in r_radarSourcePic. Aircraft radar overlay needs to be updated every time an aircraft moves, because the position of the radar moves. this overlay is created by duplicating r_radarSourcePic, and then adding any aircraft radar coverage. It is stored in r_radarTexture. | |
static void | CP_DrawRadarOverlayRow (float latMin, float latMax, int y, byte alpha, qboolean source) |
Draw radar overlay for a given latitude between 2 longitudes. | |
void | CP_AddRadarCoverage (const vec2_t pos, float innerRadius, float outerRadius, qboolean source) |
Add a radar coverage (base or aircraft) to radar overlay. | |
void | CP_UploadRadarCoverage (void) |
Smooth radar coverage. | |
void | CP_ShutdownOverlay (void) |
void | CP_InitOverlay (void) |
Variables | |
static const int | MAX_ALPHA_VALUE = 200 |
static const int | INITIAL_ALPHA_VALUE = 60 |
image_t * | r_dayandnightTexture |
image_t * | r_radarTexture |
image_t * | r_xviTexture |
static byte | r_xviAlpha [XVI_WIDTH *XVI_HEIGHT] |
static byte | r_radarPic [RADAR_WIDTH *RADAR_HEIGHT] |
static byte | r_radarSourcePic [RADAR_WIDTH *RADAR_HEIGHT] |
static byte | r_dayandnightAlpha [DAN_WIDTH *DAN_HEIGHT] |
Functions to generate and render overlay for geoscape.
Definition in file cp_overlay.c.
#define DAN_HEIGHT 256 |
Definition at line 41 of file cp_overlay.c.
Referenced by CP_CalcAndUploadDayAndNightTexture(), and CP_InitOverlay().
#define DAN_WIDTH 512 |
Definition at line 40 of file cp_overlay.c.
Referenced by CP_CalcAndUploadDayAndNightTexture(), and CP_InitOverlay().
#define DAWN 0.03 |
Definition at line 43 of file cp_overlay.c.
Referenced by CP_CalcAndUploadDayAndNightTexture().
#define RADAR_HEIGHT 256 |
Definition at line 39 of file cp_overlay.c.
Referenced by CP_AddRadarCoverage(), CP_InitOverlay(), and CP_UploadRadarCoverage().
#define RADAR_WIDTH 512 |
Definition at line 38 of file cp_overlay.c.
Referenced by CP_DrawRadarOverlayRow(), CP_DrawXVIOverlayRow(), CP_InitOverlay(), and CP_UploadRadarCoverage().
#define XVI_HEIGHT 256 |
Definition at line 37 of file cp_overlay.c.
Referenced by CP_ChangeXVILevel(), CP_DecreaseXVILevelEverywhere(), CP_GetXVILevel(), CP_GetXVIMapDimensions(), CP_IncreaseXVILevel(), CP_InitOverlay(), and CP_SetXVILevel().
#define XVI_WIDTH 512 |
Definition at line 36 of file cp_overlay.c.
Referenced by CP_ChangeXVILevel(), CP_DecreaseXVILevelEverywhere(), CP_DrawXVIOverlayPixel(), CP_DrawXVIOverlayRow(), CP_GetXVILevel(), CP_GetXVIMapDimensions(), CP_InitOverlay(), and CP_SetXVILevel().
void CP_AddRadarCoverage | ( | const vec2_t | pos, | |
float | innerRadius, | |||
float | outerRadius, | |||
qboolean | source | |||
) |
Add a radar coverage (base or aircraft) to radar overlay.
[in] | pos | Position of the center of radar |
[in] | innerRadius | Radius of the radar coverage |
[in] | outerRadius | Radius of the outer radar coverage |
[in] | source | True if we must update the source of the radar coverage, false if the copy must be updated. |
< Alpha of the inner radar range
< Alpha of the outer radar range
< current position (in pixel)
< Bounding box of the inner radar zone
< Bounding box of the outer radar zone
Definition at line 420 of file cp_overlay.c.
References byte, CP_DrawRadarOverlayRow(), CP_GetCircleDeltaLongitude(), CP_SetMinMaxOverlayRows(), f, RADAR_HEIGHT, and torad.
Referenced by RADAR_DrawCoverage(), and RADAR_UpdateStaticRadarCoverage().
void CP_CalcAndUploadDayAndNightTexture | ( | float | q | ) |
Applies alpha values to the night overlay image for 2d geoscape.
[in] | q | The angle the sun is standing against the equator on earth |
Definition at line 66 of file cp_overlay.c.
References byte, COS_ALPHA, DAN_HEIGHT, DAN_WIDTH, DAWN, HIGH_LAT, LOW_LAT, pos, r_dayandnightAlpha, R_UploadAlpha(), and SIN_ALPHA.
Referenced by MAP_DrawMap().
void CP_ChangeXVILevel | ( | const vec2_t | pos, | |
float | factor | |||
) |
Definition at line 304 of file cp_overlay.c.
References CP_IncreaseXVILevel(), f, XVI_HEIGHT, and XVI_WIDTH.
Referenced by CP_SpreadXVIAtPos().
void CP_DecreaseXVILevelEverywhere | ( | void | ) |
< current position (in pixel)
Definition at line 289 of file cp_overlay.c.
References CP_GetXVILevel(), CP_SetXVILevel(), R_UploadAlpha(), r_xviAlpha, XVI_HEIGHT, and XVI_WIDTH.
Referenced by CP_ReduceXVIEverywhere().
static void CP_DrawRadarOverlayRow | ( | float | latMin, | |
float | latMax, | |||
int | y, | |||
byte | alpha, | |||
qboolean | source | |||
) | [static] |
Draw radar overlay for a given latitude between 2 longitudes.
[in] | latMin | Minimum latitude. |
[in] | latMax | Maximum latitude. |
[in] | y | current row in radar overlay. |
[in] | source | True if we must update the source of the radar coverage, false if the copy must be updated. |
Definition at line 362 of file cp_overlay.c.
References byte, dest, EQUAL_EPSILON, f, r_radarPic, r_radarSourcePic, and RADAR_WIDTH.
Referenced by CP_AddRadarCoverage().
static void CP_DrawXVIOverlayPixel | ( | int | xMin, | |
int | xMax, | |||
const vec2_t | centerPos, | |||
int | y, | |||
const float | yLat, | |||
int | xviLevel, | |||
float | radius | |||
) | [static] |
Change the value of 1 pixel in XVI overlay, the new value is higher than old one.
[in] | xMin | Minimum column (this volumn will be reached). |
[in] | xMax | Maximum column (this volumn won't be reached). |
[in] | centerPos | Position of the center of the circle. |
[in] | y | current row in XVI overlay. |
[in] | yLat | Latitude (in degree) of the current Row. |
[in] | xviLevel | Level of XVI at the center of the circle (ie at center ). |
[in] | radius | Radius of the circle. |
Definition at line 189 of file cp_overlay.c.
References CP_GetXVILevel(), CP_SetXVILevel(), GetDistanceOnGlobe(), and XVI_WIDTH.
Referenced by CP_DrawXVIOverlayRow().
static void CP_DrawXVIOverlayRow | ( | float | latMin, | |
float | latMax, | |||
const vec2_t | center, | |||
int | y, | |||
float | yLat, | |||
int | xviLevel, | |||
float | radius | |||
) | [static] |
Draw XVI overlay for a given latitude between 2 longitudes.
[in] | latMin | Minimum latitude (in degree). |
[in] | latMax | Maximum latitude (in degree). |
[in] | center | Position of the center of the circle. |
[in] | y | current row in XVI overlay. |
[in] | yLat | Latitude (in degree) of the current Row. |
[in] | xviLevel | Level of XVI at the center of the circle (ie at center ). |
[in] | radius | Radius of the circle. |
Definition at line 220 of file cp_overlay.c.
References CP_DrawXVIOverlayPixel(), EQUAL_EPSILON, f, RADAR_WIDTH, and XVI_WIDTH.
Referenced by CP_IncreaseXVILevel().
static float CP_GetCircleDeltaLongitude | ( | const vec2_t | centerPos, | |
float | radius, | |||
const float | yLat | |||
) | [inline, static] |
Return the half longitude affected when tracing a circle at a given latitude.
[in] | centerPos | center of the circle (radar coverage, XVI infection zone). |
[in] | radius | radius of the circle. |
[in] | yLat | latitude of current point (in radians). |
Definition at line 173 of file cp_overlay.c.
Referenced by CP_AddRadarCoverage(), and CP_IncreaseXVILevel().
int CP_GetXVILevel | ( | int | x, | |
int | y | |||
) |
Definition at line 122 of file cp_overlay.c.
References INITIAL_ALPHA_VALUE, r_xviAlpha, XVI_HEIGHT, and XVI_WIDTH.
Referenced by CP_DecreaseXVILevelEverywhere(), CP_DrawXVIOverlayPixel(), CP_IncreaseXVILevel(), CP_UpdateNationXVIInfection(), and XVI_SaveXML().
void CP_GetXVIMapDimensions | ( | int * | width, | |
int * | height | |||
) |
Definition at line 103 of file cp_overlay.c.
References XVI_HEIGHT, and XVI_WIDTH.
Referenced by CP_UpdateNationXVIInfection(), and XVI_SaveXML().
static void CP_IncreaseXVILevel | ( | const vec2_t | pos, | |
int | xCenter, | |||
int | yCenter, | |||
float | factor | |||
) | [static] |
Applies spreading on xvi transparency channel centered on a given pos.
[in] | xCenter | X Position of the center of XVI spreading |
[in] | yCenter | Y Position of the center of XVI spreading |
< XVI level rate at position pos
< current position (in pixel)
< Bounding box of the XVI zone to be drawn (circle)
< radius of the new XVI circle (in degree)
Definition at line 259 of file cp_overlay.c.
References CP_DrawXVIOverlayRow(), CP_GetCircleDeltaLongitude(), CP_GetXVILevel(), CP_SetMinMaxOverlayRows(), INITIAL_ALPHA_VALUE, MAX_ALPHA_VALUE, R_UploadAlpha(), r_xviAlpha, torad, and XVI_HEIGHT.
Referenced by CP_ChangeXVILevel().
void CP_InitializeRadarOverlay | ( | qboolean | source | ) |
Radar overlay code description The radar overlay is handled in 2 times : bases radar range and aircraft radar range. Bases radar range needs to be updated only when a radar facilities is built or destroyed. The base radar overlay is stored in r_radarSourcePic. Aircraft radar overlay needs to be updated every time an aircraft moves, because the position of the radar moves. this overlay is created by duplicating r_radarSourcePic, and then adding any aircraft radar coverage. It is stored in r_radarTexture.
[in] | source | Initialize the source texture if qtrue: if you are updating base radar overlay. false if you are updating aircraft radar overlay (base radar overlay will be copied to aircraft radar overlay) |
Definition at line 345 of file cp_overlay.c.
References INITIAL_ALPHA_VALUE, r_radarPic, and r_radarSourcePic.
Referenced by RADAR_UpdateStaticRadarCoverage(), and RADAR_UpdateWholeRadarOverlay().
void CP_InitializeXVIOverlay | ( | const byte * | data | ) |
Initialize XVI overlay on geoscape.
[in] | data | Pointer to the data containing values to store in XVI map. Can be NULL for new games. This is only the alpha channel of the xvi map |
Definition at line 318 of file cp_overlay.c.
References R_UploadAlpha(), and r_xviAlpha.
Referenced by CP_CampaignInit(), and XVI_LoadXML().
void CP_InitOverlay | ( | void | ) |
Definition at line 488 of file cp_overlay.c.
References DAN_HEIGHT, DAN_WIDTH, it_effect, R_LoadImageData(), RADAR_HEIGHT, RADAR_WIDTH, XVI_HEIGHT, and XVI_WIDTH.
Referenced by CP_CampaignInit().
static void CP_SetMinMaxOverlayRows | ( | const vec2_t | pos, | |
float | radius, | |||
const int | height, | |||
int * | yMin, | |||
int * | yMax | |||
) | [static] |
Set lower and upper value of an overlay (radar, xvi) row that can be modified when tracing a circle.
[in] | pos | Position of the center of circle. |
[in] | radius | Radius of the circle to be drawn. |
[in] | height | Height of the overlay (in pixel). |
[out] | yMin | Pointer to the lower row of the overlay that should be changed. |
[out] | yMax | Pointer to the higher row of the overlay that should be changed. |
Definition at line 142 of file cp_overlay.c.
Referenced by CP_AddRadarCoverage(), and CP_IncreaseXVILevel().
void CP_SetXVILevel | ( | int | x, | |
int | y, | |||
int | value | |||
) |
Definition at line 109 of file cp_overlay.c.
References INITIAL_ALPHA_VALUE, MAX_ALPHA_VALUE, r_xviAlpha, XVI_HEIGHT, and XVI_WIDTH.
Referenced by CP_DecreaseXVILevelEverywhere(), CP_DrawXVIOverlayPixel(), and XVI_LoadXML().
void CP_ShutdownOverlay | ( | void | ) |
Definition at line 482 of file cp_overlay.c.
Referenced by CP_CampaignExit().
void CP_UploadRadarCoverage | ( | void | ) |
Smooth radar coverage.
Definition at line 475 of file cp_overlay.c.
References r_radarPic, R_SoftenTexture(), R_UploadAlpha(), RADAR_HEIGHT, and RADAR_WIDTH.
Referenced by RADAR_UpdateStaticRadarCoverage(), and RADAR_UpdateWholeRadarOverlay().
const int INITIAL_ALPHA_VALUE = 60 [static] |
Definition at line 34 of file cp_overlay.c.
Referenced by CP_GetXVILevel(), CP_IncreaseXVILevel(), CP_InitializeRadarOverlay(), and CP_SetXVILevel().
const int MAX_ALPHA_VALUE = 200 [static] |
Max alpha level - don't set this to 255 or nothing else will be visible below the mask
Definition at line 33 of file cp_overlay.c.
Referenced by CP_IncreaseXVILevel(), and CP_SetXVILevel().
byte r_dayandnightAlpha[DAN_WIDTH *DAN_HEIGHT] [static] |
this is the data that is used with r_dayandnightTexture
Definition at line 60 of file cp_overlay.c.
Referenced by CP_CalcAndUploadDayAndNightTexture().
this is the mask that is used to display day/night on (2d-)geoscape
Definition at line 46 of file cp_overlay.c.
byte r_radarPic[RADAR_WIDTH *RADAR_HEIGHT] [static] |
this is the data that is used with r_radarTexture
Definition at line 54 of file cp_overlay.c.
Referenced by CP_DrawRadarOverlayRow(), CP_InitializeRadarOverlay(), and CP_UploadRadarCoverage().
byte r_radarSourcePic[RADAR_WIDTH *RADAR_HEIGHT] [static] |
this is the data that is used with r_radarTexture
Definition at line 57 of file cp_overlay.c.
Referenced by CP_DrawRadarOverlayRow(), and CP_InitializeRadarOverlay().
radar texture
Definition at line 47 of file cp_overlay.c.
byte r_xviAlpha[XVI_WIDTH *XVI_HEIGHT] [static] |
this is the data that is used with r_xviTexture
Definition at line 51 of file cp_overlay.c.
Referenced by CP_DecreaseXVILevelEverywhere(), CP_GetXVILevel(), CP_IncreaseXVILevel(), CP_InitializeXVIOverlay(), and CP_SetXVILevel().
XVI alpha mask texture
Definition at line 48 of file cp_overlay.c.