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

sglSpotLight Class Reference

#include <sglSpotLight.hpp>

Inheritance diagram for sglSpotLight::

sglPositionalLight sglLight sglNode sglObject List of all members.

Public Methods

 sglSpotLight ()
virtual ~sglSpotLight ()
void setDirection (const sglVec3f &dir)
const sglVec3f& getDirection () const
void setCutoff (float cutoff)
float getCutoff () const
void setExponent (float exponent)
float getExponent () 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

void copyTo (sglSpotLight *dst, unsigned int mode) const

Protected Attributes

sglVec3f m_direction
float m_exponent
float m_cutoff

Detailed Description

The sglSpotLight class is a subclass of sglPositionalLight that allows the user to project a cone of light onto the geometry. In addition to the sglLight and sglPositionalLight functionality, the direction of the spotlight (relative to the local coordinate system) can be set with a call to sglSpotLight::setDirection(); the angle of the cone is set with a call to sglSpotlight::setCutoff() where the argument is between 0 and 0.5*M_PI radians (90 degrees); and the intensity is set with a call to sglSpotLight::setExponent() where the argument must be greater than or equal to zero.

The following example, configures a spotlight to be positioned along the +Z axis and shine back along the -Z axis. The width of the cone is 45 degrees (actually 90 degrees total), and the exponent (intensity) is set to 3.0:


   sglSpotLight *spot = new sglSpotLight;
   spot->setDiffuse(0.f, 0.f, 1.f, 1.f);        // blue light
   spot->setPosition(sglVec3f(0., 0., 7.0f));   // move out along +Z axis
   spot->setDirection(sglVec3f(0., 0., -1.0f)); // point along -Z axis
   spot->setCutoff(M_PI*0.25f);                 // 45 degrees

Definition at line 60 of file sglSpotLight.hpp.

Constructor & Destructor Documentation

sglSpotLight::sglSpotLight ( )

default constructor.

sglSpotLight::~sglSpotLight ( ) [virtual]

virtual destuctor.

Member Function Documentation

void sglSpotLight::setDirection ( const sglVec3f & dir )

Set the direction of the spot light. The default is (0, 0, -1).

dir   The direction. It does not need to be normalized, but its length must be non-zero.

const sglVec3f & sglSpotLight::getDirection ( ) const [inline]

Query the current direction of the spot light.

The current direction normalized.

Definition at line 77 of file sglSpotLight.hpp.

void sglSpotLight::setCutoff ( float cutoff )

Set the half-width of the spot light

cutoff   Angle in radians of half the "spread" of the spot. Valid values fall between 0 and PI/2, inclusive.

float sglSpotLight::getCutoff ( ) const [inline]

Query the current cutoff angle.

Cutoff angle

Definition at line 88 of file sglSpotLight.hpp.

void sglSpotLight::setExponent ( float exponent )

Control the concentration of the spot light.

exponent   The higher the value the more focused the light. Only non-negative values are valid. The default value is 0.

float sglSpotLight::getExponent ( ) const [inline]

Query the current exponent value.

The current exponent.

Definition at line 99 of file sglSpotLight.hpp.

virtual void sglSpotLight::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.

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

Reimplemented from sglPositionalLight.

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

Make a copy of the scenegraph rooted at this node.

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

Reimplemented from sglPositionalLight.

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

Output the state of this node to the specified ostream.

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 sglPositionalLight.

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