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 class SoROI;
00035 class SoVolumeData;
00036 class SoShaderProgram;
00037 class SoShapeHints;
00038
00183 class SoVolumeClippingGroup : public SoGroup {
00184 SO_NODE_HEADER( SoVolumeClippingGroup );
00185
00186 public:
00187
00191 SoVolumeClippingGroup();
00192
00197 SoSFInt32 numPasses;
00198
00205 SoSFBool clipOutside;
00206
00213 static SbBool isSupported(SoState* state=NULL) ;
00214
00218 static unsigned int getMaxNumPasses(SoState* state=NULL);
00219
00221 typedef void SoVolumeClippingGroupCB( SoVolumeClippingGroup *mgr, void *userData );
00222
00227 void setNotEnoughPassCallback( SoVolumeClippingGroupCB *f, void *userData );
00228
00229 private:
00230 virtual void GLRender(SoGLRenderAction *action);
00231 virtual void doAction(SoAction *action);
00232 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00233
00235 virtual void rayPick(SoRayPickAction *action);
00236
00238 virtual void notify(SoNotList *list);
00239
00240 private:
00241 static void initClass() ;
00242 static void exitClass() ;
00243
00244
00245 void activeShaderAndBindTextures(SoGLRenderAction *action);
00246
00247
00248 int getFistDepthTextureUnit(SoGLRenderAction *action) const;
00249
00250
00251 int getNumPairs() const;
00252
00253
00254 SbVec3f getTexScaleFactor() const;
00255
00256
00257 SbBool isUsingTextureArray() const;
00258
00259
00260 int getNumPassUsed() const;
00261
00262
00263 SbBool isCulled(const SbBox3f &box);
00264
00265
00266
00267 SbBool needViewportSizeUpdate() const { return m_needViewportSizeUpdate; }
00268 SbBool needNumPassesUpdate() const { return m_needNumPassesUpdate; }
00269 SbBool needExclusiveModeUpdate() const { return m_needExclusiveModeUpdate; }
00270
00271 void numPassesUpdated() { m_needNumPassesUpdate = FALSE; }
00272 void exclusiveModeUpdated() { m_needExclusiveModeUpdate = FALSE; }
00273
00274
00275
00276
00277
00278
00279
00280 void lockResources();
00281
00282
00283 void unlockResources();
00284
00285
00286 bool areResourcesLocked();
00287
00288
00289
00290
00291 void releaseResources(SoState* state);
00292
00295 inline const SbXfBox3f& getWorldBbox() const { return m_worldBbox; }
00296
00297 private:
00298 virtual ~SoVolumeClippingGroup();
00299
00300 private:
00301
00302 enum LayersState
00303 {
00304 NOT_COMPUTED,
00305 COMPUTED,
00306 };
00307
00308 LayersState m_layersState;
00309
00310 bool m_isLocked;
00311
00312
00313 static const int MAX_NUM_PASSES = 5;
00314
00315
00317 struct NotEnoughLayerCBData {
00318 NotEnoughLayerCBData() : m_notEnoughPassCB(NULL), m_notEnoughPassCBData(NULL), that(NULL) {}
00320 SoVolumeClippingGroupCB* m_notEnoughPassCB;
00322 void* m_notEnoughPassCBData;
00324 SoVolumeClippingGroup* that;
00325 };
00327 NotEnoughLayerCBData m_notEnoughLayerCBData;
00328
00338 static void notEnoughLayerCB(void *userData, SoGLDepthPeeling *mgr);
00339
00340 void commonInit() ;
00341
00342 SbBool initDepthPeeling(SoGLRenderAction *action, const SbVec2s &vpSize);
00343
00344 SbBool m_depthRendered;
00345 SoGLDepthPeeling *m_glDepthPeeling;
00346
00347 SbVec2s m_previousViewportSize;
00348
00349 SbBool m_needViewportSizeUpdate;
00350 SbBool m_needNumPassesUpdate;
00351 SbBool m_needExclusiveModeUpdate;
00352
00353
00354 void updateChildBBox(SoAction*);
00355
00356 const SbXfBox3f& getBBox(SoAction*);
00357
00358 SbBool m_applyTochild;
00359 SbXfBox3f m_bbox;
00360 bool m_bboxCacheClean;
00361
00362 SbXfBox3f m_worldBbox;
00363
00364 struct SoVolumeClippingInfos {
00365 SoVolumeClippingGroup *cg;
00366 SoGLRenderAction *ra;
00367 } m_clippingInfos;
00368 static void renderCB(void *userData, SoGLDepthPeeling *mgr);
00369
00372 SbBool m_depthPeelingPass;
00373
00374 SbBool m_releaseResources;
00375
00377 SoShapeHints* m_shapeHintOverride;
00378
00380 static bool s_debugVolumeClipping;
00381 SoShaderProgram* m_showDepthShader;
00382 void debugGLRender(SoGLRenderAction *action);
00383 void createDebugShader();
00384
00385 };
00386
00387 #endif
00388
00389
00390