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_COMPILELIGHTCHUNKINST
00055
00056 #include <stdlib.h>
00057 #include <stdio.h>
00058
00059 #include <OSGConfig.h>
00060
00061 #include "OSGLightChunkBase.h"
00062 #include "OSGLightChunk.h"
00063
00064
00065 OSG_USING_NAMESPACE
00066
00067 const OSG::BitVector LightChunkBase::DiffuseFieldMask =
00068 (TypeTraits<BitVector>::One << LightChunkBase::DiffuseFieldId);
00069
00070 const OSG::BitVector LightChunkBase::AmbientFieldMask =
00071 (TypeTraits<BitVector>::One << LightChunkBase::AmbientFieldId);
00072
00073 const OSG::BitVector LightChunkBase::SpecularFieldMask =
00074 (TypeTraits<BitVector>::One << LightChunkBase::SpecularFieldId);
00075
00076 const OSG::BitVector LightChunkBase::PositionFieldMask =
00077 (TypeTraits<BitVector>::One << LightChunkBase::PositionFieldId);
00078
00079 const OSG::BitVector LightChunkBase::DirectionFieldMask =
00080 (TypeTraits<BitVector>::One << LightChunkBase::DirectionFieldId);
00081
00082 const OSG::BitVector LightChunkBase::ExponentFieldMask =
00083 (TypeTraits<BitVector>::One << LightChunkBase::ExponentFieldId);
00084
00085 const OSG::BitVector LightChunkBase::CutoffFieldMask =
00086 (TypeTraits<BitVector>::One << LightChunkBase::CutoffFieldId);
00087
00088 const OSG::BitVector LightChunkBase::ConstantAttenuationFieldMask =
00089 (TypeTraits<BitVector>::One << LightChunkBase::ConstantAttenuationFieldId);
00090
00091 const OSG::BitVector LightChunkBase::LinearAttenuationFieldMask =
00092 (TypeTraits<BitVector>::One << LightChunkBase::LinearAttenuationFieldId);
00093
00094 const OSG::BitVector LightChunkBase::QuadraticAttenuationFieldMask =
00095 (TypeTraits<BitVector>::One << LightChunkBase::QuadraticAttenuationFieldId);
00096
00097 const OSG::BitVector LightChunkBase::MTInfluenceMask =
00098 (Inherited::MTInfluenceMask) |
00099 (static_cast<BitVector>(0x0) << Inherited::NextFieldId);
00100
00101
00102
00103
00135
00136
00137 FieldDescription *LightChunkBase::_desc[] =
00138 {
00139 new FieldDescription(SFColor4f::getClassType(),
00140 "diffuse",
00141 DiffuseFieldId, DiffuseFieldMask,
00142 false,
00143 (FieldAccessMethod) &LightChunkBase::getSFDiffuse),
00144 new FieldDescription(SFColor4f::getClassType(),
00145 "ambient",
00146 AmbientFieldId, AmbientFieldMask,
00147 false,
00148 (FieldAccessMethod) &LightChunkBase::getSFAmbient),
00149 new FieldDescription(SFColor4f::getClassType(),
00150 "specular",
00151 SpecularFieldId, SpecularFieldMask,
00152 false,
00153 (FieldAccessMethod) &LightChunkBase::getSFSpecular),
00154 new FieldDescription(SFVec4f::getClassType(),
00155 "position",
00156 PositionFieldId, PositionFieldMask,
00157 false,
00158 (FieldAccessMethod) &LightChunkBase::getSFPosition),
00159 new FieldDescription(SFVec3f::getClassType(),
00160 "direction",
00161 DirectionFieldId, DirectionFieldMask,
00162 false,
00163 (FieldAccessMethod) &LightChunkBase::getSFDirection),
00164 new FieldDescription(SFReal32::getClassType(),
00165 "exponent",
00166 ExponentFieldId, ExponentFieldMask,
00167 false,
00168 (FieldAccessMethod) &LightChunkBase::getSFExponent),
00169 new FieldDescription(SFReal32::getClassType(),
00170 "cutoff",
00171 CutoffFieldId, CutoffFieldMask,
00172 false,
00173 (FieldAccessMethod) &LightChunkBase::getSFCutoff),
00174 new FieldDescription(SFReal32::getClassType(),
00175 "constantAttenuation",
00176 ConstantAttenuationFieldId, ConstantAttenuationFieldMask,
00177 false,
00178 (FieldAccessMethod) &LightChunkBase::getSFConstantAttenuation),
00179 new FieldDescription(SFReal32::getClassType(),
00180 "linearAttenuation",
00181 LinearAttenuationFieldId, LinearAttenuationFieldMask,
00182 false,
00183 (FieldAccessMethod) &LightChunkBase::getSFLinearAttenuation),
00184 new FieldDescription(SFReal32::getClassType(),
00185 "quadraticAttenuation",
00186 QuadraticAttenuationFieldId, QuadraticAttenuationFieldMask,
00187 false,
00188 (FieldAccessMethod) &LightChunkBase::getSFQuadraticAttenuation)
00189 };
00190
00191
00192 FieldContainerType LightChunkBase::_type(
00193 "LightChunk",
00194 "StateChunk",
00195 NULL,
00196 (PrototypeCreateF) &LightChunkBase::createEmpty,
00197 LightChunk::initMethod,
00198 _desc,
00199 sizeof(_desc));
00200
00201
00202
00203
00204
00205 FieldContainerType &LightChunkBase::getType(void)
00206 {
00207 return _type;
00208 }
00209
00210 const FieldContainerType &LightChunkBase::getType(void) const
00211 {
00212 return _type;
00213 }
00214
00215
00216 FieldContainerPtr LightChunkBase::shallowCopy(void) const
00217 {
00218 LightChunkPtr returnValue;
00219
00220 newPtr(returnValue, dynamic_cast<const LightChunk *>(this));
00221
00222 return returnValue;
00223 }
00224
00225 UInt32 LightChunkBase::getContainerSize(void) const
00226 {
00227 return sizeof(LightChunk);
00228 }
00229
00230
00231 #if !defined(OSG_FIXED_MFIELDSYNC)
00232 void LightChunkBase::executeSync( FieldContainer &other,
00233 const BitVector &whichField)
00234 {
00235 this->executeSyncImpl((LightChunkBase *) &other, whichField);
00236 }
00237 #else
00238 void LightChunkBase::executeSync( FieldContainer &other,
00239 const BitVector &whichField, const SyncInfo &sInfo )
00240 {
00241 this->executeSyncImpl((LightChunkBase *) &other, whichField, sInfo);
00242 }
00243 void LightChunkBase::execBeginEdit(const BitVector &whichField,
00244 UInt32 uiAspect,
00245 UInt32 uiContainerSize)
00246 {
00247 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00248 }
00249
00250 void LightChunkBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00251 {
00252 Inherited::onDestroyAspect(uiId, uiAspect);
00253
00254 }
00255 #endif
00256
00257
00258
00259 #ifdef OSG_WIN32_ICL
00260 #pragma warning (disable : 383)
00261 #endif
00262
00263 LightChunkBase::LightChunkBase(void) :
00264 _sfDiffuse (Color4f(1,1,1,0)),
00265 _sfAmbient (Color4f(.1,.1,.1,0)),
00266 _sfSpecular (Color4f(1,1,1,0)),
00267 _sfPosition (Vec4f(0,-1,0,0)),
00268 _sfDirection (Vec3f(0,0,1)),
00269 _sfExponent (Real32(2)),
00270 _sfCutoff (Real32(180)),
00271 _sfConstantAttenuation (Real32(1)),
00272 _sfLinearAttenuation (Real32(0)),
00273 _sfQuadraticAttenuation (Real32(0)),
00274 Inherited()
00275 {
00276 }
00277
00278 #ifdef OSG_WIN32_ICL
00279 #pragma warning (default : 383)
00280 #endif
00281
00282 LightChunkBase::LightChunkBase(const LightChunkBase &source) :
00283 _sfDiffuse (source._sfDiffuse ),
00284 _sfAmbient (source._sfAmbient ),
00285 _sfSpecular (source._sfSpecular ),
00286 _sfPosition (source._sfPosition ),
00287 _sfDirection (source._sfDirection ),
00288 _sfExponent (source._sfExponent ),
00289 _sfCutoff (source._sfCutoff ),
00290 _sfConstantAttenuation (source._sfConstantAttenuation ),
00291 _sfLinearAttenuation (source._sfLinearAttenuation ),
00292 _sfQuadraticAttenuation (source._sfQuadraticAttenuation ),
00293 Inherited (source)
00294 {
00295 }
00296
00297
00298
00299 LightChunkBase::~LightChunkBase(void)
00300 {
00301 }
00302
00303
00304
00305 UInt32 LightChunkBase::getBinSize(const BitVector &whichField)
00306 {
00307 UInt32 returnValue = Inherited::getBinSize(whichField);
00308
00309 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00310 {
00311 returnValue += _sfDiffuse.getBinSize();
00312 }
00313
00314 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00315 {
00316 returnValue += _sfAmbient.getBinSize();
00317 }
00318
00319 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00320 {
00321 returnValue += _sfSpecular.getBinSize();
00322 }
00323
00324 if(FieldBits::NoField != (PositionFieldMask & whichField))
00325 {
00326 returnValue += _sfPosition.getBinSize();
00327 }
00328
00329 if(FieldBits::NoField != (DirectionFieldMask & whichField))
00330 {
00331 returnValue += _sfDirection.getBinSize();
00332 }
00333
00334 if(FieldBits::NoField != (ExponentFieldMask & whichField))
00335 {
00336 returnValue += _sfExponent.getBinSize();
00337 }
00338
00339 if(FieldBits::NoField != (CutoffFieldMask & whichField))
00340 {
00341 returnValue += _sfCutoff.getBinSize();
00342 }
00343
00344 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00345 {
00346 returnValue += _sfConstantAttenuation.getBinSize();
00347 }
00348
00349 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00350 {
00351 returnValue += _sfLinearAttenuation.getBinSize();
00352 }
00353
00354 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00355 {
00356 returnValue += _sfQuadraticAttenuation.getBinSize();
00357 }
00358
00359
00360 return returnValue;
00361 }
00362
00363 void LightChunkBase::copyToBin( BinaryDataHandler &pMem,
00364 const BitVector &whichField)
00365 {
00366 Inherited::copyToBin(pMem, whichField);
00367
00368 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00369 {
00370 _sfDiffuse.copyToBin(pMem);
00371 }
00372
00373 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00374 {
00375 _sfAmbient.copyToBin(pMem);
00376 }
00377
00378 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00379 {
00380 _sfSpecular.copyToBin(pMem);
00381 }
00382
00383 if(FieldBits::NoField != (PositionFieldMask & whichField))
00384 {
00385 _sfPosition.copyToBin(pMem);
00386 }
00387
00388 if(FieldBits::NoField != (DirectionFieldMask & whichField))
00389 {
00390 _sfDirection.copyToBin(pMem);
00391 }
00392
00393 if(FieldBits::NoField != (ExponentFieldMask & whichField))
00394 {
00395 _sfExponent.copyToBin(pMem);
00396 }
00397
00398 if(FieldBits::NoField != (CutoffFieldMask & whichField))
00399 {
00400 _sfCutoff.copyToBin(pMem);
00401 }
00402
00403 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00404 {
00405 _sfConstantAttenuation.copyToBin(pMem);
00406 }
00407
00408 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00409 {
00410 _sfLinearAttenuation.copyToBin(pMem);
00411 }
00412
00413 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00414 {
00415 _sfQuadraticAttenuation.copyToBin(pMem);
00416 }
00417
00418
00419 }
00420
00421 void LightChunkBase::copyFromBin( BinaryDataHandler &pMem,
00422 const BitVector &whichField)
00423 {
00424 Inherited::copyFromBin(pMem, whichField);
00425
00426 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00427 {
00428 _sfDiffuse.copyFromBin(pMem);
00429 }
00430
00431 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00432 {
00433 _sfAmbient.copyFromBin(pMem);
00434 }
00435
00436 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00437 {
00438 _sfSpecular.copyFromBin(pMem);
00439 }
00440
00441 if(FieldBits::NoField != (PositionFieldMask & whichField))
00442 {
00443 _sfPosition.copyFromBin(pMem);
00444 }
00445
00446 if(FieldBits::NoField != (DirectionFieldMask & whichField))
00447 {
00448 _sfDirection.copyFromBin(pMem);
00449 }
00450
00451 if(FieldBits::NoField != (ExponentFieldMask & whichField))
00452 {
00453 _sfExponent.copyFromBin(pMem);
00454 }
00455
00456 if(FieldBits::NoField != (CutoffFieldMask & whichField))
00457 {
00458 _sfCutoff.copyFromBin(pMem);
00459 }
00460
00461 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00462 {
00463 _sfConstantAttenuation.copyFromBin(pMem);
00464 }
00465
00466 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00467 {
00468 _sfLinearAttenuation.copyFromBin(pMem);
00469 }
00470
00471 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00472 {
00473 _sfQuadraticAttenuation.copyFromBin(pMem);
00474 }
00475
00476
00477 }
00478
00479 #if !defined(OSG_FIXED_MFIELDSYNC)
00480 void LightChunkBase::executeSyncImpl( LightChunkBase *pOther,
00481 const BitVector &whichField)
00482 {
00483
00484 Inherited::executeSyncImpl(pOther, whichField);
00485
00486 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00487 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00488
00489 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00490 _sfAmbient.syncWith(pOther->_sfAmbient);
00491
00492 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00493 _sfSpecular.syncWith(pOther->_sfSpecular);
00494
00495 if(FieldBits::NoField != (PositionFieldMask & whichField))
00496 _sfPosition.syncWith(pOther->_sfPosition);
00497
00498 if(FieldBits::NoField != (DirectionFieldMask & whichField))
00499 _sfDirection.syncWith(pOther->_sfDirection);
00500
00501 if(FieldBits::NoField != (ExponentFieldMask & whichField))
00502 _sfExponent.syncWith(pOther->_sfExponent);
00503
00504 if(FieldBits::NoField != (CutoffFieldMask & whichField))
00505 _sfCutoff.syncWith(pOther->_sfCutoff);
00506
00507 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00508 _sfConstantAttenuation.syncWith(pOther->_sfConstantAttenuation);
00509
00510 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00511 _sfLinearAttenuation.syncWith(pOther->_sfLinearAttenuation);
00512
00513 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00514 _sfQuadraticAttenuation.syncWith(pOther->_sfQuadraticAttenuation);
00515
00516
00517 }
00518 #else
00519 void LightChunkBase::executeSyncImpl( LightChunkBase *pOther,
00520 const BitVector &whichField,
00521 const SyncInfo &sInfo )
00522 {
00523
00524 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00525
00526 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00527 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00528
00529 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00530 _sfAmbient.syncWith(pOther->_sfAmbient);
00531
00532 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00533 _sfSpecular.syncWith(pOther->_sfSpecular);
00534
00535 if(FieldBits::NoField != (PositionFieldMask & whichField))
00536 _sfPosition.syncWith(pOther->_sfPosition);
00537
00538 if(FieldBits::NoField != (DirectionFieldMask & whichField))
00539 _sfDirection.syncWith(pOther->_sfDirection);
00540
00541 if(FieldBits::NoField != (ExponentFieldMask & whichField))
00542 _sfExponent.syncWith(pOther->_sfExponent);
00543
00544 if(FieldBits::NoField != (CutoffFieldMask & whichField))
00545 _sfCutoff.syncWith(pOther->_sfCutoff);
00546
00547 if(FieldBits::NoField != (ConstantAttenuationFieldMask & whichField))
00548 _sfConstantAttenuation.syncWith(pOther->_sfConstantAttenuation);
00549
00550 if(FieldBits::NoField != (LinearAttenuationFieldMask & whichField))
00551 _sfLinearAttenuation.syncWith(pOther->_sfLinearAttenuation);
00552
00553 if(FieldBits::NoField != (QuadraticAttenuationFieldMask & whichField))
00554 _sfQuadraticAttenuation.syncWith(pOther->_sfQuadraticAttenuation);
00555
00556
00557
00558 }
00559
00560 void LightChunkBase::execBeginEditImpl (const BitVector &whichField,
00561 UInt32 uiAspect,
00562 UInt32 uiContainerSize)
00563 {
00564 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00565
00566 }
00567 #endif
00568
00569
00570
00571 #include <OSGSFieldTypeDef.inl>
00572 #include <OSGMFieldTypeDef.inl>
00573
00574 OSG_BEGIN_NAMESPACE
00575
00576 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00577 DataType FieldDataTraits<LightChunkPtr>::_type("LightChunkPtr", "StateChunkPtr");
00578 #endif
00579
00580 OSG_DLLEXPORT_SFIELD_DEF1(LightChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00581 OSG_DLLEXPORT_MFIELD_DEF1(LightChunkPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
00582
00583 OSG_END_NAMESPACE
00584
00585
00586
00587
00588
00589 #ifdef OSG_SGI_CC
00590 #pragma set woff 1174
00591 #endif
00592
00593 #ifdef OSG_LINUX_ICC
00594 #pragma warning( disable : 177 )
00595 #endif
00596
00597 namespace
00598 {
00599 static Char8 cvsid_cpp [] = "@(#)$Id: FCBaseTemplate_cpp.h,v 1.45 2005/07/20 00:10:14 vossg Exp $";
00600 static Char8 cvsid_hpp [] = OSGLIGHTCHUNKBASE_HEADER_CVSID;
00601 static Char8 cvsid_inl [] = OSGLIGHTCHUNKBASE_INLINE_CVSID;
00602
00603 static Char8 cvsid_fields_hpp[] = OSGLIGHTCHUNKFIELDS_HEADER_CVSID;
00604 }
00605