Orxonox: orxonox::Light Class Reference

# orxonox::Light Class Reference

`#include <src/orxonox/objects/worldentities/Light.h>`

Inheritance diagram for orxonox::Light:

List of all members.

## Public Types

enum | LightTypes { Point, Directional, Spotlight }

## Public Member Functions

virtual void | changedVisibility ()
| This function gets called if the visibility of the object changes.
const Vector4 & | getAttenuation () const
const ColourValue & | getDiffuseColour () const
Ogre::Light * | getLight ()
const ColourValue & | getSpecularColour () const
const Vector3 & | getSpotlightRange () const
Light::LightTypes | getType () const
| Light (BaseObject *creator)
void | registerVariables ()
void | setAttenuation (const Vector4 &attenuation)
| Sets the attenuation parameters of the light source i.e. how it diminishes with distance.
void | setDiffuseColour (const ColourValue &colour)
void | setSpecularColour (const ColourValue &colour)
void | setSpotlightRange (const Vector3 &spotlightRange)
| Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them.
virtual void | setTeamColour (const ColourValue &colour)
void | setType (Light::LightTypes type)
virtual void | XMLPort (Element &xmlelement, XMLPort::Mode mode)
| XML loading and saving.
virtual | ~Light ()

## Private Member Functions

std::string | getTypeString () const
void | setTypeString (const std::string &type)
void | updateAttenuation ()
void | updateDiffuseColour ()
void | updateSpecularColour ()
void | updateSpotlightRange ()
void | updateType ()

## Private Attributes

Vector4 | attenuation_
ColourValue | diffuse_
Ogre::Light * | light_
ColourValue | specular_
Vector3 | spotlightRange_
LightTypes | type_

## Member Enumeration Documentation

enum orxonox::Light::LightTypes

Enumerator:

  Point | Point light sources give off light equally in all directions, so require only position not direction.
  Directional | Directional lights simulate parallel light beams from a distant source, hence have direction but no position.
  Spotlight | Spotlights simulate a cone of light from a source so require position and direction, plus extra values for falloff.

## Constructor & Destructor Documentation

orxonox::Light::Light | ( | BaseObject * | creator | ) |

References orxonox::WorldEntity::attachOgreObject(), attenuation_, diffuse_, orxonox::WorldEntity::FRONT, orxonox::BaseObject::getScene(), orxonox::Scene::getSceneManager(), orxonox::getUniqueNumberString(), light_, Point, RegisterObject, registerVariables(), orxonox::GameMode::showsGraphics(), specular_, spotlightRange_, ThrowException, type_, updateAttenuation(), updateDiffuseColour(), updateSpecularColour(), updateSpotlightRange(), updateType(), orxonox::MT_Type::Vector3, and orxonox::MT_Type::Vector4.

orxonox::Light::~Light | ( |  | ) | `[virtual]`

References orxonox::BaseObject::getScene(), orxonox::Scene::getSceneManager(), orxonox::BaseObject::isInitialized(), and light_.

## Member Function Documentation

void orxonox::Light::changedVisibility | ( |  | ) | `[virtual]`

This function gets called if the visibility of the object changes.

Reimplemented from orxonox::BaseObject.

References orxonox::BaseObject::isVisible(), light_, and SUPER.

const Vector4& orxonox::Light::getAttenuation | ( |  | ) | const`[inline]`

Referenced by XMLPort().

const ColourValue& orxonox::Light::getDiffuseColour | ( |  | ) | const`[inline]`

Referenced by XMLPort().

Ogre::Light* orxonox::Light::getLight | ( |  | ) | `[inline]`

const ColourValue& orxonox::Light::getSpecularColour | ( |  | ) | const`[inline]`

Referenced by XMLPort().

const Vector3& orxonox::Light::getSpotlightRange | ( |  | ) | const`[inline]`

Referenced by XMLPort().

Light::LightTypes orxonox::Light::getType | ( |  | ) | const`[inline]`

std::string orxonox::Light::getTypeString | ( |  | ) | const`[private]`

References Directional, Point, Spotlight, and type_.

Referenced by XMLPort().

void orxonox::Light::registerVariables | ( |  | ) |

Reimplemented from orxonox::StaticEntity.

References attenuation_, diffuse_, orxonox::Synchronisable::registerVariable(), specular_, spotlightRange_, orxonox::VariableDirection::ToClient, type_, updateAttenuation(), updateDiffuseColour(), updateSpecularColour(), updateSpotlightRange(), and updateType().

Referenced by Light().

void orxonox::Light::setAttenuation | ( | const Vector4 & | attenuation | ) | `[inline]`

Sets the attenuation parameters of the light source i.e. how it diminishes with distance.

