Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 588 lines (437 sloc) 13.688 kb
e65967f powerpacks now set charging flag correctly
rtv authored
1 #include "stage.hh"
2 #include "worldfile.hh"
3 #include "canvas.hh"
4 #include "texture_manager.hh"
5 using namespace Stg;
6
7 // speech bubble colors
4ccc5cd replaced stg_color_t with Color class and added static named constructor...
rtv authored
8 static const Color BUBBLE_FILL( 1.0, 0.8, 0.8 );// light blue/grey
9 static const Color BUBBLE_BORDER( 0,0,0 ); // black
10 static const Color BUBBLE_TEXT( 0,0,0 ); // black
e65967f powerpacks now set charging flag correctly
rtv authored
11
12 void Model::DrawSelected()
13 {
14 glPushMatrix();
15
16 glTranslatef( pose.x, pose.y, pose.z+0.01 ); // tiny Z offset raises rect above grid
17
649ba76 O(n log n) fiducial finder
Richard Vaughan authored
18 Pose gp = GetGlobalPose();
e65967f powerpacks now set charging flag correctly
rtv authored
19
20 char buf[64];
21 snprintf( buf, 63, "%s [%.2f %.2f %.2f %.2f]",
5b0ed11 Richard Vaughan extended Model::Model to take a name parameter and simplified name gener...
authored
22 Token(), gp.x, gp.y, gp.z, rtod(gp.a) );
e65967f powerpacks now set charging flag correctly
rtv authored
23
24 PushColor( 0,0,0,1 ); // text color black
25 Gl::draw_string( 0.5,0.5,0.5, buf );
26
27 glRotatef( rtod(pose.a), 0,0,1 );
28
29 Gl::pose_shift( geom.pose );
30
31 double dx = geom.size.x / 2.0 * 1.6;
32 double dy = geom.size.y / 2.0 * 1.6;
33
34 PopColor();
35
36 PushColor( 0,1,0,0.4 ); // highlight color blue
37 glRectf( -dx, -dy, dx, dy );
38 PopColor();
39
40 PushColor( 0,1,0,0.8 ); // highlight color blue
41 glLineWidth( 1 );
42 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
43 glRectf( -dx, -dy, dx, dy );
44 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
45 PopColor();
46
47 glPopMatrix();
649ba76 O(n log n) fiducial finder
Richard Vaughan authored
48
e65967f powerpacks now set charging flag correctly
rtv authored
49 }
50
51
52 void Model::DrawTrailFootprint()
53 {
996c281 replaced some c-strings with std::strings
rtv authored
54 double darkness = 0;
55 double fade = 0.5 / (double)(trail_length+1);
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
56
4de1b77 Richard Vaughan removed unused model_props file and folded model_getset and model_load i...
authored
57 PushColor( 0,0,0,1 ); // dummy push just saving the color
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
58
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
59 // this loop could be faster, but optimzing vis is not a priority
60 for( unsigned int i=0; i<trail_length; i++ )
61 {
62 // find correct offset inside ring buffer
63 TrailItem& checkpoint =
64 trail[ (i + trail_index) % trail_length ];
3ea9a04 moved trail recording to worldgui from world, and made recording trails ...
rtv authored
65
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
66 // ignore invalid items
67 if( checkpoint.time == 0 )
68 continue;
3ea9a04 moved trail recording to worldgui from world, and made recording trails ...
rtv authored
69
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
70 glPushMatrix();
71 Pose pz = checkpoint.pose;
3ea9a04 moved trail recording to worldgui from world, and made recording trails ...
rtv authored
72
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
73 Gl::pose_shift( pz );
74 Gl::pose_shift( geom.pose );
3ea9a04 moved trail recording to worldgui from world, and made recording trails ...
rtv authored
75
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
76 darkness += fade;
77 Color c = checkpoint.color;
78 c.a = darkness;
79 glColor4f( c.r, c.g, c.b, c.a );
3ea9a04 moved trail recording to worldgui from world, and made recording trails ...
rtv authored
80
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
81 blockgroup.DrawFootPrint( geom );
3ea9a04 moved trail recording to worldgui from world, and made recording trails ...
rtv authored
82
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
83 glPopMatrix();
e65967f powerpacks now set charging flag correctly
rtv authored
84 }
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
85
996c281 replaced some c-strings with std::strings
rtv authored
86 PopColor();
e65967f powerpacks now set charging flag correctly
rtv authored
87 }
88
89 void Model::DrawTrailBlocks()
90 {
91 double timescale = 0.0000001;
92
996c281 replaced some c-strings with std::strings
rtv authored
93 FOR_EACH( it, trail )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
94 {
95 TrailItem& checkpoint = *it;
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
96
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
97 glPushMatrix();
98 Pose pz = checkpoint.pose;
99 pz.z = (world->sim_time - checkpoint.time) * timescale;
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
100
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
101 Gl::pose_shift( pz );
102 Gl::pose_shift( geom.pose );
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
103
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
104 DrawBlocks();
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
105
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
106 glPopMatrix();
e65967f powerpacks now set charging flag correctly
rtv authored
107 }
108 }
109
110 void Model::DrawTrailArrows()
111 {
112 double dx = 0.2;
113 double dy = 0.07;
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
114 double timescale = 1e-7;
115
116 PushColor( 0,0,0,1 ); // dummy push
e65967f powerpacks now set charging flag correctly
rtv authored
117
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
118 FOR_EACH( it, trail )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
119 {
120 TrailItem& checkpoint = *it;
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
121
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
122 glPushMatrix();
123 Pose pz = checkpoint.pose;
124 // set the height proportional to age
125 pz.z = (world->sim_time - checkpoint.time) * timescale;
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
126
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
127 Gl::pose_shift( pz );
128 Gl::pose_shift( geom.pose );
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
129
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
130 Color& c = checkpoint.color;
131 glColor4f( c.r, c.g, c.b, c.a );
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
132
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
133 glBegin( GL_TRIANGLES );
134 glVertex3f( 0, -dy, 0);
135 glVertex3f( dx, 0, 0 );
136 glVertex3f( 0, +dy, 0 );
137 glEnd();
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
138
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
139 glPopMatrix();
140 }
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
141
142 PopColor();
e65967f powerpacks now set charging flag correctly
rtv authored
143 }
144
145 void Model::DrawOriginTree()
146 {
147 DrawPose( GetGlobalPose() );
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
148
149 FOR_EACH( it, children )
150 (*it)->DrawOriginTree();
e65967f powerpacks now set charging flag correctly
rtv authored
151 }
152
153
154 void Model::DrawBlocksTree( )
155 {
156 PushLocalCoords();
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
157
158 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
159 (*it)->DrawBlocksTree();
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
160
e65967f powerpacks now set charging flag correctly
rtv authored
161 DrawBlocks();
162 PopCoords();
163 }
164
165 void Model::DrawPose( Pose pose )
166 {
167 PushColor( 0,0,0,1 );
168 glPointSize( 4 );
169
170 glBegin( GL_POINTS );
171 glVertex3f( pose.x, pose.y, pose.z );
172 glEnd();
173
174 PopColor();
175 }
176
177 void Model::DrawBlocks( )
178 {
9e1e848 Richard Vaughan refactored blocks and blockgroups to simplify code and API
authored
179 blockgroup.CallDisplayList();
e65967f powerpacks now set charging flag correctly
rtv authored
180 }
181
182 void Model::DrawBoundingBoxTree()
183 {
184 PushLocalCoords();
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
185
186 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
187 (*it)->DrawBoundingBoxTree();
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
188
e65967f powerpacks now set charging flag correctly
rtv authored
189 DrawBoundingBox();
190 PopCoords();
191 }
192
193 void Model::DrawBoundingBox()
194 {
195 Gl::pose_shift( geom.pose );
196
197 PushColor( color );
198
199 glBegin( GL_QUAD_STRIP );
200
201 glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
202 glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, 0 );
203
204 glVertex3f( +geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
205 glVertex3f( +geom.size.x/2.0, -geom.size.y/2.0, 0 );
206
207 glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
208 glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, 0 );
209
210 glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
211 glVertex3f( +geom.size.x/2.0, +geom.size.y/2.0, 0 );
212
213 glVertex3f( -geom.size.x/2.0, +geom.size.y/2.0, geom.size.z );
214 glVertex3f( -geom.size.x/2.0, +geom.size.y/2.0, 0 );
215
216 glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, geom.size.z );
217 glVertex3f( -geom.size.x/2.0, -geom.size.y/2.0, 0 );
218
219 glEnd();
220
221 glBegin( GL_LINES );
222 glVertex2f( -0.02, 0 );
223 glVertex2f( +0.02, 0 );
224
225 glVertex2f( 0, -0.02 );
226 glVertex2f( 0, +0.02 );
227 glEnd();
228
229 PopColor();
230 }
231
232 // move into this model's local coordinate frame
233 void Model::PushLocalCoords()
234 {
235 glPushMatrix();
236
08e31b0 added option to prevent stacking of models, based on patch #2919630 from...
rtv authored
237 if( parent && parent->stack_children )
e65967f powerpacks now set charging flag correctly
rtv authored
238 glTranslatef( 0,0, parent->geom.size.z );
239
240 Gl::pose_shift( pose );
241 }
242
243 void Model::PopCoords()
244 {
245 glPopMatrix();
246 }
247
a9b91ec more STLing
rtv authored
248 void Model::AddVisualizer( Visualizer* cv, bool on_by_default )
e65967f powerpacks now set charging flag correctly
rtv authored
249 {
1e01c9d Richard Vaughan cleaning up API
authored
250 assert(cv);
251
64382ca cleaned up cmdline args
rtv authored
252 // If there's no GUI, ignore this request
253 if( ! world_gui )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
254 return;
5e9262a reworked CustomVisualizer => Visualizer - tweaked API. See ModelLaser fo...
rtv authored
255
1e01c9d Richard Vaughan cleaning up API
authored
256 //save visualizer instance
a9b91ec more STLing
rtv authored
257 cv_list.push_back( cv );
64249e4 more STLing and type safety to hopefully reduce bugs
rtv authored
258
259 //register option for all instances which share the same name
260 Canvas* canvas = world_gui->GetCanvas();
261 std::map< std::string, Option* >::iterator i = canvas->_custom_options.find( cv->GetMenuName() );
262 if( i == canvas->_custom_options.end() ) {
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
263 Option* op = new Option( cv->GetMenuName(),
264 cv->GetWorldfileName(),
265 "",
266 on_by_default,
267 world_gui );
268 canvas->_custom_options[ cv->GetMenuName() ] = op;
269 RegisterOption( op );
64249e4 more STLing and type safety to hopefully reduce bugs
rtv authored
270 }
e65967f powerpacks now set charging flag correctly
rtv authored
271 }
272
a9b91ec more STLing
rtv authored
273 void Model::RemoveVisualizer( Visualizer* cv )
e65967f powerpacks now set charging flag correctly
rtv authored
274 {
a9b91ec more STLing
rtv authored
275 if( cv )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
276 EraseAll( cv, cv_list );
1ce2551 cleaning up
rtv authored
277
278 //TODO unregister option - tricky because there might still be instances attached to different models which have the same name
e65967f powerpacks now set charging flag correctly
rtv authored
279 }
280
281
282 void Model::DrawStatusTree( Camera* cam )
283 {
284 PushLocalCoords();
285 DrawStatus( cam );
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
286 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
287 (*it)->DrawStatusTree( cam );
e65967f powerpacks now set charging flag correctly
rtv authored
288 PopCoords();
289 }
290
291 void Model::DrawStatus( Camera* cam )
292 {
996c281 replaced some c-strings with std::strings
rtv authored
293 if( power_pack || !say_string.empty() )
e65967f powerpacks now set charging flag correctly
rtv authored
294 {
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
295 float pitch = - cam->pitch();
296 float yaw = - cam->yaw();
e65967f powerpacks now set charging flag correctly
rtv authored
297
1ce2551 cleaning up
rtv authored
298 Pose gpz = GetGlobalPose();
299
e65967f powerpacks now set charging flag correctly
rtv authored
300 float robotAngle = -rtod(gpz.a);
301 glPushMatrix();
1ce2551 cleaning up
rtv authored
302
e65967f powerpacks now set charging flag correctly
rtv authored
303 // move above the robot
304 glTranslatef( 0, 0, 0.5 );
1ce2551 cleaning up
rtv authored
305
e65967f powerpacks now set charging flag correctly
rtv authored
306 // rotate to face screen
307 glRotatef( robotAngle - yaw, 0,0,1 );
308 glRotatef( -pitch, 1,0,0 );
1ce2551 cleaning up
rtv authored
309
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
310 // if( power_pack )
311 //power_pack->Visualize( cam );
1ce2551 cleaning up
rtv authored
312
996c281 replaced some c-strings with std::strings
rtv authored
313 if( !say_string.empty() )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
314 {
315 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
996c281 replaced some c-strings with std::strings
rtv authored
316
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
317 //get raster positition, add gl_width, then project back to world coords
318 glRasterPos3f( 0, 0, 0 );
319 GLfloat pos[ 4 ];
320 glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
996c281 replaced some c-strings with std::strings
rtv authored
321
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
322 GLboolean valid;
323 glGetBooleanv( GL_CURRENT_RASTER_POSITION_VALID, &valid );
1ce2551 cleaning up
rtv authored
324
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
325 if( valid )
326 {
327 //fl_font( FL_HELVETICA, 12 );
328 float w = gl_width( this->say_string.c_str() ); // scaled text width
329 float h = gl_height(); // scaled text height
996c281 replaced some c-strings with std::strings
rtv authored
330
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
331 GLdouble wx, wy, wz;
332 GLint viewport[4];
333 glGetIntegerv(GL_VIEWPORT, viewport);
996c281 replaced some c-strings with std::strings
rtv authored
334
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
335 GLdouble modelview[16];
336 glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
996c281 replaced some c-strings with std::strings
rtv authored
337
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
338 GLdouble projection[16];
339 glGetDoublev(GL_PROJECTION_MATRIX, projection);
1ce2551 cleaning up
rtv authored
340
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
341 //get width and height in world coords
342 gluUnProject( pos[0] + w, pos[1], pos[2], modelview, projection, viewport, &wx, &wy, &wz );
343 w = wx;
344 gluUnProject( pos[0], pos[1] + h, pos[2], modelview, projection, viewport, &wx, &wy, &wz );
345 h = wy;
1ce2551 cleaning up
rtv authored
346
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
347 // calculate speech bubble margin
348 const float m = h/10;
1ce2551 cleaning up
rtv authored
349
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
350 // draw inside of bubble
351 PushColor( BUBBLE_FILL );
352 glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT );
353 glPolygonMode( GL_FRONT, GL_FILL );
354 glEnable( GL_POLYGON_OFFSET_FILL );
355 glPolygonOffset( 1.0, 1.0 );
356 Gl::draw_octagon( w, h, m );
357 glDisable( GL_POLYGON_OFFSET_FILL );
358 PopColor();
1ce2551 cleaning up
rtv authored
359
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
360 // draw outline of bubble
361 PushColor( BUBBLE_BORDER );
362 glLineWidth( 1 );
363 glEnable( GL_LINE_SMOOTH );
364 glPolygonMode( GL_FRONT, GL_LINE );
365 Gl::draw_octagon( w, h, m );
366 glPopAttrib();
367 PopColor();
1ce2551 cleaning up
rtv authored
368
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
369 PushColor( BUBBLE_TEXT );
370 // draw text inside the bubble
371 Gl::draw_string( m, 2.5*m, 0, this->say_string.c_str() );
372 PopColor();
373 }
374 }
1ce2551 cleaning up
rtv authored
375 glPopMatrix();
376 }
e65967f powerpacks now set charging flag correctly
rtv authored
377
378 if( stall )
379 {
380 DrawImage( TextureManager::getInstance()._stall_texture_id, cam, 0.85 );
381 }
c69a1c9 more efficient real-time tracking
rtv authored
382
1ce2551 cleaning up
rtv authored
383 // extern GLuint glowTex;
996c281 replaced some c-strings with std::strings
rtv authored
384 // extern GLuint checkTex;
c69a1c9 more efficient real-time tracking
rtv authored
385
996c281 replaced some c-strings with std::strings
rtv authored
386 // if( parent == NULL )
387 // {
388 // glBlendFunc(GL_SRC_COLOR, GL_ONE );
389 // DrawImage( glowTex, cam, 1.0 );
390 // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
391 // }
e65967f powerpacks now set charging flag correctly
rtv authored
392 }
393
c69a1c9 more efficient real-time tracking
rtv authored
394 void Model::DrawImage( uint32_t texture_id, Camera* cam, float alpha,
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
395 double width, double height )
e65967f powerpacks now set charging flag correctly
rtv authored
396 {
3ce2d0e applied patch from Jeff Donner, fixing some signed/unsigned comparisons
rtv authored
397 (void)alpha; // avoid warning about unused var
398
e65967f powerpacks now set charging flag correctly
rtv authored
399 float yaw, pitch;
400 pitch = - cam->pitch();
401 yaw = - cam->yaw();
c69a1c9 more efficient real-time tracking
rtv authored
402
403 float robotAngle = -rtod( GetGlobalPose().a);
e65967f powerpacks now set charging flag correctly
rtv authored
404
8b06ea1 fixed broken badges
rtv authored
405 glPolygonMode( GL_FRONT, GL_FILL );
406
e65967f powerpacks now set charging flag correctly
rtv authored
407 glEnable(GL_TEXTURE_2D);
408 glBindTexture( GL_TEXTURE_2D, texture_id );
409
c69a1c9 more efficient real-time tracking
rtv authored
410 glColor4f( 1.0, 1.0, 1.0, 1.0 );
e65967f powerpacks now set charging flag correctly
rtv authored
411 glPushMatrix();
412
413 //position image above the robot
c69a1c9 more efficient real-time tracking
rtv authored
414 // TODO
e65967f powerpacks now set charging flag correctly
rtv authored
415 glTranslatef( 0.0, 0.0, ModelHeight() + 0.3 );
416
417 // rotate to face screen
418 glRotatef( robotAngle - yaw, 0,0,1 );
419 glRotatef( -pitch - 90, 1,0,0 );
420
421 //draw a square, with the textured image
422 glBegin(GL_QUADS);
423 glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.25f, 0, -0.25f );
424 glTexCoord2f(width, 0.0f); glVertex3f( 0.25f, 0, -0.25f );
425 glTexCoord2f(width, height); glVertex3f( 0.25f, 0, 0.25f );
426 glTexCoord2f(0.0f, height); glVertex3f(-0.25f, 0, 0.25f );
427 glEnd();
428
429 glBindTexture( GL_TEXTURE_2D, 0 );
430 glDisable(GL_TEXTURE_2D);
c69a1c9 more efficient real-time tracking
rtv authored
431
432 glPopMatrix();
e65967f powerpacks now set charging flag correctly
rtv authored
433 }
434
435
436 void Model::DrawFlagList( void )
437 {
2c36066 fixed color bug in flags, and more STLing
rtv authored
438 if( flag_list.size() < 1 )
e65967f powerpacks now set charging flag correctly
rtv authored
439 return;
440
afea962 Richard Vaughan *much* faster flag drawing
authored
441 Pose gp = GetGlobalPose();
442 GLfloat z = 1.0;
e65967f powerpacks now set charging flag correctly
rtv authored
443
2c36066 fixed color bug in flags, and more STLing
rtv authored
444 for( std::list<Flag*>::reverse_iterator it( flag_list.rbegin());
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
445 it != flag_list.rend();
446 it++ )
2c36066 fixed color bug in flags, and more STLing
rtv authored
447 {
afea962 Richard Vaughan *much* faster flag drawing
authored
448 double sz = (*it)->GetSize();
449 double d = sz/2.0;
450
451 (*it)->GetColor().GLSet();
452
453 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
454 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
455 glVertex3f( gp.x+0, gp.y+0, gp.z+d +z);
456
457 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
458 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
459 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
e65967f powerpacks now set charging flag correctly
rtv authored
460
afea962 Richard Vaughan *much* faster flag drawing
authored
461 glVertex3f( gp.x-d, gp.y+0, gp.z+0 +z);
462 glVertex3f( gp.x+0, gp.y-d, gp.z+0 +z);
463 glVertex3f( gp.x+0, gp.y+0, gp.z+d +z);
464
465 glVertex3f( gp.x-d, gp.y+0, gp.z+0 +z);
466 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
467 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
468
469 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
470 glVertex3f( gp.x+0, gp.y-d, gp.z+0 +z);
471 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
472
e4631ee Richard Vaughan removed redundant triangles from flag drawing
authored
473
474 // for wire-frame we only need half of the 8 triangles
475
476 //glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
477 //glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
478 //glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
479
480 //glVertex3f( gp.x-d, gp.y+0, gp.z+0 +z);
481 //glVertex3f( gp.x+0, gp.y-d, gp.z+0 +z);
482 //glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
483
484 // and two more...
485
afea962 Richard Vaughan *much* faster flag drawing
authored
486 z += sz;
e65967f powerpacks now set charging flag correctly
rtv authored
487 }
488 }
489
490
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
491 // void Model::DrawBlinkenlights()
492 // {
493 // PushLocalCoords();
e65967f powerpacks now set charging flag correctly
rtv authored
494
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
495 // GLUquadric* quadric = gluNewQuadric();
496 // //glTranslatef(0,0,1); // jump up
497 // //Pose gpose = GetGlobalPose();
498 // //glRotatef( 180 + rtod(-gpose.a),0,0,1 );
e65967f powerpacks now set charging flag correctly
rtv authored
499
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
500 // for( unsigned int i=0; i<blinkenlights->len; i++ )
501 // {
e45b70c combined laser and ranger functionality into ranger - still buggy
Richard Vaughan authored
502 // blinkenlight_t* b =
503 // (blinkenlight_t*)g_ptr_array_index( blinkenlights, i );
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
504 // assert(b);
e65967f powerpacks now set charging flag correctly
rtv authored
505
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
506 // glTranslatef( b->pose.x, b->pose.y, b->pose.z );
e65967f powerpacks now set charging flag correctly
rtv authored
507
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
508 // PushColor( b->color );
e65967f powerpacks now set charging flag correctly
rtv authored
509
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
510 // if( b->enabled )
511 // gluQuadricDrawStyle( quadric, GLU_FILL );
512 // else
513 // gluQuadricDrawStyle( quadric, GLU_LINE );
2c36066 fixed color bug in flags, and more STLing
rtv authored
514
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
515 // gluSphere( quadric, b->size/2.0, 8,8 );
e65967f powerpacks now set charging flag correctly
rtv authored
516
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
517 // PopColor();
518 // }
e65967f powerpacks now set charging flag correctly
rtv authored
519
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
520 // gluDeleteQuadric( quadric );
e65967f powerpacks now set charging flag correctly
rtv authored
521
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
522 // PopCoords();
523 // }
e65967f powerpacks now set charging flag correctly
rtv authored
524
525 void Model::DrawPicker( void )
526 {
527 //PRINT_DEBUG1( "Drawing %s", token );
528 PushLocalCoords();
529
530 // draw the boxes
531 blockgroup.DrawSolid( geom );
532
533 // recursively draw the tree below this model
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
534 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
535 (*it)->DrawPicker();
e65967f powerpacks now set charging flag correctly
rtv authored
536
537 PopCoords();
538 }
539
540 void Model::DataVisualize( Camera* cam )
541 {
3ce2d0e applied patch from Jeff Donner, fixing some signed/unsigned comparisons
rtv authored
542 (void)cam; // avoid warning about unused var
e65967f powerpacks now set charging flag correctly
rtv authored
543 }
544
545 void Model::DataVisualizeTree( Camera* cam )
546 {
547 PushLocalCoords();
548
712cd33 disabled visualization drawing for unsubscribed models
rtv authored
549 if( subs > 0 )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
550 {
551 DataVisualize( cam ); // virtual function overridden by some model types
712cd33 disabled visualization drawing for unsubscribed models
rtv authored
552
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
553 FOR_EACH( it, cv_list )
554 {
555 Visualizer* vis = *it;
556 if( world_gui->GetCanvas()->_custom_options[ vis->GetMenuName() ]->isEnabled() )
557 vis->Visualize( this, cam );
558 }
559 }
712cd33 disabled visualization drawing for unsubscribed models
rtv authored
560
e65967f powerpacks now set charging flag correctly
rtv authored
561 // and draw the children
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
562 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
563 (*it)->DataVisualizeTree( cam );
e65967f powerpacks now set charging flag correctly
rtv authored
564
565 PopCoords();
566 }
567
568 void Model::DrawGrid( void )
569 {
570 if ( gui.grid )
571 {
572 PushLocalCoords();
573
e45b70c combined laser and ranger functionality into ranger - still buggy
Richard Vaughan authored
574 bounds3d_t vol;
e65967f powerpacks now set charging flag correctly
rtv authored
575 vol.x.min = -geom.size.x/2.0;
576 vol.x.max = geom.size.x/2.0;
577 vol.y.min = -geom.size.y/2.0;
578 vol.y.max = geom.size.y/2.0;
579 vol.z.min = 0;
580 vol.z.max = geom.size.z;
581
582 PushColor( 0,0,1,0.4 );
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
583 Gl::draw_grid(vol);
e65967f powerpacks now set charging flag correctly
rtv authored
584 PopColor();
585 PopCoords();
586 }
587 }
Something went wrong with that request. Please try again.