Skip to content

Commit 27b6867

Browse files
committed
tweaked vis for ranger
1 parent 1a48d65 commit 27b6867

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

libstage/canvas.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Canvas::Canvas(WorldGui *world, int x, int y, int width, int height)
8282
// configuring GL
8383
// but that line causes a segfault in Linux/X11! TODO: test in OS X
8484

85-
mode( FL_RGB|FL_DOUBLE|FL_DEPTH|FL_MULTISAMPLE );
85+
mode( FL_RGB |FL_DOUBLE|FL_DEPTH| FL_MULTISAMPLE | FL_ALPHA );
8686

8787
perspective_camera.setPose(0.0, -4.0, 3.0);
8888
current_camera = &camera;

libstage/model_ranger.cc

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -289,30 +289,42 @@ void ModelRanger::Sensor::Visualize(ModelRanger::Vis *vis, ModelRanger *rgr) con
289289
rgr->PopColor();
290290
}
291291

292-
if (vis->showFov) {
293-
294-
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
295-
Color c = color;
296-
c.a = 0.5;
297-
rgr->PushColor(c);
298-
glBegin( GL_POLYGON );
299-
300-
glVertex2f( 0,0 );
301-
302-
for (size_t s(0); s < sample_count; s++) {
303-
const double ray_angle = s * sample_fov - fov / 2.0;
304-
const GLfloat x = range.max * cos(ray_angle);
305-
const GLfloat y = range.max * sin(ray_angle);
306-
307-
glVertex2f( x, y );
292+
if (vis->showFov)
293+
{
294+
if (sample_count == 1)
295+
{
296+
rgr->PushColor(color);
297+
glBegin( GL_LINES );
298+
glVertex2f( 0,0 );
299+
glVertex2f( range.max, 0 );
300+
glEnd();
301+
rgr->PopColor();
302+
}
303+
else
304+
{
305+
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
306+
Color c = color;
307+
c.a = 0.5;
308+
rgr->PushColor(c);
309+
glBegin( GL_POLYGON );
310+
311+
glVertex2f( 0,0 );
312+
313+
for (size_t s(0); s < sample_count; s++) {
314+
const double ray_angle = (((double)s)-0.5) * sample_fov - fov / 2.0;
315+
const GLfloat x = range.max * cos(ray_angle);
316+
const GLfloat y = range.max * sin(ray_angle);
317+
318+
glVertex2f( x, y );
319+
}
320+
321+
glVertex2f( 0,0 );
322+
323+
glEnd();
324+
325+
rgr->PopColor();
326+
}
308327
}
309-
310-
glVertex2f( 0,0 );
311-
312-
glEnd();
313-
314-
rgr->PopColor();
315-
}
316328

317329
std::vector<glpoint_t> verts( sample_count );
318330

@@ -330,7 +342,7 @@ void ModelRanger::Sensor::Visualize(ModelRanger::Vis *vis, ModelRanger *rgr) con
330342
verts[2].y = sidelen * sin(+da);
331343
} else {
332344
for (size_t s(0); s < sample_count; s++) {
333-
const double ray_angle = s * sample_fov - fov / 2.0;
345+
const double ray_angle = (((double)s)-0.5) * sample_fov - fov / 2.0;
334346
verts[s].x = (float)(ranges[s] * cos(ray_angle));
335347
verts[s].y = (float)(ranges[s] * sin(ray_angle));
336348
}

0 commit comments

Comments
 (0)