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 #ifndef _SO_TEXTURE_CUBE_MAP_
00026 #define _SO_TEXTURE_CUBE_MAP_
00027
00028 #include <Inventor/fields/SoSFColor.h>
00029 #include <Inventor/fields/SoSFEnum.h>
00030 #include <Inventor/fields/SoSFImage.h>
00031 #include <Inventor/fields/SoMFFilePathString.h>
00032 #include <Inventor/fields/SoSFBool.h>
00033 #include <Inventor/fields/SoSFNode.h>
00034 #include <Inventor/nodes/SoNode.h>
00035 #include <Inventor/nodes/SoTexture.h>
00036 #include <Inventor/image/SbRasterImage.h>
00037 #include <Inventor/caches/SoGLTexCacheList.h>
00038 #include <Inventor/sys/SoGLType.h>
00039 #include <Inventor/threads/SbThreadStorage.h>
00040
00041 class SoSensor;
00042 class SbThreadRWMutex;
00043
00044 #ifdef _MSC_VER
00045 #pragma warning( push )
00046 #pragma warning(disable:4251)
00047 #endif
00048
00050
00051
00052
00053
00054
00056
00057 class SoTextureCubeMap;
00058 typedef SbBool CubeMapPrequalifyFileCallback(const SbString &, void *, SoTextureCubeMap *);
00059
00223 class SoTextureCubeMap : public SoTexture {
00224
00225 SO_NODE_HEADER(SoTextureCubeMap);
00226
00227 public:
00228
00243 SoMFFilePathString filenames;
00244
00252 SoSFImage imagePosX;
00256 SoSFImage imagePosY;
00260 SoSFImage imagePosZ;
00264 SoSFImage imageNegX;
00268 SoSFImage imageNegY;
00272 SoSFImage imageNegZ;
00273
00279 SoSFEnum wrapT;
00285 SoSFEnum wrapR;
00286
00297 SoSFNode renderToTextureProperty;
00298
00299
00304 SoSFFloat HDRIExposure;
00305
00309 SoTextureCubeMap();
00310
00311 private:
00312 virtual void doAction(SoAction *action);
00313 virtual void GLRender(SoGLRenderAction *action);
00314
00315 static void setPrequalifyFileCallBack(CubeMapPrequalifyFileCallback *p_cb, void *u_data);
00316 static CubeMapPrequalifyFileCallback *getPrequalifyFileCallBack( void *&user_data );
00317 void allowPrequalifyFile(SbBool);
00318 SbBool isAllowPrequalifyFile() const;
00319
00320
00321 private:
00322 static void initClass();
00323 static void exitClass();
00324 const SbString &getOverrideURL() { return overrideURL; }
00325 void setOverrideURL(const SbString &path) { overrideURL = path; }
00326
00327 virtual void notify(SoNotList *list);
00328
00329
00330 virtual void fieldHasChanged( SoField *field );
00331
00334 virtual GLenum getGLInternalFormat(SoSFImage& image, float quality = 1.0);
00335
00336 private:
00337
00338 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00339
00340 virtual ~SoTextureCubeMap();
00341
00342 virtual void copyContents(const SoFieldContainer *fromFC, SbBool copyConnections);
00343
00347 void checkTexturesFormat( SoState* state );
00348
00349 private:
00350
00351
00352 SbRasterImage* m_rasterHDRIImageRBE[6];
00353
00354 SbString overrideURL;
00355
00356 static void reformatImage(unsigned char * &bytes, int w, int h, int nc, int newNC);
00357 static void fillCubeMapTextures(int i);
00358
00359 static CubeMapPrequalifyFileCallback *prequalifyFileCB;
00360 static void *prequalifyFileCB_udata;
00361 SbBool prequalifyFileFlag;
00362
00363
00364 enum IdxIMAG { IPosX=0, IPosY=1, IPosZ=2, INegX=3, INegY=4, INegZ=5 };
00365
00366
00367 void image_HasChanged( SoSFImage *image, IdxIMAG _idxImag );
00368 void filenames_HasChanged(void);
00369 void wrapS_HasChanged(void);
00370 void maxAnisotropy_HasChanged(void);
00371 void wrapT_HasChanged(void);
00372 void wrapR_HasChanged(void);
00373 void renderToTextureProperty_HasChanged(void);
00374 void useAutoMipmap_HasChanged(void);
00375 void internalFormat_HasChanged(void);
00376 void HDRIExposure_HasChanged(void);
00377
00378
00379 SbThreadStorage< SoGLTexCacheList* > m_texList;
00380
00381 SbThreadRWMutex *m_mutex;
00382
00383 SbRasterImage* m_compressedImage[6];
00384
00385 int m_numRenderCaches;
00386 };
00387
00388 #ifdef _MSC_VER
00389 #pragma warning( pop )
00390 #endif
00391
00392 #endif
00393
00394
00395