struct A3DGraphSpotLightData

Data for a spotlight source entity (A3DGraphSpotLight)

A spotlight is a lighting source with a given position which casts lights within a specific direction. Only the objects within a given radius of the spotlight’s direction are illuminated, with the light rays fading over the distance. Spotlights can be interpreted as more restrictive point lights, where only a subset of the scene is illuminated from it.



All colors within this structure are global indexes to RGB color codes. The actual values can be queried using A3DGlobalGetGraphRgbColorData.

A3DGraphSpotLightData is one of the four light source types provided by HOOPS. It is associated to the kA3DTypeGraphSpotLight entity type. The other available light sources are A3DGraphAmbientLightData, A3DGraphPointLightData and A3DGraphDirectionalLightData.


The position of the light source is expressed with m_sLocation in world space coordinates. The main use of a point light’s position is to compute the distance between the light source and the illuminated object.

Angle and direction

The direction the spotlight is pointing at is expressed with m_sDirection in world space coordinates. The angle of the beam is defined by m_dFallOfAngle while m_dFallOffExponent determines the point from where the light is attenuated, angle-wise. This value is a scale within the radius of the beam: 0 is the outer edge and 1 is the center. The lower the number, the less progressive the attenuation will be.


The phenomenon of reducing the intensity of light over the distance from its source is called attenuation. The operation is done by computing a value called attenuation factor and applying it to the light color. A light attenuation is described using three floating-point values:

  • m_dConstantAttenuation is a constant term, usually kept as 1.0.

  • m_dLinearAttenuation is multiplied with the distance from the illuminated object to the light source.

  • m_dQuadraticAttenuation is multiplied with the quadrant of the distance from the illuminated object to the light source. The following function computes the attenuation factor from an instance of A3DGraphPointLightData:

    A3DDouble attenuation_factor(const A3DGraphSpotLightData* light, A3DDouble distance) {
        return 1.0 / (
          + light->m_dLinearAttenuation * distance
          + light->m_dQuadraticAttenuation * distance * distance

Ligthing color

The color of a lighting source is usually described with a single color, referenced to by m_uiAmbientColorIndex which is applied to the receiving material. Different implementations can take benefit from making the distinction between ambient, diffuse and specular colors upon computing light. These additional information can be written into m_uiDiffuseColorIndex and m_uiSpecularColorIndex. When ununsed, these values are either set to the same value as m_uiAmbientColorIndex or A3D_DEFAULT_COLOR_INDEX.

Public Members

A3DUns32 m_uiAmbientColorIndex

The main or ambient color of the light source.

A3DUns32 m_uiDiffuseColorIndex

The diffuse color of the light source.

A3DUns32 m_uiSpecularColorIndex

The specular color of the light source.

A3DVector3dData m_sDirection

The direction of the spotlight, expressed in world space coordinates.

A3DDouble m_dFallOffAngle

Spotlight angle.

A3DDouble m_dFallOffExponent

Fall of factor, expressed as a scale of m_dFallOffAngle: [0.0;1.0]

A3DVector3dData m_sLocation

The light source position in world space coordinates.

A3DDouble m_dConstantAttenuation

Constant attenuation factor usually set to 1.0.

A3DDouble m_dLinearAttenuation

Linear attenuation factor.

A3DDouble m_dQuadraticAttenuation

Quadratic attenuation factor.