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 _OSGSIMPLEMATERIALBASE_H_
00055 #define _OSGSIMPLEMATERIALBASE_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 <OSGChunkMaterial.h>
00069
00070 #include <OSGColor3fFields.h>
00071 #include <OSGColor3fFields.h>
00072 #include <OSGColor3fFields.h>
00073 #include <OSGReal32Fields.h>
00074 #include <OSGColor3fFields.h>
00075 #include <OSGReal32Fields.h>
00076 #include <OSGBoolFields.h>
00077 #include <OSGGLenumFields.h>
00078
00079 #include <OSGSimpleMaterialFields.h>
00080
00081 OSG_BEGIN_NAMESPACE
00082
00083 class SimpleMaterial;
00084 class BinaryDataHandler;
00085
00087
00088 class OSG_SYSTEMLIB_DLLMAPPING SimpleMaterialBase : public ChunkMaterial
00089 {
00090 private:
00091
00092 typedef ChunkMaterial Inherited;
00093
00094
00095 public:
00096
00097 typedef SimpleMaterialPtr Ptr;
00098
00099 enum
00100 {
00101 AmbientFieldId = Inherited::NextFieldId,
00102 DiffuseFieldId = AmbientFieldId + 1,
00103 SpecularFieldId = DiffuseFieldId + 1,
00104 ShininessFieldId = SpecularFieldId + 1,
00105 EmissionFieldId = ShininessFieldId + 1,
00106 TransparencyFieldId = EmissionFieldId + 1,
00107 LitFieldId = TransparencyFieldId + 1,
00108 ColorMaterialFieldId = LitFieldId + 1,
00109 NextFieldId = ColorMaterialFieldId + 1
00110 };
00111
00112 static const OSG::BitVector AmbientFieldMask;
00113 static const OSG::BitVector DiffuseFieldMask;
00114 static const OSG::BitVector SpecularFieldMask;
00115 static const OSG::BitVector ShininessFieldMask;
00116 static const OSG::BitVector EmissionFieldMask;
00117 static const OSG::BitVector TransparencyFieldMask;
00118 static const OSG::BitVector LitFieldMask;
00119 static const OSG::BitVector ColorMaterialFieldMask;
00120
00121
00122 static const OSG::BitVector MTInfluenceMask;
00123
00124
00128 static FieldContainerType &getClassType (void);
00129 static UInt32 getClassTypeId (void);
00130
00132
00136 virtual FieldContainerType &getType (void);
00137 virtual const FieldContainerType &getType (void) const;
00138
00139 virtual UInt32 getContainerSize(void) const;
00140
00142
00146 SFColor3f *getSFAmbient (void);
00147 SFColor3f *getSFDiffuse (void);
00148 SFColor3f *getSFSpecular (void);
00149 SFReal32 *getSFShininess (void);
00150 SFColor3f *getSFEmission (void);
00151 SFReal32 *getSFTransparency (void);
00152 SFBool *getSFLit (void);
00153 SFGLenum *getSFColorMaterial (void);
00154
00155 Color3f &getAmbient (void);
00156 const Color3f &getAmbient (void) const;
00157 Color3f &getDiffuse (void);
00158 const Color3f &getDiffuse (void) const;
00159 Color3f &getSpecular (void);
00160 const Color3f &getSpecular (void) const;
00161 Real32 &getShininess (void);
00162 const Real32 &getShininess (void) const;
00163 Color3f &getEmission (void);
00164 const Color3f &getEmission (void) const;
00165 Real32 &getTransparency (void);
00166 const Real32 &getTransparency (void) const;
00167 bool &getLit (void);
00168 const bool &getLit (void) const;
00169 GLenum &getColorMaterial (void);
00170 const GLenum &getColorMaterial (void) const;
00171
00173
00177 void setAmbient ( const Color3f &value );
00178 void setDiffuse ( const Color3f &value );
00179 void setSpecular ( const Color3f &value );
00180 void setShininess ( const Real32 &value );
00181 void setEmission ( const Color3f &value );
00182 void setTransparency ( const Real32 &value );
00183 void setLit ( const bool &value );
00184 void setColorMaterial ( const GLenum &value );
00185
00187
00192
00196 virtual UInt32 getBinSize (const BitVector &whichField);
00197 virtual void copyToBin ( BinaryDataHandler &pMem,
00198 const BitVector &whichField);
00199 virtual void copyFromBin( BinaryDataHandler &pMem,
00200 const BitVector &whichField);
00201
00202
00204
00208 static SimpleMaterialPtr create (void);
00209 static SimpleMaterialPtr createEmpty (void);
00210
00213
00217 virtual FieldContainerPtr shallowCopy (void) const;
00218
00220
00221 protected:
00222
00223
00227 SFColor3f _sfAmbient;
00228 SFColor3f _sfDiffuse;
00229 SFColor3f _sfSpecular;
00230 SFReal32 _sfShininess;
00231 SFColor3f _sfEmission;
00232 SFReal32 _sfTransparency;
00233 SFBool _sfLit;
00234 SFGLenum _sfColorMaterial;
00235
00237
00241 SimpleMaterialBase(void);
00242 SimpleMaterialBase(const SimpleMaterialBase &source);
00243
00245
00249 virtual ~SimpleMaterialBase(void);
00250
00252
00256 #if !defined(OSG_FIXED_MFIELDSYNC)
00257 void executeSyncImpl( SimpleMaterialBase *pOther,
00258 const BitVector &whichField);
00259
00260 virtual void executeSync( FieldContainer &other,
00261 const BitVector &whichField);
00262 #else
00263 void executeSyncImpl( SimpleMaterialBase *pOther,
00264 const BitVector &whichField,
00265 const SyncInfo &sInfo );
00266
00267 virtual void executeSync( FieldContainer &other,
00268 const BitVector &whichField,
00269 const SyncInfo &sInfo);
00270
00271 virtual void execBeginEdit (const BitVector &whichField,
00272 UInt32 uiAspect,
00273 UInt32 uiContainerSize);
00274
00275 void execBeginEditImpl (const BitVector &whichField,
00276 UInt32 uiAspect,
00277 UInt32 uiContainerSize);
00278
00279 virtual void onDestroyAspect(UInt32 uiId, UInt32 uiAspect);
00280 #endif
00281
00283
00284 private:
00285
00286 friend class FieldContainer;
00287
00288 static FieldDescription *_desc[];
00289 static FieldContainerType _type;
00290
00291
00292
00293 void operator =(const SimpleMaterialBase &source);
00294 };
00295
00296
00297
00298
00299
00300
00301 typedef SimpleMaterialBase *SimpleMaterialBaseP;
00302
00303 typedef osgIF<SimpleMaterialBase::isNodeCore,
00304 CoredNodePtr<SimpleMaterial>,
00305 FieldContainer::attempt_to_create_CoredNodePtr_on_non_NodeCore_FC
00306 >::_IRet SimpleMaterialNodePtr;
00307
00308 typedef RefPtr<SimpleMaterialPtr> SimpleMaterialRefPtr;
00309
00310 OSG_END_NAMESPACE
00311
00312 #define OSGSIMPLEMATERIALBASE_HEADER_CVSID "@(#)$Id: FCBaseTemplate_h.h,v 1.38 2005/07/08 06:37:35 vossg Exp $"
00313
00314 #endif