]> icculus.org git repositories - taylor/freespace2.git/blob - src/jumpnode/jumpnode.cpp
warning cleanup
[taylor/freespace2.git] / src / jumpnode / jumpnode.cpp
1 /*
2  * $Logfile: /Freespace2/code/JumpNode/JumpNode.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Module for everything to do with jump nodes
8  *
9  * $Log$
10  * Revision 1.3  2002/06/02 04:26:34  relnev
11  * warning cleanup
12  *
13  * Revision 1.2  2002/05/07 03:16:46  theoddone33
14  * The Great Newline Fix
15  *
16  * Revision 1.1.1.1  2002/05/03 03:28:09  root
17  * Initial import.
18  *
19  * 
20  * 2     10/07/98 10:53a Dave
21  * Initial checkin.
22  * 
23  * 1     10/07/98 10:49a Dave
24  * 
25  * 9     6/13/98 6:01p Hoffoss
26  * Externalized all new (or forgot to be added) strings to all the code.
27  * 
28  * 8     5/12/98 2:03p Adam
29  * make jumpnode less bright
30  * 
31  * 7     4/01/98 8:38p Lawrance
32  * Add support for jump node icons in the briefings.
33  * 
34  * 6     3/24/98 4:27p Lawrance
35  * Use new method for dimming lines
36  * 
37  * 5     3/24/98 12:05p Lawrance
38  * Don't set alpha color for jumpnode
39  * 
40  * 4     3/23/98 11:05a Lawrance
41  * Dim jump node as it get farther away
42  * 
43  * 3     3/21/98 7:43p Lawrance
44  * Disable jump node dimming until bug with alpha colors is fixed
45  * 
46  * 2     3/21/98 7:36p Lawrance
47  * Move jump nodes to own lib.
48  * 
49  * 1     3/21/98 3:53p Lawrance
50  *
51  * $NoKeywords: $
52  */
53
54 int Num_jump_nodes = 0;
55
56 #include "object.h"
57 #include "jumpnode.h"
58 #include "model.h"
59 #include "hud.h"
60
61 jump_node_struct Jump_nodes[MAX_JUMP_NODES];
62
63 void jumpnode_render(object *jumpnode_objp, vector *pos, vector *view_pos)
64 {
65         jump_node_struct        *node;
66         matrix                          node_orient = IDENTITY_MATRIX;
67
68         node = &Jump_nodes[jumpnode_objp->instance];
69
70         if ( Fred_running ) {
71                 model_set_outline_color(0, 255, 0);             
72                 model_render(node->modelnum, &node_orient, pos, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_NO_POLYS | MR_SHOW_OUTLINE );
73         } else {
74                 if ( view_pos ) {
75                         int alpha_index = HUD_color_alpha;
76
77                         // generate alpha index based on distance to jump node
78                         float dist;
79
80                         dist = vm_vec_dist_quick(view_pos, pos);
81
82                         // linearly interpolate alpha.  At 1000m or less, full intensity.  At 10000m or more 1/2 intensity.
83                         if ( dist < 1000 ) {
84                                 alpha_index = HUD_COLOR_ALPHA_USER_MAX - 2;
85                         } else if ( dist > 10000 ) {
86                                 alpha_index = HUD_COLOR_ALPHA_USER_MIN;
87                         } else {
88                                 alpha_index = fl2i( HUD_COLOR_ALPHA_USER_MAX - 2 + (dist-1000) * (HUD_COLOR_ALPHA_USER_MIN-HUD_COLOR_ALPHA_USER_MAX-2) / (9000) + 0.5f);
89                                 if ( alpha_index < HUD_COLOR_ALPHA_USER_MIN ) {
90                                         alpha_index = HUD_COLOR_ALPHA_USER_MIN;
91                                 }
92                         }
93
94         //              nprintf(("Alan","alpha index is: %d\n", alpha_index));
95                         gr_set_color_fast(&HUD_color_defaults[alpha_index]);
96 //                      model_set_outline_color(HUD_color_red, HUD_color_green, HUD_color_blue);
97
98                 } else {
99                         gr_set_color(HUD_color_red, HUD_color_green, HUD_color_blue);
100                 }
101                 model_render(node->modelnum, &node_orient, pos, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_NO_POLYS | MR_SHOW_OUTLINE_PRESET );
102         }
103
104 }
105
106 // create a jump node object and return index to it.
107 int jumpnode_create(vector *pos)
108 {
109         int obj;
110
111         Assert(Num_jump_nodes < MAX_JUMP_NODES);
112
113         Jump_nodes[Num_jump_nodes].modelnum = model_load(NOX("subspacenode.pof"), 0, NULL);
114         if ( Jump_nodes[Num_jump_nodes].modelnum < 0 ) {
115                 Int3();
116                 return -1;
117         }
118
119         obj = obj_create(OBJ_JUMP_NODE, -1, Num_jump_nodes, NULL, pos, model_get_radius(Jump_nodes[Num_jump_nodes].modelnum), OF_RENDERS);
120         sprintf(Jump_nodes[Num_jump_nodes].name, XSTR( "Jump Node %d", 632), Num_jump_nodes);
121         if (obj >= 0) {
122                 Jump_nodes[Num_jump_nodes].objnum = obj;
123                 Num_jump_nodes++;
124         }
125         return obj;
126 }
127
128 // only called by FRED
129 void jumpnode_render_all()
130 {
131         int             i;
132         object  *jumpnode_objp;
133
134         for ( i = 0; i < Num_jump_nodes; i++ ) {        
135                 jumpnode_objp = &Objects[Jump_nodes[i].objnum];
136                 jumpnode_render(jumpnode_objp, &jumpnode_objp->pos);
137         }
138 }
139