Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
navitemstodraw.h
Go to the documentation of this file.
1 //This draws the mouse cursor
2 //**********************************
3 void NavigationSystem::DrawCursor( float x, float y, float wid, float hei, const GFXColor &col )
4 {
5  float sizex, sizey;
6  static bool modern_nav_cursor =
7  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "nav", "modern_mouse_cursor", "true" ) );
8  if (modern_nav_cursor) {
9  static string mouse_cursor_sprite = vs_config->getVariable( "graphics", "nav", "mouse_cursor_sprite", "mouse.spr" );
10  static VSSprite MouseVSSprite( mouse_cursor_sprite.c_str(), BILINEAR, GFXTRUE );
13 
14  //Draw the cursor sprite.
18  MouseVSSprite.GetSize( sizex, sizey );
19  MouseVSSprite.SetPosition( x+sizex/2, y+sizey/2 );
20  MouseVSSprite.Draw();
21  } else {
22  GFXColorf( col );
26  GFXBegin( GFXLINE );
27  GFXVertex3f( x, y, 0 );
28  GFXVertex3f( x, (y-hei), 0 );
29 
30  GFXVertex3f( x, y, 0 );
31  GFXVertex3f( (x+wid), float( y-(0.75*hei) ), 0 );
32 
33  GFXVertex3f( x, (y-hei), 0 );
34  GFXVertex3f( ( x+(0.35*wid) ), ( y-(0.6*hei) ), 0 );
35 
36  GFXVertex3f( ( x+(0.35*wid) ), ( y-(0.6*hei) ), 0 );
37  GFXVertex3f( (x+wid), float( y-(0.75*hei) ), 0 );
38  GFXEnd();
40  }
41 }
42 //**********************************
43 
44 //This draws the grid over the nav screen area
45 //**********************************
46 void NavigationSystem::DrawGrid( float &x1, float &x2, float &y1, float &y2, const GFXColor &col )
47 {
48  static bool draw_grid = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "draw_nav_grid", "true" ) );
49  if (!draw_grid)
50  return;
51  GFXColorf( col );
55 
56  float deltax = x2-x1;
57  deltax = deltax/10;
58  float deltay = y2-y1;
59  deltay = deltay/10;
60 
61  GFXBegin( GFXLINE );
62  int i;
63  for (i = 1; i < 10; i++) {
64  GFXVertex3f( x1+(i*deltax), y1, 0 );
65  GFXVertex3f( x1+(i*deltax), y2, 0 );
66  }
67 //GFXEnd();
68 //GFXBegin(GFXLINE);
69  for (i = 1; i < 10; i++) {
70  GFXVertex3f( x1, y1+(i*deltay), 0 );
71  GFXVertex3f( x2, y1+(i*deltay), 0 );
72  }
73  GFXEnd();
75 }
76 //**********************************
77 
78 //This will draw a circle over the screen
79 //**********************************
80 void NavigationSystem::DrawCircle( float x, float y, float size, const GFXColor &col )
81 {
82  GFXColorf( col );
86 
87  float i = 0.0;
88  GFXBegin( GFXLINE );
89  for ( i = 0; i < 6.28; i += (6.28/20) ) {
90  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y+( 0.5*size*sin( i ) ) ), 0 );
91  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
92  }
93  GFXEnd();
95 }
96 //**********************************
97 
98 //This will draw a half circle, centered at the top 1/4 center
99 //**********************************
100 void NavigationSystem::DrawHalfCircleTop( float x, float y, float size, const GFXColor &col )
101 {
102  GFXColorf( col );
103  GFXDisable( TEXTURE0 );
104  GFXDisable( LIGHTING );
106 
107  float i = 0.0;
108  GFXBegin( GFXLINE );
109  for ( i = 0; i < ( 3.14-(6.28/20) ); i += (6.28/20) ) {
110  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y-(0.25*size)+( 0.5*size*sin( i ) ) ), 0 );
111  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y-(0.25*size)+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
112  }
113  GFXEnd();
114  GFXEnable( TEXTURE0 );
115 }
116 //**********************************
117 
118 //This will draw a half circle, centered at the bottom 1/4 center
119 //**********************************
120 void NavigationSystem::DrawHalfCircleBottom( float x, float y, float size, const GFXColor &col )
121 {
122  GFXColorf( col );
123  GFXDisable( TEXTURE0 );
124  GFXDisable( LIGHTING );
126 
127  float i = 0.0;
128  GFXBegin( GFXLINE );
129  for ( i = 3.14; i < ( 6.28-(6.28/20) ); i += (6.28/20) ) {
130  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( (0.25*size)+y+( 0.5*size*sin( i ) ) ), 0 );
131  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( (0.25*size)+y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
132  }
133  GFXEnd();
134  GFXEnable( TEXTURE0 );
135 }
136 //**********************************
137 
138 //This will draw a planet icon. circle + lightning thingy
139 //**********************************
140 void NavigationSystem::DrawPlanet( float x, float y, float size, const GFXColor &col )
141 {
142  GFXColorf( col );
143  GFXDisable( TEXTURE0 );
144  GFXDisable( LIGHTING );
146 
147  float i = 0.0;
148  GFXBegin( GFXLINE );
149  for ( i = 0; i < 6.28; i += (6.28/20) ) {
150  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y+( 0.5*size*sin( i ) ) ), 0 );
151  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
152  }
153  GFXVertex3f( float( x-(0.5*size) ), float(y), 0 );
154  GFXVertex3f( float(x), float( y+(0.2*size) ), 0 );
155 
156  GFXVertex3f( float(x), float( y+(0.2*size) ), 0 );
157  GFXVertex3f( float(x), float( y-(0.2*size) ), 0 );
158 
159  GFXVertex3f( float(x), float( y-(0.2*size) ), 0 );
160  GFXVertex3f( float( x+(0.5*size) ), float(y), 0 );
161 
162  GFXEnd();
163  GFXEnable( TEXTURE0 );
164 }
165 //**********************************
166 
167 //This will draw a station icon. 3x3 grid
168 //**********************************
169 void NavigationSystem::DrawStation( float x, float y, float size, const GFXColor &col )
170 {
171  GFXColorf( col );
172  GFXDisable( TEXTURE0 );
173  GFXDisable( LIGHTING );
175 
176  float segment = size/3;
177  GFXBegin( GFXLINE );
178  int i;
179  for (i = 0; i < 4; i++) {
180  GFXVertex3f( ( x-(0.5*size) ), ( ( y-(0.5*size) )+(i*segment) ), 0 );
181  GFXVertex3f( ( x+(0.5*size) ), ( ( y-(0.5*size) )+(i*segment) ), 0 );
182  }
183  for (i = 0; i < 4; i++) {
184  GFXVertex3f( ( ( x-(0.5*size) )+(i*segment) ), ( y-(0.5*size) ), 0 );
185  GFXVertex3f( ( ( x-(0.5*size) )+(i*segment) ), ( y+(0.5*size) ), 0 );
186  }
187  GFXEnd();
188  GFXEnable( TEXTURE0 );
189 }
190 //**********************************
191 
192 //This will draw a jump node icon
193 //**********************************
194 void NavigationSystem::DrawJump( float x, float y, float size, const GFXColor &col )
195 {
196  GFXColorf( col );
197  GFXDisable( TEXTURE0 );
198  GFXDisable( LIGHTING );
200 
201  float i = 0.0;
202  GFXBegin( GFXLINE );
203  for ( i = 0; i < 6.28; i += (6.28/20) ) {
204  GFXVertex3f( ( x+( 0.5*size*cos( i ) ) ), ( y+( 0.5*size*sin( i ) ) ), 0 );
205  GFXVertex3f( ( x+( 0.5*size*cos( i+(6.28/20) ) ) ), ( y+( 0.5*size*sin( i+(6.28/20) ) ) ), 0 );
206  }
207  GFXVertex3f( x, float( y+(0.5*size) ), 0 );
208  GFXVertex3f( ( x+(0.125*size) ), ( y+(0.125*size) ), 0 );
209 
210  GFXVertex3f( x, float( y+(0.5*size) ), 0 );
211  GFXVertex3f( ( x-(0.125*size) ), ( y+(0.125*size) ), 0 );
212 
213  GFXVertex3f( x, float( y-(0.5*size) ), 0 );
214  GFXVertex3f( ( x+(0.125*size) ), ( y-(0.125*size) ), 0 );
215 
216  GFXVertex3f( x, float( y-(0.5*size) ), 0 );
217  GFXVertex3f( ( x-(0.125*size) ), ( y-(0.125*size) ), 0 );
218 
219  GFXVertex3f( float( x-(0.5*size) ), y, 0 );
220  GFXVertex3f( ( x-(0.125*size) ), ( y+(0.125*size) ), 0 );
221 
222  GFXVertex3f( float( x-(0.5*size) ), y, 0 );
223  GFXVertex3f( ( x-(0.125*size) ), ( y-(0.125*size) ), 0 );
224 
225  GFXVertex3f( float( x+(0.5*size) ), y, 0 );
226  GFXVertex3f( ( x+(0.125*size) ), ( y+(0.125*size) ), 0 );
227 
228  GFXVertex3f( float( x+(0.5*size) ), y, 0 );
229  GFXVertex3f( ( x+(0.125*size) ), ( y-(0.125*size) ), 0 );
230 
231  GFXEnd();
232  GFXEnable( TEXTURE0 );
233 }
234 
235 //**********************************
236 
237 //This will draw a missile icon
238 //**********************************
239 void NavigationSystem::DrawMissile( float x, float y, float size, const GFXColor &col )
240 {
241  GFXColorf( col );
242  GFXDisable( TEXTURE0 );
243  GFXDisable( LIGHTING );
245 
246  GFXBegin( GFXLINE );
247  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.125*size) ), 0 );
248  GFXVertex3f( x, float( y+(0.375*size) ), 0 );
249 
250  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.125*size) ), 0 );
251  GFXVertex3f( x, float( y+(0.375*size) ), 0 );
252 
253  GFXVertex3f( ( x-(0.25*size) ), ( y-(0.125*size) ), 0 );
254  GFXVertex3f( ( x-(0.25*size) ), ( y+(0.125*size) ), 0 );
255 
256  GFXVertex3f( ( x+(0.25*size) ), ( y-(0.125*size) ), 0 );
257  GFXVertex3f( ( x+(0.25*size) ), ( y+(0.125*size) ), 0 );
258 
259  GFXVertex3f( ( x-(0.25*size) ), ( y+(0.125*size) ), 0 );
260  GFXVertex3f( x, float( y-(0.125*size) ), 0 );
261 
262  GFXVertex3f( ( x+(0.25*size) ), ( y+(0.125*size) ), 0 );
263  GFXVertex3f( x, float( y-(0.125*size) ), 0 );
264  GFXEnd();
265 
266  GFXEnable( TEXTURE0 );
267 }
268 //**********************************
269 
270 //This will draw a square set of corners
271 //**********************************
272 void NavigationSystem::DrawTargetCorners( float x, float y, float size, const GFXColor &col )
273 {
274  GFXColorf( col );
275  GFXDisable( TEXTURE0 );
276  GFXDisable( LIGHTING );
278 
279  GFXBegin( GFXLINE );
280 
281  GFXVertex3f( ( x-(0.5*size) ), ( y+(0.5*size) ), 0 );
282  GFXVertex3f( ( x-(0.3*size) ), ( y+(0.5*size) ), 0 );
283 
284  GFXVertex3f( ( x-(0.5*size) ), ( y+(0.5*size) ), 0 );
285  GFXVertex3f( ( x-(0.5*size) ), ( y+(0.3*size) ), 0 );
286 
287  GFXVertex3f( ( x+(0.5*size) ), ( y+(0.5*size) ), 0 );
288  GFXVertex3f( ( x+(0.3*size) ), ( y+(0.5*size) ), 0 );
289 
290  GFXVertex3f( ( x+(0.5*size) ), ( y+(0.5*size) ), 0 );
291  GFXVertex3f( ( x+(0.5*size) ), ( y+(0.3*size) ), 0 );
292 
293  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.5*size) ), 0 );
294  GFXVertex3f( ( x-(0.3*size) ), ( y-(0.5*size) ), 0 );
295 
296  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.5*size) ), 0 );
297  GFXVertex3f( ( x-(0.5*size) ), ( y-(0.3*size) ), 0 );
298 
299  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.5*size) ), 0 );
300  GFXVertex3f( ( x+(0.3*size) ), ( y-(0.5*size) ), 0 );
301 
302  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.5*size) ), 0 );
303  GFXVertex3f( ( x+(0.5*size) ), ( y-(0.3*size) ), 0 );
304 
305  GFXEnd();
306  GFXEnable( TEXTURE0 );
307 }
308 //**********************************
309 
310 //This will draw an oriented circle
311 //**********************************
312 void NavigationSystem::DrawNavCircle( float x, float y, float size, float rot_x, float rot_y, const GFXColor &col )
313 {
314  GFXColorf( col );
315  GFXDisable( TEXTURE0 );
316  GFXDisable( LIGHTING );
318 
319  float alpha = 0.15;
320  int circles = 4;
321 
322  float i = 0.0;
323  GFXBegin( GFXLINE );
324  float segments = 20.0;
325  for ( i = 0; i < 6.28; i += (6.28/segments) ) {
326  QVector pos1( ( 0.6*size*cos( i ) ), ( 0.6*size*sin( i ) ), 0 );
327  QVector pos2( ( 0.6*size*cos( i+(6.28/segments) ) ), ( 0.6*size*sin( i+(6.28/segments) ) ), 0 );
328  pos1 = dxyz( pos1, 0, 0, rot_y );
329  pos1 = dxyz( pos1, rot_x, 0, 0 );
330 
331  pos2 = dxyz( pos2, 0, 0, rot_y );
332  pos2 = dxyz( pos2, rot_x, 0, 0 );
333 
334  float standard_unit = 0.25*1.2*size;
335  float zdistance1 = ( (1.2*size)-pos1.k );
336  float zdistance2 = ( (1.2*size)-pos2.k );
337  float zscale1 = standard_unit/zdistance1;
338  float zscale2 = standard_unit/zdistance2;
339  pos1 *= (zscale1*5.0);
340  pos2 *= (zscale2*5.0);
341  //pos1 *= (-0.6*size)/((pos1.k) + (0.6*size));
342  //pos2 *= (-0.6*size)/((pos2.k) + (0.6*size));
343 
344  GFXColorf( GFXColor( col.r, col.g, ( col.b*fabs( sin( i/2.0 ) ) ), col.a ) );
345  for (int j = circles; j > 0; j--) {
346  pos1 *= ( float(j)/float(circles) );
347  pos2 *= ( float(j)/float(circles) );
348 
349  QVector pos1t( (x+pos1.i), ( y+(pos1.j) ), 0 );
350  QVector pos2t( (x+pos2.i), ( y+(pos2.j) ), 0 );
351 
352  GFXVertex3f( pos1t.i, pos1t.j, 0.0 );
353  GFXVertex3f( pos2t.i, pos2t.j, 0.0 );
354  }
355  }
356  for ( i = 0; i < 6.28; i += (6.28/12.0) ) {
357  QVector pos1( ( 0.6*size*cos( i )/float(circles*2) ), ( 0.6*size*sin( i )/float(circles*2) ), 0 );
358  QVector pos2( ( 0.6*size*cos( i ) ), ( 0.6*size*sin( i ) ), 0 );
359  if ( (fabs( i-1.57 ) < 0.01) || (fabs( i-3.14 ) < 0.01) || (fabs( i-4.71 ) < 0.01) || (i < 0.01) )
360  pos2 *= 1.1;
361  pos1 = dxyz( pos1, 0, 0, rot_y );
362  pos1 = dxyz( pos1, rot_x, 0, 0 );
363 
364  pos2 = dxyz( pos2, 0, 0, rot_y );
365  pos2 = dxyz( pos2, rot_x, 0, 0 );
366 
367  float standard_unit = 0.25*1.2*size;
368  float zdistance1 = ( (1.2*size)-pos1.k );
369  float zdistance2 = ( (1.2*size)-pos2.k );
370  float zscale1 = standard_unit/zdistance1;
371  float zscale2 = standard_unit/zdistance2;
372  pos1 *= (zscale1*5.0);
373  pos2 *= (zscale2*5.0);
374 //pos1 *= (pos1.k + size)/size;
375 //pos2 *= (pos2.k + size)/size;
376 
377 //pos1.j *= 1.33333;
378 //pos2.j *= 1.33333;
379 
380  pos1.i += x;
381  pos1.j += y;
382  pos2.i += x;
383  pos2.j += y;
384 
385  GFXColorf( GFXColor( col.r, col.g, ( col.b*fabs( sin( i/2.0 ) ) ), col.a ) );
386 
387  GFXVertex3f( pos1.i, pos1.j, 0.0 );
388  GFXVertex3f( pos2.i, pos2.j, 0.0 );
389  }
390  GFXEnd();
391  GFXEnable( TEXTURE0 );
392 }
393 //**********************************
394