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_USING_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::MTInfluenceMask =
00092 (Inherited::MTInfluenceMask) |
00093 (static_cast<BitVector>(0x0) << Inherited::NextFieldId);
00094
00095
00096
00097
00123
00124
00125 FieldDescription *LightBase::_desc[] =
00126 {
00127 new FieldDescription(SFColor4f::getClassType(),
00128 "ambient",
00129 AmbientFieldId, AmbientFieldMask,
00130 false,
00131 (FieldAccessMethod) &LightBase::getSFAmbient),
00132 new FieldDescription(SFColor4f::getClassType(),
00133 "diffuse",
00134 DiffuseFieldId, DiffuseFieldMask,
00135 false,
00136 (FieldAccessMethod) &LightBase::getSFDiffuse),
00137 new FieldDescription(SFColor4f::getClassType(),
00138 "specular",
00139 SpecularFieldId, SpecularFieldMask,
00140 false,
00141 (FieldAccessMethod) &LightBase::getSFSpecular),
00142 new FieldDescription(SFNodePtr::getClassType(),
00143 "beacon",
00144 BeaconFieldId, BeaconFieldMask,
00145 false,
00146 (FieldAccessMethod) &LightBase::getSFBeacon),
00147 new FieldDescription(SFBool::getClassType(),
00148 "on",
00149 OnFieldId, OnFieldMask,
00150 false,
00151 (FieldAccessMethod) &LightBase::getSFOn),
00152 new FieldDescription(SFReal32::getClassType(),
00153 "constantAttenuation",
00154 ConstantAttenuationFieldId, ConstantAttenuationFieldMask,
00155 false,
00156 (FieldAccessMethod) &LightBase::getSFConstantAttenuation),
00157 new FieldDescription(SFReal32::getClassType(),
00158 "linearAttenuation",
00159 LinearAttenuationFieldId, LinearAttenuationFieldMask,
00160 false,
00161 (FieldAccessMethod) &LightBase::getSFLinearAttenuation),
00162 new FieldDescription(SFReal32::getClassType(),
00163 "quadraticAttenuation",
00164 QuadraticAttenuationFieldId, QuadraticAttenuationFieldMask,
00165 false,
00166 (FieldAccessMethod) &LightBase::getSFQuadraticAttenuation)
00167 };
00168
00169
00170 FieldContainerType LightBase::_type(
00171 "Light",
00172 "NodeCore",
00173 NULL,
00174 NULL,
00175 Light::initMethod,
00176 _desc,
00177 sizeof(_desc));
00178
00179
00180
00181
00182
00183 FieldContainerType &LightBase::getType(void)
00184 {
00185 return _type;
00186 }
00187
00188 const FieldContainerType &LightBase::getType(void) const
00189 {
00190 return _type;
00191 }
00192
00193
00194 UInt32 LightBase::getContainerSize(void) const
00195 {
00196 return sizeof(Light);
00197 }
00198
00199
00200 #if !defined(OSG_FIXED_MFIELDSYNC)
00201 void LightBase::executeSync( FieldContainer &other,
00202 const BitVector &whichField)
00203 {
00204 this->executeSyncImpl((LightBase *) &other, whichField);
00205 }
00206 #else
00207 void LightBase::executeSync( FieldContainer &other,
00208 const BitVector &whichField, const SyncInfo &sInfo )
00209 {
00210 this->executeSyncImpl((LightBase *) &other, whichField, sInfo);
00211 }
00212 void LightBase::execBeginEdit(const BitVector &whichField,
00213 UInt32 uiAspect,
00214 UInt32 uiContainerSize)
00215 {
00216 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00217 }
00218
00219 void LightBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00220 {
00221 Inherited::onDestroyAspect(uiId, uiAspect);
00222
00223 }
00224 #endif
00225
00226
00227
00228 #ifdef OSG_WIN32_ICL
00229 #pragma warning (disable : 383)
00230 #endif
00231
00232 LightBase::LightBase(void) :
00233 _sfAmbient (Color4f(0,0,0,1)),
00234 _sfDiffuse (Color4f(1,1,1,1)),
00235 _sfSpecular (Color4f(1,1,1,1)),
00236 _sfBeacon (),
00237 _sfOn (bool(true)),
00238 _sfConstantAttenuation (Real32(1)),
00239 _sfLinearAttenuation (Real32(0)),
00240 _sfQuadraticAttenuation (Real32(0)),
00241 Inherited()
00242 {
00243 }
00244
00245 #ifdef OSG_WIN32_ICL
00246 #pragma warning (default : 383)
00247 #endif
00248
00249 LightBase::LightBase(const LightBase &source) :
00250 _sfAmbient (source._sfAmbient ),
00251 _sfDiffuse (source._sfDiffuse ),
00252 _sfSpecular (source._sfSpecular ),
00253 _sfBeacon (source._sfBeacon ),
00254 _sfOn (source._sfOn ),
00255 _sfConstantAttenuation (source._sfConstantAttenuation ),
00256 _sfLinearAttenuation (source._sfLinearAttenuation ),
00257 _sfQuadraticAttenuation (source._sfQuadraticAttenuation ),
00258 Inherited (source)
00259 {
00260 }
00261
00262
00263
00264 LightBase::~LightBase(void)
00265 {
00266 }
00267
00268
00269
00270 UInt32 LightBase::getBinSize(const BitVector &whichField)
00271 {
00272 UInt32 returnValue = Inherited::getBinSize(whichField);
00273
00274 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00275 {
00276 returnValue += _sfAmbient.getBinSize();
00277 }
00278
00279 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00280 {
00281 returnValue += _sfDiffuse.getBinSize();
00282 }
00283
00284 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00285 {
00286 returnValue += _sfSpecular.getBinSize();
00287 }
00288
00289 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00290 {
00291 returnValue += _sfBeacon.getBinSize();
00292 }
00293
00294 if(FieldBits::NoField != (OnFieldMask & whichField))
00295 {
00296 returnValue += _sfOn.getBinSize();
00297 }
00298
00299 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00300 {
00301 returnValue += _sfConstantAttenuation.getBinSize();
00302 }
00303
00304 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00305 {
00306 returnValue += _sfLinearAttenuation.getBinSize();
00307 }
00308
00309 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00310 {
00311 returnValue += _sfQuadraticAttenuation.getBinSize();
00312 }
00313
00314
00315 return returnValue;
00316 }
00317
00318 void LightBase::copyToBin( BinaryDataHandler &pMem,
00319 const BitVector &whichField)
00320 {
00321 Inherited::copyToBin(pMem, whichField);
00322
00323 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00324 {
00325 _sfAmbient.copyToBin(pMem);
00326 }
00327
00328 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00329 {
00330 _sfDiffuse.copyToBin(pMem);
00331 }
00332
00333 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00334 {
00335 _sfSpecular.copyToBin(pMem);
00336 }
00337
00338 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00339 {
00340 _sfBeacon.copyToBin(pMem);
00341 }
00342
00343 if(FieldBits::NoField != (OnFieldMask & whichField))
00344 {
00345 _sfOn.copyToBin(pMem);
00346 }
00347
00348 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00349 {
00350 _sfConstantAttenuation.copyToBin(pMem);
00351 }
00352
00353 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00354 {
00355 _sfLinearAttenuation.copyToBin(pMem);
00356 }
00357
00358 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00359 {
00360 _sfQuadraticAttenuation.copyToBin(pMem);
00361 }
00362
00363
00364 }
00365
00366 void LightBase::copyFromBin( BinaryDataHandler &pMem,
00367 const BitVector &whichField)
00368 {
00369 Inherited::copyFromBin(pMem, whichField);
00370
00371 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00372 {
00373 _sfAmbient.copyFromBin(pMem);
00374 }
00375
00376 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00377 {
00378 _sfDiffuse.copyFromBin(pMem);
00379 }
00380
00381 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00382 {
00383 _sfSpecular.copyFromBin(pMem);
00384 }
00385
00386 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00387 {
00388 _sfBeacon.copyFromBin(pMem);
00389 }
00390
00391 if(FieldBits::NoField != (OnFieldMask & whichField))
00392 {
00393 _sfOn.copyFromBin(pMem);
00394 }
00395
00396 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00397 {
00398 _sfConstantAttenuation.copyFromBin(pMem);
00399 }
00400
00401 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00402 {
00403 _sfLinearAttenuation.copyFromBin(pMem);
00404 }
00405
00406 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00407 {
00408 _sfQuadraticAttenuation.copyFromBin(pMem);
00409 }
00410
00411
00412 }
00413
00414 #if !defined(OSG_FIXED_MFIELDSYNC)
00415 void LightBase::executeSyncImpl( LightBase *pOther,
00416 const BitVector &whichField)
00417 {
00418
00419 Inherited::executeSyncImpl(pOther, whichField);
00420
00421 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00422 _sfAmbient.syncWith(pOther->_sfAmbient);
00423
00424 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00425 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00426
00427 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00428 _sfSpecular.syncWith(pOther->_sfSpecular);
00429
00430 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00431 _sfBeacon.syncWith(pOther->_sfBeacon);
00432
00433 if(FieldBits::NoField != (OnFieldMask & whichField))
00434 _sfOn.syncWith(pOther->_sfOn);
00435
00436 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00437 _sfConstantAttenuation.syncWith(pOther->_sfConstantAttenuation);
00438
00439 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00440 _sfLinearAttenuation.syncWith(pOther->_sfLinearAttenuation);
00441
00442 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00443 _sfQuadraticAttenuation.syncWith(pOther->_sfQuadraticAttenuation);
00444
00445
00446 }
00447 #else
00448 void LightBase::executeSyncImpl( LightBase *pOther,
00449 const BitVector &whichField,
00450 const SyncInfo &sInfo )
00451 {
00452
00453 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00454
00455 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00456 _sfAmbient.syncWith(pOther->_sfAmbient);
00457
00458 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00459 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00460
00461 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00462 _sfSpecular.syncWith(pOther->_sfSpecular);
00463
00464 if(FieldBits::NoField != (BeaconFieldMask & whichField))
00465 _sfBeacon.syncWith(pOther->_sfBeacon);
00466
00467 if(FieldBits::NoField != (OnFieldMask & whichField))
00468 _sfOn.syncWith(pOther->_sfOn);
00469
00470 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00471 _sfConstantAttenuation.syncWith(pOther->_sfConstantAttenuation);
00472
00473 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00474 _sfLinearAttenuation.syncWith(pOther->_sfLinearAttenuation);
00475
00476 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00477 _sfQuadraticAttenuation.syncWith(pOther->_sfQuadraticAttenuation);
00478
00479
00480
00481 }
00482
00483 void LightBase::execBeginEditImpl (const BitVector &whichField,
00484 UInt32 uiAspect,
00485 UInt32 uiContainerSize)
00486 {
00487 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00488
00489 }
00490 #endif
00491
00492
00493
00494 OSG_BEGIN_NAMESPACE
00495
00496 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00497 DataType FieldDataTraits<LightPtr>::_type("LightPtr", "NodeCorePtr");
00498 #endif
00499
00500
00501 OSG_END_NAMESPACE
00502
00503
00504
00505
00506
00507 #ifdef OSG_SGI_CC
00508 #pragma set woff 1174
00509 #endif
00510
00511 #ifdef OSG_LINUX_ICC
00512 #pragma warning( disable : 177 )
00513 #endif
00514
00515 namespace
00516 {
00517 static Char8 cvsid_cpp [] = "@(#)$Id: FCBaseTemplate_cpp.h,v 1.42 2004/08/03 05:53:03 dirk Exp $";
00518 static Char8 cvsid_hpp [] = OSGLIGHTBASE_HEADER_CVSID;
00519 static Char8 cvsid_inl [] = OSGLIGHTBASE_INLINE_CVSID;
00520
00521 static Char8 cvsid_fields_hpp[] = OSGLIGHTFIELDS_HEADER_CVSID;
00522 }
00523