00001 #include "control_line.H" 00002 00003 ControlLineTexture::ControlLineTexture(Patch* patch) : 00004 OGLTexture(patch), 00005 _solid(new SolidColorTexture(patch, Color::white)), 00006 _toon(new ToonTexture_1D(patch)), 00007 _controlframe(new ControlFrameTexture(patch)), 00008 _sils(new SilsTexture(patch)) 00009 { 00010 static const bool SHOW_BORDERS = 00011 Config::get_var_bool("CTRL_LINE_SHOW_BORDERS",true); 00012 00013 _toon->set_tex_name("nprdata/toon_textures/clear-gray-keyline.png"); 00014 _toon->set_color(Color::white); 00015 00016 _controlframe->set_color(Color::blue_pencil_d); 00017 _sils ->set_color(Color::blue_pencil_d); 00018 _sils ->set_draw_borders(SHOW_BORDERS); 00019 } 00020 00021 ControlLineTexture::~ControlLineTexture() 00022 { 00023 gtextures().delete_all(); 00024 } 00025 00026 void 00027 ControlLineTexture::draw_filled_tris(double alpha) 00028 { 00029 _solid->draw_with_alpha(alpha); 00030 _toon->draw_with_alpha(alpha); 00031 } 00032 00033 void 00034 ControlLineTexture::draw_non_filled_tris(double alpha) 00035 { 00036 _controlframe->draw_with_alpha(alpha); 00037 _sils->draw_with_alpha(alpha); 00038 } 00039 00040 inline bool 00041 do_solid(BMESH* m) 00042 { 00043 // when secondary faces are shown, we want to see thru 00044 // the outer layers, so don't draw the solid color texture 00045 return m && !m->show_secondary_faces(); 00046 } 00047 00048 int 00049 ControlLineTexture::draw(CVIEWptr& v) 00050 { 00051 if (_ctrl) 00052 return _ctrl->draw(v); 00053 if (do_solid(mesh())) { 00054 _solid->set_color(_patch->color()); 00055 _solid->draw(v); 00056 } 00057 00058 // save polygon offset set: 00059 glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT); 00060 00061 // use reduced offset, or else the toon pixels have 00062 // bug-fights with the basecoat pixels. 00063 GL_VIEW::init_polygon_offset(0.5,0.5); // GL_ENABLE_BIT 00064 00065 // draw the toon as mainly transparent overlay: 00066 _toon->draw(v); 00067 00068 // restore previous polygon offset settings: 00069 glPopAttrib(); 00070 00071 // save the lines for draw final 00072 00073 return _patch->num_faces(); 00074 } 00075 00076 int 00077 ControlLineTexture::draw_final(CVIEWptr& v) 00078 { 00079 if (_ctrl) 00080 return _ctrl->draw_final(v); 00081 00082 // draw final tends not to use the z-buffer, but we need it: 00083 glPushAttrib(GL_ENABLE_BIT); 00084 glEnable(GL_DEPTH_TEST); 00085 _controlframe->draw(v); 00086 _sils->draw(v); 00087 glPopAttrib(); 00088 00089 return _patch->num_faces(); 00090 } 00091 00092 int 00093 ControlLineTexture::draw_vis_ref() 00094 { 00095 _solid->draw_vis_ref(); 00096 _sils ->draw_vis_ref(); 00097 return _patch->num_faces(); 00098 } 00099 00100 // end of file control_line.C