00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #define OSG_COMPILELIGHTINST
00055
00056 #include <stdlib.h>
00057 #include <stdio.h>
00058
00059 #include <OSGConfig.h>
00060
00061 #include "OSGLightBase.h"
00062 #include "OSGLight.h"
00063
00064
00065 OSG_BEGIN_NAMESPACE
00066
00067 const OSG::BitVector LightBase::AmbientFieldMask =
00068 (TypeTraits<BitVector>::One << LightBase::AmbientFieldId);
00069
00070 const OSG::BitVector LightBase::DiffuseFieldMask =
00071 (TypeTraits<BitVector>::One << LightBase::DiffuseFieldId);
00072
00073 const OSG::BitVector LightBase::SpecularFieldMask =
00074 (TypeTraits<BitVector>::One << LightBase::SpecularFieldId);
00075
00076 const OSG::BitVector LightBase::BeaconFieldMask =
00077 (TypeTraits<BitVector>::One << LightBase::BeaconFieldId);
00078
00079 const OSG::BitVector LightBase::OnFieldMask =
00080 (TypeTraits<BitVector>::One << LightBase::OnFieldId);
00081
00082 const OSG::BitVector LightBase::ConstantAttenuationFieldMask =
00083 (TypeTraits<BitVector>::One << LightBase::ConstantAttenuationFieldId);
00084
00085 const OSG::BitVector LightBase::LinearAttenuationFieldMask =
00086 (TypeTraits<BitVector>::One << LightBase::LinearAttenuationFieldId);
00087
00088 const OSG::BitVector LightBase::QuadraticAttenuationFieldMask =
00089 (TypeTraits<BitVector>::One << LightBase::QuadraticAttenuationFieldId);
00090
00091 const OSG::BitVector LightBase::ShadowIntensityFieldMask =
00092 (TypeTraits<BitVector>::One << LightBase::ShadowIntensityFieldId);
00093
00094 const OSG::BitVector LightBase::ShadowModeFieldMask =
00095 (TypeTraits<BitVector>::One << LightBase::ShadowModeFieldId);
00096
00097 const OSG::BitVector LightBase::MTInfluenceMask =
00098 (Inherited::MTInfluenceMask) |
00099 (static_cast<BitVector>(0x0) << Inherited::NextFieldId);
00100
00101
00102
00103
00135
00136
00137 FieldDescription *LightBase::_desc[] =
00138 {
00139 new FieldDescription(SFColor4f::getClassType(),
00140 "ambient",
00141 AmbientFieldId, AmbientFieldMask,
00142 false,
00143 (FieldAccessMethod) &LightBase::getSFAmbient),
00144 new FieldDescription(SFColor4f::getClassType(),
00145 "diffuse",
00146 DiffuseFieldId, DiffuseFieldMask,
00147 false,
00148 (FieldAccessMethod) &LightBase::getSFDiffuse),
00149 new FieldDescription(SFColor4f::getClassType(),
00150 "specular",
00151 SpecularFieldId, SpecularFieldMask,
00152 false,
00153 (FieldAccessMethod) &LightBase::getSFSpecular),
00154 new FieldDescription(SFNodePtr::getClassType(),
00155 "beacon",
00156 BeaconFieldId, BeaconFieldMask,
00157 false,
00158 (FieldAccessMethod) &LightBase::getSFBeacon),
00159 new FieldDescription(SFBool::getClassType(),
00160 "on",
00161 OnFieldId, OnFieldMask,
00162 false,
00163 (FieldAccessMethod) &LightBase::getSFOn),
00164 new FieldDescription(SFReal32::getClassType(),
00165 "constantAttenuation",
00166 ConstantAttenuationFieldId, ConstantAttenuationFieldMask,
00167 false,
00168 (FieldAccessMethod) &LightBase::getSFConstantAttenuation),
00169 new FieldDescription(SFReal32::getClassType(),
00170 "linearAttenuation",
00171 LinearAttenuationFieldId, LinearAttenuationFieldMask,
00172 false,
00173 (FieldAccessMethod) &LightBase::getSFLinearAttenuation),
00174 new FieldDescription(SFReal32::getClassType(),
00175 "quadraticAttenuation",
00176 QuadraticAttenuationFieldId, QuadraticAttenuationFieldMask,
00177 false,
00178 (FieldAccessMethod) &LightBase::getSFQuadraticAttenuation),
00179 new FieldDescription(SFReal32::getClassType(),
00180 "shadowIntensity",
00181 ShadowIntensityFieldId, ShadowIntensityFieldMask,
00182 false,
00183 (FieldAccessMethod) &LightBase::getSFShadowIntensity),
00184 new FieldDescription(SFUInt32::getClassType(),
00185 "shadowMode",
00186 ShadowModeFieldId, ShadowModeFieldMask,
00187 false,
00188 (FieldAccessMethod) &LightBase::getSFShadowMode)
00189 };
00190
00191
00192 FieldContainerType LightBase::_type(
00193 "Light",
00194 "Group",
00195 NULL,
00196 NULL,
00197 Light::initMethod,
00198 _desc,
00199 sizeof(_desc));
00200
00201
00202
00203
00204
00205 FieldContainerType &LightBase::getType(void)
00206 {
00207 return _type;
00208 }
00209
00210 const FieldContainerType &LightBase::getType(void) const
00211 {
00212 return _type;
00213 }
00214
00215
00216 UInt32 LightBase::getContainerSize(void) const
00217 {
00218 return sizeof(Light);
00219 }
00220
00221
00222 #if !defined(OSG_FIXED_MFIELDSYNC)
00223 void LightBase::executeSync( FieldContainer &other,
00224 const BitVector &whichField)
00225 {
00226 this->executeSyncImpl((LightBase *) &other, whichField);
00227 }
00228 #else
00229 void LightBase::executeSync( FieldContainer &other,
00230 const BitVector &whichField, const SyncInfo &sInfo )
00231 {
00232 this->executeSyncImpl((LightBase *) &other, whichField, sInfo);
00233 }
00234 void LightBase::execBeginEdit(const BitVector &whichField,
00235 UInt32 uiAspect,
00236 UInt32 uiContainerSize)
00237 {
00238 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00239 }
00240
00241 void LightBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00242 {
00243 Inherited::onDestroyAspect(uiId, uiAspect);
00244
00245 }
00246 #endif
00247
00248
00249
00250 #ifdef OSG_WIN32_ICL
00251 #pragma warning (disable : 383)
00252 #endif
00253
00254 LightBase::LightBase(void) :
00255 _sfAmbient (Color4f(0,0,0,1)),
00256 _sfDiffuse (Color4f(1,1,1,1)),
00257 _sfSpecular (Color4f(1,1,1,1)),
00258 _sfBeacon (),
00259 _sfOn (bool(true)),
00260 _sfConstantAttenuation (Real32(1)),
00261 _sfLinearAttenuation (Real32(0)),
00262 _sfQuadraticAttenuation (Real32(0)),
00263 _sfShadowIntensity (Real32(0.0f)),
00264 _sfShadowMode (UInt32(0)),
00265 Inherited()
00266 {
00267 }
00268
00269 #ifdef OSG_WIN32_ICL
00270 #pragma warning (default : 383)
00271 #endif
00272
00273 LightBase::LightBase(const LightBase &source) :
00274 _sfAmbient (source._sfAmbient ),
00275 _sfDiffuse (source._sfDiffuse ),
00276 _sfSpecular (source._sfSpecular ),
00277 _sfBeacon (source._sfBeacon ),
00278 _sfOn (source._sfOn ),
00279 _sfConstantAttenuation (source._sfConstantAttenuation ),
00280 _sfLinearAttenuation (source._sfLinearAttenuation ),
00281 _sfQuadraticAttenuation (source._sfQuadraticAttenuation ),
00282 _sfShadowIntensity (source._sfShadowIntensity ),
00283 _sfShadowMode (source._sfShadowMode ),
00284 Inherited (source)
00285 {
00286 }
00287
00288
00289
00290 LightBase::~LightBase(void)
00291 {
00292 }
00293
00294
00295
00296 UInt32 LightBase::getBinSize(const BitVector &whichField)
00297 {
00298 UInt32 returnValue = Inherited::getBinSize(whichField);
00299
00300 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00301 {
00302 returnValue += _sfAmbient.getBinSize();
00303 }
00304
00305 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00306 {
00307 returnValue += _sfDiffuse.getBinSize();
00308 }
00309
00310 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00311 {
00312 returnValue += _sfSpecular.getBinSize();
00313 }
00314
00315 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00316 {
00317 returnValue += _sfBeacon.getBinSize();
00318 }
00319
00320 if(FieldBits::NoField != (OnFieldMask & whichField))
00321 {
00322 returnValue += _sfOn.getBinSize();
00323 }
00324
00325 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00326 {
00327 returnValue += _sfConstantAttenuation.getBinSize();
00328 }
00329
00330 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00331 {
00332 returnValue += _sfLinearAttenuation.getBinSize();
00333 }
00334
00335 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00336 {
00337 returnValue += _sfQuadraticAttenuation.getBinSize();
00338 }
00339
00340 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
00341 {
00342 returnValue += _sfShadowIntensity.getBinSize();
00343 }
00344
00345 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
00346 {
00347 returnValue += _sfShadowMode.getBinSize();
00348 }
00349
00350
00351 return returnValue;
00352 }
00353
00354 void LightBase::copyToBin( BinaryDataHandler &pMem,
00355 const BitVector &whichField)
00356 {
00357 Inherited::copyToBin(pMem, whichField);
00358
00359 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00360 {
00361 _sfAmbient.copyToBin(pMem);
00362 }
00363
00364 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00365 {
00366 _sfDiffuse.copyToBin(pMem);
00367 }
00368
00369 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00370 {
00371 _sfSpecular.copyToBin(pMem);
00372 }
00373
00374 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00375 {
00376 _sfBeacon.copyToBin(pMem);
00377 }
00378
00379 if(FieldBits::NoField != (OnFieldMask & whichField))
00380 {
00381 _sfOn.copyToBin(pMem);
00382 }
00383
00384 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00385 {
00386 _sfConstantAttenuation.copyToBin(pMem);
00387 }
00388
00389 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00390 {
00391 _sfLinearAttenuation.copyToBin(pMem);
00392 }
00393
00394 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00395 {
00396 _sfQuadraticAttenuation.copyToBin(pMem);
00397 }
00398
00399 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
00400 {
00401 _sfShadowIntensity.copyToBin(pMem);
00402 }
00403
00404 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
00405 {
00406 _sfShadowMode.copyToBin(pMem);
00407 }
00408
00409
00410 }
00411
00412 void LightBase::copyFromBin( BinaryDataHandler &pMem,
00413 const BitVector &whichField)
00414 {
00415 Inherited::copyFromBin(pMem, whichField);
00416
00417 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00418 {
00419 _sfAmbient.copyFromBin(pMem);
00420 }
00421
00422 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00423 {
00424 _sfDiffuse.copyFromBin(pMem);
00425 }
00426
00427 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00428 {
00429 _sfSpecular.copyFromBin(pMem);
00430 }
00431
00432 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00433 {
00434 _sfBeacon.copyFromBin(pMem);
00435 }
00436
00437 if(FieldBits::NoField != (OnFieldMask & whichField))
00438 {
00439 _sfOn.copyFromBin(pMem);
00440 }
00441
00442 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00443 {
00444 _sfConstantAttenuation.copyFromBin(pMem);
00445 }
00446
00447 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00448 {
00449 _sfLinearAttenuation.copyFromBin(pMem);
00450 }
00451
00452 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00453 {
00454 _sfQuadraticAttenuation.copyFromBin(pMem);
00455 }
00456
00457 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
00458 {
00459 _sfShadowIntensity.copyFromBin(pMem);
00460 }
00461
00462 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
00463 {
00464 _sfShadowMode.copyFromBin(pMem);
00465 }
00466
00467
00468 }
00469
00470 #if !defined(OSG_FIXED_MFIELDSYNC)
00471 void LightBase::executeSyncImpl( LightBase *pOther,
00472 const BitVector &whichField)
00473 {
00474
00475 Inherited::executeSyncImpl(pOther, whichField);
00476
00477 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00478 _sfAmbient.syncWith(pOther->_sfAmbient);
00479
00480 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00481 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00482
00483 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00484 _sfSpecular.syncWith(pOther->_sfSpecular);
00485
00486 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00487 _sfBeacon.syncWith(pOther->_sfBeacon);
00488
00489 if(FieldBits::NoField != (OnFieldMask & whichField))
00490 _sfOn.syncWith(pOther->_sfOn);
00491
00492 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00493 _sfConstantAttenuation.syncWith(pOther->_sfConstantAttenuation);
00494
00495 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00496 _sfLinearAttenuation.syncWith(pOther->_sfLinearAttenuation);
00497
00498 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00499 _sfQuadraticAttenuation.syncWith(pOther->_sfQuadraticAttenuation);
00500
00501 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
00502 _sfShadowIntensity.syncWith(pOther->_sfShadowIntensity);
00503
00504 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
00505 _sfShadowMode.syncWith(pOther->_sfShadowMode);
00506
00507
00508 }
00509 #else
00510 void LightBase::executeSyncImpl( LightBase *pOther,
00511 const BitVector &whichField,
00512 const SyncInfo &sInfo )
00513 {
00514
00515 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00516
00517 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00518 _sfAmbient.syncWith(pOther->_sfAmbient);
00519
00520 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00521 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00522
00523 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00524 _sfSpecular.syncWith(pOther->_sfSpecular);
00525
00526 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00527 _sfBeacon.syncWith(pOther->_sfBeacon);
00528
00529 if(FieldBits::NoField != (OnFieldMask & whichField))
00530 _sfOn.syncWith(pOther->_sfOn);
00531
00532 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00533 _sfConstantAttenuation.syncWith(pOther->_sfConstantAttenuation);
00534
00535 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00536 _sfLinearAttenuation.syncWith(pOther->_sfLinearAttenuation);
00537
00538 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00539 _sfQuadraticAttenuation.syncWith(pOther->_sfQuadraticAttenuation);
00540
00541 if(FieldBits::NoField != (ShadowIntensityFieldMask & whichField))
00542 _sfShadowIntensity.syncWith(pOther->_sfShadowIntensity);
00543
00544 if(FieldBits::NoField != (ShadowModeFieldMask & whichField))
00545 _sfShadowMode.syncWith(pOther->_sfShadowMode);
00546
00547
00548
00549 }
00550
00551 void LightBase::execBeginEditImpl (const BitVector &whichField,
00552 UInt32 uiAspect,
00553 UInt32 uiContainerSize)
00554 {
00555 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00556
00557 }
00558 #endif
00559
00560
00561
00562 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00563 DataType FieldDataTraits<LightPtr>::_type("LightPtr", "GroupPtr");
00564 #endif
00565
00566
00567
00568
00569
00570
00571 #ifdef OSG_SGI_CC
00572 #pragma set woff 1174
00573 #endif
00574
00575 #ifdef OSG_LINUX_ICC
00576 #pragma warning( disable : 177 )
00577 #endif
00578
00579 namespace
00580 {
00581 static Char8 cvsid_cpp [] = "@(#)$Id: FCBaseTemplate_cpp.h,v 1.47 2006/03/17 17:03:19 pdaehne Exp $";
00582 static Char8 cvsid_hpp [] = OSGLIGHTBASE_HEADER_CVSID;
00583 static Char8 cvsid_inl [] = OSGLIGHTBASE_INLINE_CVSID;
00584
00585 static Char8 cvsid_fields_hpp[] = OSGLIGHTFIELDS_HEADER_CVSID;
00586 }
00587
00588 OSG_END_NAMESPACE
00589