Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglPositionalLight Class Reference

#include <sglPositionalLight.hpp>

Inheritance diagram for sglPositionalLight::

sglLight sglNode sglObject sglSpotLight List of all members.

Public Methods

 sglPositionalLight ()
virtual ~sglPositionalLight ()
void setPosition (const sglVec3f &pos)
void getPosition (sglVec3f &pos) const
void setAttenuation (float constant, float linear, float quadratic)
void getAttenuation (float &constant, float &linear, float &quadratic) const
void setFalloff (float falloff)
float getFalloff () const
virtual void setup (GLenum gl_light_number) const
virtual sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Methods

virtual void computeBound ()
void copyTo (sglPositionalLight *dst, unsigned int mode) const

Protected Attributes

sglVec4f m_position
float m_attenuation_constant
float m_attenuation_linear
float m_attenuation_quadratic
float m_falloff_inverse

Detailed Description

sglPositionalLight is a subclass of sglLight that is given a position in 3D space which the user can specify with call to sglPositionalLight::setPosition(). The position specified is relative to this node's local coordinate system and is affected by matrix transformation nodes in the scene graph above this node.

Associated with a positional light are a set of attenuation parameters that cause the light to falloff with distance (controled using the sglPositionalLight::setAttenuation(..) function). The size of the bounding sphere for the light is computed with a radius that equals the distance to a certain amount of falloff in the light. The percentage of falloff to use in this calculation is configurable by the user using the setFalloff() function.

Example:

   sglPositionalLight *plite = new sglPositionalLight;
   plite->setPosition(sglVec3f(0., 0., 8.0f));
   plite->setDiffuse(0.f, 1.f, 0.f, 1.f);           // green light
   plite->setAmbient(0.25f, 0.25f, 0.25f, 1.f);     // gray ambient

   // enable automatic bounding sphere computation to 20% of light
   plite->setFalloff(0.2f);
   plite->setAttenuation(1.0f, 0.0f, 0.01f);

Definition at line 64 of file sglPositionalLight.hpp.


Constructor & Destructor Documentation

sglPositionalLight::sglPositionalLight ( )
 

default constructor.

sglPositionalLight::~sglPositionalLight ( ) [virtual]
 

virtual destructor.


Member Function Documentation

void sglPositionalLight::setPosition ( const sglVec3f & pos )
 

Set the light position. Default is (0, 0, 0)

Parameters:
pos   Vector containing the position of the light relative to the local coordinate system.

void sglPositionalLight::getPosition ( sglVec3f & pos ) const
 

Get the current light position.

Parameters:
pos   Reference to vector to be set to the current position.

void sglPositionalLight::setAttenuation ( float constant,
float linear,
float quadratic )
 

Set the OpenGL attenuation parameters where the attenuation factor is equal to 1/(constant + linear*distance + quadratic*distance*distance). Only non-negative values will be accepted.

Parameters:
constant   Constant attenuation factor (default is 1).
linear   Linear attenuation factor (default is 0).
quadratic   Quadratic attenuation factor (default is 0).

void sglPositionalLight::getAttenuation ( float & constant,
float & linear,
float & quadratic ) const
 

Query the current attenuation factors.

Parameters:
constant   Reference to variable that will be set with the constant attenuation factor.
linear   Reference to variable that will be set with the linear attenuation factor.
quadratic   Reference to variable that will be set with the quadratic attenuation factor.

void sglPositionalLight::setFalloff ( float falloff )
 

Set the falloff threshold for computing a dynamic bounding sphere for this light. The radius of the sphere will equal the distance to where the light falls off to the value specified here. This will only go into effect if eDYNAMIC bounding sphere computation is selected.

Parameters:
falloff   A percentage greater than 0. The default is 0.2 (20 percent).

float sglPositionalLight::getFalloff ( ) const [inline]
 

Query the current falloff percentage.

Returns:
The current falloff threshold.

Definition at line 114 of file sglPositionalLight.hpp.

virtual void sglPositionalLight::setup ( GLenum gl_light_number ) const [virtual]
 

This function is called during sglCull::draw() function to issue the OpenGL light commands needed to activate this light before rendering.

Parameters:
gl_light_number   One of GL_LIGHT0 .. GL_LIGHT<sgl::s_max_lights-1>

Reimplemented from sglLight.

Reimplemented in sglSpotLight.

virtual sglNode* sglPositionalLight::clone ( unsigned int mode ) const [virtual]
 

Make a copy of the scenegraph rooted at this node.

Parameters:
mode   Bit masks to control the behaviour of the clone. These are OR-ed together from the mode values in sglObject::CloneModeEnum.
Returns:
Pointer to root of cloned scene graph.

Reimplemented from sglNode.

Reimplemented in sglSpotLight.

virtual void sglPositionalLight::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]
 

Output the state of this node to the specified ostream.

Parameters:
ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglLight.

Reimplemented in sglSpotLight.


The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:09 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001