SoVRMLSpotLight.3coin4 - Man Page

The SoVRMLSpotLight class defines a spot light source.


#include <Inventor/VRMLnodes/SoVRMLSpotLight.h>

Inherits SoVRMLLight.

Public Member Functions

virtual SoType getTypeId (void) const
Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and 'downward' casting.
SoVRMLSpotLight (void)
virtual void GLRender (SoGLRenderAction *action)

Static Public Member Functions

static SoType getClassTypeId (void)
static void initClass (void)

Public Attributes

SoSFVec3f location
SoSFVec3f direction
SoSFFloat beamWidth
SoSFFloat cutOffAngle
SoSFFloat radius
SoSFVec3f attenuation

Protected Member Functions

virtual const SoFieldData * getFieldData (void) const
virtual ~SoVRMLSpotLight ()

Static Protected Member Functions

static const SoFieldData ** getFieldDataPtr (void)

Additional Inherited Members

Detailed Description

The SoVRMLSpotLight class defines a spot light source.

The detailed class documentation is taken verbatim from the VRML97 standard (ISO/IEC 14772-1:1997). It is copyright The Web3D Consortium, and is used by permission of the Consortium:

SpotLight {
  exposedField SFFloat ambientIntensity  0         # [0,1]
  exposedField SFVec3f attenuation       1 0 0     # [0,inf)
  exposedField SFFloat beamWidth         1.570796  # (0,pi/2]
  exposedField SFColor color             1 1 1     # [0,1]
  exposedField SFFloat cutOffAngle       0.785398  # (0,pi/2]
  exposedField SFVec3f direction         0 0 -1    # (-inf, inf)
  exposedField SFFloat intensity         1         # [0,1]
  exposedField SFVec3f location          0 0 0     # (-inf, inf)
  exposedField SFBool  on                TRUE
  exposedField SFFloat radius            100       # [0, inf)

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.

A detailed description of ambientIntensity, color, intensity, and VRML's lighting equations is provided in 4.6.6, Light sources ( More information on lighting concepts can be found in 4.14, Lighting model (, including a detailed description of the VRML lighting equations.

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.

The radius field specifies the radial extent of the solid angle and the maximum distance from location that may be illuminated by the light source. The light source does not emit light outside this radius. The radius shall be greater than or equal to zero.

Both radius and location are affected by ancestors' transformations (scales affect radius and transformations affect location).

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. The light source's emission intensity drops off from the inner solid angle (beamWidth) to the outer solid angle (cutOffAngle) as described in the following equations:

angle = the angle between the Spotlight's direction vector
        and the vector from the Spotlight location to the point
        to be illuminated

if (angle >= cutOffAngle):
  multiplier = 0
else if (angle <= beamWidth):
  multiplier = 1
  multiplier = (angle - cutOffAngle) / (beamWidth - cutOffAngle)

intensity(angle) = SpotLight.intensity × multiplier

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. Both beamWidth and cutOffAngle shall be greater than 0.0 and less than or equal to pi/2.

Figure 6.16 depicts the beamWidth, cutOffAngle, direction, location, and radius fields of the SpotLight node.

 Figure 6.16 -- SpotLight node

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]×r^2 , 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. A detailed description of VRML's lighting equations is contained in 4.14, Lighting model (

Constructor & Destructor Documentation

SoVRMLSpotLight::SoVRMLSpotLight (void)


SoVRMLSpotLight::~SoVRMLSpotLight () [protected], [virtual]


Member Function Documentation

SoType SoVRMLSpotLight::getTypeId (void) const [virtual]

Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and 'downward' casting. Usage example:

void foo(SoNode * node)
  if (node->getTypeId() == SoFile::getClassTypeId()) {
    SoFile * filenode = (SoFile *)node;  // safe downward cast, knows the type

For application programmers wanting to extend the library with new nodes, engines, nodekits, draggers or others: this method needs to be overridden in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes) and so on.

For more information on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups.

Reimplemented from SoVRMLLight.

const SoFieldData * SoVRMLSpotLight::getFieldData (void) const [protected], [virtual]

Returns a pointer to the class-wide field data storage object for this instance. If no fields are present, returns NULL.

Reimplemented from SoVRMLLight.

void SoVRMLSpotLight::GLRender (SoGLRenderAction * action) [virtual]

Action method for the SoGLRenderAction.

This is called during rendering traversals. Nodes influencing the rendering state in any way or who wants to throw geometry primitives at OpenGL overrides this method.

Reimplemented from SoVRMLLight.

Member Data Documentation

SoSFVec3f SoVRMLSpotLight::location

The light position. Default value is (0, 0, 0).

SoSFVec3f SoVRMLSpotLight::direction

The light direction. Default value is (0, 0, 1).

SoSFFloat SoVRMLSpotLight::beamWidth

The spot beam width. Default value is PI/2.

SoSFFloat SoVRMLSpotLight::cutOffAngle

The spot light cut off angle. Default value is PI/4.

SoSFFloat SoVRMLSpotLight::radius

The light radius. Light is not emitted past it. Default value is 100.

SoSFVec3f SoVRMLSpotLight::attenuation

The attenuiation vector. Default value is (1, 0, 0).


Generated automatically by Doxygen for Coin from the source code.


Wed Jul 20 2022 Version 4.0.0 Coin