00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_VOLUME_CLIPPING_GROUP_
00025 #define _SO_VOLUME_CLIPPING_GROUP_
00026
00027 #include <Inventor/nodes/SoGroup.h>
00028 #include <Inventor/fields/SoSFInt32.h>
00029 #include <Inventor/fields/SoSFFloat.h>
00030 #include <Inventor/SbBox.h>
00031
00032 class SoGLDepthPeeling;
00033 class SoState;
00034
00169 class SoVolumeClippingGroup : public SoGroup {
00170 SO_NODE_HEADER( SoVolumeClippingGroup );
00171
00172 public:
00173
00177 SoVolumeClippingGroup();
00178
00183 SoSFInt32 numPasses;
00184
00191 SoSFBool clipOutside;
00192
00196 static unsigned int getMaxNumPasses();
00197
00199 typedef void SoVolumeClippingGroupCB( SoVolumeClippingGroup* mgr, void* userData );
00200
00205 void setNotEnoughPassCallback( SoVolumeClippingGroupCB* f, void* userData );
00206
00207 private:
00208 virtual void GLRender(SoGLRenderAction* action);
00209 virtual void doAction(SoAction* action);
00210 virtual void getBoundingBox(SoGetBoundingBoxAction* action);
00211
00213 virtual void rayPick(SoRayPickAction* action);
00214
00215 private:
00216 static void initClass();
00217 static void exitClass();
00218
00219
00220 int getFirstDepthTextureUnit( SoGLRenderAction* action ) const;
00221
00222
00223 int getNumPairs() const;
00224
00225
00226 int getNumPassUsed() const;
00227
00228
00229 SbBool isCulled(const SbBox3f& box);
00230
00231
00232
00233
00234
00235
00236
00237 void lockResources();
00238
00239
00240 void unlockResources();
00241
00242
00243 bool areResourcesLocked() const;
00244
00245
00246
00247
00248 void releaseResources();
00249
00250
00251 void setDepthPeelingTextureOnState(SoGLRenderAction* action);
00252
00255 inline const SbXfBox3f& getWorldBbox() const { return m_worldBbox; }
00256
00258 virtual void notify(SoNotList* list);
00259
00260 private:
00261 virtual ~SoVolumeClippingGroup();
00262
00263 private:
00264
00265 enum LayersState
00266 {
00267 NOT_COMPUTED,
00268 COMPUTED,
00269 };
00270
00271 LayersState m_layersState;
00272
00273 bool m_isLocked;
00274
00276 struct NotEnoughLayerCBData {
00277 NotEnoughLayerCBData() : m_notEnoughPassCB(NULL), m_notEnoughPassCBData(NULL), that(NULL) {}
00279 SoVolumeClippingGroupCB* m_notEnoughPassCB;
00281 void* m_notEnoughPassCBData;
00283 SoVolumeClippingGroup* that;
00284 };
00286 NotEnoughLayerCBData m_notEnoughLayerCBData;
00287
00297 static void notEnoughLayerCB(void* userData, SoGLDepthPeeling* mgr);
00298
00299 void commonInit();
00300
00301 SbBool initDepthPeeling(SoGLRenderAction* action, const SbVec2s& vpSize);
00302
00303 SoGLDepthPeeling* m_glDepthPeeling;
00304
00305 SbVec2s m_previousViewportSize;
00306
00307 SbBool m_needViewportSizeUpdate;
00308
00309
00310 void updateChildBBox();
00311
00312
00313 const SbXfBox3f& getBBox(SoAction*);
00314
00315 bool m_applyTochild;
00316 SbXfBox3f m_bbox;
00317 bool m_bboxCacheClean;
00318
00319 SbXfBox3f m_worldBbox;
00320
00321 struct SoVolumeClippingInfos {
00322 SoVolumeClippingGroup* cg;
00323 SoGLRenderAction* ra;
00324 } m_clippingInfos;
00325 static void renderCB(void* userData, SoGLDepthPeeling* );
00326
00329 SbBool m_depthPeelingPass;
00330
00331 SbBool m_releaseResources;
00332 };
00333
00334 #endif
00335
00336
00337