00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_TEXTURE_COORDINATE3_ELEMENT
00025 #define _SO_TEXTURE_COORDINATE3_ELEMENT
00026
00027 #include <Inventor/SbLinear.h>
00028 #include <Inventor/elements/SoReplacedTextureElement.h>
00029 #include <Inventor/STL/vector>
00030
00038 typedef const SbVec4f &
00039 SoTextureCoordinate3FunctionCB(void *userdata, const SbVec3f &point,
00040 const SbVec3f &normal);
00041
00054 SoEXTENDER_Documented class SoTextureCoordinate3Element : public SoReplacedTextureElement {
00055
00056 SO_ELEMENT_HEADER(SoTextureCoordinate3Element);
00057
00058 public:
00063 enum CoordType {
00064 EXPLICIT = 1,
00065 FUNCTION = 2
00066 };
00067
00072 static void setDefault(SoState *state, SoNode *node);
00073
00074
00075 static void setFunction(SoState *state, SoNode *node,
00076 SoTextureCoordinate3FunctionCB *func,
00077 void *userData,
00078 SbBool frcSend = FALSE);
00079
00080
00084 static void set3(SoState *state, SoNode *node,
00085 int32_t numCoords, const SbVec3f *coords,
00086 SbBool frcSend = FALSE);
00087
00091 static void set4(SoState *state, SoNode *node,
00092 int32_t numCoords, const SbVec4f *coords,
00093 SbBool frcSend = FALSE);
00094
00099 static CoordType getType(SoState *state, int unit=0);
00100
00101 virtual CoordType getType(int unit=0) const;
00102
00109 static const SoTextureCoordinate3Element * getInstance(SoState *state);
00110
00111
00112
00118 const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal,
00119 int unit=0) const;
00120
00121
00122
00126 int32_t getNum(int unit=0) const ;
00127
00128 SbBool is3D(int unit=0) const ;
00129
00130 SbBool isForceSending(int unit=0) const ;
00131
00136 const SbVec3f & get3(int index, int unit=0) const;
00137 const SbVec4f & get4(int index, int unit=0) const;
00138
00142 virtual void print(FILE *fp) const;
00143
00147 virtual void push(SoState *) ;
00148
00149 private:
00150
00152 virtual void commonInit();
00153
00155 virtual void init(SoState *state);
00156
00157 private:
00158
00159 static void initClass();
00160 static void exitClass();
00161
00162 private:
00163 struct SoTexCoord3Data {
00164 SoTexCoord3Data()
00165 :whatKind(EXPLICIT), funcCB(NULL),funcCBData(NULL),
00166 numCoords(0),coords3(NULL),coords4(NULL),coordsAre3D(FALSE),forceSend(FALSE)
00167 {}
00168
00169
00170 SoTexCoord3Data& operator=(const SoTexCoord3Data& data)
00171 {
00172 whatKind = data.whatKind ;
00173 funcCB = data.funcCB ;
00174 funcCBData = data.funcCBData ;
00175 numCoords = data.numCoords ;
00176 coords3 = data.coords3 ;
00177 coords4 = data.coords4 ;
00178 coordsAre3D = data.coordsAre3D ;
00179 forceSend = data.forceSend;
00180 return *this ;
00181 }
00182
00183
00184
00185 CoordType whatKind;
00186
00187
00188 SoTextureCoordinate3FunctionCB *funcCB;
00189 void *funcCBData;
00190
00191
00192 int32_t numCoords;
00193 const SbVec3f *coords3;
00194 const SbVec4f *coords4;
00195 SbBool coordsAre3D;
00196 SbBool forceSend;
00197 } ;
00198 SoTexCoord3Data& getData(const size_t unit) const;
00199
00200 virtual ~SoTextureCoordinate3Element();
00201
00202 private:
00203 void checkSize(const size_t size) const;
00204 mutable std::vector<SoTexCoord3Data> m_texCoord3Data ;
00205
00206
00207 SbVec3f convert3;
00208 SbVec4f convert4;
00209 };
00210
00211 #endif
00212
00213
00214