1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
42 #include "OSGConfig.h"
46 #include "OSGRenderAction.h"
47 #include "OSGPointLight.h"
49 #include "OSGStatCollector.h"
53 // Documentation for this class is emited in the
54 // OSGPointLightBase.cpp file.
55 // To modify it, please change the .fcd file (OSGPointLight.fcd) and
56 // regenerate the base file.
58 /*----------------------------- class variables ---------------------------*/
60 StatElemDesc
<StatIntElem
> PointLight::statNPointLights(
62 "number of point light sources");
64 /*-------------------------------------------------------------------------*/
67 void PointLight::setPosition(Real32 rX
, Real32 rY
, Real32 rZ
)
69 editSField(PositionFieldMask
);
71 _sfPosition
.getValue().setValues(rX
, rY
, rZ
);
74 void PointLight::setAttenuation(Real32 rConstant
,
78 editSField(ConstantAttenuationFieldMask
);
79 editSField(LinearAttenuationFieldMask
);
80 editSField(QuadraticAttenuationFieldMask
);
82 _sfConstantAttenuation
.setValue(rConstant
);
83 _sfLinearAttenuation
.setValue(rLinear
);
84 _sfQuadraticAttenuation
.setValue(rQuadratic
);
87 /*-------------------------------------------------------------------------*/
90 void PointLight::makeChunk(void)
92 Inherited::makeChunk();
94 Vec4f
pos(_sfPosition
.getValue());
98 _pChunk
->setPosition (pos
);
99 _pChunk
->setConstantAttenuation (getConstantAttenuation ());
100 _pChunk
->setLinearAttenuation (getLinearAttenuation ());
101 _pChunk
->setQuadraticAttenuation(getQuadraticAttenuation());
104 /*-------------------------------------------------------------------------*/
107 void PointLight::changed(ConstFieldMaskArg whichField
,
111 Inherited::changed(whichField
, origin
, details
);
114 /*-------------------------------------------------------------------------*/
117 void PointLight::dump( UInt32 uiIndent
,
118 const BitVector bvFlags
) const
120 Inherited::dump(uiIndent
, bvFlags
);
123 /*-------------------------------------------------------------------------*/
126 void PointLight::callLightEngineEnter(RenderAction
*ract
)
128 if(getLightEngine() != NULL
&& getLightEngine()->getEnabled() == true)
130 getLightEngine()->runOnEnter(this, LightEngine::Point
, ract
);
134 void PointLight::callLightEngineLeave(RenderAction
*ract
)
136 if(getLightEngine() != NULL
&& getLightEngine()->getEnabled() == true)
138 getLightEngine()->runOnLeave(this, LightEngine::Point
, ract
);
142 /*-------------------------------------------------------------------------*/
145 PointLight::PointLight(void) :
150 PointLight::PointLight(const PointLight
&source
) :
155 /*-------------------------------------------------------------------------*/
158 PointLight::~PointLight(void)
162 /*-------------------------------------------------------------------------*/
165 Action::ResultE
PointLight::renderEnter(Action
*action
)
167 RenderAction
*a
= dynamic_cast<RenderAction
*>(action
);
169 return Inherited::renderEnter(LightEngine::Point
,
170 PointLight::statNPointLights
,
174 Action::ResultE
PointLight::renderLeave(Action
*action
)
176 return Inherited::renderLeave(LightEngine::Point
,
180 /*-------------------------------------------------------------------------*/
183 void PointLight::initMethod(InitPhase ePhase
)
185 Inherited::initMethod(ePhase
);
187 if(ePhase
== TypeObject::SystemPost
)
189 RenderAction::registerEnterDefault(
190 PointLight::getClassType(),
191 reinterpret_cast<Action::Callback
>(&PointLight::renderEnter
));
193 RenderAction::registerLeaveDefault(
194 PointLight::getClassType(),
195 reinterpret_cast<Action::Callback
>(&PointLight::renderLeave
));