# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CPointLight Class Reference

Description of a light. More...

#include <point_light.h>

Inheritance diagram for NL3D::CPointLight:

NL3D::CPointLightNamed List of all members.

Public Types

typedef NLMISC::CSTLBlockList<
CTransform * > 
TTransformList
 The list of model this light influence. More...

typedef TTransformList::iterator ItTransformList
enum  TType { PointLight = 0, SpotLight, AmbientLight }

Public Methods

 CPointLight ()
 Constructor Default type is PointLight. More...

 ~CPointLight ()
 call resetLightModels. More...

Light setup
void setType (TType type)
 set/get the type of the light. More...

TType getType () const
void setPosition (const CVector &v)
 Set the position in WorldSpace. More...

const CVector & getPosition () const
 Get the position in WorldSpace. More...

void setAmbient (NLMISC::CRGBA ambient)
 Set the ambient color of the light. Default to Black. More...

void setDiffuse (NLMISC::CRGBA diffuse)
 Set the diffuse color of the light. Default to White. More...

void setSpecular (NLMISC::CRGBA specular)
 Set the specular color of the light. Default to White. More...

void setColor (NLMISC::CRGBA color)
 Set the diffuse and specular color of the light to the same value. don't modify _Ambient. More...

NLMISC::CRGBA getAmbient () const
 Get the ambient color of the light. More...

NLMISC::CRGBA getDiffuse () const
 Get the diffuse color of the light. More...

NLMISC::CRGBA getSpecular () const
 Get the specular color of the light. More...

void setupAttenuation (float attenuationBegin, float attenuationEnd)
 setup the attenuation of the light. More...

float getAttenuationBegin () const
 get the begin radius of the attenuation. More...

float getAttenuationEnd () const
 get the end radius of the attenuation. More...

void setupSpotAngle (float spotAngleBegin, float spotAngleEnd)
 setup the spot AngleBegin and AngleEnd that define spot attenuation of the light. More...

float getSpotAngleBegin () const
 get the begin radius of the SpotAngles. More...

float getSpotAngleEnd () const
 get the end radius of the SpotAngles. More...

void setupSpotDirection (const CVector &dir)
 setup the spot Direction. More...

const CVector & getSpotDirection () const
 get the spot Direction. More...

void serial (NLMISC::IStream &f)
Render tools.
float computeLinearAttenuation (const CVector &pos) const
 Compute a linear attenuation from a point according to attenuation and spot setup. Return [0,1]. More...

float computeLinearAttenuation (const CVector &pos, float precomputedDist, float modelRadius=0) const
 Compute a linear attenuation from a point and precomputed distance according to attenuation and spot setup. More...

void setupDriverLight (CLight &light, uint8 factor)
 setup the CLight with current pointLight state. factor is used to modulate the colors. More...

void setupDriverLightUserAttenuation (CLight &light, uint8 factor)
 setup the CLight with current pointLight state. More...

void resetLightedModels ()
 Dirt all models this light influence. More...

ItTransformList appendLightedModel (CTransform *model)
 append a model to the list. called by CLightingManager. More...

void removeLightedModel (ItTransformList it)
 remove a model from the list. called by CTransform. More...


Private Methods

void computeAttenuationFactors ()
void computeSpotAttenuationFactors ()

Private Attributes

TType _Type
CVector _Position
NLMISC::CRGBA _Ambient
NLMISC::CRGBA _Diffuse
NLMISC::CRGBA _Specular
float _AttenuationBegin
float _AttenuationEnd
float _OODeltaAttenuation
float _ConstantAttenuation
float _LinearAttenuation
float _QuadraticAttenuation
CVector _SpotDirection
float _SpotAngleBegin
float _SpotAngleEnd
float _CosSpotAngleEnd
float _OOCosSpotAngleDelta
float _SpotExponent
TTransformList _LightedModels

Static Private Attributes

NLMISC::CBlockMemory< CTransform *,
false > 
_LightedModelListMemory

Detailed Description

Description of a light.

Owned by an IG, or a CPointLightModel. With the special sunLight, this is the only light which can interact with CTransform models in the standard lighting system.

Only Positionnal with or without attenuation are supported. no directionnal. This restriction is for faster rendering, especially if VertexProgram is used. New: Spot are managed but VertexProgrammed meshes won't use localAttenuation. Special Ambiant are provided too but they are considered like PointLight for dynamic light. They are used in a special way for static light in Igs.

Author:
Lionel Berenguier , Nevrax France
Date:
2001
See also:
CLightingManager

Definition at line 69 of file point_light.h.


Member Typedef Documentation

