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
00166 class SoVolumeClippingGroup : public SoGroup {
00167 SO_NODE_HEADER( SoVolumeClippingGroup );
00168
00169 public:
00170
00174 SoVolumeClippingGroup();
00175
00180 SoSFInt32 numPasses;
00181
00188 SoSFBool clipOutside;
00189
00193 static unsigned int getMaxNumPasses();
00194
00196 typedef void SoVolumeClippingGroupCB( SoVolumeClippingGroup* mgr, void* userData );
00197
00202 void setNotEnoughPassCallback( SoVolumeClippingGroupCB* f, void* userData );
00203
00204 private:
00205 virtual void GLRender(SoGLRenderAction* action);
00206 virtual void doAction(SoAction* action);
00207 virtual void getBoundingBox(SoGetBoundingBoxAction* action);
00208
00210 virtual void rayPick(SoRayPickAction* action);
00211
00212 private:
00213 static void initClass();
00214 static void exitClass();
00215
00216
00217 int getFirstDepthTextureUnit( SoGLRenderAction* action ) const;
00218
00219
00220 int getNumPairs() const;
00221
00222
00223 int getNumPassUsed() const;
00224
00225
00226 SbBool isCulled(const SbBox3f& box);
00227
00228
00229
00230
00231
00232
00233
00234 void lockResources();
00235
00236
00237 void unlockResources();
00238
00239
00240 bool areResourcesLocked() const;
00241
00242
00243
00244
00245 void releaseResources();
00246
00247
00248 void setDepthPeelingTextureOnState(SoGLRenderAction* action);
00249
00252 inline const SbXfBox3f& getWorldBbox() const { return m_worldBbox; }
00253
00255 virtual void notify(SoNotList* list);
00256
00257 private:
00258 virtual ~SoVolumeClippingGroup();
00259
00260 private:
00261
00262 enum LayersState
00263 {
00264 NOT_COMPUTED,
00265 COMPUTED,
00266 };
00267
00268 LayersState m_layersState;
00269
00270 bool m_isLocked;
00271
00273 struct NotEnoughLayerCBData {
00274 NotEnoughLayerCBData() : m_notEnoughPassCB(NULL), m_notEnoughPassCBData(NULL), that(NULL) {}
00276 SoVolumeClippingGroupCB* m_notEnoughPassCB;
00278 void* m_notEnoughPassCBData;
00280 SoVolumeClippingGroup* that;
00281 };
00283 NotEnoughLayerCBData m_notEnoughLayerCBData;
00284
00294 static void notEnoughLayerCB(void* userData, SoGLDepthPeeling* mgr);
00295
00296 void commonInit();
00297
00298 SbBool initDepthPeeling(SoGLRenderAction* action, const SbVec2s& vpSize);
00299
00300 SoGLDepthPeeling* m_glDepthPeeling;
00301
00302 SbVec2s m_previousViewportSize;
00303
00304 SbBool m_needViewportSizeUpdate;
00305
00306
00307 void updateChildBBox();
00308
00309
00310 const SbXfBox3f& getBBox(SoAction*);
00311
00312 bool m_applyTochild;
00313 SbXfBox3f m_bbox;
00314 bool m_bboxCacheClean;
00315
00316 SbXfBox3f m_worldBbox;
00317
00318 struct SoVolumeClippingInfos {
00319 SoVolumeClippingGroup* cg;
00320 SoGLRenderAction* ra;
00321 } m_clippingInfos;
00322 static void renderCB(void* userData, SoGLDepthPeeling* );
00323
00326 SbBool m_depthPeelingPass;
00327
00328 SbBool m_releaseResources;
00329 };
00330
00331 #endif
00332
00333
00334