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 "OSGStatCollector.h"
49 #include "OSGSpotLight.h"
53 // Documentation for this class is emited in the
54 // OSGSpotLightBase.cpp file.
55 // To modify it, please change the .fcd file (OSGSpotLight.fcd) and
56 // regenerate the base file.
58 /*----------------------------- class variables ---------------------------*/
60 StatElemDesc
<StatIntElem
> SpotLight::statNSpotLights(
62 "number of spot light sources");
64 /*-------------------------------------------------------------------------*/
67 void SpotLight::changed(ConstFieldMaskArg whichField
,
71 Inherited::changed(whichField
, origin
, details
);
74 /*-------------------------------------------------------------------------*/
77 void SpotLight::makeChunk(void)
79 Inherited::makeChunk();
81 Vec4f
pos(_sfPosition
.getValue ());
85 _pChunk
->setPosition (pos
);
87 _pChunk
->setDirection( getDirection () );
88 _pChunk
->setExponent ( getSpotExponent() );
89 _pChunk
->setCutoff (osgRad2Degree(getSpotCutOff ()));
92 /*-------------------------------------------------------------------------*/
95 void SpotLight::callLightEngineEnter(RenderAction
*ract
)
97 if(getLightEngine() != NULL
&& getLightEngine()->getEnabled() == true)
99 getLightEngine()->runOnEnter(this, LightEngine::Spot
, ract
);
103 void SpotLight::callLightEngineLeave(RenderAction
*ract
)
105 if(getLightEngine() != NULL
&& getLightEngine()->getEnabled() == true)
107 getLightEngine()->runOnLeave(this, LightEngine::Spot
, ract
);
111 /*-------------------------------------------------------------------------*/
114 void SpotLight::dump( UInt32 uiIndent
,
115 const BitVector bvFlags
) const
117 Inherited::dump(uiIndent
, bvFlags
);
120 /*-------------------------------------------------------------------------*/
123 SpotLight::SpotLight(void) :
128 SpotLight::SpotLight(const SpotLight
&source
) :
133 /*-------------------------------------------------------------------------*/
136 SpotLight::~SpotLight(void)
140 /*-------------------------------------------------------------------------*/
143 Action::ResultE
SpotLight::renderEnter(Action
*action
)
145 RenderAction
*a
= dynamic_cast<RenderAction
*>(action
);
147 return Light::renderEnter(LightEngine::Spot
,
148 SpotLight::statNSpotLights
,
152 Action::ResultE
SpotLight::renderLeave(Action
*action
)
154 return Light::renderLeave(LightEngine::Spot
,
158 /*-------------------------------------------------------------------------*/
161 void SpotLight::initMethod(InitPhase ePhase
)
163 Inherited::initMethod(ePhase
);
165 if(ePhase
== TypeObject::SystemPost
)
167 RenderAction::registerEnterDefault(
168 SpotLight::getClassType(),
169 reinterpret_cast<Action::Callback
>(&SpotLight::renderEnter
));
171 RenderAction::registerLeaveDefault(
172 SpotLight::getClassType(),
173 reinterpret_cast<Action::Callback
>(&SpotLight::renderLeave
));