H3D API
2.4.1
|
The SpotLight node defines a light source that emits light from a specific point along a specific direction vector and constrained within a solid angle. More...
#include <H3D/SpotLight.h>
Public Member Functions | |
SpotLight (Inst< SFNode > _metadata=0, Inst< SFFloat > _ambientIntensity=0, Inst< SFColor > _color=0, Inst< SFFloat > _intensity=0, Inst< SFBool > _global=0, Inst< SFBool > _on=0, Inst< SFVec3f > _attenuation=0, Inst< SFFloat > _beamWidth=0, Inst< SFFloat > _cutOffAngle=0, Inst< SFVec3f > _direction=0, Inst< SFVec3f > _location=0, Inst< SFFloat > _radius=0) | |
Constructor. | |
GLLightInfo | getGLLightInfo () |
Return the OpenGL parameters for this light. | |
![]() | |
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... | |
![]() | |
X3DChildNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (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. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
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 Field * | getField (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... | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
![]() | |
virtual | ~H3DRenderStateObject () |
Destructor. | |
Public Attributes | |
H3DUniquePtr< SFVec3f > | attenuation |
The attenuation field defines how the SpotLight node's illumination falls off with distance from the light. More... | |
H3DUniquePtr< SFFloat > | beamWidth |
The beamWidth field specifies an inner solid angle in which the light source emits light at uniform full intensity (in H3DAPI it can only be the entire beamWidth angle or 0). More... | |
H3DUniquePtr< SFFloat > | cutOffAngle |
The cutOffAngle field specifies the outer bound of the solid angle. More... | |
H3DUniquePtr< SFVec3f > | direction |
The direction field specifies the direction vector of the light's central axis defined in the local coordinate system. More... | |
H3DUniquePtr< SFVec3f > | location |
The location field specifies a translation offset of the centre point of the light source from the light's local coordinate system origin. More... | |
H3DUniquePtr< SFFloat > | radius |
This field is not supported by H3DAPI. | |
![]() | |
H3DUniquePtr< SFFloat > | ambientIntensity |
Specifies the intensity of the ambient emission from the light. More... | |
H3DUniquePtr< SFColor > | color |
The color field specifies the spectral colour properties of both the direct and ambient light emission as an RGB value. More... | |
H3DUniquePtr< SFBool > | 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. More... | |
H3DUniquePtr< SFFloat > | intensity |
The intensity field specifies the brightness of the direct emission from the light. More... | |
H3DUniquePtr< SFBool > | on |
The on field specifies whether the light is enabled or disabled. More... | |
H3DUniquePtr< SFBool > | shadows |
The shadows field will determine if this light will be part of the shadow calculations of the scene. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
The DisplayList instance handling the OpenGL caching of this object. | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
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 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. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
![]() | |
GLuint | light_index |
Light index for this node, used to enable light. | |
TraverseInfo * | last_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 | |
The SpotLight node defines a light source that emits light from a specific point along a specific direction vector and constrained within a solid angle.
Spotlights may illuminate geometry nodes that respond to light sources and intersect the solid angle defined by the SpotLight. Spotlight nodes are specified in the local coordinate system and are affected by ancestors' transformations.
See X3DLightNode for a description of the ambientIntensity, color, and intensity fields.
The location field specifies a translation offset of the centre point of the light source from the light's local coordinate system origin. This point is the apex of the solid angle which bounds light emission from the given light source. The direction field specifies the direction vector of the light's central axis defined in the local coordinate system.
The on field specifies whether the light source emits light. If on is TRUE, the light source is emitting light and may illuminate geometry in the scene. If on is FALSE, the light source does not emit light and does not illuminate any geometry.
Location is affected by ancestors' transformations.
The cutOffAngle field specifies the outer bound of the solid angle. The light source does not emit light outside of this solid angle. The beamWidth field specifies an inner solid angle in which the light source emits light at uniform full intensity (in H3DAPI it can only be the entire beamWidth angle or 0). If beamWidth is less than cutOffAngle then the intensity drops of linearly from the center of the spotlight to the beamWidth, i.e. the same as a beamWidth of 0. If the beamWidth is greater than the cutOffAngle, beamWidth is defined to be equal to the cutOffAngle and the light source emits full intensity within the entire solid angle defined by cutOffAngle.
SpotLight illumination falls off with distance as specified by three attenuation coefficients. The attenuation factor is:
1/max(attenuation[0] + attenuation[1] × r + attenuation[2] × r2 , 1)
where r is the distance from the light to the surface being illuminated. The default is no attenuation. An attenuation value of (0, 0, 0) is identical to (1, 0, 0). Attenuation values shall be greater than or equal to zero.
Examples:
H3DUniquePtr< SFVec3f > H3D::SpotLight::attenuation |
The attenuation field defines how the SpotLight node's illumination falls off with distance from the light.
The attenuation factor is:
1/max(attenuation[0] + attenuation[1] × r + attenuation[2] × r2, 1)
where r is the distance from the light to the surface being illuminated.
Access type: inputOutput
Default value: 1 0 0
Valid range: [0-inf]
Referenced by H3D::PhongShader::addUniformFieldsForLight(), getGLLightInfo(), and SpotLight().
H3DUniquePtr< SFFloat > H3D::SpotLight::beamWidth |
The beamWidth field specifies an inner solid angle in which the light source emits light at uniform full intensity (in H3DAPI it can only be the entire beamWidth angle or 0).
If beamWidth is less than cutOffAngle then the intensity drops of linearly from the center of the spotlight to the beamWidth, i.e. the same as a beamWidth of 0. If the beamWidth is greater than the cutOffAngle, beamWidth is defined to be equal to the cutOffAngle and the light source emits full intensity within the entire solid angle defined by cutOffAngle.
Access type: inputOutput
Default value: pi/2
Valid range: [0-pi/2]
Referenced by H3D::PhongShader::addUniformFieldsForLight(), getGLLightInfo(), H3D::PhongShader::setupLight(), and SpotLight().
H3DUniquePtr< SFFloat > H3D::SpotLight::cutOffAngle |
The cutOffAngle field specifies the outer bound of the solid angle.
The light source does not emit light outside of this solid angle.
Access type: inputOutput
Default value: pi/4
Valid range: [0-pi/2]
Referenced by H3D::PhongShader::addUniformFieldsForLight(), getGLLightInfo(), H3D::PhongShader::setupLight(), and SpotLight().
H3DUniquePtr< SFVec3f > H3D::SpotLight::direction |
The direction field specifies the direction vector of the light's central axis defined in the local coordinate system.
Access type: inputOutput
Default value: 0 0 -1
Referenced by H3D::PhongShader::addUniformFieldsForLight(), getGLLightInfo(), and SpotLight().
H3DUniquePtr< SFVec3f > H3D::SpotLight::location |
The location field specifies a translation offset of the centre point of the light source from the light's local coordinate system origin.
This point is the apex of the solid angle which bounds light emission from the given light source.
Access type: inputOutput
Default value: 0 0 0
Referenced by H3D::PhongShader::addUniformFieldsForLight(), getGLLightInfo(), and SpotLight().