UFO: Alien Invasion
Loading...
Searching...
No Matches
r_geoscape.cpp File Reference
#include "r_local.h"
#include "r_error.h"
#include "r_sphere.h"
#include "r_geoscape.h"
#include "r_mesh.h"
#include "r_draw.h"
#include "../DateTime.h"
Include dependency graph for r_geoscape.cpp:

Go to the source code of this file.

Macros

#define MARKER_SIZE   60.0
#define SKYBOX_HALFSIZE   800.0f
 Half size of Skybox.

Functions

void R_DrawFlatGeoscape (const vec2_t nodePos, const vec2_t nodeSize, float p, float cx, float cy, float iz, const char *map, bool overlayNation, bool overlayXVI, bool overlayRadar, image_t *r_dayandnightTexture, image_t *r_xviTexture, image_t *r_radarTexture)
 Draw the day and night images of a flat geoscape multitexture feature is used to blend the images.
void R_Draw2DMapMarkers (const vec2_t screenPos, float direction, const char *model, int skin)
 Draw 3D Marker on the 2D geoscape.
void R_Draw3DMapMarkers (const vec2_t nodePos, const vec2_t nodeSize, const vec3_t rotate, const vec2_t pos, float direction, float earthRadius, const char *model, int skin)
 Draw 3D Marker on the 3D geoscape.
static void R_DrawStarfield (int texnum, const vec3_t pos, const vec3_t rotate, float timeOfDay)
 Bind and draw starfield.
static void R_RotateCelestialBody (const vec4_t v, vec4_t r, const vec3_t rotate, const vec3_t earthPos, const float celestialDist)
 rotate a planet (sun or moon) with respect to the earth
void R_Draw3DGlobe (const vec2_t pos, const vec2_t size, int day, int second, const vec3_t rotate, float zoom, const char *map, bool disableSolarRender, float ambient, bool overlayNation, bool overlayXVI, bool overlayRadar, image_t *r_xviTexture, image_t *r_radarTexture, bool renderNationGlow)
 responsible for drawing the 3d globe on geoscape param[in] rotate the rotate angle of the globe param[in] zoom the current globe zoon param[in] map the prefix of the map to use (image must be at base/pics/menu/<map>_[day|night])
static void R_DrawQuad (void)
 Draw the current texture on a quad the size of the renderbuffer.
static void R_Blur (r_framebuffer_t *source, r_framebuffer_t *dest, int tex, int dir)
 does 1D filter convolution to blur a framebuffer texture. dir=0 for horizontal, dir=1 for vertical
static void R_BlurStack (int levels, r_framebuffer_t **sources, r_framebuffer_t **dests)
 blur from the source image pyramid into the dest image pyramid
void R_DrawBloom (void)
 handle post-processing bloom

Variables

static const float starFieldVerts []
static const float starFieldTexCoords []

Macro Definition Documentation

◆ MARKER_SIZE

#define MARKER_SIZE   60.0

Definition at line 35 of file r_geoscape.cpp.

Referenced by R_Draw2DMapMarkers(), and R_Draw3DMapMarkers().

◆ SKYBOX_HALFSIZE

#define SKYBOX_HALFSIZE   800.0f

Half size of Skybox.

