GeneratedCubeMapTexture.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00028 //
00030 #ifndef __COMPOSEDCUBEMAPTEXTURE_H__
00031 #define __COMPOSEDCUBEMAPTEXTURE_H__
00032 
00033 #include "X3DEnvironmentTextureNode.h"
00034 #include "Viewpoint.h"
00035 #include "X3DTexture2DNode.h"
00036 #include "DependentNodeFields.h"
00037 #include <list>
00038 #include "SFInt32.h"
00039 
00040 namespace H3D {
00041 
00069   class H3DAPI_API GeneratedCubeMapTexture : public X3DEnvironmentTextureNode {
00070   public:
00072     GeneratedCubeMapTexture( Inst< DisplayList > _displayList = 0,
00073                              Inst< SFNode      > _metadata   = 0,
00074                              Inst< SFString    > _update     = 0,
00075                              Inst< SFInt32     > _size       = 0 );
00076 
00078     ~GeneratedCubeMapTexture();
00079 
00081     virtual void enableTexturing();
00082 
00084     virtual void disableTexturing();
00085 
00087     virtual void render();
00088 
00093     virtual void preRender() {
00094       X3DEnvironmentTextureNode::preRender();
00095       if( generating_textures ) {
00096         glPushAttrib( GL_COLOR_BUFFER_BIT );
00097         glEnable( GL_ALPHA_TEST );
00098         glAlphaFunc( GL_NEVER, 0 );
00099       }
00100     }
00101 
00103     virtual void postRender() {
00104       X3DEnvironmentTextureNode::postRender();
00105       if( generating_textures ) {
00106         glPopAttrib();
00107       }
00108     }
00109     
00112     virtual void initializeTextures();
00113 
00119     virtual void updateCubeMapTextures( X3DChildNode *n,
00120                                         Viewpoint *vp );
00121 
00122 #ifdef USE_HAPTICS
00125     virtual void traverseSG( TraverseInfo &ti );
00126 #endif
00127 
00134     static void updateAllCubeMapTextures( X3DChildNode *n,
00135                                           Viewpoint *vp );
00136 
00142     auto_ptr< SFString > update;
00143 
00149     auto_ptr< SFInt32 > size;
00150 
00152     static H3DNodeDatabase database;
00153 
00154   protected:
00156     bool textures_initialized;
00157     
00160     bool generating_textures;
00161 
00172     virtual void updateCubeMap( GLuint texture_target,
00173                                 const Vec3f & camera_position,
00174                                 const Vec3f & camera_dir,
00175                                 const Vec3f & camera_up,
00176                                 X3DChildNode *n,
00177                                 Viewpoint *vp );
00178 
00181     Matrix4f local_to_global;
00182 
00184     static list< GeneratedCubeMapTexture * > instances;
00185   };
00186 }
00187 
00188 #endif

Generated on Thu Aug 24 12:38:32 2006 for H3D API by  doxygen 1.4.5