H3D API  2.4.1
GeneratedCubeMapTexture.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
28 //
30 #ifndef __GENERATEDCUBEMAPTEXTURE_H__
31 #define __GENERATEDCUBEMAPTEXTURE_H__
32 
34 #include <H3D/X3DViewpointNode.h>
35 #include <H3D/X3DTexture2DNode.h>
38 #include <list>
39 #include <H3D/SFInt32.h>
40 
41 namespace H3D {
42 
75  class H3DAPI_API GeneratedCubeMapTexture :
78  public:
82  Field,
85 
87  GeneratedCubeMapTexture( Inst< DisplayList > _displayList = 0,
88  Inst< SFNode > _metadata = 0,
89  Inst< SFString > _update = 0,
90  Inst< SFInt32 > _size = 0,
91  Inst< SFTextureProperties > _textureProperties = 0 );
92 
95 
97  virtual void enableTexturing();
98 
100  virtual void disableTexturing();
101 
103  virtual void renderTextureProperties();
104 
106  virtual void render();
107 
112  virtual void preRender() {
114  if( generating_textures ) {
115  glEnable( GL_ALPHA_TEST );
116  glAlphaFunc( GL_NEVER, 0 );
117  }
118  }
119 
120  virtual GLbitfield getAffectedGLAttribs() {
121  return
123  GL_COLOR_BUFFER_BIT;
124  }
125 
128  virtual void initializeTextures();
129 
135  virtual void updateCubeMapTextures( X3DChildNode *n,
136  X3DViewpointNode *vp );
137 
142  virtual void traverseSG( TraverseInfo &ti );
143 
149  virtual void renderPreViewpoint( X3DChildNode *n,
150  X3DViewpointNode *vp );
151 
169  H3DUniquePtr< SFString > update;
170 
177  H3DUniquePtr< SFInt32 > size;
178 
185  H3DUniquePtr< SFTextureProperties > textureProperties;
186 
189 
190  protected:
193  GLuint fbo_id;
194 
197  GLuint rbo_id;
198 
201 
205 
216  virtual void updateCubeMap( GLuint texture_target,
217  const Vec3f & camera_position,
218  const Vec3f & camera_dir,
219  const Vec3f & camera_up,
220  X3DChildNode *n,
221  X3DViewpointNode *vp );
222 
225  Matrix4f local_to_global;
226  };
227 }
228 
229 #endif
Contains the DependentSFNode and DependentMFNode template classes.
Header file for H3DMultiPassRenderObject.
Contains the SFInt32 field class.
Header file for X3DEnvironmentTextureNode, X3D abstract scene-graph node.
Header file for X3DTexture2DNode, X3D scene-graph node.
Header file for X3DViewpointNode, X3D scene-graph node.
DependentSFNode are modified TypedSFNode fields where the field dirty status is dependent on fields i...
Definition: DependentNodeFields.h:294
Class used for specifying a field member of a node in a DependentSFNode or DependentMFNode specificat...
Definition: DependentNodeFields.h:48
The Field class.
Definition: Field.h:46
The GeneratedCubeMapTexture node defines a cubic environment map that sources its data from internall...
Definition: GeneratedCubeMapTexture.h:77
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: GeneratedCubeMapTexture.h:188
GLuint rbo_id
The id of the render buffer object we use for depth info.
Definition: GeneratedCubeMapTexture.h:197
virtual void preRender()
preRender disables rendering if it is called when rendering the cube maps for this node.
Definition: GeneratedCubeMapTexture.h:112
H3DUniquePtr< SFInt32 > size
The texture to use on the front face of the cube.
Definition: GeneratedCubeMapTexture.h:177
bool generating_textures
True if this not is currrently rendering the scene in order to create a cube map.
Definition: GeneratedCubeMapTexture.h:204
virtual GLbitfield getAffectedGLAttribs()
Returns a bitmask of the OpenGL attrib bits that will be affected by this node.
Definition: GeneratedCubeMapTexture.h:120
Matrix4f local_to_global
Transformation matrix from the local coordinate system of the node to the global coordinate system.
Definition: GeneratedCubeMapTexture.h:225
DependentSFNode< FieldRef< TextureProperties, Field, &TextureProperties::propertyChanged > > SFTextureProperties
The SFTextureProperties is dependent on the propertyChanged field of the contained TextureProperties.
Definition: GeneratedCubeMapTexture.h:84
H3DUniquePtr< SFString > update
The update field allows the user to request a regeneration of the texture.
Definition: GeneratedCubeMapTexture.h:169
GLuint fbo_id
The id of the frame buffer object we use to render into textures.
Definition: GeneratedCubeMapTexture.h:193
H3DUniquePtr< SFTextureProperties > textureProperties
The textureProperties field contains a TextureProperties node which allows fine control over a textur...
Definition: GeneratedCubeMapTexture.h:185
bool textures_initialized
True when the cube map textures has been initialized.
Definition: GeneratedCubeMapTexture.h:200
This abstract interface is inherited by all nodes that needs to render the scene an extra time(or mor...
Definition: H3DMultiPassRenderObject.h:41
TextureProperties allows fine control over a texture's application.
Definition: TextureProperties.h:195
H3DUniquePtr< Field > propertyChanged
Field that gets an event when any of the X3D fields in the TextureProperties generates an event.
Definition: TextureProperties.h:369
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
This abstract node type indicates that the concrete nodes which are instantiated based on it may be u...
Definition: X3DChildNode.h:42
This abstract node type is the base type for all node types that specify cubic environment map source...
Definition: X3DEnvironmentTextureNode.h:57
virtual GLbitfield getAffectedGLAttribs()
Returns a bitmask of the OpenGL attrib bits that will be affected by this node.
Definition: X3DTextureNode.h:110
virtual void preRender()
This function will be called by the X3DShapeNode before any rendering of geometry and before the call...
Definition: X3DTextureNode.h:96
The X3DViewpointNode node defines a specific location in the local coordinate system from which the u...
Definition: X3DViewpointNode.h:239
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194