H3D API  2.4.1
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
H3D::X3DLightNode Class Referenceabstract

The X3DLightNode abstract node type is the base type from which all node types that serve as light sources are derived. More...

#include <H3D/X3DLightNode.h>

Inheritance diagram for H3D::X3DLightNode:
Inheritance graph

Classes

struct  GLLightInfo
 A structure representing a the OpenGL representation of the specified light source. More...
 

Public Member Functions

 X3DLightNode (Inst< SFNode > _metadata=0, Inst< SFFloat > _ambientIntensity=0, Inst< SFColor > _color=0, Inst< SFBool > _global=0, Inst< SFFloat > _intensity=0, Inst< SFBool > _on=0, Inst< SFBool > _shadows=0)
 Constructor.
 
virtual void enableGraphicsState ()
 Turn the light on.
 
virtual void disableGraphicsState ()
 Turn the light off.
 
virtual void enableHapticsState (TraverseInfo &ti)
 Add light to TraverseInfo.
 
virtual void disableHapticsState (TraverseInfo &ti)
 Remove light from TraverseInfo.
 
virtual void traverseSG (TraverseInfo &ti)
 Traverse the scenegraph. More...
 
- Public Member Functions inherited from H3D::X3DChildNode
 X3DChildNode (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 void render ()
 the render() function is used for the depth-first rendering traversal of the scene-graph. More...
 
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 string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. 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::H3DRenderStateObject
virtual ~H3DRenderStateObject ()
 Destructor.
 

Static Public Member Functions

static GLuint getLightIndex (string name_for_error)
 returns an index that can be used to enable light. More...
 
static void decreaseLightIndex ()
 must be called if getLightIndex have been called outside X3DLightNode.
 
- 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.
 

Public Attributes

H3DUniquePtr< SFFloatambientIntensity
 Specifies the intensity of the ambient emission from the light. More...
 
H3DUniquePtr< SFColorcolor
 The color field specifies the spectral colour properties of both the direct and ambient light emission as an RGB value. More...
 
H3DUniquePtr< SFBoolglobal
 The global field specifies whether the X3DLightNode affects all geometries in the scene or only those geometries that are in the same parent group or any descendant to the parent group. More...
 
H3DUniquePtr< SFFloatintensity
 The intensity field specifies the brightness of the direct emission from the light. More...
 
H3DUniquePtr< SFBoolon
 The on field specifies whether the light is enabled or disabled. More...
 
H3DUniquePtr< SFBoolshadows
 The shadows field will determine if this light will be part of the shadow calculations of the scene. 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::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Protected Attributes

GLuint light_index
 Light index for this node, used to enable light.
 
TraverseInfolast_ti_ptr
 only interested in adress, what it points to will be invalid
 
H3DInt32 traverse_sg_counter
 count how many times this X3DLightNodes traverseSG function is called.
 
H3DInt32 graphics_state_counter
 count nr of times enableGraphicsState is called.
 
bool act_global
 used if the light should act as a global light.
 
list< bool > had_light_index
 true if a light index was created for each call to enableGraphicsState for this X3DLightNode
 

Additional Inherited Members

- 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.
 
- 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...
 
- 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...
 

Detailed Description

The X3DLightNode abstract node type is the base type from which all node types that serve as light sources are derived.

Any node used as a source of illumination is derived from X3DLightNode. All light sources contain an intensity, a color, and an ambientIntensity field. The intensity field specifies the brightness of the direct emission from the light, and the ambientIntensity specifies the intensity of the ambient emission from the light. Light intensity may range from 0.0 (no light emission) to 1.0 (full intensity). The color field specifies the spectral colour properties of both the direct and ambient light emission as an RGB value. The on field specifies whether the light is enabled or disabled. If the value is FALSE, then the light is disabled and will not affect any nodes in the scene. If the value is TRUE, then the light will affect other nodes.

Each light type defines a global field that determines whether the light is global or scoped. Global lights illuminate all objects that fall within their volume of lighting influence. Scoped lights only illuminate objects that are in the same transformation hierarchy as the light; i.e., only the children and descendants of its enclosing parent group are illuminated. This allows the creation of realistic effects such as lights that illuminate a single room.

Internal routes:

Member Function Documentation

◆ getLightIndex()

GLuint X3DLightNode::getLightIndex ( string  name_for_error)
static

returns an index that can be used to enable light.

Parameters
name_for_errorcontains the name to print in case the light index should be ignored.

Referenced by enableGraphicsState(), and H3D::H3DWindowNode::render().

◆ traverseSG()

void X3DLightNode::traverseSG ( TraverseInfo ti)
virtual

Traverse the scenegraph.

Stores pointer to X3DLightNode and transformation matrices for those that are global.

Parameters
tiThe TraverseInfo object containing information about the traversal.

Reimplemented from H3D::Node.

Reimplemented in H3D::PointLight, and H3D::DirectionalLight.

References act_global, H3D::TraverseInfo::getAccForwardMatrix(), global, graphics_state_counter, had_light_index, last_ti_ptr, on, and traverse_sg_counter.

Referenced by H3D::DirectionalLight::traverseSG(), and H3D::PointLight::traverseSG().

Member Data Documentation

◆ ambientIntensity

H3DUniquePtr< SFFloat > H3D::X3DLightNode::ambientIntensity

◆ color

H3DUniquePtr< SFColor > H3D::X3DLightNode::color

The color field specifies the spectral colour properties of both the direct and ambient light emission as an RGB value.

Access type: inputOutput
Default value: RGB( 1, 1, 1 )
Valid range: [0-1]

Referenced by H3D::PhongShader::addUniformFieldsForLight(), H3D::DirectionalLight::DirectionalLight(), H3D::DirectionalLight::getGLLightInfo(), H3D::PointLight::getGLLightInfo(), H3D::SpotLight::getGLLightInfo(), and X3DLightNode().

◆ global

H3DUniquePtr< SFBool > H3D::X3DLightNode::global

The global field specifies whether the X3DLightNode affects all geometries in the scene or only those geometries that are in the same parent group or any descendant to the parent group.

Access type: inputOutput
Default value: FALSE

Referenced by disableHapticsState(), enableGraphicsState(), H3D::PointLight::PointLight(), H3D::SpotLight::SpotLight(), traverseSG(), and X3DLightNode().

◆ intensity

H3DUniquePtr< SFFloat > H3D::X3DLightNode::intensity

◆ on

H3DUniquePtr< SFBool > H3D::X3DLightNode::on

The on field specifies whether the light is enabled or disabled.

If the value is FALSE, then the light is disabled and will not affect any nodes in the scene.

Access type: inputOutput
Default value: TRUE

Referenced by H3D::DirectionalLight::DirectionalLight(), enableGraphicsState(), enableHapticsState(), traverseSG(), and X3DLightNode().

◆ shadows

H3DUniquePtr< SFBool > H3D::X3DLightNode::shadows

The shadows field will determine if this light will be part of the shadow calculations of the scene.

Access type: inputOutput
Default value: TRUE

Referenced by H3D::DirectionalLight::traverseSG(), H3D::PointLight::traverseSG(), and X3DLightNode().


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