void cone::gl_render(view& scene) { if (degenerate()) return; init_model(scene); clear_gl_error(); // See sphere::gl_render() for a description of the level of detail calc. double coverage = scene.pixel_coverage( pos, radius); int lod = 0; if (coverage < 0) lod = 5; else if (coverage < 10) lod = 0; else if (coverage < 30) lod = 1; else if (coverage < 90) lod = 2; else if (coverage < 250) lod = 3; else if (coverage < 450) lod = 4; else lod = 5; lod += scene.lod_adjust; if (lod < 0) lod = 0; else if (lod > 5) lod = 5; gl_matrix_stackguard guard; const double length = axis.mag(); model_world_transform( scene.gcf, vector( length, radius, radius ) ).gl_mult(); color.gl_set(opacity); if (translucent()) { gl_enable cull_face( GL_CULL_FACE); // Render the back half. glCullFace( GL_FRONT); scene.cone_model[lod].gl_render(); // Render the front half. glCullFace( GL_BACK); scene.cone_model[lod].gl_render(); } else { scene.cone_model[lod].gl_render(); } check_gl_error(); }
void sphere::gl_render( view& geometry) { if (degenerate()) return; //init_model(); init_model(geometry); // coverage is the radius of this sphere in pixels: double coverage = geometry.pixel_coverage( pos, radius); int lod = 0; if (coverage < 0) // Behind the camera, but still visible. lod = 4; else if (coverage < 30) lod = 0; else if (coverage < 100) lod = 1; else if (coverage < 500) lod = 2; else if (coverage < 5000) lod = 3; else lod = 4; lod += geometry.lod_adjust; // allow user to reduce level of detail if (lod > 5) lod = 5; else if (lod < 0) lod = 0; gl_matrix_stackguard guard; model_world_transform( geometry.gcf, get_scale() ).gl_mult(); color.gl_set(opacity); if (translucent()) { // Spheres are convex, so we don't need to sort gl_enable cull_face( GL_CULL_FACE); // Render the back half (inside) glCullFace( GL_FRONT ); geometry.sphere_model[lod].gl_render(); // Render the front half (outside) glCullFace( GL_BACK ); geometry.sphere_model[lod].gl_render(); } else { // Render a simple sphere. geometry.sphere_model[lod].gl_render(); } }