1 // HUDNavigation.cpp
2 // Derek Meek
3 // 4-30-2004
4 
5 
6 
7 #include "autopilot/autopilot.h"
8 #include "hud/hud.h"
9 #include "hud/hudbrackets.h"
10 #include "hud/hudnavigation.h"
11 #include "hud/hudtarget.h"
12 #include "hud/hudtargetbox.h"
13 #include "object/object.h"
14 #include "render/3d.h"
15 #include "ship/ship.h"
16 
17 
18 extern void hud_target_show_dist_on_bracket(int x, int y, float distance, int font_num);
19 extern void draw_brackets_square_quick(int x1, int y1, int x2, int y2, int thick);
20 
21 /**
22  * Draws the Navigation stuff on the HUD
23  */
hud_draw_navigation()24 void hud_draw_navigation()
25 {
26 	if (CurrentNav != -1 && Navs[CurrentNav].flags & NP_VALIDTYPE && !(Navs[CurrentNav].flags & NP_NOSELECT))
27 	{
28 		int in_cockpit;
29 		if (!(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY)) )
30 			in_cockpit = 1;
31 		else
32 			in_cockpit = 0;
33 
34 		vertex target_point;	// temp vertex used to find screen position for 3-D object;
35 		auto target_pos = Navs[CurrentNav].GetPosition();
36 
37 		color NavColor;
38 
39         memset(&target_point, 0, sizeof(target_point));
40 
41 		unsigned int alpha = HUD_COLOR_ALPHA_MAX * 16;
42 
43 		if (Navs[CurrentNav].flags & NP_VISITED)
44 			gr_init_alphacolor( &NavColor, 0xFF, 0xFF, 0x00, alpha);
45 		else
46 			gr_init_alphacolor( &NavColor, 0x80, 0x80, 0xff, alpha);
47 
48 		g3_rotate_vertex(&target_point, target_pos);
49 		g3_project_vertex(&target_point);
50 
51 		if ( in_cockpit )
52 			hud_target_add_display_list(NULL, &target_point, target_pos, 0, &NavColor, Navs[CurrentNav].m_NavName, TARGET_DISPLAY_DIST);
53 	}
54 }
55