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 _OSGPARTICLESBASE_H_
00055 #define _OSGPARTICLESBASE_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 <OSGMaterialDrawable.h>
00069
00070 #include <OSGUInt32Fields.h>
00071 #include <OSGGeoPositionsFields.h>
00072 #include <OSGVec3fFields.h>
00073 #include <OSGGeoPositionsFields.h>
00074 #include <OSGGeoColorsFields.h>
00075 #include <OSGGeoNormalsFields.h>
00076 #include <OSGInt32Fields.h>
00077 #include <OSGReal32Fields.h>
00078 #include <OSGUInt32Fields.h>
00079 #include <OSGBoolFields.h>
00080 #include <OSGUInt32Fields.h>
00081 #include <OSGParticleBSP.h>
00082 #include <OSGInt32Fields.h>
00083
00084 #include <OSGParticlesFields.h>
00085
00086 OSG_BEGIN_NAMESPACE
00087
00088 class Particles;
00089 class BinaryDataHandler;
00090
00092
00093 class OSG_SYSTEMLIB_DLLMAPPING ParticlesBase : public MaterialDrawable
00094 {
00095 private:
00096
00097 typedef MaterialDrawable Inherited;
00098
00099
00100 public:
00101
00102 typedef ParticlesPtr Ptr;
00103
00104 enum
00105 {
00106 ModeFieldId = Inherited::NextFieldId,
00107 PositionsFieldId = ModeFieldId + 1,
00108 SizesFieldId = PositionsFieldId + 1,
00109 SecPositionsFieldId = SizesFieldId + 1,
00110 ColorsFieldId = SecPositionsFieldId + 1,
00111 NormalsFieldId = ColorsFieldId + 1,
00112 IndicesFieldId = NormalsFieldId + 1,
00113 TextureZsFieldId = IndicesFieldId + 1,
00114 DrawOrderFieldId = TextureZsFieldId + 1,
00115 DynamicFieldId = DrawOrderFieldId + 1,
00116 PumpFieldId = DynamicFieldId + 1,
00117 BspFieldId = PumpFieldId + 1,
00118 NumParticlesFieldId = BspFieldId + 1,
00119 NextFieldId = NumParticlesFieldId + 1
00120 };
00121
00122 static const OSG::BitVector ModeFieldMask;
00123 static const OSG::BitVector PositionsFieldMask;
00124 static const OSG::BitVector SizesFieldMask;
00125 static const OSG::BitVector SecPositionsFieldMask;
00126 static const OSG::BitVector ColorsFieldMask;
00127 static const OSG::BitVector NormalsFieldMask;
00128 static const OSG::BitVector IndicesFieldMask;
00129 static const OSG::BitVector TextureZsFieldMask;
00130 static const OSG::BitVector DrawOrderFieldMask;
00131 static const OSG::BitVector DynamicFieldMask;
00132 static const OSG::BitVector PumpFieldMask;
00133 static const OSG::BitVector BspFieldMask;
00134 static const OSG::BitVector NumParticlesFieldMask;
00135
00136
00137 static const OSG::BitVector MTInfluenceMask;
00138
00139
00143 static FieldContainerType &getClassType (void);
00144 static UInt32 getClassTypeId (void);
00145
00147
00151 virtual FieldContainerType &getType (void);
00152 virtual const FieldContainerType &getType (void) const;
00153
00154 virtual UInt32 getContainerSize(void) const;
00155
00157
00161 SFUInt32 *getSFMode (void);
00162 SFGeoPositionsPtr *getSFPositions (void);
00163 MFVec3f *getMFSizes (void);
00164 SFGeoPositionsPtr *getSFSecPositions (void);
00165 SFGeoColorsPtr *getSFColors (void);
00166 SFGeoNormalsPtr *getSFNormals (void);
00167 MFInt32 *getMFIndices (void);
00168 MFReal32 *getMFTextureZs (void);
00169 SFUInt32 *getSFDrawOrder (void);
00170 SFBool *getSFDynamic (void);
00171 SFParticleBSPTree *getSFBsp (void);
00172 SFInt32 *getSFNumParticles (void);
00173
00174 UInt32 &getMode (void);
00175 const UInt32 &getMode (void) const;
00176 GeoPositionsPtr &getPositions (void);
00177 const GeoPositionsPtr &getPositions (void) const;
00178 GeoPositionsPtr &getSecPositions (void);
00179 const GeoPositionsPtr &getSecPositions (void) const;
00180 GeoColorsPtr &getColors (void);
00181 const GeoColorsPtr &getColors (void) const;
00182 GeoNormalsPtr &getNormals (void);
00183 const GeoNormalsPtr &getNormals (void) const;
00184 UInt32 &getDrawOrder (void);
00185 const UInt32 &getDrawOrder (void) const;
00186 bool &getDynamic (void);
00187 const bool &getDynamic (void) const;
00188 ParticleBSPTree &getBsp (void);
00189 const ParticleBSPTree &getBsp (void) const;
00190 Int32 &getNumParticles (void);
00191 const Int32 &getNumParticles (void) const;
00192 Vec3f &getSizes (const UInt32 index);
00193 MFVec3f &getSizes (void);
00194 const MFVec3f &getSizes (void) const;
00195 Int32 &getIndices (const UInt32 index);
00196 MFInt32 &getIndices (void);
00197 const MFInt32 &getIndices (void) const;
00198 Real32 &getTextureZs (const UInt32 index);
00199 MFReal32 &getTextureZs (void);
00200 const MFReal32 &getTextureZs (void) const;
00201
00203
00207 void setMode ( const UInt32 &value );
00208 void setPositions ( const GeoPositionsPtr &value );
00209 void setSecPositions ( const GeoPositionsPtr &value );
00210 void setColors ( const GeoColorsPtr &value );
00211 void setNormals ( const GeoNormalsPtr &value );
00212 void setDrawOrder ( const UInt32 &value );
00213 void setDynamic ( const bool &value );
00214 void setBsp ( const ParticleBSPTree &value );
00215 void setNumParticles ( const Int32 &value );
00216
00218
00223
00227 virtual UInt32 getBinSize (const BitVector &whichField);
00228 virtual void copyToBin ( BinaryDataHandler &pMem,
00229 const BitVector &whichField);
00230 virtual void copyFromBin( BinaryDataHandler &pMem,
00231 const BitVector &whichField);
00232
00233
00235
00239 static ParticlesPtr create (void);
00240 static ParticlesPtr createEmpty (void);
00241
00244
00248 virtual FieldContainerPtr shallowCopy (void) const;
00249
00251
00252 protected:
00253
00254
00258 SFUInt32 _sfMode;
00259 SFGeoPositionsPtr _sfPositions;
00260 MFVec3f _mfSizes;
00261 SFGeoPositionsPtr _sfSecPositions;
00262 SFGeoColorsPtr _sfColors;
00263 SFGeoNormalsPtr _sfNormals;
00264 MFInt32 _mfIndices;
00265 MFReal32 _mfTextureZs;
00266 SFUInt32 _sfDrawOrder;
00267 SFBool _sfDynamic;
00268 SFParticleBSPTree _sfBsp;
00269 SFInt32 _sfNumParticles;
00270
00272
00276 ParticlesBase(void);
00277 ParticlesBase(const ParticlesBase &source);
00278
00280
00284 virtual ~ParticlesBase(void);
00285
00287
00291 #if !defined(OSG_FIXED_MFIELDSYNC)
00292 void executeSyncImpl( ParticlesBase *pOther,
00293 const BitVector &whichField);
00294
00295 virtual void executeSync( FieldContainer &other,
00296 const BitVector &whichField);
00297 #else
00298 void executeSyncImpl( ParticlesBase *pOther,
00299 const BitVector &whichField,
00300 const SyncInfo &sInfo );
00301
00302 virtual void executeSync( FieldContainer &other,
00303 const BitVector &whichField,
00304 const SyncInfo &sInfo);
00305
00306 virtual void execBeginEdit (const BitVector &whichField,
00307 UInt32 uiAspect,
00308 UInt32 uiContainerSize);
00309
00310 void execBeginEditImpl (const BitVector &whichField,
00311 UInt32 uiAspect,
00312 UInt32 uiContainerSize);
00313
00314 virtual void onDestroyAspect(UInt32 uiId, UInt32 uiAspect);
00315 #endif
00316
00318
00319 private:
00320
00321 friend class FieldContainer;
00322
00323 static FieldDescription *_desc[];
00324 static FieldContainerType _type;
00325
00326
00330 SFUInt32 _sfPump;
00331
00333
00337 SFUInt32 *getSFPump (void);
00338
00339 UInt32 &getPump (void);
00340 const UInt32 &getPump (void) const;
00341
00343
00347 void setPump (const UInt32 &value);
00348
00351
00352 void operator =(const ParticlesBase &source);
00353 };
00354
00355
00356
00357
00358
00359
00360 typedef ParticlesBase *ParticlesBaseP;
00361
00362 typedef osgIF<ParticlesBase::isNodeCore,
00363 CoredNodePtr<Particles>,
00364 FieldContainer::attempt_to_create_CoredNodePtr_on_non_NodeCore_FC
00365 >::_IRet ParticlesNodePtr;
00366
00367 typedef RefPtr<ParticlesPtr> ParticlesRefPtr;
00368
00369 OSG_END_NAMESPACE
00370
00371 #define OSGPARTICLESBASE_HEADER_CVSID "@(#)$Id: FCBaseTemplate_h.h,v 1.40 2005/07/20 00:10:14 vossg Exp $"
00372
00373 #endif