Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 669 lines (491 sloc) 15.783 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
649ba76 O(n log n) fiducial finder
Richard Vaughan authored
47
62b8f31 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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 Richard Vaughan 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
afea962 Richard Vaughan *much* faster flag drawing
authored
520 //static GLUquadric* quadric = NULL;
521
e65967f powerpacks now set charging flag correctly
rtv authored
522 void Model::DrawFlagList( void )
523 {
2c36066 fixed color bug in flags, and more STLing
rtv authored
524 if( flag_list.size() < 1 )
e65967f powerpacks now set charging flag correctly
rtv authored
525 return;
526
afea962 Richard Vaughan *much* faster flag drawing
authored
527 Pose gp = GetGlobalPose();
528 GLfloat z = 1.0;
e65967f powerpacks now set charging flag correctly
rtv authored
529
2c36066 fixed color bug in flags, and more STLing
rtv authored
530 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
531 it != flag_list.rend();
532 it++ )
2c36066 fixed color bug in flags, and more STLing
rtv authored
533 {
afea962 Richard Vaughan *much* faster flag drawing
authored
534 double sz = (*it)->GetSize();
535 double d = sz/2.0;
536
537 (*it)->GetColor().GLSet();
538
539 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
540 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
541 glVertex3f( gp.x+0, gp.y+0, gp.z+d +z);
542
543 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
544 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
545 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
e65967f powerpacks now set charging flag correctly
rtv authored
546
afea962 Richard Vaughan *much* faster flag drawing
authored
547 glVertex3f( gp.x-d, gp.y+0, gp.z+0 +z);
548 glVertex3f( gp.x+0, gp.y-d, gp.z+0 +z);
549 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
2c36066 fixed color bug in flags, and more STLing
rtv authored
550
afea962 Richard Vaughan *much* faster flag drawing
authored
551 glVertex3f( gp.x-d, gp.y+0, gp.z+0 +z);
552 glVertex3f( gp.x+0, gp.y-d, gp.z+0 +z);
553 glVertex3f( gp.x+0, gp.y+0, gp.z+d +z);
554
555 glVertex3f( gp.x-d, gp.y+0, gp.z+0 +z);
556 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
557 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
558
559 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
560 glVertex3f( gp.x+0, gp.y+d, gp.z+0 +z);
561 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
562
563 glVertex3f( gp.x+d, gp.y+0, gp.z+0 +z);
564 glVertex3f( gp.x+0, gp.y-d, gp.z+0 +z);
565 glVertex3f( gp.x+0, gp.y+0, gp.z-d +z);
566
567 z += sz;
e65967f powerpacks now set charging flag correctly
rtv authored
568 }
569 }
570
571
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
572 // void Model::DrawBlinkenlights()
573 // {
574 // PushLocalCoords();
e65967f powerpacks now set charging flag correctly
rtv authored
575
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
576 // GLUquadric* quadric = gluNewQuadric();
577 // //glTranslatef(0,0,1); // jump up
578 // //Pose gpose = GetGlobalPose();
579 // //glRotatef( 180 + rtod(-gpose.a),0,0,1 );
e65967f powerpacks now set charging flag correctly
rtv authored
580
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
581 // for( unsigned int i=0; i<blinkenlights->len; i++ )
582 // {
e45b70c combined laser and ranger functionality into ranger - still buggy
Richard Vaughan authored
583 // blinkenlight_t* b =
584 // (blinkenlight_t*)g_ptr_array_index( blinkenlights, i );
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
585 // assert(b);
e65967f powerpacks now set charging flag correctly
rtv authored
586
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
587 // glTranslatef( b->pose.x, b->pose.y, b->pose.z );
e65967f powerpacks now set charging flag correctly
rtv authored
588
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
589 // PushColor( b->color );
e65967f powerpacks now set charging flag correctly
rtv authored
590
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
591 // if( b->enabled )
592 // gluQuadricDrawStyle( quadric, GLU_FILL );
593 // else
594 // gluQuadricDrawStyle( quadric, GLU_LINE );
2c36066 fixed color bug in flags, and more STLing
rtv authored
595
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
596 // gluSphere( quadric, b->size/2.0, 8,8 );
e65967f powerpacks now set charging flag correctly
rtv authored
597
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
598 // PopColor();
599 // }
e65967f powerpacks now set charging flag correctly
rtv authored
600
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
601 // gluDeleteQuadric( quadric );
e65967f powerpacks now set charging flag correctly
rtv authored
602
910541e removed glib2 dependency (after many years of good service. Thanks GLib....
rtv authored
603 // PopCoords();
604 // }
e65967f powerpacks now set charging flag correctly
rtv authored
605
606 void Model::DrawPicker( void )
607 {
608 //PRINT_DEBUG1( "Drawing %s", token );
609 PushLocalCoords();
610
611 // draw the boxes
612 blockgroup.DrawSolid( geom );
613
614 // recursively draw the tree below this model
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
615 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
616 (*it)->DrawPicker();
e65967f powerpacks now set charging flag correctly
rtv authored
617
618 PopCoords();
619 }
620
621 void Model::DataVisualize( Camera* cam )
622 {
3ce2d0e applied patch from Jeff Donner, fixing some signed/unsigned comparisons
rtv authored
623 (void)cam; // avoid warning about unused var
e65967f powerpacks now set charging flag correctly
rtv authored
624 }
625
626 void Model::DataVisualizeTree( Camera* cam )
627 {
628 PushLocalCoords();
629
712cd33 disabled visualization drawing for unsubscribed models
rtv authored
630 if( subs > 0 )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
631 {
632 DataVisualize( cam ); // virtual function overridden by some model types
712cd33 disabled visualization drawing for unsubscribed models
rtv authored
633
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
634 FOR_EACH( it, cv_list )
635 {
636 Visualizer* vis = *it;
637 if( world_gui->GetCanvas()->_custom_options[ vis->GetMenuName() ]->isEnabled() )
638 vis->Visualize( this, cam );
639 }
640 }
712cd33 disabled visualization drawing for unsubscribed models
rtv authored
641
e65967f powerpacks now set charging flag correctly
rtv authored
642 // and draw the children
5dee8f1 more STL-ization. may reduce performance slightly in worlds with few mod...
rtv authored
643 FOR_EACH( it, children )
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
644 (*it)->DataVisualizeTree( cam );
e65967f powerpacks now set charging flag correctly
rtv authored
645
646 PopCoords();
647 }
648
649 void Model::DrawGrid( void )
650 {
651 if ( gui.grid )
652 {
653 PushLocalCoords();
654
e45b70c combined laser and ranger functionality into ranger - still buggy
Richard Vaughan authored
655 bounds3d_t vol;
e65967f powerpacks now set charging flag correctly
rtv authored
656 vol.x.min = -geom.size.x/2.0;
657 vol.x.max = geom.size.x/2.0;
658 vol.y.min = -geom.size.y/2.0;
659 vol.y.max = geom.size.y/2.0;
660 vol.z.min = 0;
661 vol.z.max = geom.size.z;
662
663 PushColor( 0,0,1,0.4 );
62b8f31 Richard Vaughan simplified and sped up wordfile load and save, and added a new fasr exam...
authored
664 Gl::draw_grid(vol);
e65967f powerpacks now set charging flag correctly
rtv authored
665 PopColor();
666 PopCoords();
667 }
668 }
Something went wrong with that request. Please try again.