H3D API  2.4.1
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
H3D::GeneratedCubeMapTexture Class Reference

The GeneratedCubeMapTexture node defines a cubic environment map that sources its data from internally generated images. More...

#include <H3D/GeneratedCubeMapTexture.h>

Inheritance diagram for H3D::GeneratedCubeMapTexture:
Inheritance graph

Public Types

typedef DependentSFNode< FieldRef< TextureProperties, Field, &TextureProperties::propertyChanged > > SFTextureProperties
 The SFTextureProperties is dependent on the propertyChanged field of the contained TextureProperties.
 
- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 

Public Member Functions

 GeneratedCubeMapTexture (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< SFString > _update=0, Inst< SFInt32 > _size=0, Inst< SFTextureProperties > _textureProperties=0)
 Constructor.
 
 ~GeneratedCubeMapTexture ()
 Destructor.
 
virtual void enableTexturing ()
 Enables cube map texturing.
 
virtual void disableTexturing ()
 Disables cube map texturing.
 
virtual void renderTextureProperties ()
 Render all OpenGL texture properties.
 
virtual void render ()
 Creates the cube map from the texture fields.
 
virtual void preRender ()
 preRender disables rendering if it is called when rendering the cube maps for this node. More...
 
virtual GLbitfield getAffectedGLAttribs ()
 Returns a bitmask of the OpenGL attrib bits that will be affected by this node. More...
 
virtual void initializeTextures ()
 Initialize OpenGL textures by allocation memory and setting up texture parameters.
 
virtual void updateCubeMapTextures (X3DChildNode *n, X3DViewpointNode *vp)
 Updates the cube map textures by rendering the given node from all directionss and saving the result as textures. More...
 
virtual void traverseSG (TraverseInfo &ti)
 Saves the accumulatedForwardMatrix in the local_to_global member variable. More...
 
virtual void renderPreViewpoint (X3DChildNode *n, X3DViewpointNode *vp)
 Updates the cube map textures of the GeneratedCubeMapTexture. More...
 
- Public Member Functions inherited from H3D::X3DEnvironmentTextureNode
 X3DEnvironmentTextureNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::H3DSingleTextureNode
 H3DSingleTextureNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< UpdateSaveToURL > _saveToUrl=0, Inst< SFBool > _saveSuccess=0, Inst< SFInt32 > _saveHeight=0, Inst< SFInt32 > _saveWidth=0)
 Constructor.
 
virtual ~H3DSingleTextureNode ()
 Destructor.
 
virtual GLuint getTextureId ()
 Get the OpenGL texture id that is used for this texture.
 
virtual GLuint getTextureUnit ()
 Get the OpenGL texture unit that is used for this texture.
 
virtual GLenum getTextureTarget ()
 Get the OpenGL texture target that is used for this texture.
 
virtual int getTextureWidth ()
 Get the texture width.
 
virtual int getTextureHeight ()
 Get the texture height.
 
virtual int getTextureDepth ()
 Get the texture depth.
 
virtual void setTextureWidth (int _width)
 Set the texture width.
 
virtual void setTextureHeight (int _height)
 Set the texture height.
 
virtual void setTextureDepth (int _depth)
 Set the texture depth.
 
virtual void setTextureId (GLuint _id)
 Set the OpenGL texture id that is used for this texture.
 
virtual void setTextureUnit (GLint unit)
 Set the OpenGL texture unit that is used for this texture.
 
virtual void setTextureTarget (GLenum target)
 Set the OpenGL texture target that is used for this texture.
 
virtual bool makeResident ()
 { Bindless texturing functions More...
 
virtual void makeNonResident ()
 Make the texture non-resident.
 
virtual bool isResident ()
 Returns true if the texture is resident in GPU memory or false otherwise.
 
virtual GLuint64 getTextureHandle ()
 Get the bindless texture handle, or 0 the texture has never been resident. More...
 
virtual void invalidateTextureHandle ()
 This should be called if the texture object is to be replaced. More...
 
void addShaderField (Field &_field)
 Add a shader field which contains this texture node. More...
 
void removeShaderField (Field &_field)
 Remove a shader field which contains this texture node. More...
 
virtual void inUse ()
 Call to signify that this texture is currently in use. More...
 
- Public Member Functions inherited from H3D::X3DTextureNode
 X3DTextureNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< UpdateSaveToURL > _saveToUrl=0, Inst< SFBool > _saveSuccess=0, Inst< SFInt32 > _saveHeight=0, Inst< SFInt32 > _saveWidth=0)
 Constructor.
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual void postRender ()
 This function will be called by the X3DShapeNode after the geometry has been rendered to restore the states to what it was before the call to preRender().
 
