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

normals_texture.H

Go to the documentation of this file.
00001 /**********************************************************************
00002  * normals_texture.H:
00003  **********************************************************************/
00004 #ifndef NORMALS_TEXTURE_H_IS_INCLUDED
00005 #define NORMALS_TEXTURE_H_IS_INCLUDED
00006 
00007 #include "smooth_shade.H"
00008 #include <map>
00009 
00010 /**********************************************************************
00011  * VertNormalsTexture:
00012  *
00013  *      Shows the vertex normals of the patch as red GL lines
00014  *      sticking out. No base coat.
00015  **********************************************************************/
00016 class VertNormalsTexture : public BasicTexture {
00017  public:
00018    //******** MANAGERS ********
00019    VertNormalsTexture(Patch* patch = 0) : BasicTexture(patch) {}
00020 
00021    virtual ~VertNormalsTexture() {}
00022 
00023    //******** RUN-TIME TYPE ID ********
00024    DEFINE_RTTI_METHODS2("VertNormals", BasicTexture, CDATA_ITEM *);
00025 
00026    //******** GTexture VIRTUAL METHODS ********
00027    virtual bool draws_filled() const  { return false; }
00028    virtual int  draw(CVIEWptr& v); 
00029 
00030    //******** DATA_ITEM VIRTUAL METHODS ********
00031    virtual DATA_ITEM  *dup() const { return new VertNormalsTexture; }
00032 };
00033 
00034 
00035 /************************
00036 Helper storage class 
00037 for UV Verts Texture
00038 ************************/
00039 class UV_grads 
00040 {
00041 public :
00042    Wvec U_grad;
00043    Wvec V_grad;
00044 };
00045 
00046 
00047 /**********************************************************************
00048  * VertUVTexture:
00049  *
00050  *      Shows the UV gradients of the patch as blue(U) and green(V) GL lines
00051  *      sticking out. No base coat.
00052  **********************************************************************/
00053 class VertUVTexture : public BasicTexture {
00054  public:
00055    //******** MANAGERS ********
00056    VertUVTexture(Patch* patch = 0) : BasicTexture(patch) {}
00057 
00058    virtual ~VertUVTexture() {}
00059 
00060    //******** RUN-TIME TYPE ID ********
00061    DEFINE_RTTI_METHODS2("VertUV", BasicTexture, CDATA_ITEM *);
00062 
00063    //******** GTexture VIRTUAL METHODS ********
00064    virtual bool draws_filled() const  { return false; }
00065    virtual int  draw(CVIEWptr& v); 
00066 
00067    virtual void compute_UV_grads();
00068 
00069    //******** DATA_ITEM VIRTUAL METHODS ********
00070    virtual DATA_ITEM  *dup() const { return new VertUVTexture; }
00071 
00072 protected:
00073 
00074    map<int,UV_grads> face_gradient_map;
00075 
00076 };
00077 
00078 
00079 
00080 
00081 
00082 /**********************************************************************
00083  * NormalsTexture:
00084  *
00085  *   Draws the plain vertex normals with a gouraud shaded base coat.
00086  *   Added capability to display UV gradients in similar manner.
00087  **********************************************************************/
00088 class NormalsTexture : public OGLTexture {
00089  public:
00090    //******** MANAGERS ********
00091    NormalsTexture(Patch* patch = 0) :
00092       OGLTexture(patch),
00093       _smooth(new SmoothShadeTexture(patch)),
00094       _normals(new VertNormalsTexture(patch)),
00095       _uv_vecs(new VertUVTexture(patch))
00096       {
00097     
00098       }
00099 
00100    virtual ~NormalsTexture() { gtextures().delete_all(); }
00101 
00102    //******** RUN-TIME TYPE ID ********
00103    DEFINE_RTTI_METHODS2("Normals", OGLTexture, CDATA_ITEM *);
00104 
00105    //******** GTexture VIRTUAL METHODS ********
00106 
00107    virtual GTexture_list gtextures() const {
00108       return GTexture_list(_smooth, _normals, _uv_vecs);
00109    }
00110    
00111    virtual int set_color(CCOLOR& col) {
00112       _smooth->set_color(col);
00113       return 1;
00114    }
00115    virtual void draw_filled_tris(double alpha) {
00116       _smooth->draw_with_alpha(alpha);
00117    }
00118    virtual void draw_non_filled_tris(double alpha) {
00119       _normals->draw_with_alpha(alpha);
00120    }
00121 
00122    virtual int draw(CVIEWptr& v); 
00123 
00124 
00125 
00126 
00127    //******** DATA_ITEM VIRTUAL METHODS ********
00128    virtual DATA_ITEM  *dup() const { return new NormalsTexture; }
00129 
00130    //extra texture coord debug stuff
00131    static bool uv_vectors() { return _uv_vectors;};
00132    static void set_uv_vectors(bool set_v) { _uv_vectors = set_v; };
00133    static void toggle_uv_vectors() { _uv_vectors = !_uv_vectors; };
00134 
00135  protected:
00136    SmoothShadeTexture* _smooth;
00137    VertNormalsTexture* _normals;
00138    VertUVTexture* _uv_vecs;
00139 
00140   
00141    static bool _uv_vectors;  // display uv vectors instead of normals
00142 
00143 };
00144 
00145 #endif // NORMALS_TEXTURE_H_IS_INCLUDED
00146 
00147 /* end of file normals_texture.H */

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