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_COMPILEFRESNELMATERIALINST
00055
00056 #include <stdlib.h>
00057 #include <stdio.h>
00058
00059 #include <OSGConfig.h>
00060
00061 #include "OSGFresnelMaterialBase.h"
00062 #include "OSGFresnelMaterial.h"
00063
00064 #include <OSGGL.h>
00065
00066 OSG_USING_NAMESPACE
00067
00068 const OSG::BitVector FresnelMaterialBase::AmbientFieldMask =
00069 (TypeTraits<BitVector>::One << FresnelMaterialBase::AmbientFieldId);
00070
00071 const OSG::BitVector FresnelMaterialBase::DiffuseFieldMask =
00072 (TypeTraits<BitVector>::One << FresnelMaterialBase::DiffuseFieldId);
00073
00074 const OSG::BitVector FresnelMaterialBase::SpecularFieldMask =
00075 (TypeTraits<BitVector>::One << FresnelMaterialBase::SpecularFieldId);
00076
00077 const OSG::BitVector FresnelMaterialBase::ShininessFieldMask =
00078 (TypeTraits<BitVector>::One << FresnelMaterialBase::ShininessFieldId);
00079
00080 const OSG::BitVector FresnelMaterialBase::EmissionFieldMask =
00081 (TypeTraits<BitVector>::One << FresnelMaterialBase::EmissionFieldId);
00082
00083 const OSG::BitVector FresnelMaterialBase::TransparencyFieldMask =
00084 (TypeTraits<BitVector>::One << FresnelMaterialBase::TransparencyFieldId);
00085
00086 const OSG::BitVector FresnelMaterialBase::LitFieldMask =
00087 (TypeTraits<BitVector>::One << FresnelMaterialBase::LitFieldId);
00088
00089 const OSG::BitVector FresnelMaterialBase::ColorMaterialFieldMask =
00090 (TypeTraits<BitVector>::One << FresnelMaterialBase::ColorMaterialFieldId);
00091
00092 const OSG::BitVector FresnelMaterialBase::IndexFieldMask =
00093 (TypeTraits<BitVector>::One << FresnelMaterialBase::IndexFieldId);
00094
00095 const OSG::BitVector FresnelMaterialBase::ScaleFieldMask =
00096 (TypeTraits<BitVector>::One << FresnelMaterialBase::ScaleFieldId);
00097
00098 const OSG::BitVector FresnelMaterialBase::BiasFieldMask =
00099 (TypeTraits<BitVector>::One << FresnelMaterialBase::BiasFieldId);
00100
00101 const OSG::BitVector FresnelMaterialBase::ImageFieldMask =
00102 (TypeTraits<BitVector>::One << FresnelMaterialBase::ImageFieldId);
00103
00104 const OSG::BitVector FresnelMaterialBase::MTInfluenceMask =
00105 (Inherited::MTInfluenceMask) |
00106 (static_cast<BitVector>(0x0) << Inherited::NextFieldId);
00107
00108
00109
00110
00148
00149
00150 FieldDescription *FresnelMaterialBase::_desc[] =
00151 {
00152 new FieldDescription(SFColor3f::getClassType(),
00153 "ambient",
00154 AmbientFieldId, AmbientFieldMask,
00155 false,
00156 (FieldAccessMethod) &FresnelMaterialBase::getSFAmbient),
00157 new FieldDescription(SFColor3f::getClassType(),
00158 "diffuse",
00159 DiffuseFieldId, DiffuseFieldMask,
00160 false,
00161 (FieldAccessMethod) &FresnelMaterialBase::getSFDiffuse),
00162 new FieldDescription(SFColor3f::getClassType(),
00163 "specular",
00164 SpecularFieldId, SpecularFieldMask,
00165 false,
00166 (FieldAccessMethod) &FresnelMaterialBase::getSFSpecular),
00167 new FieldDescription(SFReal32::getClassType(),
00168 "shininess",
00169 ShininessFieldId, ShininessFieldMask,
00170 false,
00171 (FieldAccessMethod) &FresnelMaterialBase::getSFShininess),
00172 new FieldDescription(SFColor3f::getClassType(),
00173 "emission",
00174 EmissionFieldId, EmissionFieldMask,
00175 false,
00176 (FieldAccessMethod) &FresnelMaterialBase::getSFEmission),
00177 new FieldDescription(SFReal32::getClassType(),
00178 "transparency",
00179 TransparencyFieldId, TransparencyFieldMask,
00180 false,
00181 (FieldAccessMethod) &FresnelMaterialBase::getSFTransparency),
00182 new FieldDescription(SFBool::getClassType(),
00183 "lit",
00184 LitFieldId, LitFieldMask,
00185 false,
00186 (FieldAccessMethod) &FresnelMaterialBase::getSFLit),
00187 new FieldDescription(SFGLenum::getClassType(),
00188 "colorMaterial",
00189 ColorMaterialFieldId, ColorMaterialFieldMask,
00190 false,
00191 (FieldAccessMethod) &FresnelMaterialBase::getSFColorMaterial),
00192 new FieldDescription(SFReal32::getClassType(),
00193 "index",
00194 IndexFieldId, IndexFieldMask,
00195 false,
00196 (FieldAccessMethod) &FresnelMaterialBase::getSFIndex),
00197 new FieldDescription(SFReal32::getClassType(),
00198 "scale",
00199 ScaleFieldId, ScaleFieldMask,
00200 false,
00201 (FieldAccessMethod) &FresnelMaterialBase::getSFScale),
00202 new FieldDescription(SFReal32::getClassType(),
00203 "bias",
00204 BiasFieldId, BiasFieldMask,
00205 false,
00206 (FieldAccessMethod) &FresnelMaterialBase::getSFBias),
00207 new FieldDescription(SFImagePtr::getClassType(),
00208 "image",
00209 ImageFieldId, ImageFieldMask,
00210 false,
00211 (FieldAccessMethod) &FresnelMaterialBase::getSFImage)
00212 };
00213
00214
00215 FieldContainerType FresnelMaterialBase::_type(
00216 "FresnelMaterial",
00217 "ChunkMaterial",
00218 NULL,
00219 (PrototypeCreateF) &FresnelMaterialBase::createEmpty,
00220 FresnelMaterial::initMethod,
00221 _desc,
00222 sizeof(_desc));
00223
00224
00225
00226
00227
00228 FieldContainerType &FresnelMaterialBase::getType(void)
00229 {
00230 return _type;
00231 }
00232
00233 const FieldContainerType &FresnelMaterialBase::getType(void) const
00234 {
00235 return _type;
00236 }
00237
00238
00239 FieldContainerPtr FresnelMaterialBase::shallowCopy(void) const
00240 {
00241 FresnelMaterialPtr returnValue;
00242
00243 newPtr(returnValue, dynamic_cast<const FresnelMaterial *>(this));
00244
00245 return returnValue;
00246 }
00247
00248 UInt32 FresnelMaterialBase::getContainerSize(void) const
00249 {
00250 return sizeof(FresnelMaterial);
00251 }
00252
00253
00254 #if !defined(OSG_FIXED_MFIELDSYNC)
00255 void FresnelMaterialBase::executeSync( FieldContainer &other,
00256 const BitVector &whichField)
00257 {
00258 this->executeSyncImpl((FresnelMaterialBase *) &other, whichField);
00259 }
00260 #else
00261 void FresnelMaterialBase::executeSync( FieldContainer &other,
00262 const BitVector &whichField, const SyncInfo &sInfo )
00263 {
00264 this->executeSyncImpl((FresnelMaterialBase *) &other, whichField, sInfo);
00265 }
00266 void FresnelMaterialBase::execBeginEdit(const BitVector &whichField,
00267 UInt32 uiAspect,
00268 UInt32 uiContainerSize)
00269 {
00270 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00271 }
00272
00273 void FresnelMaterialBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00274 {
00275 Inherited::onDestroyAspect(uiId, uiAspect);
00276
00277 }
00278 #endif
00279
00280
00281
00282 #ifdef OSG_WIN32_ICL
00283 #pragma warning (disable : 383)
00284 #endif
00285
00286 FresnelMaterialBase::FresnelMaterialBase(void) :
00287 _sfAmbient (Color3f(0,0,0)),
00288 _sfDiffuse (Color3f(0,0,0)),
00289 _sfSpecular (Color3f(0,0,0)),
00290 _sfShininess (Real32(1)),
00291 _sfEmission (Color3f(0,0,0)),
00292 _sfTransparency (Real32(0)),
00293 _sfLit (bool(true)),
00294 _sfColorMaterial (GLenum(GL_DIFFUSE)),
00295 _sfIndex (Real32(0)),
00296 _sfScale (Real32(1)),
00297 _sfBias (Real32(1)),
00298 _sfImage (),
00299 Inherited()
00300 {
00301 }
00302
00303 #ifdef OSG_WIN32_ICL
00304 #pragma warning (default : 383)
00305 #endif
00306
00307 FresnelMaterialBase::FresnelMaterialBase(const FresnelMaterialBase &source) :
00308 _sfAmbient (source._sfAmbient ),
00309 _sfDiffuse (source._sfDiffuse ),
00310 _sfSpecular (source._sfSpecular ),
00311 _sfShininess (source._sfShininess ),
00312 _sfEmission (source._sfEmission ),
00313 _sfTransparency (source._sfTransparency ),
00314 _sfLit (source._sfLit ),
00315 _sfColorMaterial (source._sfColorMaterial ),
00316 _sfIndex (source._sfIndex ),
00317 _sfScale (source._sfScale ),
00318 _sfBias (source._sfBias ),
00319 _sfImage (source._sfImage ),
00320 Inherited (source)
00321 {
00322 }
00323
00324
00325
00326 FresnelMaterialBase::~FresnelMaterialBase(void)
00327 {
00328 }
00329
00330
00331
00332 UInt32 FresnelMaterialBase::getBinSize(const BitVector &whichField)
00333 {
00334 UInt32 returnValue = Inherited::getBinSize(whichField);
00335
00336 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00337 {
00338 returnValue += _sfAmbient.getBinSize();
00339 }
00340
00341 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00342 {
00343 returnValue += _sfDiffuse.getBinSize();
00344 }
00345
00346 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00347 {
00348 returnValue += _sfSpecular.getBinSize();
00349 }
00350
00351 if(FieldBits::NoField != (ShininessFieldMask & whichField))
00352 {
00353 returnValue += _sfShininess.getBinSize();
00354 }
00355
00356 if(FieldBits::NoField != (EmissionFieldMask & whichField))
00357 {
00358 returnValue += _sfEmission.getBinSize();
00359 }
00360
00361 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00362 {
00363 returnValue += _sfTransparency.getBinSize();
00364 }
00365
00366 if(FieldBits::NoField != (LitFieldMask & whichField))
00367 {
00368 returnValue += _sfLit.getBinSize();
00369 }
00370
00371 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00372 {
00373 returnValue += _sfColorMaterial.getBinSize();
00374 }
00375
00376 if(FieldBits::NoField != (IndexFieldMask & whichField))
00377 {
00378 returnValue += _sfIndex.getBinSize();
00379 }
00380
00381 if(FieldBits::NoField != (ScaleFieldMask & whichField))
00382 {
00383 returnValue += _sfScale.getBinSize();
00384 }
00385
00386 if(FieldBits::NoField != (BiasFieldMask & whichField))
00387 {
00388 returnValue += _sfBias.getBinSize();
00389 }
00390
00391 if(FieldBits::NoField != (ImageFieldMask & whichField))
00392 {
00393 returnValue += _sfImage.getBinSize();
00394 }
00395
00396
00397 return returnValue;
00398 }
00399
00400 void FresnelMaterialBase::copyToBin( BinaryDataHandler &pMem,
00401 const BitVector &whichField)
00402 {
00403 Inherited::copyToBin(pMem, whichField);
00404
00405 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00406 {
00407 _sfAmbient.copyToBin(pMem);
00408 }
00409
00410 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00411 {
00412 _sfDiffuse.copyToBin(pMem);
00413 }
00414
00415 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00416 {
00417 _sfSpecular.copyToBin(pMem);
00418 }
00419
00420 if(FieldBits::NoField != (ShininessFieldMask & whichField))
00421 {
00422 _sfShininess.copyToBin(pMem);
00423 }
00424
00425 if(FieldBits::NoField != (EmissionFieldMask & whichField))
00426 {
00427 _sfEmission.copyToBin(pMem);
00428 }
00429
00430 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00431 {
00432 _sfTransparency.copyToBin(pMem);
00433 }
00434
00435 if(FieldBits::NoField != (LitFieldMask & whichField))
00436 {
00437 _sfLit.copyToBin(pMem);
00438 }
00439
00440 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00441 {
00442 _sfColorMaterial.copyToBin(pMem);
00443 }
00444
00445 if(FieldBits::NoField != (IndexFieldMask & whichField))
00446 {
00447 _sfIndex.copyToBin(pMem);
00448 }
00449
00450 if(FieldBits::NoField != (ScaleFieldMask & whichField))
00451 {
00452 _sfScale.copyToBin(pMem);
00453 }
00454
00455 if(FieldBits::NoField != (BiasFieldMask & whichField))
00456 {
00457 _sfBias.copyToBin(pMem);
00458 }
00459
00460 if(FieldBits::NoField != (ImageFieldMask & whichField))
00461 {
00462 _sfImage.copyToBin(pMem);
00463 }
00464
00465
00466 }
00467
00468 void FresnelMaterialBase::copyFromBin( BinaryDataHandler &pMem,
00469 const BitVector &whichField)
00470 {
00471 Inherited::copyFromBin(pMem, whichField);
00472
00473 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00474 {
00475 _sfAmbient.copyFromBin(pMem);
00476 }
00477
00478 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00479 {
00480 _sfDiffuse.copyFromBin(pMem);
00481 }
00482
00483 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00484 {
00485 _sfSpecular.copyFromBin(pMem);
00486 }
00487
00488 if(FieldBits::NoField != (ShininessFieldMask & whichField))
00489 {
00490 _sfShininess.copyFromBin(pMem);
00491 }
00492
00493 if(FieldBits::NoField != (EmissionFieldMask & whichField))
00494 {
00495 _sfEmission.copyFromBin(pMem);
00496 }
00497
00498 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00499 {
00500 _sfTransparency.copyFromBin(pMem);
00501 }
00502
00503 if(FieldBits::NoField != (LitFieldMask & whichField))
00504 {
00505 _sfLit.copyFromBin(pMem);
00506 }
00507
00508 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00509 {
00510 _sfColorMaterial.copyFromBin(pMem);
00511 }
00512
00513 if(FieldBits::NoField != (IndexFieldMask & whichField))
00514 {
00515 _sfIndex.copyFromBin(pMem);
00516 }
00517
00518 if(FieldBits::NoField != (ScaleFieldMask & whichField))
00519 {
00520 _sfScale.copyFromBin(pMem);
00521 }
00522
00523 if(FieldBits::NoField != (BiasFieldMask & whichField))
00524 {
00525 _sfBias.copyFromBin(pMem);
00526 }
00527
00528 if(FieldBits::NoField != (ImageFieldMask & whichField))
00529 {
00530 _sfImage.copyFromBin(pMem);
00531 }
00532
00533
00534 }
00535
00536 #if !defined(OSG_FIXED_MFIELDSYNC)
00537 void FresnelMaterialBase::executeSyncImpl( FresnelMaterialBase *pOther,
00538 const BitVector &whichField)
00539 {
00540
00541 Inherited::executeSyncImpl(pOther, whichField);
00542
00543 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00544 _sfAmbient.syncWith(pOther->_sfAmbient);
00545
00546 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00547 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00548
00549 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00550 _sfSpecular.syncWith(pOther->_sfSpecular);
00551
00552 if(FieldBits::NoField != (ShininessFieldMask & whichField))
00553 _sfShininess.syncWith(pOther->_sfShininess);
00554
00555 if(FieldBits::NoField != (EmissionFieldMask & whichField))
00556 _sfEmission.syncWith(pOther->_sfEmission);
00557
00558 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00559 _sfTransparency.syncWith(pOther->_sfTransparency);
00560
00561 if(FieldBits::NoField != (LitFieldMask & whichField))
00562 _sfLit.syncWith(pOther->_sfLit);
00563
00564 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00565 _sfColorMaterial.syncWith(pOther->_sfColorMaterial);
00566
00567 if(FieldBits::NoField != (IndexFieldMask & whichField))
00568 _sfIndex.syncWith(pOther->_sfIndex);
00569
00570 if(FieldBits::NoField != (ScaleFieldMask & whichField))
00571 _sfScale.syncWith(pOther->_sfScale);
00572
00573 if(FieldBits::NoField != (BiasFieldMask & whichField))
00574 _sfBias.syncWith(pOther->_sfBias);
00575
00576 if(FieldBits::NoField != (ImageFieldMask & whichField))
00577 _sfImage.syncWith(pOther->_sfImage);
00578
00579
00580 }
00581 #else
00582 void FresnelMaterialBase::executeSyncImpl( FresnelMaterialBase *pOther,
00583 const BitVector &whichField,
00584 const SyncInfo &sInfo )
00585 {
00586
00587 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00588
00589 if(FieldBits::NoField != (AmbientFieldMask & whichField))
00590 _sfAmbient.syncWith(pOther->_sfAmbient);
00591
00592 if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00593 _sfDiffuse.syncWith(pOther->_sfDiffuse);
00594
00595 if(FieldBits::NoField != (SpecularFieldMask & whichField))
00596 _sfSpecular.syncWith(pOther->_sfSpecular);
00597
00598 if(FieldBits::NoField != (ShininessFieldMask & whichField))
00599 _sfShininess.syncWith(pOther->_sfShininess);
00600
00601 if(FieldBits::NoField != (EmissionFieldMask & whichField))
00602 _sfEmission.syncWith(pOther->_sfEmission);
00603
00604 if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00605 _sfTransparency.syncWith(pOther->_sfTransparency);
00606
00607 if(FieldBits::NoField != (LitFieldMask & whichField))
00608 _sfLit.syncWith(pOther->_sfLit);
00609
00610 if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00611 _sfColorMaterial.syncWith(pOther->_sfColorMaterial);
00612
00613 if(FieldBits::NoField != (IndexFieldMask & whichField))
00614 _sfIndex.syncWith(pOther->_sfIndex);
00615
00616 if(FieldBits::NoField != (ScaleFieldMask & whichField))
00617 _sfScale.syncWith(pOther->_sfScale);
00618
00619 if(FieldBits::NoField != (BiasFieldMask & whichField))
00620 _sfBias.syncWith(pOther->_sfBias);
00621
00622 if(FieldBits::NoField != (ImageFieldMask & whichField))
00623 _sfImage.syncWith(pOther->_sfImage);
00624
00625
00626
00627 }
00628
00629 void FresnelMaterialBase::execBeginEditImpl (const BitVector &whichField,
00630 UInt32 uiAspect,
00631 UInt32 uiContainerSize)
00632 {
00633 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00634
00635 }
00636 #endif
00637
00638
00639
00640 OSG_BEGIN_NAMESPACE
00641
00642 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00643 DataType FieldDataTraits<FresnelMaterialPtr>::_type("FresnelMaterialPtr", "ChunkMaterialPtr");
00644 #endif
00645
00646
00647 OSG_END_NAMESPACE
00648
00649
00650
00651
00652
00653 #ifdef OSG_SGI_CC
00654 #pragma set woff 1174
00655 #endif
00656
00657 #ifdef OSG_LINUX_ICC
00658 #pragma warning( disable : 177 )
00659 #endif
00660
00661 namespace
00662 {
00663 static Char8 cvsid_cpp [] = "@(#)$Id: OSGFresnelMaterialBase.cpp,v 1.5 2005/07/20 00:09:24 vossg Exp $";
00664 static Char8 cvsid_hpp [] = OSGFRESNELMATERIALBASE_HEADER_CVSID;
00665 static Char8 cvsid_inl [] = OSGFRESNELMATERIALBASE_INLINE_CVSID;
00666
00667 static Char8 cvsid_fields_hpp[] = OSGFRESNELMATERIALFIELDS_HEADER_CVSID;
00668 }
00669