Parameters:

  | attenuation.x | range (The absolute upper range of the light in world units)
  | attenuation.y | constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation)
  | attenuation.z | linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance)
  | attenuation.w | quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula)

Quote from the Ogre API: Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects. Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity. This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here!

Quote from the Ogre wiki: "Using these numbers, the light has 100% intensity at 0 distance, and trails off to near black at a distance equal to the Range. Keep in mind that most of the light falls in the first 20% of the range."

Range Constant Linear Quadratic 3250, 1.0, 0.0014, 0.000007 600, 1.0, 0.007, 0.0002 325, 1.0, 0.014, 0.0007 200, 1.0, 0.022, 0.0019 160, 1.0, 0.027, 0.0028 100, 1.0, 0.045, 0.0075 65, 1.0, 0.07, 0.017 50, 1.0, 0.09, 0.032 32, 1.0, 0.14, 0.07 20, 1.0, 0.22, 0.20 13, 1.0, 0.35, 0.44 7, 1.0, 0.7, 1.8

Referenced by XMLPort().

void orxonox::Light::setDiffuseColour | ( | const ColourValue & | colour | ) | `[inline]`

Referenced by XMLPort().

void orxonox::Light::setSpecularColour | ( | const ColourValue & | colour | ) | `[inline]`

Referenced by XMLPort().

void orxonox::Light::setSpotlightRange | ( | const Vector3 & | spotlightRange | ) | `[inline]`

Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them.

Parameters:

  | spotlightRange.x | innerAngle (The angle covered by the bright inner cone)
  | spotlightRange.x | outerAngle (The angle covered by the outer cone)
  | spotlightRange.x | falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.)

Referenced by XMLPort().

virtual void orxonox::Light::setTeamColour | ( | const ColourValue & | colour | ) | `[inline, virtual]`

Implements orxonox::TeamColourable.

void orxonox::Light::setType | ( | Light::LightTypes | type | ) | `[inline]`

Referenced by setTypeString().

void orxonox::Light::setTypeString | ( | const std::string & | type | ) | `[private]`

References Directional, Point, setType(), and Spotlight.

Referenced by XMLPort().

void orxonox::Light::updateAttenuation | ( |  | ) | `[private]`

References attenuation_, Directional, light_, and type_.

Referenced by Light(), registerVariables(), and updateType().

void orxonox::Light::updateDiffuseColour | ( |  | ) | `[private]`

References diffuse_, and light_.

Referenced by Light(), and registerVariables().

void orxonox::Light::updateSpecularColour | ( |  | ) | `[private]`

References light_, and specular_.

Referenced by Light(), and registerVariables().

void orxonox::Light::updateSpotlightRange | ( |  | ) | `[private]`

References orxonox::MT_Type::Degree, light_, Spotlight, spotlightRange_, and type_.

Referenced by Light(), registerVariables(), and updateType().

void orxonox::Light::updateType | ( |  | ) | `[private]`

References Directional, light_, Spotlight, type_, updateAttenuation(), and updateSpotlightRange().

Referenced by Light(), and registerVariables().

void orxonox::Light::XMLPort | ( | Element & | xmlelement,
|  | XMLPort::Mode | mode |
| ) |  |  | `[virtual]`

XML loading and saving.

Parameters:

  | xmlelement | The XML-element
  | loading | Loading (true) or saving (false)

Returns:
  The XML-element

Reimplemented from orxonox::WorldEntity.

References getAttenuation(), getDiffuseColour(), getSpecularColour(), getSpotlightRange(), getTypeString(), setAttenuation(), setDiffuseColour(), setSpecularColour(), setSpotlightRange(), setTypeString(), SUPER, orxonox::MT_Type::Vector3, orxonox::MT_Type::Vector4, and XMLPortParam.

## Member Data Documentation

Vector4 orxonox::Light::attenuation_`[private]`

Referenced by Light(), registerVariables(), and updateAttenuation().

ColourValue orxonox::Light::diffuse_`[private]`

Referenced by Light(), registerVariables(), and updateDiffuseColour().

Ogre::Light* orxonox::Light::light_`[private]`

Referenced by changedVisibility(), Light(), updateAttenuation(), updateDiffuseColour(), updateSpecularColour(), updateSpotlightRange(), updateType(), and ~Light().

ColourValue orxonox::Light::specular_`[private]`

Referenced by Light(), registerVariables(), and updateSpecularColour().

Vector3 orxonox::Light::spotlightRange_`[private]`

Referenced by Light(), registerVariables(), and updateSpotlightRange().

LightTypes orxonox::Light::type_`[private]`

Referenced by getTypeString(), Light(), registerVariables(), updateAttenuation(), updateSpotlightRange(), and updateType().

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

- src/orxonox/objects/worldentities/Light.h
- src/orxonox/objects/worldentities/Light.cc