Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

solid_color.H

Go to the documentation of this file.
00001 /**********************************************************************
00002  * solid_color.H:
00003  **********************************************************************/
00004 #ifndef SOLID_COLOR_H_IS_INCLUDED
00005 #define SOLID_COLOR_H_IS_INCLUDED
00006 
00007 #include "basic_texture.H"
00008 
00009 /**********************************************************************
00010  * SolidColorTexture:
00011  *
00012  *      XXX - should rename UnlitColorTexture or something
00013  *            this draws the patch without lighting
00014  **********************************************************************/
00015 class SolidColorTexture : public BasicTexture {
00016  public:
00017    static TAGlist*      _solid_color_texture_tags;
00018 
00019    //******** MANAGERS ********
00020    SolidColorTexture(Patch* patch = 0,
00021                      CCOLOR& col = COLOR::white,
00022                      StripCB* cb = 0) :
00023       BasicTexture(patch, cb ? cb : new GLStripCB),
00024       _color(col),
00025       _alpha(1),
00026       _track_view_color(false) {}
00027 
00028    //******** RUN-TIME TYPE ID ********
00029    DEFINE_RTTI_METHODS2("Solid Coloring", BasicTexture, CDATA_ITEM *);
00030 
00031    // Set this to make the GTexture track the view's background color:
00032    void set_track_view_color(bool b = true) { _track_view_color = b; }
00033 
00034    CCOLOR& get_color()   const { return _color; }
00035    //******** GTexture VIRTUAL METHODS ********
00036    virtual int  set_color(CCOLOR& c)   { _color = c; return 1; }
00037    virtual int  set_alpha(double a)    { _alpha = a; return 1; }
00038    virtual int draw(CVIEWptr& v); 
00039    virtual int  write_stream(ostream& os) const;
00040    virtual int  read_stream (istream& is, str_list &leftover);
00041 
00042    //******** DATA_ITEM VIRTUAL METHODS ********
00043    virtual DATA_ITEM  *dup() const { return new SolidColorTexture; }
00044    virtual CTAGlist &tags         ()             const;
00045 
00046    /******** I/O functions ********/
00047    COLOR&         color_()             { return _color;  }
00048 
00049  protected:
00050    COLOR        _color;
00051    double       _alpha;
00052    bool         _track_view_color;
00053 };
00054 
00055 
00056 /**********************************************************************
00057  * VertColorStripCB:
00058  *
00059  *      for drawing individual vertex colors
00060  **********************************************************************/
00061 class VertColorStripCB : public GLStripCB {
00062  public:
00063    virtual void faceCB(CBvert* v, CBface*) {
00064       if (v->has_color())
00065          GL_COL(v->color(), v->alpha());
00066       glVertex3dv(v->loc().data());
00067    }
00068 };
00069 
00070 /**********************************************************************
00071  * VertColorTexture:
00072  *
00073  *      draws mesh with vertex colors, no lighting.
00074  **********************************************************************/
00075 class VertColorTexture : public SolidColorTexture {
00076  public:
00077    //******** MANAGERS ********
00078    VertColorTexture(Patch* patch = 0, StripCB* cb=0) :
00079       SolidColorTexture(patch, COLOR::white, cb ? cb : new VertColorStripCB) {}
00080 
00081    //******** RUN-TIME TYPE ID ********
00082    DEFINE_RTTI_METHODS2("Vertex colors", BasicTexture, CDATA_ITEM *);
00083 
00084    //******** DATA_ITEM METHODS ********
00085    virtual DATA_ITEM  *dup() const { return new VertColorTexture; }
00086 };
00087 
00088 #endif // SOLID_COLOR_H_IS_INCLUDED
00089 
00090 /* end of file solid_color.H */

Generated on Mon Sep 18 11:39:33 2006 for jot by  doxygen 1.4.4