Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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