From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03091.html | 2413 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2413 insertions(+) create mode 100644 docs/doxygen/nel/a03091.html (limited to 'docs/doxygen/nel/a03091.html') diff --git a/docs/doxygen/nel/a03091.html b/docs/doxygen/nel/a03091.html new file mode 100644 index 00000000..41a7d90e --- /dev/null +++ b/docs/doxygen/nel/a03091.html @@ -0,0 +1,2413 @@ + + +NeL: NL3D::CPointLight class Reference + + + +
+

NL3D::CPointLight Class Reference

#include <point_light.h> +

+

Inheritance diagram for NL3D::CPointLight: +

+ +NL3D::CPointLightNamed + +

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

Light setup

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

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

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

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

const CVectorgetPosition () const
 Get the position in WorldSpace.

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

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

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

const CVectorgetSpotDirection () const
 get the spot Direction

TType getType () const
 Get the ambient color of the light.

void serial (NLMISC::IStream &f)
 Get the ambient color of the light.

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

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

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

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

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

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

void setupAttenuation (float attenuationBegin, float attenuationEnd)
void setupSpotAngle (float spotAngleBegin, float spotAngleEnd)
void setupSpotDirection (const CVector &dir)

Public Types

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

enum  TType { PointLight = 0, +SpotLight, +AmbientLight + }

Public Member Functions

 CPointLight (const CPointLight &o)
 do not copy _LightedModels.

 CPointLight ()
CPointLightoperator= (const CPointLight &o)
 do not copy _LightedModels.

 ~CPointLight ()
 call resetLightModels.


Static Public Member Functions

void purge ()

Private Member Functions

void computeAttenuationFactors ()
void computeSpotAttenuationFactors ()

Private Attributes

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

Static Private Attributes

NLMISC::CBlockMemory< CTransform *,
+ false > 
_LightedModelListMemory
+


Member Typedef Documentation

+

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

+ +

+Definition at line 74 of file point_light.h. +

+Referenced by appendLightedModel(), and removeLightedModel().

+

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

+

00077         {
+00078                 // The light is a point.
+00079                 PointLight= 0, 
+00080 
+00081                 // The light is a spotlight with a cone.
+00082                 SpotLight,
+00083 
+00084                 // The light is an Ambient PointLight in an Ig.
+00085                 AmbientLight
+00086         };
+
+


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 _AttenuationBegin, _AttenuationEnd, _CosSpotAngleEnd, _OOCosSpotAngleDelta, _SpotAngleBegin, _SpotAngleEnd, _SpotDirection, _SpotExponent, computeAttenuationFactors(), computeSpotAttenuationFactors(), and NLMISC::CVector::set(). +

+

00046                          : _LightedModels(&_LightedModelListMemory)
+00047 {
+00048         _Position= CVector::Null;
+00049         _Ambient= CRGBA::Black;
+00050         _Diffuse= _Specular= CRGBA::White;
+00051 
+00052         // Default setup. this is arbitrary
+00053         _AttenuationBegin= 10;
+00054         _AttenuationEnd= 30;
+00055 
+00056         // Default spot setup. this is arbitrary
+00057         _SpotDirection.set(0,1,0);
+00058         _SpotAngleBegin= float(NLMISC::Pi/4);
+00059         _SpotAngleEnd= float(NLMISC::Pi/2);
+00060 
+00061         // compute AttenuationFactors only one time.
+00062         static  bool    done= false;
+00063         static  float   cAtt, lAtt, qAtt;
+00064         static  float   spotCOOD, spotCAE, spotEXP;
+00065         if(!done)
+00066         {
+00067                 done= true;
+00068                 computeAttenuationFactors();
+00069                 computeSpotAttenuationFactors();
+00070                 // bkup setup.
+00071                 cAtt= _ConstantAttenuation;
+00072                 lAtt= _LinearAttenuation;
+00073                 qAtt= _QuadraticAttenuation;
+00074                 spotCAE= _CosSpotAngleEnd;
+00075                 spotCOOD= _OOCosSpotAngleDelta;
+00076                 spotEXP= _SpotExponent;
+00077         }
+00078         else
+00079         {
+00080                 // just copy bkuped setup.
+00081                 _ConstantAttenuation= cAtt;
+00082                 _LinearAttenuation= lAtt;
+00083                 _QuadraticAttenuation= qAtt;
+00084                 _CosSpotAngleEnd= spotCAE;
+00085                 _OOCosSpotAngleDelta= spotCOOD;
+00086                 _SpotExponent= spotEXP;
+00087         }
+00088 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CPointLight::~CPointLight  ) 
+
+ + + + + +
+   + + +

