Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGSimpleMaterialBase.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *               Copyright (C) 2000-2002 by the OpenSG Forum                 *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 /*****************************************************************************\
00040  *****************************************************************************
00041  **                                                                         **
00042  **                  This file is automatically generated.                  **
00043  **                                                                         **
00044  **          Any changes made to this file WILL be lost when it is          **
00045  **           regenerated, which can become necessary at any time.          **
00046  **                                                                         **
00047  **     Do not change this file, changes should be done in the derived      **
00048  **     class SimpleMaterial!
00049  **                                                                         **
00050  *****************************************************************************
00051 \*****************************************************************************/
00052 
00053 
00054 #define OSG_COMPILESIMPLEMATERIALINST
00055 
00056 #include <stdlib.h>
00057 #include <stdio.h>
00058 
00059 #include <OSGConfig.h>
00060 
00061 #include "OSGSimpleMaterialBase.h"
00062 #include "OSGSimpleMaterial.h"
00063 
00064 #include <OSGGL.h>                        // ColorMaterial default header
00065 
00066 OSG_USING_NAMESPACE
00067 
00068 const OSG::BitVector  SimpleMaterialBase::AmbientFieldMask = 
00069     (TypeTraits<BitVector>::One << SimpleMaterialBase::AmbientFieldId);
00070 
00071 const OSG::BitVector  SimpleMaterialBase::DiffuseFieldMask = 
00072     (TypeTraits<BitVector>::One << SimpleMaterialBase::DiffuseFieldId);
00073 
00074 const OSG::BitVector  SimpleMaterialBase::SpecularFieldMask = 
00075     (TypeTraits<BitVector>::One << SimpleMaterialBase::SpecularFieldId);
00076 
00077 const OSG::BitVector  SimpleMaterialBase::ShininessFieldMask = 
00078     (TypeTraits<BitVector>::One << SimpleMaterialBase::ShininessFieldId);
00079 
00080 const OSG::BitVector  SimpleMaterialBase::EmissionFieldMask = 
00081     (TypeTraits<BitVector>::One << SimpleMaterialBase::EmissionFieldId);
00082 
00083 const OSG::BitVector  SimpleMaterialBase::TransparencyFieldMask = 
00084     (TypeTraits<BitVector>::One << SimpleMaterialBase::TransparencyFieldId);
00085 
00086 const OSG::BitVector  SimpleMaterialBase::LitFieldMask = 
00087     (TypeTraits<BitVector>::One << SimpleMaterialBase::LitFieldId);
00088 
00089 const OSG::BitVector  SimpleMaterialBase::ColorMaterialFieldMask = 
00090     (TypeTraits<BitVector>::One << SimpleMaterialBase::ColorMaterialFieldId);
00091 
00092 const OSG::BitVector SimpleMaterialBase::MTInfluenceMask = 
00093     (Inherited::MTInfluenceMask) | 
00094     (static_cast<BitVector>(0x0) << Inherited::NextFieldId); 
00095 
00096 
00097 // Field descriptions
00098 
00124 
00125 
00126 FieldDescription *SimpleMaterialBase::_desc[] = 
00127 {
00128     new FieldDescription(SFColor3f::getClassType(), 
00129                      "ambient", 
00130                      AmbientFieldId, AmbientFieldMask,
00131                      false,
00132                      (FieldAccessMethod) &SimpleMaterialBase::getSFAmbient),
00133     new FieldDescription(SFColor3f::getClassType(), 
00134                      "diffuse", 
00135                      DiffuseFieldId, DiffuseFieldMask,
00136                      false,
00137                      (FieldAccessMethod) &SimpleMaterialBase::getSFDiffuse),
00138     new FieldDescription(SFColor3f::getClassType(), 
00139                      "specular", 
00140                      SpecularFieldId, SpecularFieldMask,
00141                      false,
00142                      (FieldAccessMethod) &SimpleMaterialBase::getSFSpecular),
00143     new FieldDescription(SFReal32::getClassType(), 
00144                      "shininess", 
00145                      ShininessFieldId, ShininessFieldMask,
00146                      false,
00147                      (FieldAccessMethod) &SimpleMaterialBase::getSFShininess),
00148     new FieldDescription(SFColor3f::getClassType(), 
00149                      "emission", 
00150                      EmissionFieldId, EmissionFieldMask,
00151                      false,
00152                      (FieldAccessMethod) &SimpleMaterialBase::getSFEmission),
00153     new FieldDescription(SFReal32::getClassType(), 
00154                      "transparency", 
00155                      TransparencyFieldId, TransparencyFieldMask,
00156                      false,
00157                      (FieldAccessMethod) &SimpleMaterialBase::getSFTransparency),
00158     new FieldDescription(SFBool::getClassType(), 
00159                      "lit", 
00160                      LitFieldId, LitFieldMask,
00161                      false,
00162                      (FieldAccessMethod) &SimpleMaterialBase::getSFLit),
00163     new FieldDescription(SFGLenum::getClassType(), 
00164                      "colorMaterial", 
00165                      ColorMaterialFieldId, ColorMaterialFieldMask,
00166                      false,
00167                      (FieldAccessMethod) &SimpleMaterialBase::getSFColorMaterial)
00168 };
00169 
00170 
00171 FieldContainerType SimpleMaterialBase::_type(
00172     "SimpleMaterial",
00173     "ChunkMaterial",
00174     NULL,
00175     (PrototypeCreateF) &SimpleMaterialBase::createEmpty,
00176     SimpleMaterial::initMethod,
00177     _desc,
00178     sizeof(_desc));
00179 
00180 //OSG_FIELD_CONTAINER_DEF(SimpleMaterialBase, SimpleMaterialPtr)
00181 
00182 /*------------------------------ get -----------------------------------*/
00183 
00184 FieldContainerType &SimpleMaterialBase::getType(void) 
00185 {
00186     return _type; 
00187 } 
00188 
00189 const FieldContainerType &SimpleMaterialBase::getType(void) const 
00190 {
00191     return _type;
00192 } 
00193 
00194 
00195 FieldContainerPtr SimpleMaterialBase::shallowCopy(void) const 
00196 { 
00197     SimpleMaterialPtr returnValue; 
00198 
00199     newPtr(returnValue, dynamic_cast<const SimpleMaterial *>(this)); 
00200 
00201     return returnValue; 
00202 }
00203 
00204 UInt32 SimpleMaterialBase::getContainerSize(void) const 
00205 { 
00206     return sizeof(SimpleMaterial); 
00207 }
00208 
00209 
00210 #if !defined(OSG_FIXED_MFIELDSYNC)
00211 void SimpleMaterialBase::executeSync(      FieldContainer &other,
00212                                     const BitVector      &whichField)
00213 {
00214     this->executeSyncImpl((SimpleMaterialBase *) &other, whichField);
00215 }
00216 #else
00217 void SimpleMaterialBase::executeSync(      FieldContainer &other,
00218                                     const BitVector      &whichField,                                    const SyncInfo       &sInfo     )
00219 {
00220     this->executeSyncImpl((SimpleMaterialBase *) &other, whichField, sInfo);
00221 }
00222 void SimpleMaterialBase::execBeginEdit(const BitVector &whichField, 
00223                                             UInt32     uiAspect,
00224                                             UInt32     uiContainerSize) 
00225 {
00226     this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00227 }
00228 
00229 void SimpleMaterialBase::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00230 {
00231     Inherited::onDestroyAspect(uiId, uiAspect);
00232 
00233 }
00234 #endif
00235 
00236 /*------------------------- constructors ----------------------------------*/
00237 
00238 #ifdef OSG_WIN32_ICL
00239 #pragma warning (disable : 383)
00240 #endif
00241 
00242 SimpleMaterialBase::SimpleMaterialBase(void) :
00243     _sfAmbient                (Color3f(0,0,0)), 
00244     _sfDiffuse                (Color3f(0,0,0)), 
00245     _sfSpecular               (Color3f(0,0,0)), 
00246     _sfShininess              (Real32(1)), 
00247     _sfEmission               (Color3f(0,0,0)), 
00248     _sfTransparency           (Real32(0)), 
00249     _sfLit                    (bool(true)), 
00250     _sfColorMaterial          (GLenum(GL_DIFFUSE)), 
00251     Inherited() 
00252 {
00253 }
00254 
00255 #ifdef OSG_WIN32_ICL
00256 #pragma warning (default : 383)
00257 #endif
00258 
00259 SimpleMaterialBase::SimpleMaterialBase(const SimpleMaterialBase &source) :
00260     _sfAmbient                (source._sfAmbient                ), 
00261     _sfDiffuse                (source._sfDiffuse                ), 
00262     _sfSpecular               (source._sfSpecular               ), 
00263     _sfShininess              (source._sfShininess              ), 
00264     _sfEmission               (source._sfEmission               ), 
00265     _sfTransparency           (source._sfTransparency           ), 
00266     _sfLit                    (source._sfLit                    ), 
00267     _sfColorMaterial          (source._sfColorMaterial          ), 
00268     Inherited                 (source)
00269 {
00270 }
00271 
00272 /*-------------------------- destructors ----------------------------------*/
00273 
00274 SimpleMaterialBase::~SimpleMaterialBase(void)
00275 {
00276 }
00277 
00278 /*------------------------------ access -----------------------------------*/
00279 
00280 UInt32 SimpleMaterialBase::getBinSize(const BitVector &whichField)
00281 {
00282     UInt32 returnValue = Inherited::getBinSize(whichField);
00283 
00284     if(FieldBits::NoField != (AmbientFieldMask & whichField))
00285     {
00286         returnValue += _sfAmbient.getBinSize();
00287     }
00288 
00289     if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00290     {
00291         returnValue += _sfDiffuse.getBinSize();
00292     }
00293 
00294     if(FieldBits::NoField != (SpecularFieldMask & whichField))
00295     {
00296         returnValue += _sfSpecular.getBinSize();
00297     }
00298 
00299     if(FieldBits::NoField != (ShininessFieldMask & whichField))
00300     {
00301         returnValue += _sfShininess.getBinSize();
00302     }
00303 
00304     if(FieldBits::NoField != (EmissionFieldMask & whichField))
00305     {
00306         returnValue += _sfEmission.getBinSize();
00307     }
00308 
00309     if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00310     {
00311         returnValue += _sfTransparency.getBinSize();
00312     }
00313 
00314     if(FieldBits::NoField != (LitFieldMask & whichField))
00315     {
00316         returnValue += _sfLit.getBinSize();
00317     }
00318 
00319     if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00320     {
00321         returnValue += _sfColorMaterial.getBinSize();
00322     }
00323 
00324 
00325     return returnValue;
00326 }
00327 
00328 void SimpleMaterialBase::copyToBin(      BinaryDataHandler &pMem,
00329                                   const BitVector         &whichField)
00330 {
00331     Inherited::copyToBin(pMem, whichField);
00332 
00333     if(FieldBits::NoField != (AmbientFieldMask & whichField))
00334     {
00335         _sfAmbient.copyToBin(pMem);
00336     }
00337 
00338     if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00339     {
00340         _sfDiffuse.copyToBin(pMem);
00341     }
00342 
00343     if(FieldBits::NoField != (SpecularFieldMask & whichField))
00344     {
00345         _sfSpecular.copyToBin(pMem);
00346     }
00347 
00348     if(FieldBits::NoField != (ShininessFieldMask & whichField))
00349     {
00350         _sfShininess.copyToBin(pMem);
00351     }
00352 
00353     if(FieldBits::NoField != (EmissionFieldMask & whichField))
00354     {
00355         _sfEmission.copyToBin(pMem);
00356     }
00357 
00358     if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00359     {
00360         _sfTransparency.copyToBin(pMem);
00361     }
00362 
00363     if(FieldBits::NoField != (LitFieldMask & whichField))
00364     {
00365         _sfLit.copyToBin(pMem);
00366     }
00367 
00368     if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00369     {
00370         _sfColorMaterial.copyToBin(pMem);
00371     }
00372 
00373 
00374 }
00375 
00376 void SimpleMaterialBase::copyFromBin(      BinaryDataHandler &pMem,
00377                                     const BitVector    &whichField)
00378 {
00379     Inherited::copyFromBin(pMem, whichField);
00380 
00381     if(FieldBits::NoField != (AmbientFieldMask & whichField))
00382     {
00383         _sfAmbient.copyFromBin(pMem);
00384     }
00385 
00386     if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00387     {
00388         _sfDiffuse.copyFromBin(pMem);
00389     }
00390 
00391     if(FieldBits::NoField != (SpecularFieldMask & whichField))
00392     {
00393         _sfSpecular.copyFromBin(pMem);
00394     }
00395 
00396     if(FieldBits::NoField != (ShininessFieldMask & whichField))
00397     {
00398         _sfShininess.copyFromBin(pMem);
00399     }
00400 
00401     if(FieldBits::NoField != (EmissionFieldMask & whichField))
00402     {
00403         _sfEmission.copyFromBin(pMem);
00404     }
00405 
00406     if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00407     {
00408         _sfTransparency.copyFromBin(pMem);
00409     }
00410 
00411     if(FieldBits::NoField != (LitFieldMask & whichField))
00412     {
00413         _sfLit.copyFromBin(pMem);
00414     }
00415 
00416     if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00417     {
00418         _sfColorMaterial.copyFromBin(pMem);
00419     }
00420 
00421 
00422 }
00423 
00424 #if !defined(OSG_FIXED_MFIELDSYNC)
00425 void SimpleMaterialBase::executeSyncImpl(      SimpleMaterialBase *pOther,
00426                                         const BitVector         &whichField)
00427 {
00428 
00429     Inherited::executeSyncImpl(pOther, whichField);
00430 
00431     if(FieldBits::NoField != (AmbientFieldMask & whichField))
00432         _sfAmbient.syncWith(pOther->_sfAmbient);
00433 
00434     if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00435         _sfDiffuse.syncWith(pOther->_sfDiffuse);
00436 
00437     if(FieldBits::NoField != (SpecularFieldMask & whichField))
00438         _sfSpecular.syncWith(pOther->_sfSpecular);
00439 
00440     if(FieldBits::NoField != (ShininessFieldMask & whichField))
00441         _sfShininess.syncWith(pOther->_sfShininess);
00442 
00443     if(FieldBits::NoField != (EmissionFieldMask & whichField))
00444         _sfEmission.syncWith(pOther->_sfEmission);
00445 
00446     if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00447         _sfTransparency.syncWith(pOther->_sfTransparency);
00448 
00449     if(FieldBits::NoField != (LitFieldMask & whichField))
00450         _sfLit.syncWith(pOther->_sfLit);
00451 
00452     if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00453         _sfColorMaterial.syncWith(pOther->_sfColorMaterial);
00454 
00455 
00456 }
00457 #else
00458 void SimpleMaterialBase::executeSyncImpl(      SimpleMaterialBase *pOther,
00459                                         const BitVector         &whichField,
00460                                         const SyncInfo          &sInfo      )
00461 {
00462 
00463     Inherited::executeSyncImpl(pOther, whichField, sInfo);
00464 
00465     if(FieldBits::NoField != (AmbientFieldMask & whichField))
00466         _sfAmbient.syncWith(pOther->_sfAmbient);
00467 
00468     if(FieldBits::NoField != (DiffuseFieldMask & whichField))
00469         _sfDiffuse.syncWith(pOther->_sfDiffuse);
00470 
00471     if(FieldBits::NoField != (SpecularFieldMask & whichField))
00472         _sfSpecular.syncWith(pOther->_sfSpecular);
00473 
00474     if(FieldBits::NoField != (ShininessFieldMask & whichField))
00475         _sfShininess.syncWith(pOther->_sfShininess);
00476 
00477     if(FieldBits::NoField != (EmissionFieldMask & whichField))
00478         _sfEmission.syncWith(pOther->_sfEmission);
00479 
00480     if(FieldBits::NoField != (TransparencyFieldMask & whichField))
00481         _sfTransparency.syncWith(pOther->_sfTransparency);
00482 
00483     if(FieldBits::NoField != (LitFieldMask & whichField))
00484         _sfLit.syncWith(pOther->_sfLit);
00485 
00486     if(FieldBits::NoField != (ColorMaterialFieldMask & whichField))
00487         _sfColorMaterial.syncWith(pOther->_sfColorMaterial);
00488 
00489 
00490 
00491 }
00492 
00493 void SimpleMaterialBase::execBeginEditImpl (const BitVector &whichField, 
00494                                                  UInt32     uiAspect,
00495                                                  UInt32     uiContainerSize)
00496 {
00497     Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00498 
00499 }
00500 #endif
00501 
00502 
00503 
00504 OSG_BEGIN_NAMESPACE
00505 
00506 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00507 DataType FieldDataTraits<SimpleMaterialPtr>::_type("SimpleMaterialPtr", "ChunkMaterialPtr");
00508 #endif
00509 
00510 
00511 OSG_END_NAMESPACE
00512 
00513 
00514 /*------------------------------------------------------------------------*/
00515 /*                              cvs id's                                  */
00516 
00517 #ifdef OSG_SGI_CC
00518 #pragma set woff 1174
00519 #endif
00520 
00521 #ifdef OSG_LINUX_ICC
00522 #pragma warning( disable : 177 )
00523 #endif
00524 
00525 namespace
00526 {
00527     static Char8 cvsid_cpp       [] = "@(#)$Id: FCBaseTemplate_cpp.h,v 1.42 2004/08/03 05:53:03 dirk Exp $";
00528     static Char8 cvsid_hpp       [] = OSGSIMPLEMATERIALBASE_HEADER_CVSID;
00529     static Char8 cvsid_inl       [] = OSGSIMPLEMATERIALBASE_INLINE_CVSID;
00530 
00531     static Char8 cvsid_fields_hpp[] = OSGSIMPLEMATERIALFIELDS_HEADER_CVSID;
00532 }
00533 

Generated on Thu Aug 25 04:10:08 2005 for OpenSG by  doxygen 1.4.3