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

glsl_xtoon.H

Go to the documentation of this file.
00001 /**********************************************************************
00002  * glsl_xtoon.H:
00003  **********************************************************************/
00004 #ifndef GLSL_XTOON_H_IS_INCLUDED
00005 #define GLSL_XTOON_H_IS_INCLUDED
00006 
00007 #include "glsl_shader.H"
00008 
00009 /**********************************************************************
00010  * GLSLToonXShader:
00011  *
00012  *  GLSL version of the extended toon shader
00013  *
00014  **********************************************************************/
00015 class GLSLXToonShader : public GLSLShader {
00016  public:
00017    //******** MANAGERS ********
00018    GLSLXToonShader(Patch* patch = 0);
00019 
00020    //******** RUN-TIME TYPE ID ********
00021    DEFINE_RTTI_METHODS3("GLSL XToon",
00022                         GLSLXToonShader*, BasicTexture, CDATA_ITEM*);
00023 
00024    // Set the name of the texture to use (full path):
00025    void set_tex(Cstr_ptr& full_path_name);
00026 
00027    //******** GLSLShader VIRTUAL METHODS ********
00028 
00029    // Called in init(); query and store the "locations" of
00030    // uniform and attribute variables here:
00031    virtual bool get_variable_locs();
00032 
00033    // Send values of uniform variables to the shader:
00034    virtual bool set_uniform_variables() const;
00035 
00036    // Init the 1D toon texture by loading from file:
00037    virtual void init_textures();
00038 
00039    // Activate the 1D toon texture for drawing:
00040    virtual void activate_textures();
00041 
00042    virtual void set_gl_state(GLbitfield mask=0) const;
00043 
00044    //******** GTexture VIRTUAL METHODS ********
00045 
00046    // Draw the patch:
00047   // virtual int draw(CVIEWptr& v); 
00048    //virtual int load_tex(); //loads texture
00049 
00050 
00051    //******** DATA_ITEM VIRTUAL METHODS ********
00052    virtual DATA_ITEM  *dup() const { return new GLSLXToonShader; }
00053 
00054 
00055 
00056 
00057    //******** Accessors ********
00058 
00059    virtual Cstr_ptr& get_tex_name() const       { return _tex_name;     }
00060    virtual void set_tex_name(Cstr_ptr& tn)  {
00061      // cerr << "GLSLXToonShader::set_tex_name: deconstructing... ";
00062      // _tex = NULL;
00063      // cerr << "done" << endl;
00064       _tex_name = tn; 
00065      set_tex(_tex_name);
00066    }
00067 
00068    virtual str_ptr      get_layer_name() const     { return _layer_name;   }
00069    virtual void         set_layer_name(Cstr_ptr ln){ _layer_name = ln;   _update_uniforms=true;  }
00070    virtual int          get_use_paper() const      { return false;}//_use_paper;    }
00071    virtual void         set_use_paper(int p)       { _use_paper = p;    _update_uniforms=true;   }
00072    virtual int          get_travel_paper() const   { return _travel_paper; }
00073    virtual void         set_travel_paper(int t)    { _travel_paper = t; _update_uniforms=true; }
00074    virtual int          get_transparent() const    { return _transparent;  }
00075    virtual int          get_annotate() const       { return _annotate;     }
00076    virtual double       get_alpha() const          { return _alpha;        }
00077    virtual void         set_alpha(double a)        { _alpha = a;     _update_uniforms=true;       }
00078    virtual COLOR        get_color() const          { return _color;        }
00079    virtual int          set_color(CCOLOR &c)       { _color = c; _update_uniforms=true; return 0; }
00080    virtual int          get_light_index() const    { return _light_index;  }
00081    virtual void         set_light_index(int i)     { _light_index = i;     _update_uniforms=true; }
00082    virtual int          get_light_dir() const      { return _light_dir;    }
00083    virtual void         set_light_dir(int d)       { _update_uniforms=true; _light_dir = d;       }
00084    virtual int          get_light_cam() const      { return _light_cam;    }
00085    virtual void         set_light_cam(int c)       { _light_cam = c;     _update_uniforms=true;   }
00086    virtual mlib::Wvec   get_light_coords() const   { return _light_coords; }
00087    virtual void         set_light_coords(mlib::CWvec &c) { _light_coords = c;   _update_uniforms=true;  }
00088    virtual double       get_target_length() const  { return _target_length;}
00089    virtual void         set_target_length(double t){ _target_length = t;   _update_uniforms=true; }
00090    virtual double       get_max_factor() const     { return _max_factor;   }
00091    virtual void         set_max_factor(double f)   { _max_factor = f;     _update_uniforms=true;  }
00092    virtual double       get_smooth_factor() const  { return _smooth_factor;}
00093    virtual void         set_smooth_factor(double f){ _smooth_factor = f;   _update_uniforms=true; }
00094    virtual double       get_smooth_detail() const  { return _smoothDetail;}
00095    virtual void         set_smooth_detail(int d)   { _smoothDetail = d;   _update_uniforms=true; }
00096 
00097    //******** IO Methods **********
00098 
00099    void                 put_layer_name(TAGformat &d) const;
00100    void                 get_layer_name(TAGformat &d);
00101    void                 put_tex_name(TAGformat &d) const;
00102    void                 get_tex_name(TAGformat &d);
00103 
00104    int&                 use_paper_()   { return _use_paper; }//_use_paper;    }  
00105    int&                 travel_paper_(){ return _travel_paper; }
00106    double&              alpha_()       { return _alpha;        }
00107    COLOR&               color_()       { return _color;        }
00108    int&                 light_index_() { return _light_index;  }
00109    int&                 light_dir_()   { return _light_dir;    }
00110    int&                 light_cam_()   { return _light_cam;    }
00111    mlib::Wvec&          light_coords_(){ return _light_coords; }
00112    void                 set_detail_map(int dmap) { _detail_map = dmap;  _update_uniforms=true;}
00113    bool                 normals_smoothed(){ return _normals_smoothed; }
00114    bool                 normals_elliptic(){ return _normals_elliptic; }
00115    bool                 normals_spheric(){ return _normals_spheric; }
00116    bool                 normals_cylindric(){ return _normals_cylindric; }
00117    void                 update_curvatures(bool b);
00118    void                 set_inv_detail(bool b) {_invert_detail = b;   _update_uniforms=true;}
00119    void                                 set_normals(int i);
00120 
00121 
00122  protected:
00123    //******** Internal Methods ********
00124    //bool load_texture();
00125   // bool activate_texture();
00126    //void load_uniforms();
00127 
00128    //******** Member Variables ********
00129 
00130    TEXTUREglptr _tex;   
00131    Image        _image;
00132    str_ptr      _tex_name;
00133    str_ptr      _layer_name;
00134    int          _use_paper;
00135    int          _travel_paper;
00136    int          _transparent;
00137    int          _annotate;
00138    COLOR        _color;
00139    double       _alpha;
00140    int          _light_index;
00141    int          _light_dir;
00142    int          _light_cam;
00143    mlib::Wvec   _light_coords;
00144    int          _detail_map;
00145    double       _target_length;
00146    double       _max_factor;
00147    bool         _normals_smoothed;
00148    bool         _normals_elliptic;
00149    bool         _normals_spheric;
00150    bool         _normals_cylindric;
00151    double       _smooth_factor;
00152    bool         _update_curvatures;
00153    double       _frame_rate;
00154    int          _nb_stat_frames;
00155    bool         _invert_detail;
00156    bool         _update_uniforms;
00157    bool         _tex_is_good;
00158    int          _smoothNormal;
00159    int          _smoothDetail;
00160 
00161 
00162 
00163    GLint _tex_loc;
00164    GLint _Dmap_loc;
00165    GLint _Sdtl_loc;
00166    GLint _Sfct_loc;
00167    GLint _trgt_loc;
00168    GLint _Mfct_loc;
00169    GLint _Fpnt_loc;
00170    GLint _Lidx_loc;
00171    GLint _Ldir_loc;
00172    GLint _Lcam_loc;
00173    GLint _Lcoord_loc;
00174 
00175 
00176 
00177    //******** VIRTUAL METHODS ********
00178 
00179    // Return the names of the xtoon GLSL shader programs:
00180    virtual str_ptr vp_filename() { return vp_name("xtoon"); }
00181    virtual str_ptr fp_filename() { return fp_name("xtoon"); }
00182 };
00183 
00184 #endif // GLSL_XTOON_H_IS_INCLUDED
00185 
00186 // end of file glsl_xtoon.H

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