+call resetLightModels. +

+ +

+Definition at line 127 of file point_light.cpp. +

+References resetLightedModels(). +

+

00128 {
+00129         resetLightedModels();
+00130 }
+
+

+ + + + +
+ + + + + + + + + + +
NL3D::CPointLight::CPointLight const CPointLight o  ) 
+
+ + + + + +
+   + + +

+do not copy _LightedModels. +

+ +

+Definition at line 92 of file point_light.cpp. +

+References operator=(). +

+

00092                                              : _LightedModels(&_LightedModelListMemory)
+00093 {
+00094         // copy (no need to init)
+00095         operator=(o);
+00096 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
CPointLight::ItTransformList NL3D::CPointLight::appendLightedModel CTransform model  ) 
+
+ + + + + +
+   + + +

+append a model to the list. called by CLightingManager. +

+ +

+Definition at line 409 of file point_light.cpp. +

+References _LightedModels, and ItTransformList. +

+Referenced by NL3D::CLightingManager::computeModelLightContributions(). +

+

00410 {
+00411         // append the entry in the list
+00412         _LightedModels.push_back(model);
+00413         ItTransformList it= _LightedModels.end();
+00414         it--;
+00415         return it;
+00416 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPointLight::computeAttenuationFactors  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 180 of file point_light.cpp. +

+References _AttenuationBegin, _AttenuationEnd, _OODeltaAttenuation, NL3D::CLight::getConstantAttenuation(), NL3D::CLight::getLinearAttenuation(), NL3D::CLight::getQuadraticAttenuation(), and NL3D::CLight::setupAttenuation(). +

+Referenced by CPointLight(), serial(), and setupAttenuation(). +

+

00181 {
+00182         // disable attenuation?
+00183         if(_AttenuationBegin==0 && _AttenuationEnd==0)
+00184         {
+00185                 // setup for attenuation disabled.
+00186                 _ConstantAttenuation= 1;
+00187                 _LinearAttenuation= 0;
+00188                 _QuadraticAttenuation= 0;
+00189         }
+00190         else
+00191         {
+00192                 // precompute attenuation values, with help of CLight formula!!
+00193                 static  CLight  dummyLight;
+00194                 dummyLight.setupAttenuation(_AttenuationBegin, _AttenuationEnd);
+00195                 _ConstantAttenuation= dummyLight.getConstantAttenuation();
+00196                 _LinearAttenuation= dummyLight.getLinearAttenuation();
+00197                 _QuadraticAttenuation= dummyLight.getQuadraticAttenuation();
+00198 
+00199                 // setup _OODeltaAttenuation
+00200                 _OODeltaAttenuation= _AttenuationEnd - _AttenuationBegin;
+00201                 if(_OODeltaAttenuation <=0 )
+00202                         _OODeltaAttenuation= 0;
+00203                 else
+00204                         _OODeltaAttenuation= 1.0f / _OODeltaAttenuation;
+00205         }
+00206 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
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 273 of file point_light.cpp. +

+References _AttenuationBegin, _AttenuationEnd, _CosSpotAngleEnd, _OOCosSpotAngleDelta, _OODeltaAttenuation, _SpotDirection, NLMISC::clamp(), and NLMISC::sqr(). +

+

00274 {
+00275         float   gAtt;
+00276 
+00277         // Attenuation Distance
+00278         if(_AttenuationEnd==0)
+00279                 gAtt= 1;
+00280         else
+00281         {
+00282                 float   distMinusRadius= dist - modelRadius;
+00283                 if(distMinusRadius<_AttenuationBegin)
+00284                         gAtt= 1;
+00285                 else if(distMinusRadius<_AttenuationEnd)
+00286                 {
+00287                         gAtt= (_AttenuationEnd - distMinusRadius) * _OODeltaAttenuation;
+00288                 }
+00289                 else
+00290                         gAtt= 0;
+00291         }
+00292 
+00293         // Spot Attenuation
+00294         if(_Type== SpotLight)
+00295         {
+00296                 float   spotAtt;
+00297 
+00298                 // Compute unnormalized direction
+00299                 CVector dir= pos - _Position;
+00300                 // get cosAngle(dir, SpotDirection):
+00301                 float   cosAngleDirSpot= (dir*_SpotDirection) / dist;
+00302 
+00303                 // Modify with modelRadius. NB: made Only for big models.
+00304                 if(modelRadius>0)
+00305                 {
+00306                         // If the pointLight is in the model, consider no spotAtt
+00307                         if(modelRadius > dist)
+00308                                 spotAtt= 1;
+00309                         else
+00310                         {
+00311                                 // compute the angle of the cone made by the model sphere and the pointLightCenter.
+00312                                 float   cosAngleSphere= modelRadius / sqrtf( sqr(dist) + sqr(modelRadius) ); 
+00313                                 /* If this one is smaller than cosAngleDirSpot, it's mean that the angle of this cone is greater than the 
+00314                                         angleDirSpot, hence a part of the sphere "ps" exist such that _SportDirection*(ps-_Position).normed() == 1
+00315                                         => no spotAttenuation
+00316                                 */
+00317                                 if(cosAngleSphere < cosAngleDirSpot)
+00318                                         spotAtt= 1;
+00319                                 else
+00320                                 {
+00321                                         // Must compute cos( AngleDirSpot-AngleSphere )
+00322                                         float   sinAngleSphere= sqrtf(1 - sqr(cosAngleSphere));
+00323                                         float   sinAngleDirSpot= sqrtf(1 - sqr(cosAngleDirSpot));
+00324                                         float   cosDelta= cosAngleSphere * cosAngleDirSpot + sinAngleSphere * sinAngleDirSpot;
+00325 
+00326                                         // spot attenuation on the exterior of the sphere
+00327                                         spotAtt= (cosDelta - _CosSpotAngleEnd) * _OOCosSpotAngleDelta;
+00328                                 }
+00329                         }
+00330                 }
+00331                 else
+00332                 {
+00333                         // spot attenuation
+00334                         spotAtt= (cosAngleDirSpot - _CosSpotAngleEnd) * _OOCosSpotAngleDelta;
+00335                 }
+00336 
+00337                 // modulate
+00338                 clamp(spotAtt, 0.f, 1.f);
+00339                 gAtt*= spotAtt;
+00340         }
+00341 
+00342         return gAtt;
+00343 }
+
+

+ + + + +
+ + + + + + + + + + +
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 267 of file point_light.cpp. +

+Referenced by NL3D::CLightingManager::computeModelLightContributions(), NL3D::CPatch::generateTileVegetable(), NL3D::CZoneLighter::processZonePointLightRT(), NL3D::CZoneLighter::CPointLightRT::testRaytrace(), NL3D::CInstanceLighter::CPointLightRT::testRaytrace(), and NL3D::CTransform::traverseLight(). +

+

00268 {
+00269         return computeLinearAttenuation(pos, (pos - _Position).norm() );
+00270 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPointLight::computeSpotAttenuationFactors  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 210 of file point_light.cpp. +

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

+Referenced by CPointLight(), serial(), and setupSpotAngle(). +

+

00211 {
+00212         // Factors for linear Attenuation.
+00213         float   cosSpotAngleBegin= (float)cosf(_SpotAngleBegin);
+00214         _CosSpotAngleEnd= (float)cos(_SpotAngleEnd);
+00215         if(cosSpotAngleBegin - _CosSpotAngleEnd > 0)
+00216                 _OOCosSpotAngleDelta= 1.0f / (cosSpotAngleBegin - _CosSpotAngleEnd);
+00217         else
+00218                 _OOCosSpotAngleDelta= 1e10f;
+00219 
+00220         // compute an exponent such that at middleAngle, att is 0.5f.
+00221         float   caMiddle= (cosSpotAngleBegin + _CosSpotAngleEnd) /2;
+00222         float divid=(float)log (caMiddle);
+00223         if (divid==0.f)
+00224                 divid=0.0001f;
+00225         _SpotExponent= (float)(log (0.5)/divid);
+00226 }
+
+

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

+Get the ambient color of the light. +

+ +

+Definition at line 129 of file point_light.h. +

+Referenced by NL3D::CLightContribution::computeCurrentAmbient(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CPointLightNamed::CPointLightNamed(), NL3D::CPointLightUser::getAmbient(), and NL3D::CSurfaceLightGrid::getStaticLightSetup(). +

+

00129 {return _Ambient;}
+
+

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

+get the begin radius of the attenuation. +

+ +

+Definition at line 141 of file point_light.h. +

+References _AttenuationBegin. +

+Referenced by NL3D::CZoneLighter::addStaticPointLight(), NL3D::CInstanceLighter::addStaticPointLight(), NL3D::CPatchDLMPointLight::compile(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CPointLightUser::getAttenuationBegin(), and NL3D::CPSLight::step(). +

+

00141 {return _AttenuationBegin;}
+
+

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

+get the end radius of the attenuation. +

+ +

+Definition at line 143 of file point_light.h. +

+References _AttenuationEnd. +

+Referenced by NL3D::CLightingManager::addDynamicLight(), NL3D::CZoneLighter::addStaticPointLight(), NL3D::CInstanceLighter::addStaticPointLight(), NL3D::CPatchDLMPointLight::compile(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CPointLightUser::getAttenuationEnd(), NL3D::CZoneLighter::CPredPointLightToPoint::operator()(), NL3D::CInstanceLighter::CPredPointLightToPoint::operator()(), and NL3D::CPSLight::step(). +

+

00143 {return _AttenuationEnd;}
+
+

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

+Get the diffuse color of the light. +

+ +

+Definition at line 131 of file point_light.h. +

+Referenced by NL3D::CPatchDLMPointLight::compile(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CShadowMapManager::computeShadowColors(), NL3D::CShadowMapManager::computeShadowDirection(), NL3D::CPointLightNamed::CPointLightNamed(), NL3D::CPointLightUser::getDiffuse(), NL3D::CSkeletonModel::renderCLod(), NL3D::CPointLightNamed::serial(), NL3D::CPSLight::step(), and NL3D::CParticleSystemModel::traverseRender(). +

+

00131 {return _Diffuse;}
+
+

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

+Get the position in WorldSpace. +

+ +

+Definition at line 116 of file point_light.h. +

+Referenced by NL3D::CLightingManager::addDynamicLight(), NL3D::CZoneLighter::addStaticPointLight(), NL3D::CInstanceLighter::addStaticPointLight(), NL3D::CPatchDLMPointLight::compile(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CShadowMapManager::computeShadowDirection(), NL3D::CPatch::generateTileVegetable(), NL3D::CSkeletonModel::renderCLod(), and NL3D::CTransform::traverseLight(). +

+

00116 {return _Position;}
+
+

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

+Get the specular color of the light. +

+ +

+Definition at line 133 of file point_light.h. +

+Referenced by NL3D::CPointLightNamed::CPointLightNamed(), and NL3D::CPointLightUser::getSpecular(). +

+

00133 {return _Specular;}
+
+

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

+get the begin radius of the SpotAngles. +

+ +

+Definition at line 151 of file point_light.h. +

+References _SpotAngleBegin. +

+Referenced by NL3D::CPatchDLMPointLight::compile(), and NL3D::CPointLightUser::getSpotAngleBegin(). +

+

00151 {return _SpotAngleBegin;}
+
+

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

+get the end radius of the SpotAngles. +

+ +

+Definition at line 153 of file point_light.h. +

+References _SpotAngleEnd. +

+Referenced by NL3D::CPatchDLMPointLight::compile(), and NL3D::CPointLightUser::getSpotAngleEnd(). +

+

00153 {return _SpotAngleEnd;}
+
+

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

+get the spot Direction +

+ +

+Definition at line 161 of file point_light.h. +

+References _SpotDirection. +

+Referenced by NL3D::CPatchDLMPointLight::compile(), and NL3D::CPointLightModel::traverseLight(). +

+

00161 {return _SpotDirection;}
+
+

+ + + + +
+ + + + + + + + + +
CPointLight::TType NL3D::CPointLight::getType  )  const
+
+ + + + + +
+   + + +

+Get the ambient color of the light. +

+ +

+Definition at line 138 of file point_light.cpp. +

+Referenced by NL3D::CPatchDLMPointLight::compile(), NL3D::CZoneLighter::compilePointLightRT(), NL3D::CInstanceLighter::compilePointLightRT(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CPointLightUser::isSpotlight(), NL3D::CInstanceLighter::processIGPointLightRT(), NL3D::CZoneLighter::CPointLightRT::testRaytrace(), NL3D::CInstanceLighter::CPointLightRT::testRaytrace(), and NL3D::CPointLightModel::traverseLight(). +

+

00139 {
+00140         return _Type;
+00141 }
+
+

+ + + + +
+ + + + + + + + + + +
CPointLight & NL3D::CPointLight::operator= const CPointLight o  ) 
+
+ + + + + +
+   + + +

+do not copy _LightedModels. +

+copy all but _LightedModels !! +

+Definition at line 99 of file point_light.cpp. +

+References _Ambient, _AttenuationBegin, _AttenuationEnd, _ConstantAttenuation, _CosSpotAngleEnd, _Diffuse, _LinearAttenuation, _OOCosSpotAngleDelta, _OODeltaAttenuation, _Position, _QuadraticAttenuation, _Specular, _SpotAngleBegin, _SpotAngleEnd, _SpotDirection, _SpotExponent, and _Type. +

+Referenced by CPointLight(). +

+

00100 {
+00102         _Type= o._Type;
+00103         _Position= o._Position;
+00104         _Ambient= o._Ambient;
+00105         _Diffuse= o._Diffuse;
+00106         _Specular= o._Specular;
+00107 
+00108         _AttenuationBegin= o._AttenuationBegin;
+00109         _AttenuationEnd= o._AttenuationEnd;
+00110         _OODeltaAttenuation= o._OODeltaAttenuation;
+00111         _ConstantAttenuation= o._ConstantAttenuation;
+00112         _LinearAttenuation= o._LinearAttenuation;
+00113         _QuadraticAttenuation= o._QuadraticAttenuation;
+00114 
+00115         _SpotDirection= o._SpotDirection;
+00116         _SpotAngleBegin= o._SpotAngleBegin;
+00117         _SpotAngleEnd= o._SpotAngleEnd;
+00118         _CosSpotAngleEnd= o._CosSpotAngleEnd;
+00119         _OOCosSpotAngleDelta= o._OOCosSpotAngleDelta;
+00120         _SpotExponent= o._SpotExponent;
+00121 
+00122         return *this;
+00123 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPointLight::purge  )  [static]
+
+ + + + + +
+   + + +

+ +

+Definition at line 424 of file point_light.cpp. +

+References _LightedModelListMemory, and NLMISC::CBlockMemory< CTransform *, false >::purge(). +

+

00425 {
+00426         _LightedModelListMemory.purge();
+00427 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPointLight::removeLightedModel ItTransformList  it  ) 
+
+ + + + + +
+   + + +

+remove a model from the list. called by CTransform. +

+ +

+Definition at line 418 of file point_light.cpp. +

+References _LightedModels, and ItTransformList. +

+Referenced by NL3D::CTransform::resetLighting(). +

+

00419 {
+00420         // delete the entry in the list.
+00421         _LightedModels.erase(it);
+00422 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPointLight::resetLightedModels  ) 
+
+ + + + + +
+   + + +

+Dirt all models this light influence. +

+ +

+Definition at line 393 of file point_light.cpp. +

+References _LightedModels, nlassert, and NL3D::CTransform::resetLighting(). +

+Referenced by NL3D::CPointLightModel::traverseLight(), and ~CPointLight(). +

+

00394 {
+00395         // For each transform, resetLighting him.
+00396         while(_LightedModels.begin() != _LightedModels.end() )
+00397         {
+00398                 CTransform      *model= *_LightedModels.begin();
+00399                 // reset lighting
+00400                 model->resetLighting();
+00401 
+00402                 // NB: the transform must erase him from this list.
+00403                 nlassert( _LightedModels.begin() == _LightedModels.end() || *_LightedModels.begin() != model );
+00404         }
+00405 }
+
+

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

+Get the ambient color of the light. +

+ +

+Reimplemented in NL3D::CPointLightNamed. +

+Definition at line 230 of file point_light.cpp. +

+References _AttenuationBegin, _AttenuationEnd, _SpotAngleBegin, _SpotAngleEnd, _SpotDirection, computeAttenuationFactors(), computeSpotAttenuationFactors(), NLMISC::IStream::isReading(), NLMISC::IStream::serial(), NLMISC::IStream::serialEnum(), NLMISC::IStream::serialVersion(), NLMISC::CVector::set(), and sint. +

+

00231 {
+00232         sint    ver= f.serialVersion(1);
+00233 
+00234         if(ver>=1)
+00235         {
+00236                 f.serialEnum(_Type);
+00237                 f.serial(_SpotDirection);
+00238                 f.serial(_SpotAngleBegin);
+00239                 f.serial(_SpotAngleEnd);
+00240         }
+00241         else if(f.isReading())
+00242         {
+00243                 _Type= PointLight;
+00244                 _SpotDirection.set(0,1,0);
+00245                 _SpotAngleBegin= float(NLMISC::Pi/4);
+00246                 _SpotAngleEnd= float(NLMISC::Pi/2);
+00247         }
+00248 
+00249         f.serial(_Position);
+00250         f.serial(_Ambient);
+00251         f.serial(_Diffuse);
+00252         f.serial(_Specular);
+00253         f.serial(_AttenuationBegin);
+00254         f.serial(_AttenuationEnd);
+00255 
+00256         // precompute.
+00257         if(f.isReading())
+00258         {
+00259                 computeAttenuationFactors();
+00260                 computeSpotAttenuationFactors();
+00261         }
+00262 
+00263 }
+
+

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

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

+ +

+Definition at line 120 of file point_light.h. +

+Referenced by NL3D::CPointLightUser::setAmbient(), and NL3D::CPointLightNamed::setLightFactor(). +

+

00120 {_Ambient=ambient;}
+
+

+ + + + +
+ + + + + + + + + + +
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 126 of file point_light.h. +

+Referenced by NL3D::CPointLightUser::setColor(), and NL3D::CPSLight::step(). +

+

00126 {_Diffuse= _Specular= color;}
+
+

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

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

+ +

+Definition at line 122 of file point_light.h. +

+Referenced by NL3D::CPointLightUser::setDiffuse(), and NL3D::CPointLightNamed::setLightFactor(). +

+

00122 {_Diffuse=diffuse;}
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPointLight::setPosition const CVector v  )  [inline]
+
+ + + + + +
+   + + +

+Set the position in WorldSpace. +

+ +

+Definition at line 114 of file point_light.h. +

+References v. +

+Referenced by NL3D::CPointLightModel::traverseLight(). +

+

00114 {_Position= v;}
+
+

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

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

+ +

+Definition at line 124 of file point_light.h. +

+Referenced by NL3D::CPointLightNamed::setLightFactor(), and NL3D::CPointLightUser::setSpecular(). +

+

00124 {_Specular=specular;}
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPointLight::setType TType  type  ) 
+
+ + + + + +
+   + + +

+set/get the type of the light. +

+ +

+Definition at line 134 of file point_light.cpp. +

+References type. +

+Referenced by NL3D::CPointLightUser::enableSpotlight(). +

+

00135 {
+00136         _Type= type;
+00137 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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 144 of file point_light.cpp. +

+References _AttenuationBegin, _AttenuationEnd, and computeAttenuationFactors(). +

+Referenced by NL3D::CPointLightUser::setupAttenuation(), and NL3D::CPSLight::step(). +

+

00145 {
+00146         // set values.
+00147         attenuationBegin= max(attenuationBegin, 0.f);
+00148         attenuationEnd= max(attenuationEnd, attenuationBegin);
+00149         _AttenuationBegin= attenuationBegin;
+00150         _AttenuationEnd= attenuationEnd;
+00151 
+00152         // update factors.
+00153         computeAttenuationFactors();
+00154 
+00155 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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 346 of file point_light.cpp. +

+References _SpotDirection, _SpotExponent, NLMISC::CRGBA::modulateFromuiRGBOnly(), NL3D::CLight::setupPointLight(), NL3D::CLight::setupSpotLight(), uint, and uint8. +

+

00347 {
+00348         // expand 0..255 to 0..256, to avoid loss of precision.
+00349         uint    ufactor= factor + (factor>>7);  // add 0 or 1.
+00350 
+00351         // modulate with factor
+00352         CRGBA   ambient, diffuse, specular;
+00353         ambient.modulateFromuiRGBOnly(_Ambient, ufactor);
+00354         diffuse.modulateFromuiRGBOnly(_Diffuse, ufactor);
+00355         specular.modulateFromuiRGBOnly(_Specular, ufactor);
+00356 
+00357         // setup the pointLight
+00358         if(_Type == SpotLight )
+00359         {
+00360                 light.setupSpotLight(ambient, diffuse, specular, _Position, _SpotDirection, 
+00361                         _SpotExponent, float(NLMISC::Pi/2) ,
+00362                         _ConstantAttenuation, _LinearAttenuation, _QuadraticAttenuation);
+00363         }
+00364         // PointLight or AmbientLight
+00365         else
+00366         {
+00367                 light.setupPointLight(ambient, diffuse, specular, _Position, CVector::Null, 
+00368                         _ConstantAttenuation, _LinearAttenuation, _QuadraticAttenuation);
+00369         }
+00370 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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 374 of file point_light.cpp. +

+References NLMISC::CRGBA::modulateFromuiRGBOnly(), NL3D::CLight::setupPointLight(), uint, and uint8. +

+

00375 {
+00376         // expand 0..255 to 0..256, to avoid loss of precision.
+00377         uint    ufactor= factor + (factor>>7);  // add 0 or 1.
+00378 
+00379         // modulate with factor
+00380         CRGBA   ambient, diffuse, specular;
+00381         ambient.modulateFromuiRGBOnly(_Ambient, ufactor);
+00382         diffuse.modulateFromuiRGBOnly(_Diffuse, ufactor);
+00383         specular.modulateFromuiRGBOnly(_Specular, ufactor);
+00384 
+00385         // setup the pointLight, disabling attenuation. 
+00386         // NB: setup a pointLight even if it is a SpotLight because already attenuated
+00387         light.setupPointLight(ambient, diffuse, specular, _Position, CVector::Null, 
+00388                 1, 0, 0);
+00389 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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 159 of file point_light.cpp. +

+References _SpotAngleBegin, _SpotAngleEnd, NLMISC::clamp(), computeSpotAttenuationFactors(), and NLMISC::Pi. +

+Referenced by NL3D::CPointLightUser::setupSpotAngle(). +

+

00160 {
+00161         clamp(spotAngleBegin, 0.f, float(Pi));
+00162         clamp(spotAngleEnd, spotAngleBegin, float(Pi));
+00163         _SpotAngleBegin= spotAngleBegin;
+00164         _SpotAngleEnd= spotAngleEnd;
+00165 
+00166         // update factors.
+00167         computeSpotAttenuationFactors();
+00168 }
+
+

+ + + + +
+ + + + + + + + + + +
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 172 of file point_light.cpp. +

+References _SpotDirection, and NLMISC::CVector::normalize(). +

+Referenced by NL3D::CPointLightModel::traverseLight(). +

+

00173 {
+00174         _SpotDirection= dir;
+00175         _SpotDirection.normalize();
+00176 }
+
+


Field Documentation

+

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

+ +

+Definition at line 217 of file point_light.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
float NL3D::CPointLight::_AttenuationBegin [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 222 of file point_light.h. +

+Referenced by computeAttenuationFactors(), computeLinearAttenuation(), CPointLight(), getAttenuationBegin(), operator=(), serial(), and setupAttenuation().

+

+ + + + +
+ + +
float NL3D::CPointLight::_AttenuationEnd [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 222 of file point_light.h. +

+Referenced by computeAttenuationFactors(), computeLinearAttenuation(), CPointLight(), getAttenuationEnd(), operator=(), serial(), and setupAttenuation().

+

+ + + + +
+ + +
float NL3D::CPointLight::_ConstantAttenuation [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 224 of file point_light.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
float NL3D::CPointLight::_CosSpotAngleEnd [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 232 of file point_light.h. +

+Referenced by computeLinearAttenuation(), computeSpotAttenuationFactors(), CPointLight(), and operator=().

+

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

+ +

+Definition at line 218 of file point_light.h. +

+Referenced by operator=().

+

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

+ +

+Referenced by purge().

+

+ + + + +
+ + +
TTransformList NL3D::CPointLight::_LightedModels [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 241 of file point_light.h. +

+Referenced by appendLightedModel(), removeLightedModel(), and resetLightedModels().

+

+ + + + +
+ + +
float NL3D::CPointLight::_LinearAttenuation [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 225 of file point_light.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
float NL3D::CPointLight::_OOCosSpotAngleDelta [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 234 of file point_light.h. +

+Referenced by computeLinearAttenuation(), computeSpotAttenuationFactors(), CPointLight(), and operator=().

+

+ + + + +
+ + +
float NL3D::CPointLight::_OODeltaAttenuation [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 223 of file point_light.h. +

+Referenced by computeAttenuationFactors(), computeLinearAttenuation(), and operator=().

+

+ + + + +
+ + +
CVector NL3D::CPointLight::_Position [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 214 of file point_light.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
float NL3D::CPointLight::_QuadraticAttenuation [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 226 of file point_light.h. +

+Referenced by operator=().

+

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

+ +

+Definition at line 219 of file point_light.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
float NL3D::CPointLight::_SpotAngleBegin [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 230 of file point_light.h. +

+Referenced by computeSpotAttenuationFactors(), CPointLight(), getSpotAngleBegin(), operator=(), serial(), and setupSpotAngle().

+

+ + + + +
+ + +
float NL3D::CPointLight::_SpotAngleEnd [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 231 of file point_light.h. +

+Referenced by computeSpotAttenuationFactors(), CPointLight(), getSpotAngleEnd(), operator=(), serial(), and setupSpotAngle().

+

+ + + + +
+ + +
CVector NL3D::CPointLight::_SpotDirection [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 229 of file point_light.h. +

+Referenced by computeLinearAttenuation(), CPointLight(), getSpotDirection(), operator=(), serial(), setupDriverLight(), and setupSpotDirection().

+

+ + + + +
+ + +
float NL3D::CPointLight::_SpotExponent [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 235 of file point_light.h. +

+Referenced by computeSpotAttenuationFactors(), CPointLight(), operator=(), and setupDriverLight().

+

+ + + + +
+ + +
TType NL3D::CPointLight::_Type [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 211 of file point_light.h. +

+Referenced by operator=().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 07:01:38 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1