-static void gis_plugin_radar_expose(GisPlugin *_self)
-{
- GisPluginRadar *self = GIS_PLUGIN_RADAR(_self);
- g_debug("GisPluginRadar: expose");
- if (self->cur_sweep == NULL)
- return;
- Sweep *sweep = self->cur_sweep;
-
-#ifdef MARCHING
- /* Draw the surface */
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glDisable(GL_TEXTURE_2D);
- float light_ambient[] = {0.1f, 0.1f, 0.0f};
- float light_diffuse[] = {0.9f, 0.9f, 0.9f};
- float light_position[] = {-300000.0f, 500000.0f, 400000.0f, 1.0f};
- glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT0, GL_POSITION, light_position);
- glEnable(GL_LIGHT0);
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
- glColor4f(1,1,1,0.75);
- g_debug("ntri=%d", self->cur_num_triangles);
- glBegin(GL_TRIANGLES);
- for (int i = 0; i < self->cur_num_triangles; i++) {
- TRIANGLE t = self->cur_triangles[i];
- do_normal(t.p[0].x, t.p[0].y, t.p[0].z,
- t.p[1].x, t.p[1].y, t.p[1].z,
- t.p[2].x, t.p[2].y, t.p[2].z);
- glVertex3f(t.p[0].x, t.p[0].y, t.p[0].z);
- glVertex3f(t.p[1].x, t.p[1].y, t.p[1].z);
- glVertex3f(t.p[2].x, t.p[2].y, t.p[2].z);
- }
- glEnd();
- glPopMatrix();
-#endif
-
- g_debug("GisPluginRadar: expose - setting camera");
- Radar_header *h = &self->cur_radar->h;
- gdouble lat = (double)h->latd + (double)h->latm/60 + (double)h->lats/(60*60);
- gdouble lon = (double)h->lond + (double)h->lonm/60 + (double)h->lons/(60*60);
- gdouble elev = h->height;
- gis_viewer_center_position(self->viewer, lat, lon, elev);
-
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
- glColor4f(1,1,1,1);
-
- /* Draw the rays */
- glBindTexture(GL_TEXTURE_2D, self->cur_sweep_tex);
- glBegin(GL_QUAD_STRIP);
- for (int ri = 0; ri <= sweep->h.nrays; ri++) {
- Ray *ray = NULL;
- double angle = 0;
- if (ri < sweep->h.nrays) {
- ray = sweep->ray[ri];
- angle = deg2rad(ray->h.azimuth - ((double)ray->h.beam_width/2.));
- } else {
- /* Do the right side of the last sweep */
- ray = sweep->ray[ri-1];
- angle = deg2rad(ray->h.azimuth + ((double)ray->h.beam_width/2.));
- }
-
- double lx = sin(angle);
- double ly = cos(angle);
-
- double near_dist = ray->h.range_bin1;
- double far_dist = ray->h.nbins*ray->h.gate_size + ray->h.range_bin1;
-
- /* (find middle of bin) / scale for opengl */
- // near left
- glTexCoord2f(0.0, (double)ri/sweep->h.nrays-0.01);
- glVertex3f(lx*near_dist, ly*near_dist, 2.0);
-
- // far left
- // todo: correct range-height function
- double height = sin(deg2rad(ray->h.elev)) * far_dist;
- glTexCoord2f(1.0, (double)ri/sweep->h.nrays-0.01);
- glVertex3f(lx*far_dist, ly*far_dist, height);
- }
- glEnd();
- //g_print("ri=%d, nr=%d, bw=%f\n", _ri, sweep->h.nrays, sweep->h.beam_width);
-
- /* Texture debug */
- //glBegin(GL_QUADS);
- //glTexCoord2d( 0., 0.); glVertex3f(-500., 0., 0.); // bot left
- //glTexCoord2d( 0., 1.); glVertex3f(-500., 500., 0.); // top left
- //glTexCoord2d( 1., 1.); glVertex3f( 0., 500., 3.); // top right
- //glTexCoord2d( 1., 0.); glVertex3f( 0., 0., 3.); // bot right
- //glEnd();
-
- /* Print the color table */
- glMatrixMode(GL_MODELVIEW ); glLoadIdentity();
- glMatrixMode(GL_PROJECTION); glLoadIdentity();
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_COLOR_MATERIAL);
- glBegin(GL_QUADS);
- int i;
- for (i = 0; i < 256; i++) {
- glColor4ubv(self->cur_colormap->data[i]);
- glVertex3f(-1.0, (float)((i ) - 256/2)/(256/2), 0.0); // bot left
- glVertex3f(-1.0, (float)((i+1) - 256/2)/(256/2), 0.0); // top left
- glVertex3f(-0.9, (float)((i+1) - 256/2)/(256/2), 0.0); // top right
- glVertex3f(-0.9, (float)((i ) - 256/2)/(256/2), 0.0); // bot right
- }
- glEnd();
-}
-