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 #ifndef _OSGPARTICLEBSP_H_
00040 #define _OSGPARTICLEBSP_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045
00046 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00047
00048 #include <OSGConfig.h>
00049
00050 #include <OSGMaterialDrawable.h>
00051
00052 #include <OSGGeoPropertyBase.h>
00053
00054 OSG_BEGIN_NAMESPACE
00055
00056 typedef GeoPositions::PtrType GeoPositionsPtr;
00057
00058 class Particles;
00059 typedef FCPtr<MaterialDrawablePtr, Particles> ParticlesPtr;
00060
00061 class ParticleBSPTree;
00062
00066 class OSG_SYSTEMLIB_DLLMAPPING ParticleBSPNode
00067 {
00068
00069 public:
00070
00071 enum { X=0, Y, Z, Leaf } Axis;
00072
00073
00077 ParticleBSPNode(void);
00078 ParticleBSPNode(const ParticleBSPNode &source);
00079
00080 ParticleBSPNode(UInt32 value);
00081 ParticleBSPNode(UInt8 axis, Real32 splitvalue);
00082
00084
00088 ~ParticleBSPNode(void);
00089
00091
00095 inline bool isLeaf (void) const;
00096 inline Int32 getValue (void) const;
00097 inline Real32 getSplitValue(void) const;
00098 inline UInt8 getAxis (void) const;
00099
00100 inline void setValue (Int32 value);
00101 inline void setSplit (UInt8 axis, Real32 splitvalue);
00102
00104
00108 void dump( UInt32 uiIndent = 0,
00109 const BitVector bvFlags = 0) const;
00110
00112
00113 protected:
00114
00115
00116 private:
00117
00118 UInt8 _axis;
00119
00120 union
00121 {
00122 Int32 _value;
00123 Real32 _splitvalue;
00124 };
00125 };
00126
00130 class OSG_SYSTEMLIB_DLLMAPPING ParticleBSPTree
00131 {
00132
00133 public:
00134
00135
00139 ParticleBSPTree(void);
00140
00142
00146 virtual ~ParticleBSPTree(void);
00147
00149
00153 inline bool created(void);
00154
00155 void build (Particles *core);
00156
00157 void destroy(void);
00158
00160
00164 Int32 *traverse(const Pnt3f &refPoint, UInt32 &length,
00165 Int32 *order = NULL) const;
00166
00167 Int32 *traverse(const Vec3f &refVec, UInt32 &length,
00168 Int32 *order = NULL) const;
00169
00171
00175 virtual void dump( UInt32 uiIndent = 0,
00176 const BitVector bvFlags = 0) const;
00177
00178 void putToString(std::string &outVal) const;
00179
00180 bool getFromString(const Char8 *&inVal);
00181
00182 UInt32 getBinSize(void) const;
00183
00184 void copyToBin(BinaryDataHandler &pMem) const;
00185
00186 void copyFromBin(BinaryDataHandler &pMem);
00187
00189
00190 protected:
00191
00192
00196 UInt32 doTraverse(const Pnt3f &refPoint, UInt32 index, UInt32 length,
00197 Int32 *order) const;
00198
00199 UInt32 doTraverse(const Vec3f &refVec, UInt32 index, UInt32 length,
00200 Int32 *order) const;
00201
00203
00207 UInt32 doBuild(std::vector<Int32>::iterator begin,
00208 std::vector<Int32>::iterator end,
00209 UInt32 nodeindex,
00210 GeoPositionsPtr pos );
00211
00214
00215 private:
00216
00217 std::vector<ParticleBSPNode> _tree;
00218 };
00219
00220
00221 #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00222
00225 #if !defined(OSG_DOC_DEV_TRAITS)
00226
00227 #endif
00228
00229 template <>
00230 struct FieldDataTraits<ParticleBSPTree> :
00231 public FieldTraitsRecurseBase<ParticleBSPTree>
00232 {
00233 static DataType _type;
00234
00235 enum { StringConvertable = ToStringConvertable |
00236 FromStringConvertable };
00237
00238 static DataType &getType (void) { return _type; }
00239
00240 static Char8 *getSName (void) { return "SFParticleBSPTree"; }
00241 static Char8 *getMName (void) { return "MFParticleBSPTree"; }
00242
00243 static ParticleBSPTree getDefault (void) { return ParticleBSPTree(); }
00244
00245 static bool getFromString( ParticleBSPTree &outVal,
00246 const Char8 *&inVal)
00247 {
00248 return outVal.getFromString(inVal);
00249 }
00250
00251 static void putToString (const ParticleBSPTree &inVal,
00252 std::string &outVal)
00253 {
00254 inVal.putToString(outVal);
00255 }
00256
00257 static UInt32 getBinSize(const ParticleBSPTree &oObject)
00258 {
00259 return oObject.getBinSize();
00260 }
00261
00262 static void copyToBin( BinaryDataHandler &pMem,
00263 const ParticleBSPTree &oObject)
00264 {
00265 oObject.copyToBin(pMem);
00266 }
00267
00268 static void copyFromBin(BinaryDataHandler &pMem,
00269 ParticleBSPTree &oObject)
00270 {
00271 oObject.copyFromBin(pMem);
00272 }
00273 };
00274
00275 #if !defined(OSG_DOC_DEV_TRAITS)
00276
00278 #endif
00279
00280 #endif // !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00281
00285 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_FIELD_TYPEDEFS)
00286
00288 typedef SField<ParticleBSPTree> SFParticleBSPTree;
00289 #endif
00290
00291 #ifndef OSG_COMPILEPARTICLEBSPINST
00292 OSG_DLLEXPORT_DECL1(SField, ParticleBSPTree, OSG_SYSTEMLIB_DLLTMPLMAPPING)
00293 #endif
00294
00295
00296 OSG_END_NAMESPACE
00297
00298 #include <OSGParticleBSP.inl>
00299
00300 #define OSGPARTICLEBSP_HEADER_CVSID "@(#)$Id: $"
00301
00302 #endif // exclude from user doc
00303
00304 #endif