fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Light / OSGSpotLight.cpp
blob97b7726c20c6c159ac63f798fa0dbb1ed9786f5f
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #include <cstdlib>
40 #include <cstdio>
42 #include "OSGConfig.h"
44 #include "OSGGL.h"
46 #include "OSGRenderAction.h"
47 #include "OSGStatCollector.h"
49 #include "OSGSpotLight.h"
51 OSG_USING_NAMESPACE
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(
61 "NSpotLights",
62 "number of spot light sources");
64 /*-------------------------------------------------------------------------*/
65 /* Changed */
67 void SpotLight::changed(ConstFieldMaskArg whichField,
68 UInt32 origin,
69 BitVector details)
71 Inherited::changed(whichField, origin, details);
74 /*-------------------------------------------------------------------------*/
75 /* Chunk */
77 void SpotLight::makeChunk(void)
79 Inherited::makeChunk();
81 Vec4f pos(_sfPosition.getValue ());
83 pos[3] = 1.f;
85 _pChunk->setPosition (pos );
87 _pChunk->setDirection( getDirection () );
88 _pChunk->setExponent ( getSpotExponent() );
89 _pChunk->setCutoff (osgRad2Degree(getSpotCutOff ()));
92 /*-------------------------------------------------------------------------*/
93 /* LightEngine */
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 /*-------------------------------------------------------------------------*/
112 /* Dump */
114 void SpotLight::dump( UInt32 uiIndent,
115 const BitVector bvFlags) const
117 Inherited::dump(uiIndent, bvFlags);
120 /*-------------------------------------------------------------------------*/
121 /* Constructors */
123 SpotLight::SpotLight(void) :
124 Inherited()
128 SpotLight::SpotLight(const SpotLight &source) :
129 Inherited(source)
133 /*-------------------------------------------------------------------------*/
134 /* Destructor */
136 SpotLight::~SpotLight(void)
140 /*-------------------------------------------------------------------------*/
141 /* Rendering */
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,
155 action);
158 /*-------------------------------------------------------------------------*/
159 /* Init */
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));