typedef TTransformList::iterator NL3D::CPointLight::ItTransformList
 

Definition at line 74 of file point_light.h.

Referenced by appendLightedModel.

typedef NLMISC::CSTLBlockList<CTransform*> NL3D::CPointLight::TTransformList
 

The list of model this light influence.

Definition at line 73 of file point_light.h.


Member Enumeration Documentation

enum NL3D::CPointLight::TType
 

Enumeration values:
PointLight 
SpotLight 
AmbientLight 

Definition at line 76 of file point_light.h.


Constructor & Destructor Documentation

NL3D::CPointLight::CPointLight  
 

Constructor Default type is PointLight.

Default ambient is Black, Diffuse and Specular are white. Position is CVector::Null. Attenuation is 10-30.

Definition at line 46 of file point_light.cpp.

References _Ambient, _AttenuationBegin, _AttenuationEnd, _ConstantAttenuation, _CosSpotAngleEnd, _Diffuse, _LinearAttenuation, _OOCosSpotAngleDelta, _Position, _QuadraticAttenuation, _Specular, _SpotAngleBegin, _SpotAngleEnd, _SpotDirection, _SpotExponent, computeAttenuationFactors, and computeSpotAttenuationFactors.

NL3D::CPointLight::~CPointLight  
 

call resetLightModels.

Definition at line 92 of file point_light.cpp.

References resetLightedModels.


Member Function Documentation

CPointLight::ItTransformList NL3D::CPointLight::appendLightedModel CTransform   model
 

append a model to the list. called by CLightingManager.

Definition at line 374 of file point_light.cpp.

References _LightedModels, and ItTransformList.

void NL3D::CPointLight::computeAttenuationFactors   [private]
 

Definition at line 145 of file point_light.cpp.

References _AttenuationBegin, _AttenuationEnd, _ConstantAttenuation, _LinearAttenuation, _OODeltaAttenuation, and _QuadraticAttenuation.

Referenced by CPointLight, serial, and setupAttenuation.

float NL3D::CPointLight::computeLinearAttenuation const CVector &    pos,
float    precomputedDist,
float    modelRadius = 0
const
 

Compute a linear attenuation from a point and precomputed distance according to attenuation and spot setup.

Return [0,1]

Parameters:
modelRadius  if !0, suppose the point is a sphere, and compute the approximate Max attenuation from every point on this sphere

Definition at line 238 of file point_light.cpp.

References _AttenuationBegin, _AttenuationEnd, _CosSpotAngleEnd, _OOCosSpotAngleDelta, _OODeltaAttenuation, _Position, _SpotDirection, _Type, NLMISC::clamp, SpotLight, and NLMISC::sqr.

float NL3D::CPointLight::computeLinearAttenuation const CVector &    pos const
 

Compute a linear attenuation from a point according to attenuation and spot setup. Return [0,1].

Definition at line 232 of file point_light.cpp.

References _Position.

void NL3D::CPointLight::computeSpotAttenuationFactors   [private]
 

Definition at line 175 of file point_light.cpp.

References _CosSpotAngleEnd, _OOCosSpotAngleDelta, _SpotAngleBegin, _SpotAngleEnd, and _SpotExponent.

Referenced by CPointLight, serial, and setupSpotAngle.

NLMISC::CRGBA NL3D::CPointLight::getAmbient   const [inline]
 

Get the ambient color of the light.

Definition at line 125 of file point_light.h.

References _Ambient.

Referenced by NL3D::CPointLightNamed::CPointLightNamed.

float NL3D::CPointLight::getAttenuationBegin   const [inline]
 

get the begin radius of the attenuation.

Definition at line 137 of file point_light.h.

References _AttenuationBegin.

float NL3D::CPointLight::getAttenuationEnd   const [inline]
 

get the end radius of the attenuation.

Definition at line 139 of file point_light.h.

References _AttenuationEnd.

NLMISC::CRGBA NL3D::CPointLight::getDiffuse   const [inline]
 

Get the diffuse color of the light.

Definition at line 127 of file point_light.h.

References _Diffuse.

Referenced by NL3D::CPointLightNamed::CPointLightNamed.

const CVector& NL3D::CPointLight::getPosition   const [inline]
 

Get the position in WorldSpace.

Definition at line 112 of file point_light.h.

References _Position.

NLMISC::CRGBA NL3D::CPointLight::getSpecular   const [inline]
 

Get the specular color of the light.

Definition at line 129 of file point_light.h.

References _Specular.

Referenced by NL3D::CPointLightNamed::CPointLightNamed.

float NL3D::CPointLight::getSpotAngleBegin   const [inline]
 

