File: hudnavigation.cpp

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (52 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (2)
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
// HUDNavigation.cpp
// Derek Meek
// 4-30-2004



#include "autopilot/autopilot.h"
#include "hud/hud.h"
#include "hud/hudbrackets.h"
#include "hud/hudnavigation.h"
#include "hud/hudtarget.h"
#include "hud/hudtargetbox.h"
#include "object/object.h"
#include "render/3d.h"
#include "ship/ship.h"


extern void hud_target_show_dist_on_bracket(int x, int y, float distance, int font_num);
extern void draw_brackets_square_quick(int x1, int y1, int x2, int y2, int thick);

/**
 * Draws the Navigation stuff on the HUD
 */
void hud_draw_navigation()
{
	if (CurrentNav != -1 && Navs[CurrentNav].flags & NP_VALIDTYPE && !(Navs[CurrentNav].flags & NP_NOSELECT))
	{
		int in_cockpit;
		if (!(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY)) )
			in_cockpit = 1;
		else
			in_cockpit = 0;

		vertex target_point;	// temp vertex used to find screen position for 3-D object;
		auto target_pos = Navs[CurrentNav].GetPosition();

		color NavColor;
        
        memset(&target_point, 0, sizeof(target_point));

		unsigned int alpha = HUD_COLOR_ALPHA_MAX * 16;

		auto rgb = (Navs[CurrentNav].flags & NP_VISITED) ? Navs[CurrentNav].visited_color : Navs[CurrentNav].normal_color;
		gr_init_alphacolor( &NavColor, rgb[0], rgb[1], rgb[2], alpha );

		g3_rotate_vertex(&target_point, target_pos);
		g3_project_vertex(&target_point);

		if ( in_cockpit )
			hud_target_add_display_list(NULL, &target_point, target_pos, 0, &NavColor, Navs[CurrentNav].m_NavName, TARGET_DISPLAY_DIST);
	}
}