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 "OSGDirectionalLight.h"
47 #include "OSGRenderAction.h"
49 #include "OSGStatCollector.h"
53 // Documentation for this class is emited in the
54 // OSGDirectionalLightBase.cpp file.
55 // To modify it, please change the .fcd file (OSGDirectionalLight.fcd) and
56 // regenerate the base file.
58 /*----------------------------- class variables ---------------------------*/
60 StatElemDesc
<StatIntElem
> DirectionalLight::statNDirectionalLights(
62 "number of directional light sources");
65 /*-------------------------------------------------------------------------*/
68 void DirectionalLight::setDirection(Real32 rX
, Real32 rY
, Real32 rZ
)
70 editSField(DirectionFieldMask
);
72 _sfDirection
.getValue().setValues(rX
, rY
, rZ
);
75 /*-------------------------------------------------------------------------*/
78 void DirectionalLight::changed(ConstFieldMaskArg whichField
,
82 Inherited::changed(whichField
, origin
, details
);
85 /*-------------------------------------------------------------------------*/
88 void DirectionalLight::makeChunk(void)
90 Inherited::makeChunk();
92 Vec4f
dir(_sfDirection
.getValue());
96 _pChunk
->setPosition(dir
);
99 /*-------------------------------------------------------------------------*/
102 void DirectionalLight::callLightEngineEnter(RenderAction
*ract
)
104 if(getLightEngine() != NULL
&& getLightEngine()->getEnabled() == true)
106 getLightEngine()->runOnEnter(this, LightEngine::Directional
, ract
);
110 void DirectionalLight::callLightEngineLeave(RenderAction
*ract
)
112 if(getLightEngine() != NULL
&& getLightEngine()->getEnabled() == true)
114 getLightEngine()->runOnLeave(this, LightEngine::Directional
, ract
);
118 /*-------------------------------------------------------------------------*/
121 void DirectionalLight::dump( UInt32 uiIndent
,
122 const BitVector bvFlags
) const
124 Inherited::dump(uiIndent
, bvFlags
);
127 /*-------------------------------------------------------------------------*/
130 DirectionalLight::DirectionalLight(void) :
135 DirectionalLight::DirectionalLight(const DirectionalLight
&source
) :
140 /*-------------------------------------------------------------------------*/
143 DirectionalLight::~DirectionalLight(void)
147 /*-------------------------------------------------------------------------*/
150 Action::ResultE
DirectionalLight::renderEnter(Action
*action
)
152 RenderAction
*a
= dynamic_cast<RenderAction
*>(action
);
154 return Inherited::renderEnter(LightEngine::Directional
,
155 DirectionalLight::statNDirectionalLights
,
159 Action::ResultE
DirectionalLight::renderLeave(Action
*action
)
161 return Inherited::renderLeave(LightEngine::Directional
, action
);
164 /*-------------------------------------------------------------------------*/
167 void DirectionalLight::initMethod(InitPhase ePhase
)
169 Inherited::initMethod(ePhase
);
171 if(ePhase
== TypeObject::SystemPost
)
173 RenderAction::registerEnterDefault(
174 DirectionalLight::getClassType(),
175 reinterpret_cast<Action::Callback
>(
176 &DirectionalLight::renderEnter
));
178 RenderAction::registerLeaveDefault(
179 DirectionalLight::getClassType(),
180 reinterpret_cast<Action::Callback
>(
181 &DirectionalLight::renderLeave
));