get the begin radius of the SpotAngles.

Definition at line 147 of file point_light.h.

References _SpotAngleBegin.

float NL3D::CPointLight::getSpotAngleEnd   const [inline]
 

get the end radius of the SpotAngles.

Definition at line 149 of file point_light.h.

References _SpotAngleEnd.

const CVector& NL3D::CPointLight::getSpotDirection   const [inline]
 

get the spot Direction.

Definition at line 157 of file point_light.h.

References _SpotDirection.

CPointLight::TType NL3D::CPointLight::getType   const
 

Definition at line 103 of file point_light.cpp.

References _Type.

void NL3D::CPointLight::removeLightedModel ItTransformList    it
 

remove a model from the list. called by CTransform.

Definition at line 383 of file point_light.cpp.

References _LightedModels.

void NL3D::CPointLight::resetLightedModels  
 

Dirt all models this light influence.

Definition at line 358 of file point_light.cpp.

References _LightedModels, and nlassert.

Referenced by ~CPointLight.

void NL3D::CPointLight::serial NLMISC::IStream   f
 

Reimplemented in NL3D::CPointLightNamed.

Definition at line 195 of file point_light.cpp.

References _Ambient, _AttenuationBegin, _AttenuationEnd, _Diffuse, _Position, _Specular, _SpotAngleBegin, _SpotAngleEnd, _SpotDirection, _Type, computeAttenuationFactors, computeSpotAttenuationFactors, NLMISC::IStream::isReading, PointLight, NLMISC::IStream::serial, NLMISC::IStream::serialEnum, and NLMISC::IStream::serialVersion.

void NL3D::CPointLight::setAmbient NLMISC::CRGBA    ambient [inline]
 

Set the ambient color of the light. Default to Black.

Definition at line 116 of file point_light.h.

References _Ambient.

Referenced by NL3D::CPointLightNamed::setLightFactor.

void NL3D::CPointLight::setColor NLMISC::CRGBA    color [inline]
 

Set the diffuse and specular color of the light to the same value. don't modify _Ambient.

Definition at line 122 of file point_light.h.

References _Diffuse, and _Specular.

void NL3D::CPointLight::setDiffuse NLMISC::CRGBA    diffuse [inline]
 

Set the diffuse color of the light. Default to White.

Definition at line 118 of file point_light.h.

References _Diffuse.

Referenced by NL3D::CPointLightNamed::setLightFactor.

void NL3D::CPointLight::setPosition const CVector &    v [inline]
 

Set the position in WorldSpace.

Definition at line 110 of file point_light.h.

References _Position, and v.

void NL3D::CPointLight::setSpecular NLMISC::CRGBA    specular [inline]
 

Set the specular color of the light. Default to White.

Definition at line 120 of file point_light.h.

References _Specular.

Referenced by NL3D::CPointLightNamed::setLightFactor.

void NL3D::CPointLight::setType TType    type
 

set/get the type of the light.

Definition at line 99 of file point_light.cpp.

References _Type, and type.

void NL3D::CPointLight::setupAttenuation float    attenuationBegin,
float    attenuationEnd
 

setup the attenuation of the light.

if (0,0) attenuation is disabled. clamp(attenuationBegin,0 , +oo) and calmp(attenuationEnd, attenuationBegin, +oo)

Definition at line 109 of file point_light.cpp.

References _AttenuationBegin, _AttenuationEnd, and computeAttenuationFactors.

void NL3D::CPointLight::setupDriverLight CLight   light,
uint8    factor
 

setup the CLight with current pointLight state. factor is used to modulate the colors.

Definition at line 311 of file point_light.cpp.

References _Ambient, _ConstantAttenuation, _Diffuse, _LinearAttenuation, _Position, _QuadraticAttenuation, _Specular, _SpotDirection, _SpotExponent, _Type, and SpotLight.

void NL3D::CPointLight::setupDriverLightUserAttenuation CLight   light,
uint8    factor
 

setup the CLight with current pointLight state.

Don't use driver Attenuation and use software one setuped with an additional userAttenuation

Parameters:
factor  is used to modulate the colors. Should also integrate light attenuation.

Definition at line 339 of file point_light.cpp.

References _Ambient, _Diffuse, _Position, and _Specular.

void NL3D::CPointLight::setupSpotAngle float    spotAngleBegin,
float    spotAngleEnd
 

setup the spot AngleBegin and AngleEnd that define spot attenuation of the light.

Usefull only if SpotLight NB: clamp(angleBegin, 0, PI); clamp(angleEnd, angleBegin, PI); Default is PI/4, PI/2

Definition at line 124 of file point_light.cpp.