virtual Vec3f textureSize ()
 Sometimes the texture represents a volume in space, e.g. More...
 
virtual GLuint renderImage (Image *image, GLenum texture_target, bool scale_to_power_of_two)
 Installs the image as a OpenGL texture. More...
 
virtual GLint glInternalFormat (Image *image)
 Returns the internal OpenGL format to use given an Image, e.g. More...
 
virtual GLenum glPixelFormat (Image *image)
 Returns the OpenGL pixel format to use given an Image, e.g. More...
 
virtual GLenum glPixelComponentType (Image *image)
 Returns the OpenGL pixel compnent type to use given an Image, e.g. More...
 
virtual void glTexImage (Image *, GLenum, bool)
 Install the given image as a OpenGL texture with a call to a glTexImage function. More...
 
virtual ImagerenderToImage (H3DInt32 _width, H3DInt32 _height, bool output_float_texture=false)
 Create a new Image object which contains the result of rendering this texture. More...
 
- Public Member Functions inherited from H3D::X3DAppearanceChildNode
 X3DAppearanceChildNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
- Public Member Functions inherited from H3D::H3DDisplayListObject
 H3DDisplayListObject (Inst< DisplayList > _displayList=0)
 Constructor.
 
- Public Member Functions inherited from H3D::H3DMultiPassRenderObject
 H3DMultiPassRenderObject ()
 Constructor.
 
virtual ~H3DMultiPassRenderObject ()
 Destructor.
 
virtual void renderPostViewpoint (X3DChildNode *, X3DViewpointNode *)
 This function will be called after the viewpoint has been set up for the scene to be rendered and before the scene is rendered. More...
 
virtual void renderPostScene (X3DChildNode *, X3DViewpointNode *)
 This function will be called after the scene has been rendered. More...
 
void resetCounter ()
 Reset the counter.
 

Public Attributes

H3DUniquePtr< SFStringupdate
 The update field allows the user to request a regeneration of the texture. More...
 
H3DUniquePtr< SFInt32size
 The texture to use on the front face of the cube. More...
 
H3DUniquePtr< SFTexturePropertiestextureProperties
 The textureProperties field contains a TextureProperties node which allows fine control over a texture's application. More...
 
- Public Attributes inherited from H3D::X3DTextureNode
H3DUniquePtr< UpdateSaveToURLsaveToUrl
 When a new value is specified for saveToUrl the current texture is rendered to a buffer and saved to the specified filename. More...
 
H3DUniquePtr< SFBoolsaveSuccess
 Contains the result of the last save operation. More...
 
H3DUniquePtr< SFInt32saveHeight
 The height of the image to write to file when the saveToUrl field is used. More...
 
H3DUniquePtr< SFInt32saveWidth
 The width of the image to write to file when the saveToUrl field is used. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 
- Public Attributes inherited from H3D::H3DDisplayListObject
H3DUniquePtr< DisplayListdisplayList
 The DisplayList instance handling the OpenGL caching of this object.
 

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DTextureNode
static bool load_images_in_separate_thread = true
 This is the default value for the GlobalSettings::loadTexturesInThread field. More...
 
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Protected Member Functions

virtual void updateCubeMap (GLuint texture_target, const Vec3f &camera_position, const Vec3f &camera_dir, const Vec3f &camera_up, X3DChildNode *n, X3DViewpointNode *vp)
 Renders a scene and puts it into a texture. More...
 
- Protected Member Functions inherited from H3D::X3DTextureNode
virtual std::pair< H3DInt32, H3DInt32getDefaultSaveDimensions ()
 Returns the default dimensions to use when this texture is saved to file. More...
 
GLint glCompressedInternalFormat (GLint _format, const std::string &_compression)
 Given a non-compressed internal format, return an equivelent compressed format based on the compression settings. More...
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 

Protected Attributes

GLuint fbo_id
 The id of the frame buffer object we use to render into textures.
 
GLuint rbo_id
 The id of the render buffer object we use for depth info.
 
bool textures_initialized
 True when the cube map textures has been initialized.
 
bool generating_textures
 True if this not is currrently rendering the scene in order to create a cube map.
 
Matrix4f local_to_global
 Transformation matrix from the local coordinate system of the node to the global coordinate system.
 
