00001
00002
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
00012
00013
00014
00015
00016 class VertNormalsTexture : public BasicTexture {
00017 public:
00018
00019 VertNormalsTexture(Patch* patch = 0) : BasicTexture(patch) {}
00020
00021 virtual ~VertNormalsTexture() {}
00022
00023
00024 DEFINE_RTTI_METHODS2("VertNormals", BasicTexture, CDATA_ITEM *);
00025
00026
00027 virtual bool draws_filled() const { return false; }
00028 virtual int draw(CVIEWptr& v);
00029
00030
00031 virtual DATA_ITEM *dup() const { return new VertNormalsTexture; }
00032 };
00033
00034
00035
00036
00037
00038
00039 class UV_grads
00040 {
00041 public :
00042 Wvec U_grad;
00043 Wvec V_grad;
00044 };
00045
00046
00047
00048
00049
00050
00051
00052
00053 class VertUVTexture : public BasicTexture {
00054 public:
00055
00056 VertUVTexture(Patch* patch = 0) : BasicTexture(patch) {}
00057
00058 virtual ~VertUVTexture() {}
00059
00060
00061 DEFINE_RTTI_METHODS2("VertUV", BasicTexture, CDATA_ITEM *);
00062
00063
00064 virtual bool draws_filled() const { return false; }
00065 virtual int draw(CVIEWptr& v);
00066
00067 virtual void compute_UV_grads();
00068
00069
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
00084
00085
00086
00087
00088 class NormalsTexture : public OGLTexture {
00089 public:
00090
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
00103 DEFINE_RTTI_METHODS2("Normals", OGLTexture, CDATA_ITEM *);
00104
00105
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
00128 virtual DATA_ITEM *dup() const { return new NormalsTexture; }
00129
00130
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;
00142
00143 };
00144
00145 #endif // NORMALS_TEXTURE_H_IS_INCLUDED
00146
00147