Note
The bigger, the less perspective default you'll have, but the more you'll zoom on the texture (and see it's default).
See also
R_DrawStarfield
R_Setup2D

Definition at line 306 of file r_geoscape.cpp.

Referenced by R_Draw3DGlobe().

Function Documentation

◆ R_Blur()

void R_Blur ( r_framebuffer_t * source,
r_framebuffer_t * dest,
int tex,
int dir )
static

does 1D filter convolution to blur a framebuffer texture. dir=0 for horizontal, dir=1 for vertical

Definition at line 725 of file r_geoscape.cpp.

References dest, R_BindTextureForTexUnit(), R_DrawQuad(), R_EnableBlur(), r_state, R_UseViewport(), r_framebuffer_t::textures, and texunit_0.

Referenced by R_BlurStack(), and R_DrawBloom().

◆ R_BlurStack()

void R_BlurStack ( int levels,
r_framebuffer_t ** sources,
r_framebuffer_t ** dests )
static

blur from the source image pyramid into the dest image pyramid

Definition at line 740 of file r_geoscape.cpp.

References default_program, i, R_BindTextureForTexUnit(), R_Blur(), R_DrawQuad(), r_state, R_UseFramebuffer(), R_UseProgram(), R_UseViewport(), sources, texunit_0, and texunit_1.

Referenced by R_DrawBloom().

◆ R_Draw2DMapMarkers()

void R_Draw2DMapMarkers ( const vec2_t screenPos,
float direction,
const char * model,
int skin )

Draw 3D Marker on the 2D geoscape.

Parameters
[in]screenPosPosition on screenlongitude and latitude of the model to draw.
[in]directionangle giving the direction the model is heading toward.
[in]modelThe name of the model of the marker.
[in]skinNumber of modelskin to draw on marker

Definition at line 180 of file r_geoscape.cpp.

References modelInfo_t::angles, modelInfo_t::center, Com_Printf(), MARKER_SIZE, modelInfo_t::model, modelInfo_t::name, OBJZERO, modelInfo_t::origin, R_DrawModelDirect(), R_FindModel(), R_ModelAutoScale(), scale, modelInfo_t::skin, vec3_origin, VectorCopy, and viddef.

Referenced by GAME_GetImportData().

◆ R_Draw3DGlobe()

void R_Draw3DGlobe ( const vec2_t pos,
const vec2_t size,
int day,
int second,
const vec3_t rotate,
float zoom,
const char * map,
bool disableSolarRender,
float ambient,
bool overlayNation,
bool overlayXVI,
bool overlayRadar,
image_t * r_xviTexture,
image_t * r_radarTexture,
bool renderNationGlow )

responsible for drawing the 3d globe on geoscape param[in] rotate the rotate angle of the globe param[in] zoom the current globe zoon param[in] map the prefix of the map to use (image must be at base/pics/menu/<map>_[day|night])

See also
R_DrawFlatGeoscape
R_SphereGenerate
Todo
render atmosphere glow even when postprocessing is disabled
Todo
Replace this magic number with some speaking constant

Definition at line 430 of file r_geoscape.cpp.

References Com_Error(), DateTime::DAYS_PER_YEAR, ERR_FATAL, GL_SOURCE0_ALPHA, GL_SOURCE0_RGB, GL_SOURCE1_RGB, GL_SOURCE2_RGB, int(), it_pic, it_wrappic, m, M_PI, r_config, R_DrawBuffers(), R_DrawStarfield(), R_DrawTexture(), R_FindImage(), R_FreeImage(), r_globeEarth, r_globeEarthAtmosphere, r_globeMoon, r_noTexture, r_postprocess, r_programs, r_radarTexture, R_RotateCelestialBody(), R_SelectTexture(), R_SphereRender(), r_state, r_xviTexture, DateTime::SEASONS_PER_YEAR, DateTime::SECONDS_PER_DAY, SIN_ALPHA, SKYBOX_HALFSIZE, STANDARD_3D_ZOOM, image_t::texnum, texunit_diffuse, va(), Vector4Set, VectorCopy, VectorSet, and viddef.

Referenced by uiGeoscapeNode::draw().

◆ R_Draw3DMapMarkers()

void R_Draw3DMapMarkers ( const vec2_t nodePos,
const vec2_t nodeSize,
const vec3_t rotate,
const vec2_t pos,
float direction,
float earthRadius,
const char * model,
int skin )

Draw 3D Marker on the 3D geoscape.

Parameters
[in]nodePosThe position, normalized (1024x768)
[in]nodeSizeThe dimensions, normalized (1024x768)
[in]rotatevector giving the angles of earth rotation due to player view.
[in]poslongitude and latitude of the model to draw.
[in]directionangle giving the direction the model is heading toward.
[in]earthRadiusRadius of earth on screen (this include zoom).
[in]modelThe name of the model of the marker.
[in]skinNumber of modelskin to draw on marker

Definition at line 237 of file r_geoscape.cpp.

References modelInfo_t::angles, modelInfo_t::center, Com_Printf(), MARKER_SIZE, modelInfo_t::model, modelInfo_t::name, OBJZERO, modelInfo_t::origin, R_DrawModelDirect(), R_FindModel(), R_ModelAutoScale(), scale, modelInfo_t::skin, vec3_origin, VectorCopy, and viddef.

Referenced by GAME_GetImportData().

◆ R_DrawBloom()

◆ R_DrawFlatGeoscape()

void R_DrawFlatGeoscape ( const vec2_t nodePos,
const vec2_t nodeSize,
float p,
float cx,
float cy,
float iz,
const char * map,
bool overlayNation,
bool overlayXVI,
bool overlayRadar,
image_t * r_dayandnightTexture,
image_t * r_xviTexture,
image_t * r_radarTexture )

Draw the day and night images of a flat geoscape multitexture feature is used to blend the images.

See also
R_Draw3DGlobe
Parameters
[in]nodePosThe position, normalized (1024x768)
[in]nodeSizeThe dimensions, normalized (1024x768)
[in]pThe horizontal shift of the night map
[in]cx,cyThe x/y texture coordinates
[in]izThe zoomlevel of the geoscape - see ccs.zoom
[in]mapThe geoscape map to draw (can be changed in the campaign definition)
[in]overlayNation,overlayXVI,overlayRadarWhether these overlays should be drawn or not
[in]r_dayandnightTexture,r_xviTexture,r_radarTextureThe textures used for the corresponding overlays

Definition at line 50 of file r_geoscape.cpp.

References Com_Error(), ERR_FATAL, it_wrappic, R_BindArray(), R_BindDefaultArray(), R_BindLightmapTexture(), R_BindTexture, r_dayandnightTexture, R_EnableTexture(), R_FindImage(), r_noTexture, r_radarTexture, R_SelectTexture(), r_xviTexture, refdef, image_t::texnum, texunit_diffuse, texunit_lightmap, va(), and viddef.

Referenced by uiGeoscapeNode::draw().

◆ R_DrawQuad()

void R_DrawQuad ( void )
inlinestatic

Draw the current texture on a quad the size of the renderbuffer.

Todo
use default_texcoords

Definition at line 704 of file r_geoscape.cpp.

References fbo_render, R_BindArray(), R_BindDefaultArray(), refdef, and Vector2FromInt.

Referenced by R_Blur(), R_BlurStack(), and R_DrawBloom().

◆ R_DrawStarfield()

void R_DrawStarfield ( int texnum,
const vec3_t pos,
const vec3_t rotate,
float timeOfDay )
static

Bind and draw starfield.

Parameters
[in]texnumThe texture id (already uploaded of course)
[in]posThe earth position
[in]rotatethe rotate angle of the globe
[in]timeOfDayThe earth rotation (time of day) in arcseconds
Note
We draw a skybox: the camera is inside a cube rotating at earth rotation speed (stars seems to rotate because we see earth as idle, but in reality stars are statics and earth rotate around itself)
See also
R_Setup2D
R_Draw3DGlobe

< Angle of rotation of starfield

Definition at line 367 of file r_geoscape.cpp.

References PITCH, R_BindTexture, refdef, ROLL, SKYBOX_DEPTH, starFieldTexCoords, starFieldVerts, todeg, VectorSet, and YAW.

Referenced by R_Draw3DGlobe().

◆ R_RotateCelestialBody()

void R_RotateCelestialBody ( const vec4_t v,
vec4_t r,
const vec3_t rotate,
const vec3_t earthPos,
const float celestialDist )
inlinestatic

rotate a planet (sun or moon) with respect to the earth

Definition at line 407 of file r_geoscape.cpp.

References PITCH, RotatePointAroundVector(), v, Vector4Set, VectorSet, and YAW.

Referenced by R_Draw3DGlobe().

Variable Documentation

◆ starFieldTexCoords

const float starFieldTexCoords[]
static
Initial value:
= {
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
}

Definition at line 346 of file r_geoscape.cpp.

Referenced by R_DrawStarfield().

◆ starFieldVerts

const float starFieldVerts[]
static

Definition at line 308 of file r_geoscape.cpp.

Referenced by R_DrawStarfield().