References _SpotAngleBegin, _SpotAngleEnd, NLMISC::clamp, computeSpotAttenuationFactors, and NLMISC::Pi.

void NL3D::CPointLight::setupSpotDirection const CVector &    dir
 

setup the spot Direction.

Usefull only if SpotLight. Normalized internally Default is (0, 1, 0)

Definition at line 137 of file point_light.cpp.

References _SpotDirection.


Member Data Documentation

NLMISC::CRGBA NL3D::CPointLight::_Ambient [private]
 

Definition at line 210 of file point_light.h.

Referenced by CPointLight, getAmbient, serial, setAmbient, setupDriverLight, and setupDriverLightUserAttenuation.

float NL3D::CPointLight::_AttenuationBegin [private]
 

Definition at line 215 of file point_light.h.

Referenced by computeAttenuationFactors, computeLinearAttenuation, CPointLight, getAttenuationBegin, serial, and setupAttenuation.

float NL3D::CPointLight::_AttenuationEnd [private]
 

Definition at line 215 of file point_light.h.

Referenced by computeAttenuationFactors, computeLinearAttenuation, CPointLight, getAttenuationEnd, serial, and setupAttenuation.

float NL3D::CPointLight::_ConstantAttenuation [private]
 

Definition at line 217 of file point_light.h.

Referenced by computeAttenuationFactors, CPointLight, and setupDriverLight.

float NL3D::CPointLight::_CosSpotAngleEnd [private]
 

Definition at line 225 of file point_light.h.

Referenced by computeLinearAttenuation, computeSpotAttenuationFactors, and CPointLight.

NLMISC::CRGBA NL3D::CPointLight::_Diffuse [private]
 

Definition at line 211 of file point_light.h.

Referenced by CPointLight, getDiffuse, serial, setColor, setDiffuse, setupDriverLight, and setupDriverLightUserAttenuation.

NLMISC::CBlockMemory< CTransform *, false > NL3D::CPointLight::_LightedModelListMemory [static, private]
 

TTransformList NL3D::CPointLight::_LightedModels [private]
 

Definition at line 234 of file point_light.h.

Referenced by appendLightedModel, removeLightedModel, and resetLightedModels.

float NL3D::CPointLight::_LinearAttenuation [private]
 

Definition at line 218 of file point_light.h.

Referenced by computeAttenuationFactors, CPointLight, and setupDriverLight.

float NL3D::CPointLight::_OOCosSpotAngleDelta [private]
 

Definition at line 227 of file point_light.h.

Referenced by computeLinearAttenuation, computeSpotAttenuationFactors, and CPointLight.

float NL3D::CPointLight::_OODeltaAttenuation [private]
 

Definition at line 216 of file point_light.h.

Referenced by computeAttenuationFactors, and computeLinearAttenuation.

CVector NL3D::CPointLight::_Position [private]
 

Definition at line 207 of file point_light.h.

Referenced by computeLinearAttenuation, CPointLight, getPosition, serial, setPosition, setupDriverLight, and setupDriverLightUserAttenuation.

float NL3D::CPointLight::_QuadraticAttenuation [private]
 

Definition at line 219 of file point_light.h.

Referenced by computeAttenuationFactors, CPointLight, and setupDriverLight.

NLMISC::CRGBA NL3D::CPointLight::_Specular [private]
 

Definition at line 212 of file point_light.h.

Referenced by CPointLight, getSpecular, serial, setColor, setSpecular, setupDriverLight, and setupDriverLightUserAttenuation.

float NL3D::CPointLight::_SpotAngleBegin [private]
 

Definition at line 223 of file point_light.h.

Referenced by computeSpotAttenuationFactors, CPointLight, getSpotAngleBegin, serial, and setupSpotAngle.

float NL3D::CPointLight::_SpotAngleEnd [private]
 

Definition at line 224 of file point_light.h.

Referenced by computeSpotAttenuationFactors, CPointLight, getSpotAngleEnd, serial, and setupSpotAngle.

CVector NL3D::CPointLight::_SpotDirection [private]
 

Definition at line 222 of file point_light.h.

Referenced by computeLinearAttenuation, CPointLight, getSpotDirection, serial, setupDriverLight, and setupSpotDirection.

float NL3D::CPointLight::_SpotExponent [private]
 

Definition at line 228 of file point_light.h.

Referenced by computeSpotAttenuationFactors, CPointLight, and setupDriverLight.

TType NL3D::CPointLight::_Type [private]
 

Definition at line 204 of file point_light.h.

Referenced by computeLinearAttenuation, getType, serial, setType, and setupDriverLight.


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