fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGMultiLightChunk.inl
blob66274d077abb8a4b323a337d733321f2b35c8790
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *               Copyright (C) 2000-2013 by the OpenSG Forum                 *
6  *                                                                           *
7  * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net  *
8  *                                                                           *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11  *                                License                                    *
12  *                                                                           *
13  * This library is free software; you can redistribute it and/or modify it   *
14  * under the terms of the GNU Library General Public License as published    *
15  * by the Free Software Foundation, version 2.                               *
16  *                                                                           *
17  * This library is distributed in the hope that it will be useful, but       *
18  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
20  * Library General Public License for more details.                          *
21  *                                                                           *
22  * You should have received a copy of the GNU Library General Public         *
23  * License along with this library; if not, write to the Free Software       *
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
25  *                                                                           *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28  *                                Changes                                    *
29  *                                                                           *
30  *                                                                           *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
38 //  Includes
39 //---------------------------------------------------------------------------
41 OSG_BEGIN_NAMESPACE
43 inline 
44 UInt32 MultiLightChunk::numLights() const
46     return static_cast<UInt32>(_mfPosition.size());
49 inline
50 const Pnt3f& MultiLightChunk::getPosition(const UInt32 idx) const
52     OSG_ASSERT(idx < _mfPosition.size());
53     return Inherited::getPosition(idx);
56 inline
57 const Vec3f& MultiLightChunk::getDirection(const UInt32 idx) const
59     OSG_ASSERT(idx < _mfDirection.size());
60     return Inherited::getDirection(idx);
63 inline
64 const Color3f& MultiLightChunk::getColor(const UInt32 idx) const
66     OSG_ASSERT(idx < _mfColor.size());
67     return Inherited::getColor(idx);
70 inline
71 Real32 MultiLightChunk::getIntensity(const UInt32 idx) const
73     OSG_ASSERT(idx < _mfIntensity.size());
74     return Inherited::getIntensity(idx);
77 inline
78 const Vec3f& MultiLightChunk::getAmbientIntensity(const UInt32 idx) const
80     OSG_ASSERT(idx < _mfAmbientIntensity.size());
81     return Inherited::getAmbientIntensity(idx);
84 inline
85 const Vec3f& MultiLightChunk::getDiffuseIntensity(const UInt32 idx) const
87     OSG_ASSERT(idx < _mfDiffuseIntensity.size());
88     return Inherited::getDiffuseIntensity(idx);
91 inline
92 const Vec3f& MultiLightChunk::getSpecularIntensity(const UInt32 idx) const
94     OSG_ASSERT(idx < _mfSpecularIntensity.size());
95     return Inherited::getSpecularIntensity(idx);
98 inline
99 const Vec3f& MultiLightChunk::getAttenuation(const UInt32 idx) const
101     OSG_ASSERT(idx < _mfAttenuation.size());
102     return Inherited::getAttenuation(idx);
105 inline
106 Real32 MultiLightChunk::getRange(const UInt32 idx) const
108     OSG_ASSERT(idx < _mfRangeCutOff.size());
109     return Inherited::getRangeCutOff(idx);
112 inline
113 Real32 MultiLightChunk::getSpotlightAngle(const UInt32 idx) const
115     OSG_ASSERT(idx < _mfSpotlightAngle.size());
116     return Inherited::getSpotlightAngle(idx);
119 inline
120 Real32 MultiLightChunk::getSpotExponent(const UInt32 idx) const
122     OSG_ASSERT(idx < _mfSpotExponent.size());
123     return Inherited::getSpotExponent(idx);
126 inline
127 Real32 MultiLightChunk::getInnerSuperEllipsesWidth(const UInt32 idx) const
129     OSG_ASSERT(idx < _mfInnerSuperEllipsesWidth.size());
130     return Inherited::getInnerSuperEllipsesWidth(idx);
133 inline
134 Real32 MultiLightChunk::getInnerSuperEllipsesHeight(const UInt32 idx) const
136     OSG_ASSERT(idx < _mfInnerSuperEllipsesHeight.size());
137     return Inherited::getInnerSuperEllipsesHeight(idx);
140 inline
141 Real32 MultiLightChunk::getOuterSuperEllipsesWidth(const UInt32 idx) const
143     OSG_ASSERT(idx < _mfOuterSuperEllipsesWidth.size());
144     return Inherited::getOuterSuperEllipsesWidth(idx);
147 inline
148 Real32 MultiLightChunk::getOuterSuperEllipsesHeight(const UInt32 idx) const
150     OSG_ASSERT(idx < _mfOuterSuperEllipsesHeight.size());
151     return Inherited::getOuterSuperEllipsesHeight(idx);
154 inline
155 Real32 MultiLightChunk::getSuperEllipsesRoundness(const UInt32 idx) const
157     OSG_ASSERT(idx < _mfSuperEllipsesRoundness.size());
158     return Inherited::getSuperEllipsesRoundness(idx);
161 inline
162 Real32 MultiLightChunk::getSuperEllipsesTwist(const UInt32 idx) const
164     OSG_ASSERT(idx < _mfSuperEllipsesTwist.size());
165     return Inherited::getSuperEllipsesTwist(idx);
168 inline
169 Real32 MultiLightChunk::getRangeCutOn(const UInt32 idx) const
171     OSG_ASSERT(idx < _mfRangeCutOn.size());
172     return Inherited::getRangeCutOn(idx);
175 inline
176 Real32 MultiLightChunk::getRangeCutOff(const UInt32 idx) const
178     OSG_ASSERT(idx < _mfRangeCutOff.size());
179     return Inherited::getRangeCutOff(idx);
182 inline
183 Real32 MultiLightChunk::getRangeNearZone(const UInt32 idx) const
185     OSG_ASSERT(idx < _mfRangeNearZone.size());
186     return Inherited::getRangeNearZone(idx);
189 inline
190 Real32 MultiLightChunk::getRangeFarZone(const UInt32 idx) const
192     OSG_ASSERT(idx < _mfRangeFarZone.size());
193     return Inherited::getRangeFarZone(idx);
196 inline
197 UInt8 MultiLightChunk::getType(const UInt32 idx) const
199     OSG_ASSERT(idx < _mfType.size());
200     return Inherited::getType(idx);
203 inline
204 bool MultiLightChunk::getEnabled(const UInt32 idx) const
206     OSG_ASSERT(idx < _mfEnabled.size());
207     return Inherited::getEnabled(idx);
210 inline
211 Node* MultiLightChunk::getBeacon(const UInt32 idx) const
213     OSG_ASSERT(idx < _mfBeacon.size());
214     return Inherited::getBeacon(idx);
217 inline
218 void MultiLightChunk::setPosition(const UInt32 idx, const Pnt3f& position)
220     OSG_ASSERT(idx < _mfPosition.size());
221     editPosition(idx) = position;
224 inline
225 void MultiLightChunk::setDirection(const UInt32 idx, const Vec3f& direction)
227     OSG_ASSERT(idx < _mfDirection.size());
228     editDirection(idx) = direction;
231 inline
232 void MultiLightChunk::setColor(const UInt32 idx, const Color3f& color)
234     OSG_ASSERT(idx < _mfColor.size());
235     editColor(idx) = color;
238 inline
239 void MultiLightChunk::setIntensity(const UInt32 idx, Real32 intensity)
241     OSG_ASSERT(idx < _mfIntensity.size());
242     editIntensity(idx) = intensity;
245 inline
246 void MultiLightChunk::setAmbientIntensity(const UInt32 idx, const Vec3f& intensity)
248     OSG_ASSERT(idx < _mfAmbientIntensity.size());
249     editAmbientIntensity(idx) = intensity;
252 inline
253 void MultiLightChunk::setDiffuseIntensity(const UInt32 idx, const Vec3f& intensity)
255     OSG_ASSERT(idx < _mfDiffuseIntensity.size());
256     editDiffuseIntensity(idx) = intensity;
259 inline
260 void MultiLightChunk::setSpecularIntensity(const UInt32 idx, const Vec3f& intensity)
262     OSG_ASSERT(idx < _mfSpecularIntensity.size());
263     editSpecularIntensity(idx) = intensity;
266 inline
267 void MultiLightChunk::setAttenuation(const UInt32 idx, const Vec3f& attenuation)
269     OSG_ASSERT(idx < _mfAttenuation.size());
270     editAttenuation(idx) = attenuation;
273 inline
274 void MultiLightChunk::setRange(const UInt32 idx, Real32 range)
276     OSG_ASSERT(idx < _mfRangeCutOff.size());
277     editRangeCutOff(idx) = range;
280 inline
281 void MultiLightChunk::setSpotlightAngle(const UInt32 idx, Real32 angle)
283     OSG_ASSERT(idx < _mfSpotlightAngle.size());
284     editSpotlightAngle(idx) = angle;
287 inline
288 void MultiLightChunk::setSpotExponent(const UInt32 idx, Real32 exponent)
290     OSG_ASSERT(idx < _mfSpotExponent.size());
291     editSpotExponent(idx) = exponent;
294 inline
295 void MultiLightChunk::setInnerSuperEllipsesWidth(const UInt32 idx, Real32 width)
297     OSG_ASSERT(idx < _mfInnerSuperEllipsesWidth.size());
298     editInnerSuperEllipsesWidth(idx) = width;
301 inline
302 void MultiLightChunk::setInnerSuperEllipsesHeight(const UInt32 idx, Real32 height)
304     OSG_ASSERT(idx < _mfInnerSuperEllipsesHeight.size());
305     editInnerSuperEllipsesHeight(idx) = height;
308 inline
309 void MultiLightChunk::setOuterSuperEllipsesWidth(const UInt32 idx, Real32 width)
311     OSG_ASSERT(idx < _mfOuterSuperEllipsesWidth.size());
312     editOuterSuperEllipsesWidth(idx) = width;
315 inline
316 void MultiLightChunk::setOuterSuperEllipsesHeight(const UInt32 idx, Real32 height)
318     OSG_ASSERT(idx < _mfOuterSuperEllipsesHeight.size());
319     editOuterSuperEllipsesHeight(idx) = height;
322 inline
323 void MultiLightChunk::setSuperEllipsesRoundness(const UInt32 idx, Real32 roundness)
325     OSG_ASSERT(idx < _mfSuperEllipsesRoundness.size());
326     editSuperEllipsesRoundness(idx) = roundness;
329 inline
330 void MultiLightChunk::setSuperEllipsesTwist(const UInt32 idx, Real32 twist)
332     OSG_ASSERT(idx < _mfSuperEllipsesTwist.size());
333     editSuperEllipsesTwist(idx) = twist;
336 inline
337 void MultiLightChunk::setRangeCutOn(const UInt32 idx, Real32 cutOn)
339     OSG_ASSERT(idx < _mfRangeCutOn.size());
340     editRangeCutOn(idx) = cutOn;
343 inline
344 void MultiLightChunk::setRangeCutOff(const UInt32 idx, Real32 cutOff)
346     OSG_ASSERT(idx < _mfRangeCutOff.size());
347     editRangeCutOff(idx) = cutOff;
350 inline
351 void MultiLightChunk::setRangeNearZone(const UInt32 idx, Real32 nearZone)
353     OSG_ASSERT(idx < _mfRangeNearZone.size());
354     editRangeNearZone(idx) = nearZone;
357 inline
358 void MultiLightChunk::setRangeFarZone(const UInt32 idx, Real32 farZone)
360     OSG_ASSERT(idx < _mfRangeFarZone.size());
361     editRangeFarZone(idx) = farZone;
364 inline
365 void MultiLightChunk::setType(const UInt32 idx, MultiLight::Type eType)
367     OSG_ASSERT(idx < _mfType.size());
368     editType(idx) = eType;
371 inline
372 void MultiLightChunk::setEnabled(const UInt32 idx, bool flag)
374     OSG_ASSERT(idx < _mfEnabled.size());
375     editEnabled(idx) = flag;
378 inline
379 void MultiLightChunk::setBeacon(const UInt32 idx, Node* const beacon)
381     OSG_ASSERT(idx < _mfBeacon.size());
383     editMField(BeaconFieldMask, _mfBeacon);
384     _mfBeacon.replace(idx, beacon);
387 inline
388 void MultiLightChunk::changedBeacon()
390     editMField(BeaconFieldMask, _mfBeacon);
393 inline
394 bool MultiLightChunk::check_invariant() const
396     std::size_t sz = _mfPosition.size();
398     if (getHasSeparateIntensities()
399       && (
400         sz != _mfAmbientIntensity.size() ||
401         sz != _mfDiffuseIntensity.size() ||
402         sz != _mfSpecularIntensity.size()))
403         return false;
405     if (getHasColor() && sz != _mfColor.size())
406         return false;
408     if (getHasIntensity() && sz != _mfIntensity.size())
409         return false;
411     if (getHasAttenuation() && sz != _mfAttenuation.size())
412         return false;
414     if (getHasRangeCutOn() && sz != _mfRangeCutOn.size())
415         return false;
417     if (getHasRangeCutOff() && sz != _mfRangeCutOff.size())
418         return false;
420     if (getHasRangeNearZone() && sz != _mfRangeNearZone.size())
421         return false;
423     if (getHasRangeFarZone() && sz != _mfRangeFarZone.size())
424         return false;
426     if (getHasSpotExponent() && sz != _mfSpotExponent.size())
427         return false;
429     if (getHasCinemaLight()
430       && (
431         sz != _mfInnerSuperEllipsesWidth.size() ||
432         sz != _mfInnerSuperEllipsesHeight.size() ||
433         sz != _mfOuterSuperEllipsesWidth.size() ||
434         sz != _mfOuterSuperEllipsesHeight.size() ||
435         sz != _mfSuperEllipsesRoundness.size() ||
436         sz != _mfSuperEllipsesTwist.size()))
437         return false;
439     return sz == _mfDirection.size() 
440         && sz == _mfSpotlightAngle.size() 
441         && sz == _mfType.size() 
442         && sz == _mfEnabled.size() 
443         && sz == _mfBeacon.size();
446 OSG_END_NAMESPACE