- Protected Attributes inherited from H3D::H3DSingleTextureNode
GLuint64 texture_handle
 The texture handle (GPU)
 
GLuint texture_id
 The OpenGL texture id of the installed texture, 0 if not installed.
 
GLint texture_unit
 The OpenGL texture unit that is used to render this texture. More...
 
GLenum texture_target
 The OpenGL texture target that is used to render this texture.
 
int texture_width
 texture width
 
int texture_height
 texture height
 
int texture_depth
 texture depth
 
Field::FieldVector shader_fields
 Shader fields which contain this texture.
 
H3DTime last_used
 Time-stamp at which this texture was last used.
 
bool is_resident
 True if this texture is currently resident.
 

Additional Inherited Members

- Static Public Member Functions inherited from H3D::H3DSingleTextureNode
static void makeUnusedTexturesNonResident (H3DTime _unusedTime)
 Look at all resident textures and make those that have not been used recently non-resident. More...
 
- Static Public Member Functions inherited from H3D::X3DTextureNode
static X3DTextureNodegetActiveTexture ()
 Gets the currently active texture, i.e. More...
 
static void setActiveTexture (X3DTextureNode *t)
 Set the active texture. More...
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 
- Static Public Member Functions inherited from H3D::H3DMultiPassRenderObject
static void renderPreViewpointAll (X3DChildNode *n, X3DViewpointNode *vp)
 Run renderPreViewpoint on all instances of H3DMultiPassRenderObject.
 
static void renderPostViewpointAll (X3DChildNode *n, X3DViewpointNode *vp)
 Run renderPostViewpoint on all instances of H3DMultiPassRenderObject.
 
static void renderPostSceneAll (X3DChildNode *n, X3DViewpointNode *vp)
 Run renderPostScene on all instances of H3DMultiPassRenderObject.
 
static void resetCounters ()
 Run resetCounter on all instances of H3DMultiPassRenderObject.
 
static void setMultiPassTransparencyAll (bool b)
 If multi pass transparency is set to true the scene should be rendered three times graphically, once for all solid objects, once for the back side of transparent objects and once for the front face of transparent objects. More...
 
- Protected Types inherited from H3D::H3DSingleTextureNode
typedef std::vector< H3DSingleTextureNode * > TextureVector
 }
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 
- Static Protected Attributes inherited from H3D::H3DSingleTextureNode
static TextureVector resident_textures
 List of all currently resident textures.
 

Detailed Description

The GeneratedCubeMapTexture node defines a cubic environment map that sources its data from internally generated images.

The viewpoint location of a texture is the location of the geometry in world space.

The field of view shall be 90 degrees with an aspect ratio of 1:1.

The size field indicates the resolution of the generated images in number of pixels per side.

The update field allows the user to request a regeneration of the texture. Setting this field to "ALWAYS" will make the texture be rendered every frame. A value of "NONE" will stop rendering so that no further updates are performed even if the contained scene graph changes. When the value is set to "NEXT_FRAME_ONLY", it is an instruction to render the texture at the end of this frame, and then not to render again. What this means is that the update frame indicator is set to this frame, and at the start of the next frame, the update value will be automatically set back to "NONE" to indicate that the rendering has taken place already. Since this is a field change value, it will automatically generate an output event that may be routed.

Examples:

Internal routes:

Member Function Documentation

◆ getAffectedGLAttribs()

virtual GLbitfield H3D::GeneratedCubeMapTexture::getAffectedGLAttribs ( )
inlinevirtual

Returns a bitmask of the OpenGL attrib bits that will be affected by this node.

The value can be used in glPushAttrib in order to save the current state.

Reimplemented from H3D::X3DTextureNode.

References H3D::X3DTextureNode::getAffectedGLAttribs().

◆ preRender()

virtual void H3D::GeneratedCubeMapTexture::preRender ( )
inlinevirtual

preRender disables rendering if it is called when rendering the cube maps for this node.

This will cause the geometry the GeneratedCubeMapTexture is applied to, not to be rendered as part of the cube map.

Reimplemented from H3D::X3DTextureNode.

References H3D::X3DTextureNode::preRender().

◆ renderPreViewpoint()

void GeneratedCubeMapTexture::renderPreViewpoint ( X3DChildNode n,
X3DViewpointNode vp 
)
virtual

Updates the cube map textures of the GeneratedCubeMapTexture.

The update field will be checked to see if an update is required.

