Skip to content
This repository
Newer
Older
100644 668 lines (491 sloc) 15.783 kb
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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
4ccc5cd7 » rtv
2009-07-03 replaced stg_color_t with Color class and added static named construc…
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
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
18 Pose gp = GetGlobalPose();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
19
20 char buf[64];
21 snprintf( buf, 63, "%s [%.2f %.2f %.2f %.2f]",
5b0ed11a »
2011-10-26 extended Model::Model to take a name parameter and simplified name ge…
22 Token(), gp.x, gp.y, gp.z, rtod(gp.a) );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
47
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
48 // testing
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
49
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
50 // highlight all fiducial robots within a certain range
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
51
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
52 // Gl::pose_inverse_shift( gp );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
53
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
54 // double rng = 10.0;
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
55
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
60
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
63
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
66
67
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
68 // PushColor( Color(1,0,0,0.5) );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
69
70
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
71 // std::vector<Model*> candidates;
72 // std::set<Model*> horiz, vert;
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
73
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
74 // while( xmin != xmax )
75 // {
76 // //candidates.insert( *xmin );
77 // horiz.insert( *xmin);
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
78
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
79 // Pose op = (*xmin)->GetGlobalPose();
80 // glRectf( op.x - 5, op.y - 5, op.x + 5, op.y + 5 );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
81
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
82 // xmin++;
83 // }
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
84
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
85 // PopColor();
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
86
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
87 // PushColor( Color(0,0,1,0.5) );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
88
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
89 // while( ymin != ymax )
90 // {
91 // vert.insert( *ymin );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
92
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
93 // // candidates.insert( *ymin );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
94
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
95 // Pose op = (*ymin)->GetGlobalPose();
96 // glRectf( op.x - 5, op.y - 5, op.x + 5, op.y + 5 );
97 // ymin++;
98 // }
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
99
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
100 // PopColor();
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
101
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
102 // PushColor( Color(0,1,0,0.5) );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
103
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
104 // std::set_intersection( horiz.begin(), horiz.end(),
105 // vert.begin(), vert.end(),
106 // std::inserter( candidates, candidates.end() ) );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
107
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
108 // //printf( "cand sz %lu\n", candidates.size() );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
109
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
110 // glTranslatef( 0,0,1.0 );
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
111
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 // }
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
117
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
118 // PopColor();
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
119
120
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
121 glPopMatrix();
649ba768 » Richard Vaughan
2010-06-15 O(n log n) fiducial finder
122
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
123 }
124
125
126 void Model::DrawTrailFootprint()
127 {
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
128 double darkness = 0;
129 double fade = 0.5 / (double)(trail_length+1);
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
130
4de1b778 »
2011-12-02 removed unused model_props file and folded model_getset and model_loa…
131 PushColor( 0,0,0,1 ); // dummy push just saving the color
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
132
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 ];
3ea9a043 » rtv
2009-10-27 moved trail recording to worldgui from world, and made recording trai…
139
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
140 // ignore invalid items
141 if( checkpoint.time == 0 )
142 continue;
3ea9a043 » rtv
2009-10-27 moved trail recording to worldgui from world, and made recording trai…
143
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
144 glPushMatrix();
145 Pose pz = checkpoint.pose;
3ea9a043 » rtv
2009-10-27 moved trail recording to worldgui from world, and made recording trai…
146
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
147 Gl::pose_shift( pz );
148 Gl::pose_shift( geom.pose );
3ea9a043 » rtv
2009-10-27 moved trail recording to worldgui from world, and made recording trai…
149
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
150 darkness += fade;
151 Color c = checkpoint.color;
152 c.a = darkness;
153 glColor4f( c.r, c.g, c.b, c.a );
3ea9a043 » rtv
2009-10-27 moved trail recording to worldgui from world, and made recording trai…
154
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
155 blockgroup.DrawFootPrint( geom );
3ea9a043 » rtv
2009-10-27 moved trail recording to worldgui from world, and made recording trai…
156
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
157 glPopMatrix();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
158 }
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
159
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
160 PopColor();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
161 }
162
163 void Model::DrawTrailBlocks()
164 {
165 double timescale = 0.0000001;
166
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
167 FOR_EACH( it, trail )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
168 {
169 TrailItem& checkpoint = *it;
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
170
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
171 glPushMatrix();
172 Pose pz = checkpoint.pose;
173 pz.z = (world->sim_time - checkpoint.time) * timescale;
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
174
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
175 Gl::pose_shift( pz );
176 Gl::pose_shift( geom.pose );
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
177
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
178 DrawBlocks();
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
179
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
180 glPopMatrix();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
181 }
182 }
183
184 void Model::DrawTrailArrows()
185 {
186 double dx = 0.2;
187 double dy = 0.07;
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
188 double timescale = 1e-7;
189
190 PushColor( 0,0,0,1 ); // dummy push
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
191
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
192 FOR_EACH( it, trail )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
193 {
194 TrailItem& checkpoint = *it;
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
195
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
196 glPushMatrix();
197 Pose pz = checkpoint.pose;
198 // set the height proportional to age
199 pz.z = (world->sim_time - checkpoint.time) * timescale;
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
200
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
201 Gl::pose_shift( pz );
202 Gl::pose_shift( geom.pose );
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
203
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
204 Color& c = checkpoint.color;
205 glColor4f( c.r, c.g, c.b, c.a );
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
206
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
207 glBegin( GL_TRIANGLES );
208 glVertex3f( 0, -dy, 0);
209 glVertex3f( dx, 0, 0 );
210 glVertex3f( 0, +dy, 0 );
211 glEnd();
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
212
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
213 glPopMatrix();
214 }
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
215
216 PopColor();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
217 }
218
219 void Model::DrawOriginTree()
220 {
221 DrawPose( GetGlobalPose() );
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
222
223 FOR_EACH( it, children )
224 (*it)->DrawOriginTree();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
225 }
226
227
228 void Model::DrawBlocksTree( )
229 {
230 PushLocalCoords();
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
231
232 FOR_EACH( it, children )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
233 (*it)->DrawBlocksTree();
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
234
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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();
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
259
260 FOR_EACH( it, children )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
261 (*it)->DrawBoundingBoxTree();
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
262
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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
08e31b0e » rtv
2010-01-19 added option to prevent stacking of models, based on patch #2919630 f…
311 if( parent && parent->stack_children )
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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
a9b91ec0 » rtv
2009-07-16 more STLing
322 void Model::AddVisualizer( Visualizer* cv, bool on_by_default )
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
323 {
a9b91ec0 » rtv
2009-07-16 more STLing
324 if( !cv )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
325 return;
64382ca9 » rtv
2009-04-02 cleaned up cmdline args
326
327 // If there's no GUI, ignore this request
328 if( ! world_gui )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
329 return;
5e9262a7 » rtv
2009-03-27 reworked CustomVisualizer => Visualizer - tweaked API. See ModelLaser…
330
64249e4c » rtv
2009-08-26 more STLing and type safety to hopefully reduce bugs
331 //save visual instance
a9b91ec0 » rtv
2009-07-16 more STLing
332 cv_list.push_back( cv );
64249e4c » rtv
2009-08-26 more STLing and type safety to hopefully reduce bugs
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() ) {
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 );
64249e4c » rtv
2009-08-26 more STLing and type safety to hopefully reduce bugs
345 }
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
346 }
347
a9b91ec0 » rtv
2009-07-16 more STLing
348 void Model::RemoveVisualizer( Visualizer* cv )
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
349 {
a9b91ec0 » rtv
2009-07-16 more STLing
350 if( cv )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
351 EraseAll( cv, cv_list );
1ce2551b » rtv
2009-08-15 cleaning up
352
353 //TODO unregister option - tricky because there might still be instances attached to different models which have the same name
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
354 }
355
356
357 void Model::DrawStatusTree( Camera* cam )
358 {
359 PushLocalCoords();
360 DrawStatus( cam );
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
361 FOR_EACH( it, children )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
362 (*it)->DrawStatusTree( cam );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
363 PopCoords();
364 }
365
366 void Model::DrawStatus( Camera* cam )
367 {
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
368 if( power_pack || !say_string.empty() )
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
369 {
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
370 float pitch = - cam->pitch();
371 float yaw = - cam->yaw();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
372
1ce2551b » rtv
2009-08-15 cleaning up
373 Pose gpz = GetGlobalPose();
374
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
375 float robotAngle = -rtod(gpz.a);
376 glPushMatrix();
1ce2551b » rtv
2009-08-15 cleaning up
377
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
378 // move above the robot
379 glTranslatef( 0, 0, 0.5 );
1ce2551b » rtv
2009-08-15 cleaning up
380
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
381 // rotate to face screen
382 glRotatef( robotAngle - yaw, 0,0,1 );
383 glRotatef( -pitch, 1,0,0 );
1ce2551b » rtv
2009-08-15 cleaning up
384
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
385 // if( power_pack )
386 //power_pack->Visualize( cam );
1ce2551b » rtv
2009-08-15 cleaning up
387
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
388 if( !say_string.empty() )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
389 {
390 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
391
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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);
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
396
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
397 GLboolean valid;
398 glGetBooleanv( GL_CURRENT_RASTER_POSITION_VALID, &valid );
1ce2551b » rtv
2009-08-15 cleaning up
399
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
405
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
406 GLdouble wx, wy, wz;
407 GLint viewport[4];
408 glGetIntegerv(GL_VIEWPORT, viewport);
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
409
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
410 GLdouble modelview[16];
411 glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
412
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
413 GLdouble projection[16];
414 glGetDoublev(GL_PROJECTION_MATRIX, projection);
1ce2551b » rtv
2009-08-15 cleaning up
415
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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;
1ce2551b » rtv
2009-08-15 cleaning up
421
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
422 // calculate speech bubble margin
423 const float m = h/10;
1ce2551b » rtv
2009-08-15 cleaning up
424
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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();
1ce2551b » rtv
2009-08-15 cleaning up
434
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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();
1ce2551b » rtv
2009-08-15 cleaning up
443
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 }
1ce2551b » rtv
2009-08-15 cleaning up
450 glPopMatrix();
451 }
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
452
453 if( stall )
454 {
455 DrawImage( TextureManager::getInstance()._stall_texture_id, cam, 0.85 );
456 }
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
457
1ce2551b » rtv
2009-08-15 cleaning up
458 // extern GLuint glowTex;
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
459 // extern GLuint checkTex;
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
460
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
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 // }
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
467 }
468
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
469 void Model::DrawImage( uint32_t texture_id, Camera* cam, float alpha,
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
470 double width, double height )
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
471 {
3ce2d0eb » rtv
2009-10-20 applied patch from Jeff Donner, fixing some signed/unsigned comparisons
472 (void)alpha; // avoid warning about unused var
473
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
474 float yaw, pitch;
475 pitch = - cam->pitch();
476 yaw = - cam->yaw();
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
477
478 float robotAngle = -rtod( GetGlobalPose().a);
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
479
8b06ea17 » rtv
2009-04-07 fixed broken badges
480 glPolygonMode( GL_FRONT, GL_FILL );
481
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
482 glEnable(GL_TEXTURE_2D);
483 glBindTexture( GL_TEXTURE_2D, texture_id );
484
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
485 glColor4f( 1.0, 1.0, 1.0, 1.0 );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
486 glPushMatrix();
487
488 //position image above the robot
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
489 // TODO
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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);
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
506
996c2812 » rtv
2009-09-26 replaced some c-strings with std::strings
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();
c69a1c9a » rtv
2009-08-15 more efficient real-time tracking
515
516 glPopMatrix();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
517 }
518
519
afea9629 »
2011-12-02 *much* faster flag drawing
520 //static GLUquadric* quadric = NULL;
521
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
522 void Model::DrawFlagList( void )
523 {
2c360663 » rtv
2009-07-16 fixed color bug in flags, and more STLing
524 if( flag_list.size() < 1 )
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
525 return;
526
afea9629 »
2011-12-02 *much* faster flag drawing
527 Pose gp = GetGlobalPose();
528 GLfloat z = 1.0;
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
529
2c360663 » rtv
2009-07-16 fixed color bug in flags, and more STLing
530 for( std::list<Flag*>::reverse_iterator it( flag_list.rbegin());
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
531 it != flag_list.rend();
532 it++ )
2c360663 » rtv
2009-07-16 fixed color bug in flags, and more STLing
533 {
afea9629 »
2011-12-02 *much* faster flag drawing
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);
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
546
afea9629 »
2011-12-02 *much* faster flag drawing
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);
2c360663 » rtv
2009-07-16 fixed color bug in flags, and more STLing
550
afea9629 »
2011-12-02 *much* faster flag drawing
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;
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
568 }
569 }
570
571
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
572 // void Model::DrawBlinkenlights()
573 // {
574 // PushLocalCoords();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
575
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
576 // GLUquadric* quadric = gluNewQuadric();
577 // //glTranslatef(0,0,1); // jump up
578 // //Pose gpose = GetGlobalPose();
579 // //glRotatef( 180 + rtod(-gpose.a),0,0,1 );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
580
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
581 // for( unsigned int i=0; i<blinkenlights->len; i++ )
582 // {
e45b70c4 » Richard Vaughan
2010-07-20 combined laser and ranger functionality into ranger - still buggy
583 // blinkenlight_t* b =
584 // (blinkenlight_t*)g_ptr_array_index( blinkenlights, i );
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
585 // assert(b);
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
586
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
587 // glTranslatef( b->pose.x, b->pose.y, b->pose.z );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
588
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
589 // PushColor( b->color );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
590
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
591 // if( b->enabled )
592 // gluQuadricDrawStyle( quadric, GLU_FILL );
593 // else
594 // gluQuadricDrawStyle( quadric, GLU_LINE );
2c360663 » rtv
2009-07-16 fixed color bug in flags, and more STLing
595
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
596 // gluSphere( quadric, b->size/2.0, 8,8 );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
597
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
598 // PopColor();
599 // }
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
600
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
601 // gluDeleteQuadric( quadric );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
602
910541e2 » rtv
2009-07-22 removed glib2 dependency (after many years of good service. Thanks GL…
603 // PopCoords();
604 // }
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
615 FOR_EACH( it, children )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
616 (*it)->DrawPicker();
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
617
618 PopCoords();
619 }
620
621 void Model::DataVisualize( Camera* cam )
622 {
3ce2d0eb » rtv
2009-10-20 applied patch from Jeff Donner, fixing some signed/unsigned comparisons
623 (void)cam; // avoid warning about unused var
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
624 }
625
626 void Model::DataVisualizeTree( Camera* cam )
627 {
628 PushLocalCoords();
629
712cd33d » rtv
2009-08-21 disabled visualization drawing for unsubscribed models
630 if( subs > 0 )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
631 {
632 DataVisualize( cam ); // virtual function overridden by some model types
712cd33d » rtv
2009-08-21 disabled visualization drawing for unsubscribed models
633
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
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 }
712cd33d » rtv
2009-08-21 disabled visualization drawing for unsubscribed models
641
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
642 // and draw the children
5dee8f12 » rtv
2009-06-23 more STL-ization. may reduce performance slightly in worlds with few …
643 FOR_EACH( it, children )
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
644 (*it)->DataVisualizeTree( cam );
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
645
646 PopCoords();
647 }
648
649 void Model::DrawGrid( void )
650 {
651 if ( gui.grid )
652 {
653 PushLocalCoords();
654
e45b70c4 » Richard Vaughan
2010-07-20 combined laser and ranger functionality into ranger - still buggy
655 bounds3d_t vol;
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
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 );
62b8f31a »
2011-11-09 simplified and sped up wordfile load and save, and added a new fasr e…
664 Gl::draw_grid(vol);
e65967fe » rtv
2009-02-09 powerpacks now set charging flag correctly
665 PopColor();
666 PopCoords();
667 }
668 }
Something went wrong with that request. Please try again.