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