Parameters
nThe scenegraph to render.
vpThe viewpoint the scene is currently rendered with in the normal rendering.

Reimplemented from H3D::H3DMultiPassRenderObject.

References H3DUtil::RefCountedClass::getName(), H3D::H3DSingleTextureNode::getTextureId(), update, and updateCubeMapTextures().

◆ traverseSG()

void GeneratedCubeMapTexture::traverseSG ( TraverseInfo ti)
virtual

Saves the accumulatedForwardMatrix in the local_to_global member variable.

Parameters
tiThe TraverseInfo object containing information about the traversal.

Reimplemented from H3D::H3DMultiPassRenderObject.

References H3D::TraverseInfo::getAccForwardMatrix(), local_to_global, H3D::H3DMultiPassRenderObject::traverseSG(), and H3D::Node::traverseSG().

◆ updateCubeMap()

void GeneratedCubeMapTexture::updateCubeMap ( GLuint  texture_target,
const Vec3f &  camera_position,
const Vec3f &  camera_dir,
const Vec3f &  camera_up,
X3DChildNode n,
X3DViewpointNode vp 
)
protectedvirtual

Renders a scene and puts it into a texture.

Parameters
texture_targetThe texture target of the texture to put the rendered scene in.
camera_positionThe position of the camera used to render the scene (in the coordinate system of vp)
camera_dirThe look at vector of the camera.
camera_upThe up vector of the camera.
nThe node to render.
vpThe X3DViewpointNode that is used currently in the normal rendering of the scene.

References H3D::X3DViewpointNode::accForwardMatrix, H3D::X3DShapeNode::ALL, H3D::H3DDisplayListObject::displayList, H3D::DeviceInfo::getActive(), H3D::X3DBackgroundNode::getActive(), local_to_global, rbo_id, H3D::Node::render(), H3D::X3DBackgroundNode::renderBackground(), H3D::DeviceInfo::renderStyli(), Rotation(), size, H3D::X3DShapeNode::SOLID, H3D::H3DSingleTextureNode::texture_id, H3D::H3DSingleTextureNode::texture_target, H3D::X3DViewpointNode::totalOrientation, H3D::X3DShapeNode::TRANSPARENT_BACK, and H3D::X3DShapeNode::TRANSPARENT_FRONT.

Referenced by updateCubeMapTextures().

◆ updateCubeMapTextures()

void GeneratedCubeMapTexture::updateCubeMapTextures ( X3DChildNode n,
X3DViewpointNode vp 
)
virtual

Updates the cube map textures by rendering the given node from all directionss and saving the result as textures.

Parameters
nThe scenegraph to render.
vpThe viewpoint the scene is currently rendered with in the normal rendering.

References H3D::H3DDisplayListObject::displayList, fbo_id, generating_textures, initializeTextures(), H3D::H3DSingleTextureNode::texture_id, textures_initialized, and updateCubeMap().

Referenced by renderPreViewpoint().

Member Data Documentation

◆ size

H3DUniquePtr< SFInt32 > H3D::GeneratedCubeMapTexture::size

The texture to use on the front face of the cube.

Access type: inputOutput
Default value: 128

Referenced by GeneratedCubeMapTexture(), initializeTextures(), and updateCubeMap().

◆ textureProperties

H3DUniquePtr< SFTextureProperties > H3D::GeneratedCubeMapTexture::textureProperties

The textureProperties field contains a TextureProperties node which allows fine control over a texture's application.

Access type: inputOutput

Referenced by GeneratedCubeMapTexture(), and renderTextureProperties().

◆ update

H3DUniquePtr< SFString > H3D::GeneratedCubeMapTexture::update

The update field allows the user to request a regeneration of the texture.

Setting this field to "ALWAYS" will make the texture be rendered every frame. A value of "NONE" will stop rendering so that no further updates are performed even if the contained scene graph changes. When the value is set to "NEXT_FRAME_ONLY", it is an instruction to render the texture at the end of this frame, and then not to render again. What this means is that the update frame indicator is set to this frame, and at the start of the next frame, the update value will be automatically set back to "NONE" to indicate that the rendering has taken place already. Since this is a field change value, it will automatically generate an output event that may be routed.

Access type: inputOutput Default value: "NONE" Valid values: "NONE", "ALWAYS", "NEXT_FRAME_ONLY"

Referenced by GeneratedCubeMapTexture(), and renderPreViewpoint().


The documentation for this class was generated from the following files: