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 #ifndef _OSGMATERIALCHUNKBASE_H_
00055 #define _OSGMATERIALCHUNKBASE_H_
00056 #ifdef __sgi
00057 #pragma once
00058 #endif
00059
00060
00061 #include <OSGConfig.h>
00062 #include <OSGSystemDef.h>
00063
00064 #include <OSGBaseTypes.h>
00065 #include <OSGRefPtr.h>
00066 #include <OSGCoredNodePtr.h>
00067
00068 #include <OSGStateChunk.h>
00069
00070 #include <OSGColor4fFields.h>
00071 #include <OSGColor4fFields.h>
00072 #include <OSGColor4fFields.h>
00073 #include <OSGColor4fFields.h>
00074 #include <OSGReal32Fields.h>
00075 #include <OSGBoolFields.h>
00076 #include <OSGGLenumFields.h>
00077 #include <OSGBoolFields.h>
00078 #include <OSGColor4fFields.h>
00079 #include <OSGColor4fFields.h>
00080 #include <OSGColor4fFields.h>
00081 #include <OSGColor4fFields.h>
00082 #include <OSGReal32Fields.h>
00083 #include <OSGGLenumFields.h>
00084
00085 #include <OSGMaterialChunkFields.h>
00086
00087 OSG_BEGIN_NAMESPACE
00088
00089 class MaterialChunk;
00090 class BinaryDataHandler;
00091
00093
00094 class OSG_SYSTEMLIB_DLLMAPPING MaterialChunkBase : public StateChunk
00095 {
00096 private:
00097
00098 typedef StateChunk Inherited;
00099
00100
00101 public:
00102
00103 typedef MaterialChunkPtr Ptr;
00104
00105 enum
00106 {
00107 DiffuseFieldId = Inherited::NextFieldId,
00108 AmbientFieldId = DiffuseFieldId + 1,
00109 SpecularFieldId = AmbientFieldId + 1,
00110 EmissionFieldId = SpecularFieldId + 1,
00111 ShininessFieldId = EmissionFieldId + 1,
00112 LitFieldId = ShininessFieldId + 1,
00113 ColorMaterialFieldId = LitFieldId + 1,
00114 BackMaterialFieldId = ColorMaterialFieldId + 1,
00115 BackDiffuseFieldId = BackMaterialFieldId + 1,
00116 BackAmbientFieldId = BackDiffuseFieldId + 1,
00117 BackSpecularFieldId = BackAmbientFieldId + 1,
00118 BackEmissionFieldId = BackSpecularFieldId + 1,
00119 BackShininessFieldId = BackEmissionFieldId + 1,
00120 BackColorMaterialFieldId = BackShininessFieldId + 1,
00121 NextFieldId = BackColorMaterialFieldId + 1
00122 };
00123
00124 static const OSG::BitVector DiffuseFieldMask;
00125 static const OSG::BitVector AmbientFieldMask;
00126 static const OSG::BitVector SpecularFieldMask;
00127 static const OSG::BitVector EmissionFieldMask;
00128 static const OSG::BitVector ShininessFieldMask;
00129 static const OSG::BitVector LitFieldMask;
00130 static const OSG::BitVector ColorMaterialFieldMask;
00131 static const OSG::BitVector BackMaterialFieldMask;
00132 static const OSG::BitVector BackDiffuseFieldMask;
00133 static const OSG::BitVector BackAmbientFieldMask;
00134 static const OSG::BitVector BackSpecularFieldMask;
00135 static const OSG::BitVector BackEmissionFieldMask;
00136 static const OSG::BitVector BackShininessFieldMask;
00137 static const OSG::BitVector BackColorMaterialFieldMask;
00138
00139
00140 static const OSG::BitVector MTInfluenceMask;
00141
00142
00146 static FieldContainerType &getClassType (void);
00147 static UInt32 getClassTypeId (void);
00148
00150
00154 virtual FieldContainerType &getType (void);
00155 virtual const FieldContainerType &getType (void) const;
00156
00157 virtual UInt32 getContainerSize(void) const;
00158
00160
00164 SFColor4f *getSFDiffuse (void);
00165 SFColor4f *getSFAmbient (void);
00166 SFColor4f *getSFSpecular (void);
00167 SFColor4f *getSFEmission (void);
00168 SFReal32 *getSFShininess (void);
00169 SFBool *getSFLit (void);
00170 SFGLenum *getSFColorMaterial (void);
00171 SFBool *getSFBackMaterial (void);
00172 SFColor4f *getSFBackDiffuse (void);
00173 SFColor4f *getSFBackAmbient (void);
00174 SFColor4f *getSFBackSpecular (void);
00175 SFColor4f *getSFBackEmission (void);
00176 SFReal32 *getSFBackShininess (void);
00177 SFGLenum *getSFBackColorMaterial(void);
00178
00179 Color4f &getDiffuse (void);
00180 const Color4f &getDiffuse (void) const;
00181 Color4f &getAmbient (void);
00182 const Color4f &getAmbient (void) const;
00183 Color4f &getSpecular (void);
00184 const Color4f &getSpecular (void) const;
00185 Color4f &getEmission (void);
00186 const Color4f &getEmission (void) const;
00187 Real32 &getShininess (void);
00188 const Real32 &getShininess (void) const;
00189 bool &getLit (void);
00190 const bool &getLit (void) const;
00191 GLenum &getColorMaterial (void);
00192 const GLenum &getColorMaterial (void) const;
00193 bool &getBackMaterial (void);
00194 const bool &getBackMaterial (void) const;
00195 Color4f &getBackDiffuse (void);
00196 const Color4f &getBackDiffuse (void) const;
00197 Color4f &getBackAmbient (void);
00198 const Color4f &getBackAmbient (void) const;
00199 Color4f &getBackSpecular (void);
00200 const Color4f &getBackSpecular (void) const;
00201 Color4f &getBackEmission (void);
00202 const Color4f &getBackEmission (void) const;
00203 Real32 &getBackShininess (void);
00204 const Real32 &getBackShininess (void) const;
00205 GLenum &getBackColorMaterial(void);
00206 const GLenum &getBackColorMaterial(void) const;
00207
00209
00213 void setDiffuse ( const Color4f &value );
00214 void setAmbient ( const Color4f &value );
00215 void setSpecular ( const Color4f &value );
00216 void setEmission ( const Color4f &value );
00217 void setShininess ( const Real32 &value );
00218 void setLit ( const bool &value );
00219 void setColorMaterial ( const GLenum &value );
00220 void setBackMaterial ( const bool &value );
00221 void setBackDiffuse ( const Color4f &value );
00222 void setBackAmbient ( const Color4f &value );
00223 void setBackSpecular ( const Color4f &value );
00224 void setBackEmission ( const Color4f &value );
00225 void setBackShininess ( const Real32 &value );
00226 void setBackColorMaterial( const GLenum &value );
00227
00229
00234
00238 virtual UInt32 getBinSize (const BitVector &whichField);
00239 virtual void copyToBin ( BinaryDataHandler &pMem,
00240 const BitVector &whichField);
00241 virtual void copyFromBin( BinaryDataHandler &pMem,
00242 const BitVector &whichField);
00243
00244
00246
00250 static MaterialChunkPtr create (void);
00251 static MaterialChunkPtr createEmpty (void);
00252
00255
00259 virtual FieldContainerPtr shallowCopy (void) const;
00260
00262
00263 protected:
00264
00265
00269 SFColor4f _sfDiffuse;
00270 SFColor4f _sfAmbient;
00271 SFColor4f _sfSpecular;
00272 SFColor4f _sfEmission;
00273 SFReal32 _sfShininess;
00274 SFBool _sfLit;
00275 SFGLenum _sfColorMaterial;
00276 SFBool _sfBackMaterial;
00277 SFColor4f _sfBackDiffuse;
00278 SFColor4f _sfBackAmbient;
00279 SFColor4f _sfBackSpecular;
00280 SFColor4f _sfBackEmission;
00281 SFReal32 _sfBackShininess;
00282 SFGLenum _sfBackColorMaterial;
00283
00285
00289 MaterialChunkBase(void);
00290 MaterialChunkBase(const MaterialChunkBase &source);
00291
00293
00297 virtual ~MaterialChunkBase(void);
00298
00300
00304 #if !defined(OSG_FIXED_MFIELDSYNC)
00305 void executeSyncImpl( MaterialChunkBase *pOther,
00306 const BitVector &whichField);
00307
00308 virtual void executeSync( FieldContainer &other,
00309 const BitVector &whichField);
00310 #else
00311 void executeSyncImpl( MaterialChunkBase *pOther,
00312 const BitVector &whichField,
00313 const SyncInfo &sInfo );
00314
00315 virtual void executeSync( FieldContainer &other,
00316 const BitVector &whichField,
00317 const SyncInfo &sInfo);
00318
00319 virtual void execBeginEdit (const BitVector &whichField,
00320 UInt32 uiAspect,
00321 UInt32 uiContainerSize);
00322
00323 void execBeginEditImpl (const BitVector &whichField,
00324 UInt32 uiAspect,
00325 UInt32 uiContainerSize);
00326
00327 virtual void onDestroyAspect(UInt32 uiId, UInt32 uiAspect);
00328 #endif
00329
00331
00332 private:
00333
00334 friend class FieldContainer;
00335
00336 static FieldDescription *_desc[];
00337 static FieldContainerType _type;
00338
00339
00340
00341 void operator =(const MaterialChunkBase &source);
00342 };
00343
00344
00345
00346
00347
00348
00349 typedef MaterialChunkBase *MaterialChunkBaseP;
00350
00351 typedef osgIF<MaterialChunkBase::isNodeCore,
00352 CoredNodePtr<MaterialChunk>,
00353 FieldContainer::attempt_to_create_CoredNodePtr_on_non_NodeCore_FC
00354 >::_IRet MaterialChunkNodePtr;
00355
00356 typedef RefPtr<MaterialChunkPtr> MaterialChunkRefPtr;
00357
00358 OSG_END_NAMESPACE
00359
00360 #define OSGMATERIALCHUNKBASE_HEADER_CVSID "@(#)$Id: FCBaseTemplate_h.h,v 1.40 2005/07/20 00:10:14 vossg Exp $"
00361
00362 #endif