00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __SGL_BEZIERSURFACESET_HPP
00027 #define __SGL_BEZIERSURFACESET_HPP
00028
00029 #include <sgl.h>
00030 #include <sglGeoSet.hpp>
00031
00032
00033
00090 class SGL_DLL_API sglBezierSurfaceSet : public sglGeoSet
00091 {
00092 public:
00094 sglBezierSurfaceSet();
00096 virtual ~sglBezierSurfaceSet();
00097
00099 void setTexCoordBind(BindEnum bind);
00101 BindEnum getTexCoordBind() const;
00102
00106 void setCoordOrder(GLint order_u = 4, GLint order_v = 4);
00108 void setTexCoordOrder(GLint order_u = 4, GLint order_v = 4);
00110 void setNormalOrder(GLint order_u = 4, GLint order_v = 4);
00112 void setColorOrder(GLint order_u = 4, GLint order_v = 4);
00113
00115 void getCoordOrder(GLint &order_u, GLint &order_v)
00116 { order_u = m_vorder_u; order_v = m_vorder_v; }
00118 void getTexCoordOrder(GLint &order_u, GLint &order_v)
00119 { order_u = m_torder_u; order_v = m_torder_v; }
00121 void getNormalOrder(GLint &order_u, GLint &order_v)
00122 { order_u = m_norder_u; order_v = m_norder_v; }
00124 void getColorOrder(GLint &order_u, GLint &order_v)
00125 { order_u = m_corder_u; order_v = m_corder_v; }
00126
00128 void setRange(float min_u = 0, float max_u = 1.0f,
00129 float min_v = 0, float max_v = 1.0f);
00131 void getRange(float &min_u, float &max_u, float &min_v, float &max_v);
00132
00136 void setNumSegments(unsigned int num_u, unsigned int num_v);
00138 void setNumSegments(unsigned int &num_u, unsigned int &num_v)
00139 { num_u = m_segments_u; num_v = m_segments_v; }
00140
00142 virtual void addStats(sglStats &stats) const;
00143
00145 virtual void drawGeometry(const vector<sglTexCoords> &tex_coords) const;
00146
00148 sglStats::PrimEnum getPrimType() const {return sglStats::eBEZIER_SURFACES;}
00150 GLenum getGLPrimType() const {return GL_QUAD_STRIP;}
00152 unsigned int getPrimSize() const {return (m_segments_u+1)*(m_segments_v+1);}
00154 AAEnum getAAType() const {return ePOLYGON_AA;}
00155
00156 protected:
00157 virtual bool computeBounds();
00158 virtual void updateDrawFunc();
00159
00160 private:
00161 sglBezierSurfaceSet(const sglBezierSurfaceSet &);
00162 sglBezierSurfaceSet &operator=(const sglBezierSurfaceSet &);
00163
00164 typedef void (*Map2Func)(float, float, int, int,
00165 float, float, int, int, const void*);
00166 static void invalidFunc(float, float, int, int,
00167 float, float, int, int, const void*);
00168 static void applyVerts3f(float, float, int, int,
00169 float, float, int, int, const void*);
00170 static void applyVerts3d(float, float, int, int,
00171 float, float, int, int, const void*);
00172 static void applyVerts4f(float, float, int, int,
00173 float, float, int, int, const void*);
00174 static void applyVerts4d(float, float, int, int,
00175 float, float, int, int, const void*);
00176 static void applyNorms3f(float, float, int, int,
00177 float, float, int, int, const void*);
00178 static void applyNorms3d(float, float, int, int,
00179 float, float, int, int, const void*);
00180 static void applyColors4f(float, float, int, int,
00181 float, float, int, int, const void*);
00182 static void applyColors4d(float, float, int, int,
00183 float, float, int, int, const void*);
00184 static void applyTexCoords1f(float, float, int, int,
00185 float, float, int, int, const void*);
00186 static void applyTexCoords1d(float, float, int, int,
00187 float, float, int, int, const void*);
00188 static void applyTexCoords2f(float, float, int, int,
00189 float, float, int, int, const void*);
00190 static void applyTexCoords2d(float, float, int, int,
00191 float, float, int, int, const void*);
00192 static void applyTexCoords3f(float, float, int, int,
00193 float, float, int, int, const void*);
00194 static void applyTexCoords3d(float, float, int, int,
00195 float, float, int, int, const void*);
00196 static void applyTexCoords4f(float, float, int, int,
00197 float, float, int, int, const void*);
00198 static void applyTexCoords4d(float, float, int, int,
00199 float, float, int, int, const void*);
00200
00201 protected:
00202 GLint m_vorder_u;
00203 GLint m_vorder_v;
00204 GLint m_norder_u;
00205 GLint m_norder_v;
00206 GLint m_corder_u;
00207 GLint m_corder_v;
00208 GLint m_torder_u;
00209 GLint m_torder_v;
00210
00211 float m_min_u;
00212 float m_min_v;
00213 float m_max_u;
00214 float m_max_v;
00215
00216 unsigned int m_segments_u;
00217 unsigned int m_segments_v;
00218
00219 static Map2Func s_vfunc_table[24];
00220 static Map2Func s_nfunc_table[8];
00221 static Map2Func s_cfunc_table[16];
00222 static Map2Func s_tfunc_table[32];
00223 };
00224
00225 #endif