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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SO_TEXTURE_COORDINATE_ELEMENT
00051 #define _SO_TEXTURE_COORDINATE_ELEMENT
00052
00053 #include <Inventor/SbLinear.h>
00054 #include <Inventor/elements/SoReplacedTextureElement.h>
00055
00056 #include <Inventor/STL/vector>
00057
00063 typedef const SbVec4f &
00064 SoTextureCoordinateFunctionCB(void *userdata, const SbVec3f &point,
00065 const SbVec3f &normal);
00066
00078 SoEXTENDER_Documented class SoTextureCoordinateElement : public SoReplacedTextureElement {
00079
00080 SO_ELEMENT_HEADER(SoTextureCoordinateElement);
00081
00082 public:
00087 enum CoordType {
00088 EXPLICIT = 1,
00089 FUNCTION = 2
00090 };
00091
00096 static void setDefault(SoState *state, SoNode *node);
00097
00098
00099 static void setFunction(SoState *state, SoNode *node,
00100 SoTextureCoordinateFunctionCB *func,
00101 void *userData,
00102 SbBool frcSend = FALSE);
00103
00107 static void set2(SoState *state, SoNode *node,
00108 int32_t numCoords, const SbVec2f *coords,
00109 SbBool frcSend = FALSE);
00110
00114 static void set4(SoState *state, SoNode *node,
00115 int32_t numCoords, const SbVec4f *coords,
00116 SbBool frcSend = FALSE);
00117
00122 static CoordType getType(SoState *state, int unit=0);
00123
00124 virtual CoordType getType(int unit=0) const;
00125
00132 static const SoTextureCoordinateElement * getInstance(SoState *state);
00133
00134
00135
00141 const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal,
00142 int unit=0) const;
00143
00144
00145
00149 int32_t getNum(int unit=0) const ;
00150
00151 SbBool is2D(int unit=0) const ;
00152
00153 SbBool isForceSending(int unit=0) const ;
00154
00159 const SbVec2f & get2(int index, int unit=0) const;
00160 const SbVec4f & get4(int index, int unit=0) const;
00161
00165 virtual void print(FILE *fp) const;
00166
00170 virtual void push(SoState *) ;
00171
00172 private:
00173
00175 virtual void commonInit();
00176
00178 virtual void init(SoState *state);
00179
00180 private:
00181
00182 static void initClass();
00183 static void exitClass();
00184
00185 private:
00186
00187 virtual ~SoTextureCoordinateElement();
00188
00189 struct SoTexCoordData
00190 {
00191
00192 CoordType whatKind;
00193
00194
00195 SoTextureCoordinateFunctionCB *funcCB;
00196 void *funcCBData;
00197
00198
00199 int32_t numCoords;
00200 const SbVec2f *coords2;
00201 const SbVec4f *coords4;
00202 SbBool coordsAre2D;
00203 SbBool forceSend;
00204
00205 SoTexCoordData() :
00206 whatKind(EXPLICIT),
00207 funcCB(NULL),
00208 funcCBData(NULL),
00209 numCoords(0),
00210 coords2(NULL),
00211 coords4(NULL),
00212 coordsAre2D(FALSE),
00213 forceSend(FALSE)
00214 {
00215 }
00216
00217 void initValues( const CoordType &type )
00218 {
00219 whatKind = type;
00220 funcCB = NULL;
00221 funcCBData = NULL;
00222 numCoords = 0;
00223 coords2 = NULL;
00224 coords4 = NULL;
00225 coordsAre2D = FALSE;
00226 forceSend = FALSE;
00227 }
00228
00229 SoTexCoordData& operator=(const SoTexCoordData& data)
00230 {
00231 whatKind = data.whatKind ;
00232 funcCB = data.funcCB ;
00233 funcCBData = data.funcCBData ;
00234 numCoords = data.numCoords ;
00235 coords2 = data.coords2 ;
00236 coords4 = data.coords4 ;
00237 coordsAre2D = data.coordsAre2D ;
00238 forceSend = data.forceSend;
00239 return *this ;
00240 }
00241 } ;
00242
00243 SoTexCoordData& getTexCoordData( const int unit ) const;
00244
00245 private:
00246 SbVec2f m_convert2;
00247 SbVec4f m_convert4;
00248
00249 typedef std::vector<SoTexCoordData> SoTexCoordDataList;
00250
00251 mutable SoTexCoordDataList m_texCoordData ;
00252 };
00253
00254 #endif
00255