00001
00002
00003
00004 #ifndef TOON_TEXTURE_H_IS_INCLUDED
00005 #define TOON_TEXTURE_H_IS_INCLUDED
00006
00007 #include "geom/texturegl.H"
00008 #include "gtex/basic_texture.H"
00009
00010 class ToonTexCB : public GLStripCB {
00011 public:
00012 virtual void faceCB(CBvert* v, CBface* f);
00013 };
00014
00015 class XToonTexture : public BasicTexture {
00016 private:
00017
00018 static TAGlist *_ntt_tags;
00019
00020 protected:
00021 static LIST<str_ptr>* _toon_texture_names;
00022 static LIST<TEXTUREptr>* _toon_texture_ptrs;
00023 static LIST<str_ptr>* _toon_texture_remap_orig_names;
00024 static LIST<str_ptr>* _toon_texture_remap_new_names;
00025
00026
00027 TEXTUREptr _tex;
00028 str_ptr _tex_name;
00029 str_ptr _layer_name;
00030 int _use_paper;
00031 int _travel_paper;
00032 int _transparent;
00033 int _annotate;
00034 COLOR _color;
00035 double _alpha;
00036 int _light_index;
00037 int _light_dir;
00038 int _light_cam;
00039 mlib::Wvec _light_coords;
00040 int _detail_map;
00041 double _target_length;
00042 double _max_factor;
00043 bool _update_smoothing;
00044 bool _update_elliptic;
00045 bool _update_spheric;
00046 bool _update_cylindric;
00047 bool _normals_smoothed;
00048 bool _normals_elliptic;
00049 bool _normals_spheric;
00050 bool _normals_cylindric;
00051 double _smooth_factor;
00052 bool _update_curvatures;
00053 double _frame_rate;
00054 int _nb_stat_frames;
00055
00056 public:
00057
00058 XToonTexture(Patch* patch = 0) :
00059 BasicTexture(patch, new ToonTexCB),
00060 _tex_name(NULL_STR),
00061 _layer_name("Shader"),
00062 _use_paper(0),
00063 _travel_paper(0),
00064 _transparent(1),
00065 _annotate(1),
00066 _color(COLOR::white),
00067 _alpha(1.0),
00068 _light_index(0),
00069 _light_dir(1),
00070 _light_cam(1),
00071 _light_coords(mlib::Wvec(0,0,1)),
00072 _target_length(10.0),
00073 _max_factor(12.0),
00074 _update_smoothing(false),
00075 _update_elliptic(false),
00076 _update_spheric(false),
00077 _update_cylindric(false),
00078 _normals_smoothed(false),
00079 _normals_elliptic(false),
00080 _normals_spheric(false),
00081 _normals_cylindric(false),
00082 _smooth_factor(0.5),
00083 _update_curvatures(false),
00084 _frame_rate(0.0), _nb_stat_frames(0){}
00085
00086
00087 enum {User, Depth, Focus, Orientation, Flow, Specularity, Curvature};
00088
00089
00090
00091 public:
00092
00093 virtual str_ptr get_tex_name() const { return _tex_name; }
00094 virtual void set_tex_name(Cstr_ptr tn) { _tex_name = tn; _tex=NULL; }
00095 virtual str_ptr get_layer_name() const { return _layer_name; }
00096 virtual void set_layer_name(Cstr_ptr ln){ _layer_name = ln; }
00097 virtual int get_use_paper() const { return _use_paper; }
00098 virtual void set_use_paper(int p) { _use_paper = p; }
00099 virtual int get_travel_paper() const { return _travel_paper; }
00100 virtual void set_travel_paper(int t) { _travel_paper = t; }
00101 virtual int get_transparent() const { return _transparent; }
00102 virtual int get_annotate() const { return _annotate; }
00103 virtual double get_alpha() const { return _alpha; }
00104 virtual void set_alpha(double a) { _alpha = a; }
00105 virtual COLOR get_color() const { return _color; }
00106 virtual int set_color(CCOLOR &c) { _color = c; return 1; }
00107 virtual int get_light_index() const { return _light_index; }
00108 virtual void set_light_index(int i) { _light_index = i; }
00109 virtual int get_light_dir() const { return _light_dir; }
00110 virtual void set_light_dir(int d) { _light_dir = d; }
00111 virtual int get_light_cam() const { return _light_cam; }
00112 virtual void set_light_cam(int c) { _light_cam = c; }
00113 virtual mlib::Wvec get_light_coords() const { return _light_coords; }
00114 virtual void set_light_coords(mlib::CWvec &c) { _light_coords = c; }
00115 virtual double get_target_length() const { return _target_length;}
00116 virtual void set_target_length(double t){ _target_length = t; }
00117 virtual double get_max_factor() const { return _max_factor; }
00118 virtual void set_max_factor(double f) { _max_factor = f; }
00119 virtual double get_smooth_factor() const { return _smooth_factor;}
00120 virtual void set_smooth_factor(double f){ _smooth_factor = f; }
00121
00122 protected:
00123
00124 void update_tex();
00125 void update_lights(CVIEWptr &v);
00126 void update_cam();
00127 void print_frame_rate();
00128
00129 public:
00130
00131 virtual int draw(CVIEWptr& v);
00132
00133
00134 virtual DATA_ITEM* dup() const { return new XToonTexture; }
00135 virtual CTAGlist& tags() const;
00136
00137
00138 void put_layer_name(TAGformat &d) const;
00139 void get_layer_name(TAGformat &d);
00140 void put_tex_name(TAGformat &d) const;
00141 void get_tex_name(TAGformat &d);
00142
00143 int& use_paper_() { return _use_paper; }
00144 int& travel_paper_(){ return _travel_paper; }
00145 double& alpha_() { return _alpha; }
00146 COLOR& color_() { return _color; }
00147 int& light_index_() { return _light_index; }
00148 int& light_dir_() { return _light_dir; }
00149 int& light_cam_() { return _light_cam; }
00150 mlib::Wvec& light_coords_(){ return _light_coords; }
00151 void set_detail_map(int dmap) { print_frame_rate(); _detail_map = dmap; }
00152 bool normals_smoothed(){ return _normals_smoothed; }
00153 bool normals_elliptic(){ return _normals_elliptic; }
00154 bool normals_spheric(){ return _normals_spheric; }
00155 bool normals_cylindric(){ return _normals_cylindric; }
00156 void update_smoothing(bool b);
00157 void update_elliptic(bool b);
00158 void update_spheric(bool b);
00159 void update_cylindric(bool b);
00160 void update_curvatures(bool b);
00161 void set_inv_detail(bool b);
00162
00163
00164 void put_transparent(TAGformat &d) const;
00165 void get_transparent(TAGformat &d);
00166 void put_annotate(TAGformat &d) const;
00167 void get_annotate(TAGformat &d);
00168
00169
00170 DEFINE_RTTI_METHODS3("XToon", XToonTexture*, OGLTexture, CDATA_ITEM *);
00171 };
00172
00173 #endif // TOON_TEXTURE_H_IS_INCLUDED
00174
00175