00001
00002
00003
00004 #ifndef SOLID_COLOR_H_IS_INCLUDED
00005 #define SOLID_COLOR_H_IS_INCLUDED
00006
00007 #include "basic_texture.H"
00008
00009
00010
00011
00012
00013
00014
00015 class SolidColorTexture : public BasicTexture {
00016 public:
00017 static TAGlist* _solid_color_texture_tags;
00018
00019
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
00029 DEFINE_RTTI_METHODS2("Solid Coloring", BasicTexture, CDATA_ITEM *);
00030
00031
00032 void set_track_view_color(bool b = true) { _track_view_color = b; }
00033
00034 CCOLOR& get_color() const { return _color; }
00035
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
00043 virtual DATA_ITEM *dup() const { return new SolidColorTexture; }
00044 virtual CTAGlist &tags () const;
00045
00046
00047 COLOR& color_() { return _color; }
00048
00049 protected:
00050 COLOR _color;
00051 double _alpha;
00052 bool _track_view_color;
00053 };
00054
00055
00056
00057
00058
00059
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
00072
00073
00074
00075 class VertColorTexture : public SolidColorTexture {
00076 public:
00077
00078 VertColorTexture(Patch* patch = 0, StripCB* cb=0) :
00079 SolidColorTexture(patch, COLOR::white, cb ? cb : new VertColorStripCB) {}
00080
00081
00082 DEFINE_RTTI_METHODS2("Vertex colors", BasicTexture, CDATA_ITEM *);
00083
00084
00085 virtual DATA_ITEM *dup() const { return new VertColorTexture; }
00086 };
00087
00088 #endif // SOLID_COLOR_H_IS_INCLUDED
00089
00090