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 #ifndef _SO_GL_RENDER_ACTION_
00050 #define _SO_GL_RENDER_ACTION_
00051
00052 #include <Inventor/SbViewportRegion.h>
00053 #include <Inventor/nodes/SoViewport.h>
00054 #include <Inventor/actions/SoSubAction.h>
00055 #include <Inventor/elements/SoShapeStyleElement.h>
00056 #include <Inventor/elements/SoDecimationTypeElement.h>
00057 #include <Inventor/lists/SoPathList.h>
00058 #include <Inventor/lists/SoSensorList.h>
00059
00060 #ifdef _MSC_VER
00061 #pragma warning( push )
00062 #pragma warning(disable:4251)
00063 #endif
00064
00065 class SbBox3f;
00066 class SoGetBoundingBoxAction;
00067 class SoGLDepthPeeling;
00068 class SoCamera;
00069 class SoSeparator;
00070 class SoGLRenderActionSync;
00071 class SoGLRenderActionImpl;
00072
00073
00078 typedef void SoGLRenderPassCB(void *userData);
00079
00081
00082
00083
00084
00085
00087
00182 class SoGLRenderAction : public SoAction {
00183
00184 SO_ACTION_HEADER(SoGLRenderAction);
00185
00186 public:
00187
00221 enum TransparencyType
00222 {
00223 SoDEPRECATED
00225 NO_TRANSPARENCY,
00226
00231 NO_SORT,
00232
00240 OPAQUE_FIRST,
00241
00246 SORTED_OBJECT,
00247
00283 SORTED_PIXEL,
00284
00285 };
00286
00308 enum FastEditSavePolicy {
00315 DISABLE,
00316
00333 EACH_FRAME,
00334
00348 WHEN_NEEDED
00349 };
00350
00352 enum AbortCode {
00356 CONTINUE,
00357
00361 ABORT,
00362
00366 PRUNE,
00367
00371 DELAY
00372 };
00373
00379 typedef AbortCode SoGLRenderAbortCB(void *userData);
00380
00382 enum InvalidateCacheMode {
00386 OFF,
00387
00393 ONCE,
00394
00399 ALWAYS
00400 };
00401
00406 SoGLRenderAction(const SbViewportRegion &viewportRegion);
00407
00408 #ifndef HIDDEN_FROM_DOC
00409
00410 virtual ~SoGLRenderAction();
00411 #endif // HIDDEN_FROM_DOC
00412
00416 void setViewportRegion(const SbViewportRegion &newRegion);
00417
00421 const SbViewportRegion &getViewportRegion() const { return vpRegion; }
00422
00427 void setLogicalViewportRegion(const SbViewportRegion &newLogicalRegion);
00428
00432 const SbViewportRegion& getLogicalViewportRegion() const;
00433
00442 void setUpdateArea(const SbVec2f &origin, const SbVec2f &size);
00443
00447 void getUpdateArea(SbVec2f &origin, SbVec2f &size) const;
00448
00457 void setAbortCallback(SoGLRenderAbortCB *func, void *userData)
00458 { abortCB = func; abortData = userData; }
00459
00493 void setTransparencyType(TransparencyType type);
00494
00499 TransparencyType getTransparencyType() const
00500 { return m_transpType; }
00501
00511 void setFastEditSavePolicy(FastEditSavePolicy policy, SbBool fastEditDelayedObjects = FALSE);
00512
00516 FastEditSavePolicy getFastEditSavePolicy() const
00517 { return m_fastEditPolicy; }
00518
00529 void setSmoothing(SbBool smooth);
00530
00534 SbBool isSmoothing() const { return doSmooth; }
00535
00551 void setNumPasses(int num);
00552
00556 int getNumPasses() const { return numPasses; }
00557
00562 void setPassUpdate(SbBool flag) { passUpdate = flag; }
00563
00571 SbBool isPassUpdate() const { return passUpdate; }
00572
00578 void setPassCallback(SoGLRenderPassCB *func, void *userData)
00579 { passCB = func; passData = userData; }
00580
00589 void setCacheContext(uint32_t context);
00590
00594 uint32_t getCacheContext() const;
00595
00600 static uint32_t generateCacheContext();
00601
00605 static bool isUsedCacheContext( uint32_t context );
00606
00632 void setSortedLayersNumPasses(int num)
00633 { m_sortedLayersNumPasses = num; }
00634
00635
00641 int getSortedLayersNumPasses() const
00642 { return m_sortedLayersNumPasses ; }
00643
00649 static SbBool isSortedLayersSupported(SoState* state=NULL) ;
00650
00667 void setAlphaTest( SbBool flag );
00668
00672 SbBool isAlphaTest() const
00673 { return m_alphaTest; }
00674
00675
00684 void setRenderingIsRemote(SbBool flag);
00689 SbBool getRenderingIsRemote() const;
00690
00694 virtual void invalidateState();
00695
00701 void setDecimationValue(SoDecimationTypeElement::Type type,
00702 float percentage = 1.0);
00703
00707 SoDecimationTypeElement::Type getDecimationType() { return decType; };
00708
00713 float getDecimationPercentage() { return decPercent; };
00714
00730 void setInvalidateCacheMode(InvalidateCacheMode icm);
00731
00735 InvalidateCacheMode getInvalidateCacheMode();
00736
00744 uint32_t getFrameCounter() const { return m_frameCounter; }
00745
00750 void resetFrameCounter( uint32_t count = 0 ) { m_frameCounter = count; }
00751
00753 virtual void apply(SoNode* node);
00754
00756 virtual void apply(SoPath* path);
00757
00759 virtual void apply(const SoPathList &pathList, SbBool obeysRules = FALSE) { SoAction::apply(pathList, obeysRules); }
00760
00769 enum AutoCacheMode
00770 {
00771 DO_AUTO_CACHE = 1,
00772 DONT_AUTO_CACHE = 2
00773 };
00774
00780 void shouldAutoCache( AutoCacheMode mode );
00781
00782 private:
00784 inline bool isDoingDepthPeeling() const { return m_isDoingDepthPeeling; }
00785
00789 int getDepthPeelingPass();
00790
00795 void enableDepthPeeling3D(bool flag) const;
00796
00797 SoGLDepthPeeling* getDepthPeelingInterface() const;
00798
00799
00800 int getCurPass() const { return curPass; }
00801
00802
00803 SbBool abortNow()
00804 { return (hasTerminated() || (abortCB != NULL && checkAbort())); }
00805
00806
00807
00808
00809
00810
00811
00812
00813 virtual SbBool handleTransparency(SbBool isTransparent = FALSE, SbBool isLinesOrPoints = FALSE);
00814
00816 virtual void setUpState();
00817
00822 void setDelayedObjDepthWrite( SbBool flag ) { m_delayedObjDepthWrite = flag; }
00823
00828 SbBool getDelayedObjDepthWrite() const { return m_delayedObjDepthWrite; }
00829
00836 virtual bool preDelayedTraversal();
00837
00844 virtual void postDelayedTraversal();
00845
00846 private:
00847 static void initClass();
00848 static void exitClass();
00849
00851 inline bool isFloatingPointFramebuffer() const { return m_floatingPointFramebuffer; }
00852 inline void setFloatingPointFramebuffer(bool flag) { m_floatingPointFramebuffer = flag; }
00853
00854
00855 SbBool isDelaying() const { return delayObjs; }
00856
00857
00858 void removeAllDelayedPath();
00859
00860 bool isTraversalPassTransparent();
00861
00862 bool handleFastEdit(SoSeparator* sep);
00863
00864 int getCullTestResults() { return cullBits; }
00865 void setCullTestResults(int b) { cullBits = b; }
00866
00867
00868 void setBackFaceCullingIgnored(SbBool flag) { m_isBackFaceCullingIgnored = flag; }
00869 SbBool isBackFaceCullingIgnored() const { return m_isBackFaceCullingIgnored; }
00870
00871 SbBool isLogicalRegionSet() const;
00872
00873 void setTiledViewportRegion(const SbVec4f& region, int info = 0);
00874
00875
00876
00877 void setDoubleBuffer(SbBool db);
00878
00879 void setForceRender();
00880
00881 void setViewing(SbBool viewing);
00882
00883 SbBool hasDelayedNodesToRender() const;
00884
00885 void setFirstStereoPass(SbBool first);
00886
00887 SoPathList transpPaths;
00888
00889 void setRenderingFromOffscreen(SbBool renderFromOffscreen)
00890 { m_renderingFromOffscreen = renderFromOffscreen; }
00891
00892 SbBool getRenderingFromOffscreen() const
00893 { return m_renderingFromOffscreen; }
00894
00895
00896
00897 SbBool hasDrawnTransparentObjs() const
00898 { return m_hasDrawnTransparentObjs; }
00899
00900
00901 void setFullSceneAntialiasingElement( SbBool enable, int filterMask );
00902
00904 enum RenderMode {
00908 ALL_OBJECTS,
00912 OPAQUE_OBJECTS,
00916 DELAYED_OBJECTS
00917 };
00918
00919
00920
00921
00922
00923 void setRestrictObjectRenderingMode( const RenderMode mode = ALL_OBJECTS )
00924 { m_restrictObjectRendering = mode; };
00925
00926 int getRestrictObjectRenderingMode() const
00927 { return m_restrictObjectRendering; };
00928
00929 SoGLRenderActionSync* getSynchronizer() const;
00930 void setSynchronizer( SoGLRenderActionSync* );
00931
00932 virtual void updateParametersFrom( SoGLRenderAction* );
00933 SoGLRenderPassCB* getPassCallback( void*& data )
00934 {
00935 data = passData;
00936 return passCB;
00937 }
00938
00939 SoGLRenderActionImpl* getImpl();
00940
00941
00942
00943 SoGLDepthPeeling* setDepthPeelingInterface(SoGLDepthPeeling*);
00944
00945 bool isFastEditManipulating();
00946
00947 SoPathList delayedPaths;
00948
00954 bool isLazyEvaluating() const { return m_lazyEvaluating; }
00955 void setLazyEvaluating(bool value) { m_lazyEvaluating = value; }
00956
00957 private:
00958
00959 virtual void beginTraversal(SoNode *node);
00960
00961 SoINTERNAL private:
00962
00963 void setFastEditSavePolicyInternal(FastEditSavePolicy policy)
00964 { m_fastEditPolicy = policy; }
00965
00966
00967 void setTransparencyTypeInternal(TransparencyType type)
00968 { m_transpType = type; }
00969
00970 private:
00971
00975 template<typename SO_NODE_OR_SO_PATH> void commonApply(SO_NODE_OR_SO_PATH* nodeOrPath);
00976
00977 SoGLRenderActionSync* m_synchronizer;
00978
00979 FastEditSavePolicy m_fastEditPolicy;
00980 TransparencyType m_transpType;
00981
00985 void removeInvalidPaths();
00986
00988 bool m_isDoingDepthPeeling;
00989
00990 SbBool m_hasDrawnTransparentObjs;
00991 SbBool m_isViewing;
00992 SoNode* m_appliedNode;
00993 SbBool m_isFirstApply;
00994 SbBool m_firstStereoPass;
00995 int m_lastStereoMode;
00996
00997 int m_useCacheOpt;
00998 int m_useCompactPaths;
00999
01000 SbViewportRegion vpRegion;
01001
01002
01003 SoRef<SoViewport> m_viewport;
01004
01005 SbVec2f updateOrigin;
01006 SbVec2f updateSize;
01007
01008
01009
01010 SoGLRenderAbortCB *abortCB;
01011 void *abortData;
01012
01013
01014 SbBool doSmooth;
01015 int numPasses;
01016 int curPass;
01017 SbBool passUpdate;
01018 SoGLRenderPassCB *passCB;
01019 void *passData;
01020
01021
01022 SbBool delayObjs;
01023 SbBool fastEditObjs;
01024
01025 SbBool m_shouldSortOpaquePaths ;
01026 SbBool m_shouldSortTranspPaths ;
01027 SbBool sortObjs;
01028
01029 SbBool remoteRendering;
01030
01031
01032 SoDecimationTypeElement::Type decType;
01033 float decPercent;
01034
01035
01036
01037
01038 enum flags {
01039 TRANSPARENCY_TYPE = 0x01,
01040 SMOOTHING = 0x02,
01041 ALPHA_TEST = 0x04,
01042 FASTEDIT_SAVE_POLICY = 0x08,
01043 SCENE_GRAPH = 0x10,
01044 ANTIALIASING = 0x20,
01045 ALL = 0x3F
01046 };
01047 uint32_t whatChanged;
01048
01049
01050 void enableBlending(SbBool enable);
01051
01052
01053 void enableSmoothing(SbBool enable);
01054
01055
01056 SbBool checkAbort();
01057
01058
01059
01060 int cullBits;
01061
01062
01063 SbBool m_isBackFaceCullingIgnored;
01064
01065 SbBool m_delayedObjDepthWrite;
01066
01067
01068 SbBool m_renderingFromOffscreen;
01069
01070 SbBool m_alphaTest;
01071
01072
01073 uint32_t m_frameCounter;
01074
01075
01076
01077 bool m_lazyEvaluating;
01078
01079
01080
01081 int m_sortedLayersNumPasses ;
01082
01083
01084 void renderSortedLayers(SoNode *node) ;
01085 void initDepthPeeling(SoNode *node);
01086
01087
01088 static void renderSortedLayersCB(void *userData, SoGLDepthPeeling *mgr) ;
01089
01090 SoGLDepthPeeling *m_glDepthPeeling ;
01091
01092 static void cameraPostCB( SoCamera *camera, SoGLRenderAction* renderAction );
01093 bool m_ignoreCameraPostCB;
01094
01095
01096
01097 InvalidateCacheMode m_invalidateAllCaches;
01098 RenderMode m_restrictObjectRendering;
01099
01100 bool m_floatingPointFramebuffer;
01101
01102
01103 SbBool m_fsaaEnable;
01104 int m_fsaaFilterMask;
01105
01106 SoGLRenderActionImpl* m_impl;
01107 };
01108
01109
01110
01111 inline SoGLRenderActionSync* SoGLRenderAction::getSynchronizer() const
01112 {
01113 return m_synchronizer;
01114 }
01115
01116 inline SoGLRenderActionImpl* SoGLRenderAction::getImpl()
01117 {
01118 return m_impl;
01119 }
01120
01121 #ifdef _MSC_VER
01122 #pragma warning( pop )
01123 #endif
01124 #endif
01125
01126