00001 /********************************************************************** 00002 * hidden_line.H: 00003 **********************************************************************/ 00004 #ifndef HIDDEN_LINE_H_IS_INCLUDED 00005 #define HIDDEN_LINE_H_IS_INCLUDED 00006 00007 #include "geom/gl_view.H" 00008 00009 #include "solid_color.H" 00010 #include "wireframe.H" 00011 00012 /********************************************************************** 00013 * HiddenLineTexture: 00014 **********************************************************************/ 00015 class HiddenLineTexture : public OGLTexture { 00016 public: 00017 00018 //******** MANAGERS ******** 00019 00020 HiddenLineTexture(Patch* patch = 0) : 00021 OGLTexture(patch), 00022 _solidcolor(new SolidColorTexture(patch, COLOR::white)), 00023 _wireframe( new WireframeTexture (patch, COLOR::black)) {} 00024 00025 virtual ~HiddenLineTexture() { gtextures().delete_all(); } 00026 00027 //******** RUN-TIME TYPD ID ******** 00028 00029 DEFINE_RTTI_METHODS3("Hidden Line", HiddenLineTexture*, 00030 OGLTexture, CDATA_ITEM *); 00031 00032 //******** GTexture VIRTUAL METHODS ******** 00033 00034 virtual GTexture_list gtextures() const { 00035 return GTexture_list(_solidcolor, _wireframe); 00036 } 00037 00038 virtual void draw_filled_tris(double alpha) { 00039 _solidcolor->draw_with_alpha(alpha); 00040 } 00041 virtual void draw_non_filled_tris(double alpha) { 00042 _wireframe->draw_with_alpha(alpha); 00043 } 00044 00045 // draw the solid stuff first, all patches agree 00046 // (see draw_final): 00047 virtual int draw(CVIEWptr& v) { 00048 if (_ctrl) 00049 return _ctrl->draw(v); 00050 00051 return _solidcolor->draw(v); 00052 } 00053 00054 // draw the wireframe stuff last, only after 00055 // every patch has drawn solid. avoid ugly 00056 // blending artifacts that way. 00057 virtual int draw_final(CVIEWptr& v) { 00058 if (_ctrl) 00059 return _ctrl->draw_final(v); 00060 00061 // draw final tends not to use the z-buffer, but we need it: 00062 glPushAttrib(GL_ENABLE_BIT); 00063 glEnable(GL_DEPTH_TEST); 00064 _wireframe->draw(v); 00065 glPopAttrib(); 00066 return _patch->num_faces(); 00067 } 00068 00069 int set_wire_color(CCOLOR& c) { return _wireframe->set_color(c); } 00070 CCOLOR& wire_color() const{ return _wireframe->color(); } 00071 00072 virtual int set_color(CCOLOR& c) { return _solidcolor->set_color(c); } 00073 CCOLOR& color() const { return _solidcolor->get_color(); } 00074 00075 void set_width(float w) { _wireframe->set_width(w); } 00076 float width() const { return _wireframe->width(); } 00077 00078 //******** DATA_ITEM VIRTUAL METHODS ******** 00079 00080 virtual DATA_ITEM *dup() const { return new HiddenLineTexture; } 00081 00082 protected: 00083 SolidColorTexture* _solidcolor; 00084 WireframeTexture* _wireframe; 00085 }; 00086 00087 #endif // HIDDEN_LINE_H_IS_INCLUDED 00088 00089 // end of file hidden_line.H