1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
44 UInt32 MultiLightChunk::numLights() const
46 return static_cast<UInt32>(_mfPosition.size());
50 const Pnt3f& MultiLightChunk::getPosition(const UInt32 idx) const
52 OSG_ASSERT(idx < _mfPosition.size());
53 return Inherited::getPosition(idx);
57 const Vec3f& MultiLightChunk::getDirection(const UInt32 idx) const
59 OSG_ASSERT(idx < _mfDirection.size());
60 return Inherited::getDirection(idx);
64 const Color3f& MultiLightChunk::getColor(const UInt32 idx) const
66 OSG_ASSERT(idx < _mfColor.size());
67 return Inherited::getColor(idx);
71 Real32 MultiLightChunk::getIntensity(const UInt32 idx) const
73 OSG_ASSERT(idx < _mfIntensity.size());
74 return Inherited::getIntensity(idx);
78 const Vec3f& MultiLightChunk::getAmbientIntensity(const UInt32 idx) const
80 OSG_ASSERT(idx < _mfAmbientIntensity.size());
81 return Inherited::getAmbientIntensity(idx);
85 const Vec3f& MultiLightChunk::getDiffuseIntensity(const UInt32 idx) const
87 OSG_ASSERT(idx < _mfDiffuseIntensity.size());
88 return Inherited::getDiffuseIntensity(idx);
92 const Vec3f& MultiLightChunk::getSpecularIntensity(const UInt32 idx) const
94 OSG_ASSERT(idx < _mfSpecularIntensity.size());
95 return Inherited::getSpecularIntensity(idx);
99 const Vec3f& MultiLightChunk::getAttenuation(const UInt32 idx) const
101 OSG_ASSERT(idx < _mfAttenuation.size());
102 return Inherited::getAttenuation(idx);
106 Real32 MultiLightChunk::getRange(const UInt32 idx) const
108 OSG_ASSERT(idx < _mfRangeCutOff.size());
109 return Inherited::getRangeCutOff(idx);
113 Real32 MultiLightChunk::getSpotlightAngle(const UInt32 idx) const
115 OSG_ASSERT(idx < _mfSpotlightAngle.size());
116 return Inherited::getSpotlightAngle(idx);
120 Real32 MultiLightChunk::getSpotExponent(const UInt32 idx) const
122 OSG_ASSERT(idx < _mfSpotExponent.size());
123 return Inherited::getSpotExponent(idx);
127 Real32 MultiLightChunk::getInnerSuperEllipsesWidth(const UInt32 idx) const
129 OSG_ASSERT(idx < _mfInnerSuperEllipsesWidth.size());
130 return Inherited::getInnerSuperEllipsesWidth(idx);
134 Real32 MultiLightChunk::getInnerSuperEllipsesHeight(const UInt32 idx) const
136 OSG_ASSERT(idx < _mfInnerSuperEllipsesHeight.size());
137 return Inherited::getInnerSuperEllipsesHeight(idx);
141 Real32 MultiLightChunk::getOuterSuperEllipsesWidth(const UInt32 idx) const
143 OSG_ASSERT(idx < _mfOuterSuperEllipsesWidth.size());
144 return Inherited::getOuterSuperEllipsesWidth(idx);
148 Real32 MultiLightChunk::getOuterSuperEllipsesHeight(const UInt32 idx) const
150 OSG_ASSERT(idx < _mfOuterSuperEllipsesHeight.size());
151 return Inherited::getOuterSuperEllipsesHeight(idx);
155 Real32 MultiLightChunk::getSuperEllipsesRoundness(const UInt32 idx) const
157 OSG_ASSERT(idx < _mfSuperEllipsesRoundness.size());
158 return Inherited::getSuperEllipsesRoundness(idx);
162 Real32 MultiLightChunk::getSuperEllipsesTwist(const UInt32 idx) const
164 OSG_ASSERT(idx < _mfSuperEllipsesTwist.size());
165 return Inherited::getSuperEllipsesTwist(idx);
169 Real32 MultiLightChunk::getRangeCutOn(const UInt32 idx) const
171 OSG_ASSERT(idx < _mfRangeCutOn.size());
172 return Inherited::getRangeCutOn(idx);
176 Real32 MultiLightChunk::getRangeCutOff(const UInt32 idx) const
178 OSG_ASSERT(idx < _mfRangeCutOff.size());
179 return Inherited::getRangeCutOff(idx);
183 Real32 MultiLightChunk::getRangeNearZone(const UInt32 idx) const
185 OSG_ASSERT(idx < _mfRangeNearZone.size());
186 return Inherited::getRangeNearZone(idx);
190 Real32 MultiLightChunk::getRangeFarZone(const UInt32 idx) const
192 OSG_ASSERT(idx < _mfRangeFarZone.size());
193 return Inherited::getRangeFarZone(idx);
197 UInt8 MultiLightChunk::getType(const UInt32 idx) const
199 OSG_ASSERT(idx < _mfType.size());
200 return Inherited::getType(idx);
204 bool MultiLightChunk::getEnabled(const UInt32 idx) const
206 OSG_ASSERT(idx < _mfEnabled.size());
207 return Inherited::getEnabled(idx);
211 Node* MultiLightChunk::getBeacon(const UInt32 idx) const
213 OSG_ASSERT(idx < _mfBeacon.size());
214 return Inherited::getBeacon(idx);
218 void MultiLightChunk::setPosition(const UInt32 idx, const Pnt3f& position)
220 OSG_ASSERT(idx < _mfPosition.size());
221 editPosition(idx) = position;
225 void MultiLightChunk::setDirection(const UInt32 idx, const Vec3f& direction)
227 OSG_ASSERT(idx < _mfDirection.size());
228 editDirection(idx) = direction;
232 void MultiLightChunk::setColor(const UInt32 idx, const Color3f& color)
234 OSG_ASSERT(idx < _mfColor.size());
235 editColor(idx) = color;
239 void MultiLightChunk::setIntensity(const UInt32 idx, Real32 intensity)
241 OSG_ASSERT(idx < _mfIntensity.size());
242 editIntensity(idx) = intensity;
246 void MultiLightChunk::setAmbientIntensity(const UInt32 idx, const Vec3f& intensity)
248 OSG_ASSERT(idx < _mfAmbientIntensity.size());
249 editAmbientIntensity(idx) = intensity;
253 void MultiLightChunk::setDiffuseIntensity(const UInt32 idx, const Vec3f& intensity)
255 OSG_ASSERT(idx < _mfDiffuseIntensity.size());
256 editDiffuseIntensity(idx) = intensity;
260 void MultiLightChunk::setSpecularIntensity(const UInt32 idx, const Vec3f& intensity)
262 OSG_ASSERT(idx < _mfSpecularIntensity.size());
263 editSpecularIntensity(idx) = intensity;
267 void MultiLightChunk::setAttenuation(const UInt32 idx, const Vec3f& attenuation)
269 OSG_ASSERT(idx < _mfAttenuation.size());
270 editAttenuation(idx) = attenuation;
274 void MultiLightChunk::setRange(const UInt32 idx, Real32 range)
276 OSG_ASSERT(idx < _mfRangeCutOff.size());
277 editRangeCutOff(idx) = range;
281 void MultiLightChunk::setSpotlightAngle(const UInt32 idx, Real32 angle)
283 OSG_ASSERT(idx < _mfSpotlightAngle.size());
284 editSpotlightAngle(idx) = angle;
288 void MultiLightChunk::setSpotExponent(const UInt32 idx, Real32 exponent)
290 OSG_ASSERT(idx < _mfSpotExponent.size());
291 editSpotExponent(idx) = exponent;
295 void MultiLightChunk::setInnerSuperEllipsesWidth(const UInt32 idx, Real32 width)
297 OSG_ASSERT(idx < _mfInnerSuperEllipsesWidth.size());
298 editInnerSuperEllipsesWidth(idx) = width;
302 void MultiLightChunk::setInnerSuperEllipsesHeight(const UInt32 idx, Real32 height)
304 OSG_ASSERT(idx < _mfInnerSuperEllipsesHeight.size());
305 editInnerSuperEllipsesHeight(idx) = height;
309 void MultiLightChunk::setOuterSuperEllipsesWidth(const UInt32 idx, Real32 width)
311 OSG_ASSERT(idx < _mfOuterSuperEllipsesWidth.size());
312 editOuterSuperEllipsesWidth(idx) = width;
316 void MultiLightChunk::setOuterSuperEllipsesHeight(const UInt32 idx, Real32 height)
318 OSG_ASSERT(idx < _mfOuterSuperEllipsesHeight.size());
319 editOuterSuperEllipsesHeight(idx) = height;
323 void MultiLightChunk::setSuperEllipsesRoundness(const UInt32 idx, Real32 roundness)
325 OSG_ASSERT(idx < _mfSuperEllipsesRoundness.size());
326 editSuperEllipsesRoundness(idx) = roundness;
330 void MultiLightChunk::setSuperEllipsesTwist(const UInt32 idx, Real32 twist)
332 OSG_ASSERT(idx < _mfSuperEllipsesTwist.size());
333 editSuperEllipsesTwist(idx) = twist;
337 void MultiLightChunk::setRangeCutOn(const UInt32 idx, Real32 cutOn)
339 OSG_ASSERT(idx < _mfRangeCutOn.size());
340 editRangeCutOn(idx) = cutOn;
344 void MultiLightChunk::setRangeCutOff(const UInt32 idx, Real32 cutOff)
346 OSG_ASSERT(idx < _mfRangeCutOff.size());
347 editRangeCutOff(idx) = cutOff;
351 void MultiLightChunk::setRangeNearZone(const UInt32 idx, Real32 nearZone)
353 OSG_ASSERT(idx < _mfRangeNearZone.size());
354 editRangeNearZone(idx) = nearZone;
358 void MultiLightChunk::setRangeFarZone(const UInt32 idx, Real32 farZone)
360 OSG_ASSERT(idx < _mfRangeFarZone.size());
361 editRangeFarZone(idx) = farZone;
365 void MultiLightChunk::setType(const UInt32 idx, MultiLight::Type eType)
367 OSG_ASSERT(idx < _mfType.size());
368 editType(idx) = eType;
372 void MultiLightChunk::setEnabled(const UInt32 idx, bool flag)
374 OSG_ASSERT(idx < _mfEnabled.size());
375 editEnabled(idx) = flag;
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);
388 void MultiLightChunk::changedBeacon()
390 editMField(BeaconFieldMask, _mfBeacon);
394 bool MultiLightChunk::check_invariant() const
396 std::size_t sz = _mfPosition.size();
398 if (getHasSeparateIntensities()
400 sz != _mfAmbientIntensity.size() ||
401 sz != _mfDiffuseIntensity.size() ||
402 sz != _mfSpecularIntensity.size()))
405 if (getHasColor() && sz != _mfColor.size())
408 if (getHasIntensity() && sz != _mfIntensity.size())
411 if (getHasAttenuation() && sz != _mfAttenuation.size())
414 if (getHasRangeCutOn() && sz != _mfRangeCutOn.size())
417 if (getHasRangeCutOff() && sz != _mfRangeCutOff.size())
420 if (getHasRangeNearZone() && sz != _mfRangeNearZone.size())
423 if (getHasRangeFarZone() && sz != _mfRangeFarZone.size())
426 if (getHasSpotExponent() && sz != _mfSpotExponent.size())
429 if (getHasCinemaLight()
431 sz != _mfInnerSuperEllipsesWidth.size() ||
432 sz != _mfInnerSuperEllipsesHeight.size() ||
433 sz != _mfOuterSuperEllipsesWidth.size() ||
434 sz != _mfOuterSuperEllipsesHeight.size() ||
435 sz != _mfSuperEllipsesRoundness.size() ||
436 sz != _mfSuperEllipsesTwist.size()))
439 return sz == _mfDirection.size()
440 && sz == _mfSpotlightAngle.size()
441 && sz == _mfType.size()
442 && sz == _mfEnabled.size()
443 && sz == _mfBeacon.size();