00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : Patrick Vigneras (Nov 1999) 00022 **=======================================================================*/ 00023 00024 #ifndef _SO_TEXTURE_3_ 00025 #define _SO_TEXTURE_3_ 00026 00027 #include <Inventor/fields/SoSFColor.h> 00028 #include <Inventor/fields/SoSFEnum.h> 00029 #include <Inventor/fields/SoSFImage3.h> 00030 #include <Inventor/fields/SoMFFilePathString.h> 00031 #include <Inventor/fields/SoSFBool.h> 00032 #include <Inventor/image/SbRasterImage.h> 00033 #include <Inventor/nodes/SoNode.h> 00034 #include <Inventor/nodes/SoTexture.h> 00035 #include <Inventor/sys/SoGLType.h> 00036 #include <Inventor/threads/SbThreadStorage.h> 00037 #include <Inventor/elements/SoTextureImage3Element.h> 00038 00039 class SoSensor; 00040 class SbThreadRWMutex; 00041 00043 // 00044 // Class: SoTexture3 00045 // 00046 // Texture node. 00047 // 00049 00175 class SoTexture3 : public SoTexture { 00176 00177 SO_NODE_HEADER(SoTexture3); 00178 00179 public: 00180 00182 enum Layout { 00186 VOLUME = 0, 00187 00191 ARRAY = 1, 00192 }; 00193 00213 SoMFFilePathString filenames; 00214 00222 SoSFImage3 images; 00223 00229 SoSFEnum wrapT; 00230 00236 SoSFEnum wrapR; 00237 00250 SoSFEnum layout; 00251 00255 SoTexture3(); 00256 00257 private: 00258 virtual void doAction(SoAction *action); 00259 virtual void GLRender(SoGLRenderAction *action); 00260 00261 private: 00262 static void initClass(); 00263 static void exitClass(); 00264 00265 // Manages field dependencies, when one of them change 00266 virtual void fieldHasChanged( SoField *field ); // override of SoFieldContainer 00267 00271 static bool isTexture3DSupported(SoState* state=NULL); 00272 00273 private: 00274 // Reads stuff into instance. Returns FALSE on error. 00275 virtual SbBool readInstance(SoInput *in, unsigned short flags); 00276 00277 virtual ~SoTexture3(); 00278 00279 private: 00281 SoTextureImageElement::SoTexImageData getTextureConfiguration(SoState* state); 00282 00283 static void reformatImage(unsigned char * &bytes, int w, int h, int nc, int newNC); 00284 00285 // These keep the image and filename fields in sync. 00286 void field_HasChanged(const SoField& field); 00287 void image_HasChanged(void); 00288 void filenames_HasChanged(void); 00289 void layout_HasChanged(void); 00290 00292 void handleSubTexture(SoState* state); 00293 00294 // A mutex to protect the accesses to the renderList : 00295 // a problem occured when a system can't share display lists. 00296 SbThreadRWMutex* m_mutex; 00297 00298 static int s_texture3D_extendionId; 00299 friend class SoGLTextureImage3Element; 00300 }; 00301 00302 #endif /* _SO_TEXTURE_3_ */ 00303 00304