25 #include "../ui_nodes.h"
26 #include "../ui_input.h"
27 #include "../ui_parse.h"
28 #include "../ui_behaviour.h"
29 #include "../ui_actions.h"
30 #include "../ui_render.h"
32 #include "../../renderer/r_framebuffer.h"
33 #include "../../renderer/r_geoscape.h"
34 #include "../../cl_shared.h"
35 #include "../../cgame/cl_game.h"
36 #include "../../input/cl_input.h"
37 #include "../../input/cl_keys.h"
39 #include "../../../common/scripts_lua.h"
41 #define EXTRADATA_TYPE mapExtraData_t
42 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
43 #define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
107 const float epsilon = 0.1f;
108 if (diffAngle > epsilon) {
114 rotationSpeed = std::min(diffAngle,
UI_MAPEXTRADATACONST(node).curRotationSpeed + rotationSpeed * 0.5
f);
123 const float epsilonZoom = 0.01f;
125 if (fabsf(diffZoom) > epsilonZoom) {
132 speed = std::min(maxSpeed, newSpeed);
157 const float length = sqrt(dist1 * dist1 + dist2 * dist2);
181 const float sin_q = sin(q);
182 const float cos_q = cos(q);
187 const float phi = x * dphi - q;
188 sin_phi[x] = sin(phi);
189 cos_phi[x] = cos(phi);
196 const float root = sqrt(1 - a * a);
198 const float pos = sin_phi[x] * root * sin_q - (a *
SIN_ALPHA + cos_phi[x] * root *
COS_ALPHA) * cos_q;
202 else if (pos <= -
DAWN)
205 *px++ = (
byte) (128.0 * (pos /
DAWN + 1));
250 const char* map = data.
map;
256 static float lastQ = 0.0f;
270 bool disableSolarRender =
false;
272 disableSolarRender =
true;
300 for (
int i = 0;
i < 2;
i++) {
379 while (pos[0] > 180.0)
381 while (pos[0] < -180.0)
404 dist = sqrt((x - mid[0]) * (x - mid[0]) + (y - mid[1]) * (y - mid[1]));
416 v[0] = - (y - mid[1]);
417 v[1] = - (x - mid[0]);
418 v[2] = - sqrt(radius * radius - (x - mid[0]) * (x - mid[0]) - (y - mid[1]) * (y - mid[1]));
512 bool down = deltaY > 0;
548 m->
zoom(node,
false);
564 const float zoomAmount = 50.0f;
584 Com_Printf(
"UI_GeoscapeNodeZoom_f: Invalid parameter: %s\n", cmd);
614 float scrollX = 0.0f, scrollY = 0.0f;
615 const float scrollAmount = 80.0f;
630 scrollX = scrollAmount;
633 scrollX = -scrollAmount;
636 scrollY = scrollAmount;
639 scrollY = -scrollAmount;
642 Com_Printf(
"UI_GeoscapeNodeScroll_f: Invalid parameter\n");
681 for (
int i = 0;
i < 2;
i++) {
696 behaviour->
name =
"geoscape";
712 cl_3dmapAmbient =
Cvar_Get(
"cl_3dmapAmbient",
"0",
CVAR_ARCHIVE,
"3D geoscape ambient lighting factor");
713 cl_mapzoommax =
Cvar_Get(
"cl_mapzoommax",
"6.0",
CVAR_ARCHIVE,
"Maximum geoscape zooming value");
714 cl_mapzoommin =
Cvar_Get(
"cl_mapzoommin",
"1.0",
CVAR_ARCHIVE,
"Minimum geoscape zooming value");
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
const char * Cmd_Argv(int arg)
Returns a given argument.
bool R_EnableRenderbuffer(bool enable)
Enable the render to the framebuffer.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
#define VectorCopy(src, dest)
#define Mem_AllocTypeN(type, n)
void UI_PopClipRect(void)
#define VectorSet(v, x, y, z)
void calcAndUploadDayAndNightTexture(uiNode_t *node, float q)
Applies alpha values to the night overlay image for 2d geoscape.
void smoothRotate(uiNode_t *node)
smooth rotation of the 3D geoscape
static const float GLOBE_ROTATE
void smoothTranslate(uiNode_t *node)
smooth translation of the 2D geoscape
void VecToPolar(const vec3_t v, vec2_t a)
Converts vector coordinates into polar coordinates.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
static const float SMOOTHACCELERATION
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
mapDragMode_t
Status of the node.
uiBehaviour_t * behaviour
image_t * R_LoadImageData(const char *name, const byte *pic, int width, int height, imagetype_t type)
Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it...
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Rotate a point around a given vector.
void startMouseShifting(uiNode_t *node, int x, int y)
void Com_Printf(const char *const fmt,...)
#define UI_MAPEXTRADATACONST(node)
#define VectorScale(in, scale, out)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
static const float SMOOTHING_STEP_2D
static cvar_t * cl_mapzoommin
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
static void UI_GeoscapeNodeZoomIn(uiNode_t *node, const uiCallContext_t *context)
void zoom(uiNode_t *node, bool out)
void screenToMap(const uiNode_t *node, int x, int y, vec2_t pos)
Return longitude and latitude of a point of the screen for 2D geoscape.
void GAME_DrawMapMarkers(uiNode_t *node)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
static cvar_t * cl_mapzoommax
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
geoscapeData_t geoscapeData
float Cvar_GetValue(const char *varName)
Returns the float value of a cvar.
#define Vector4Set(v, r, g, b, a)
QGL_EXTERN GLuint GLsizei GLsizei * length
void screenTo3DMap(const uiNode_t *node, int x, int y, vec2_t pos)
Return longitude and latitude of a point of the screen for 3D geoscape (globe)
#define Vector2Set(v, x, y)
#define UI_MAPEXTRADATA(node)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
SharedPtr< uiNode > UINodePtr
void R_UploadAlpha(const image_t *image, const byte *alphaData)
void onCapturedMouseLost(uiNode_t *node) override
Called when the node have lost the captured node We clean cached data.
static cvar_t * cl_3dmapAmbient
void draw(uiNode_t *node) override
Engine-side time information in the game.
Atomic structure used to define most of the UI.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
#define GLOBE_RADIUS
radius of the globe in screen coordinates
void onLeftClick(uiNode_t *node, int x, int y) override
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Contain the context of the calling of a function.
#define VectorAdd(a, b, dest)
node behaviour, how a node work
void onMouseUp(uiNode_t *node, int x, int y, int button) override
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...
vec_t VectorNormalize(vec3_t v)
Calculate unit vector for a given vec3_t.
image_t * r_dayandnightTexture
#define Vector2Copy(src, dest)
static uiNode_t * geoscapeNode
bool onStartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button) override
Send mouse event when a pressed mouse button is dragged.
void UI_PushClipRect(int x, int y, int width, int height)
void UI_RegisterGeoscapeNode(uiBehaviour_t *behaviour)
void R_DrawBloom(void)
handle post-processing bloom
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...
GLsizei const GLvoid * data
static void UI_GeoscapeNodeZoomOut(uiNode_t *node, const uiCallContext_t *context)
static const float ROTATE_SPEED
static void UI_GeoscapeNodeScroll_f(void)
Command binding for map scrolling.
void GAME_DrawMap(geoscapeData_t *data)
QGL_EXTERN int GLboolean GLfloat * v
#define VectorSubtract(a, b, dest)
static void UI_GeoscapeNodeZoom_f(void)
Command binding for map zooming.
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
void GAME_MapClick(uiNode_t *node, int x, int y, const vec2_t pos)
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...