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 SoCache;
00069 class SoCamera;
00070 class SoSeparator;
00071 class SoGLRenderActionSync;
00072 class SoGLRenderActionImpl;
00073
00074
00079 typedef void SoGLRenderPassCB(void *userData);
00080
00082
00083
00084
00085
00086
00088
00189 class SoGLRenderAction : public SoAction {
00190
00191 SO_ACTION_HEADER(SoGLRenderAction);
00192
00193 public:
00194
00228 enum TransparencyType
00229 {
00230 SoDEPRECATED
00232 NO_TRANSPARENCY,
00233
00242 NO_SORT,
00243
00258 OPAQUE_FIRST,
00259
00265 SORTED_OBJECT,
00266
00302 SORTED_PIXEL,
00303
00304 };
00305
00327 enum FastEditSavePolicy {
00334 DISABLE,
00335
00352 EACH_FRAME,
00353
00367 WHEN_NEEDED
00368 };
00369
00371 enum AbortCode {
00375 CONTINUE,
00376
00380 ABORT,
00381
00385 PRUNE,
00386
00390 DELAY
00391 };
00392
00398 typedef AbortCode SoGLRenderAbortCB(void *userData);
00399
00401 enum InvalidateCacheMode {
00405 OFF,
00406
00412 ONCE,
00413
00418 ALWAYS
00419 };
00420
00425 SoGLRenderAction(const SbViewportRegion &viewportRegion);
00426
00427 #ifndef HIDDEN_FROM_DOC
00428
00429 virtual ~SoGLRenderAction();
00430 #endif // HIDDEN_FROM_DOC
00431
00435 void setViewportRegion(const SbViewportRegion &newRegion);
00436
00440 const SbViewportRegion &getViewportRegion() const { return vpRegion; }
00441
00446 void setLogicalViewportRegion(const SbViewportRegion &newLogicalRegion);
00447
00451 const SbViewportRegion& getLogicalViewportRegion() const;
00452
00461 void setUpdateArea(const SbVec2f &origin, const SbVec2f &size);
00462
00466 void getUpdateArea(SbVec2f &origin, SbVec2f &size) const;
00467
00476 void setAbortCallback(SoGLRenderAbortCB *func, void *userData)
00477 { abortCB = func; abortData = userData; }
00478
00512 void setTransparencyType(TransparencyType type);
00513
00518 TransparencyType getTransparencyType() const
00519 { return m_transpType; }
00520
00530 void setFastEditSavePolicy(FastEditSavePolicy policy, SbBool fastEditDelayedObjects = FALSE);
00531
00535 FastEditSavePolicy getFastEditSavePolicy() const
00536 { return m_fastEditPolicy; }
00537 SoDEPRECATED
00548 void setSmoothing(SbBool smooth);
00549 SoDEPRECATED
00554 SbBool isSmoothing() const { return doSmooth; }
00555
00571 void setNumPasses(int num);
00572
00576 int getNumPasses() const { return numPasses; }
00577
00582 void setPassUpdate(SbBool flag) { passUpdate = flag; }
00583
00591 SbBool isPassUpdate() const { return passUpdate; }
00592
00598 void setPassCallback(SoGLRenderPassCB *func, void *userData)
00599 { passCB = func; passData = userData; }
00600
00609 void setCacheContext(uint32_t context);
00610
00614 uint32_t getCacheContext() const;
00615
00620 static uint32_t generateCacheContext();
00621
00625 static bool isUsedCacheContext( uint32_t context );
00626
00652 void setSortedLayersNumPasses(int num)
00653 { m_sortedLayersNumPasses = num; }
00654
00655
00661 int getSortedLayersNumPasses() const
00662 { return m_sortedLayersNumPasses ; }
00663
00669 static SbBool isSortedLayersSupported(SoState* state=NULL) ;
00670
00687 void setAlphaTest( SbBool flag );
00688
00692 SbBool isAlphaTest() const
00693 { return m_alphaTest; }
00694
00695
00704 void setRenderingIsRemote(SbBool flag);
00709 SbBool getRenderingIsRemote() const;
00710
00714 virtual void invalidateState();
00715
00721 void setDecimationValue(SoDecimationTypeElement::Type type,
00722 float percentage = 1.0);
00723
00727 SoDecimationTypeElement::Type getDecimationType() { return decType; };
00728
00733 float getDecimationPercentage() { return decPercent; };
00734
00750 void setInvalidateCacheMode(InvalidateCacheMode icm);
00751
00755 InvalidateCacheMode getInvalidateCacheMode();
00756
00764 uint32_t getFrameCounter() const { return m_frameCounter; }
00765
00770 void resetFrameCounter( uint32_t count = 0 ) { m_frameCounter = count; }
00771
00773 virtual void apply(SoNode* node);
00774
00776 virtual void apply(SoPath* path);
00777
00779 virtual void apply(const SoPathList &pathList, SbBool obeysRules = FALSE) { SoAction::apply(pathList, obeysRules); }
00780
00789 enum AutoCacheMode
00790 {
00791 DO_AUTO_CACHE = 1,
00792 DONT_AUTO_CACHE = 2
00793 };
00794
00800 void shouldAutoCache( AutoCacheMode mode );
00801
00802 private:
00804 inline bool isDoingDepthPeeling() const { return m_isDoingDepthPeeling; }
00805
00809 int getDepthPeelingPass();
00810
00815 void enableDepthPeeling3D(bool flag) const;
00816
00817 SoGLDepthPeeling* getDepthPeelingInterface() const;
00818
00819
00820 int getCurPass() const { return curPass; }
00821
00822
00823 SbBool abortNow()
00824 { return (hasTerminated() || (abortCB != NULL && checkAbort())); }
00825
00826
00827
00828
00829
00830
00831
00832
00833 virtual SbBool handleTransparency(SbBool isTransparent = FALSE, SbBool isLinesOrPoints = FALSE);
00834
00836 virtual void setUpState();
00837
00842 void setDelayedObjDepthWrite( SbBool flag ) { m_delayedObjDepthWrite = flag; }
00843
00848 SbBool getDelayedObjDepthWrite() const { return m_delayedObjDepthWrite; }
00849
00856 virtual bool preDelayedTraversal();
00857
00864 virtual void postDelayedTraversal();
00865
00871 void setCache( SoCache* cache );
00872
00874 SoCache* getCache() const;
00875
00876 private:
00877 static void initClass();
00878 static void exitClass();
00879
00881 inline bool isFloatingPointFramebuffer() const { return m_floatingPointFramebuffer; }
00882 inline void setFloatingPointFramebuffer(bool flag) { m_floatingPointFramebuffer = flag; }
00883
00884
00885 SbBool isDelaying() const { return delayObjs; }
00886
00887
00888 bool stateContainsTransparency() const;
00889
00890
00891 void removeAllDelayedPath();
00892
00893 bool isTraversalPassTransparent();
00894
00895 bool handleFastEdit(SoSeparator* sep);
00896
00897 int getCullTestResults() { return cullBits; }
00898 void setCullTestResults(int b) { cullBits = b; }
00899
00900 SbBool isLogicalRegionSet() const;
00901
00902 void setTiledViewportRegion(const SbVec4f& region, int info = 0);
00903
00904
00905
00906 void setDoubleBuffer(SbBool db);
00907
00908 void setForceRender();
00909
00910 void setViewing(SbBool viewing);
00911
00912 SbBool hasDelayedNodesToRender() const;
00913
00914 void setFirstStereoPass(SbBool first);
00915
00916 SoPathList transpPaths;
00917
00918 void setRenderingFromOffscreen(SbBool renderFromOffscreen)
00919 { m_renderingFromOffscreen = renderFromOffscreen; }
00920
00921 SbBool getRenderingFromOffscreen() const
00922 { return m_renderingFromOffscreen; }
00923
00924
00925
00926 SbBool hasDrawnTransparentObjs() const
00927 { return m_hasDrawnTransparentObjs; }
00928
00929
00930 void setFullSceneAntialiasingElement( SbBool enable, int filterMask );
00931
00933 enum RenderMode {
00937 ALL_OBJECTS,
00941 OPAQUE_OBJECTS,
00945 DELAYED_OBJECTS
00946 };
00947
00948
00949
00950
00951
00952 void setRestrictObjectRenderingMode( const RenderMode mode = ALL_OBJECTS )
00953 { m_restrictObjectRendering = mode; };
00954
00955 int getRestrictObjectRenderingMode() const
00956 { return m_restrictObjectRendering; };
00957
00958 SoGLRenderActionSync* getSynchronizer() const;
00959 void setSynchronizer( SoGLRenderActionSync* );
00960
00961 virtual void updateParametersFrom( SoGLRenderAction* );
00962 SoGLRenderPassCB* getPassCallback( void*& data )
00963 {
00964 data = passData;
00965 return passCB;
00966 }
00967
00968 SoGLRenderActionImpl* getImpl();
00969
00970
00971
00972 SoGLDepthPeeling* setDepthPeelingInterface(SoGLDepthPeeling*);
00973
00974 bool isFastEditManipulating();
00975
00976 SoPathList delayedPaths;
00977
00983 bool isLazyEvaluating() const { return m_lazyEvaluating; }
00984 void setLazyEvaluating(bool value) { m_lazyEvaluating = value; }
00985
00986 void copyParametersFrom( SoGLRenderAction* action );
00987
00988
00989
00990
00991 enum flags {
00992 TRANSPARENCY_TYPE = 0x01,
00993 SMOOTHING = 0x02,
00994 ALPHA_TEST = 0x04,
00995 FASTEDIT_SAVE_POLICY = 0x08,
00996 SCENE_GRAPH = 0x10,
00997 ANTIALIASING = 0x20,
00998 ALL = 0x3F
00999 };
01000
01001 private:
01002
01003 virtual void beginTraversal(SoNode *node);
01004
01005 SoINTERNAL private:
01006
01007 void setFastEditSavePolicyInternal(FastEditSavePolicy policy)
01008 { m_fastEditPolicy = policy; }
01009
01010
01011 void setTransparencyTypeInternal(TransparencyType type)
01012 { m_transpType = type; }
01013
01014 uint32_t getWhatChanged() const
01015 {
01016 return whatChanged;
01017 }
01018
01019 private:
01020
01024 template<typename SO_NODE_OR_SO_PATH> void commonApply(SO_NODE_OR_SO_PATH* nodeOrPath);
01025
01026 SoGLRenderActionSync* m_synchronizer;
01027
01028 FastEditSavePolicy m_fastEditPolicy;
01029 TransparencyType m_transpType;
01030
01034 void removeInvalidPaths();
01035
01037 bool m_isDoingDepthPeeling;
01038
01039 SbBool m_hasDrawnTransparentObjs;
01040 SbBool m_isViewing;
01041 SoNode* m_appliedNode;
01042 SbBool m_isFirstApply;
01043 SbBool m_firstStereoPass;
01044 int m_lastStereoMode;
01045
01046 int m_useCacheOpt;
01047 int m_useCompactPaths;
01048
01049 SbViewportRegion vpRegion;
01050
01051
01052 SoRef<SoViewport> m_viewport;
01053
01054 SbVec2f updateOrigin;
01055 SbVec2f updateSize;
01056
01057
01058
01059 SoGLRenderAbortCB *abortCB;
01060 void *abortData;
01061
01062
01063 SbBool doSmooth;
01064 int numPasses;
01065 int curPass;
01066 SbBool passUpdate;
01067 SoGLRenderPassCB *passCB;
01068 void *passData;
01069
01070
01071 SbBool delayObjs;
01072 SbBool fastEditObjs;
01073
01074 SbBool m_shouldSortOpaquePaths ;
01075 SbBool m_shouldSortTranspPaths ;
01076 SbBool sortObjs;
01077
01078 SbBool remoteRendering;
01079
01080
01081 SoDecimationTypeElement::Type decType;
01082 float decPercent;
01083
01084 uint32_t whatChanged;
01085
01086
01087 void enableBlending(SbBool enable);
01088
01089
01090 void enableSmoothing(SbBool enable);
01091
01092
01093 SbBool checkAbort();
01094
01095
01096
01097 int cullBits;
01098
01099 SbBool m_delayedObjDepthWrite;
01100
01101
01102 SbBool m_renderingFromOffscreen;
01103
01104 SbBool m_alphaTest;
01105
01106
01107 uint32_t m_frameCounter;
01108
01109
01110
01111 bool m_lazyEvaluating;
01112
01113
01114
01115 int m_sortedLayersNumPasses ;
01116
01117
01118 void renderSortedLayers(SoNode *node) ;
01119 void initDepthPeeling(SoNode *node);
01120
01121
01122 static void renderSortedLayersCB(void *userData, SoGLDepthPeeling *mgr) ;
01123
01124 SoGLDepthPeeling *m_glDepthPeeling ;
01125
01126 static void cameraPostCB( SoCamera *camera, SoGLRenderAction* renderAction );
01127 bool m_ignoreCameraPostCB;
01128
01129
01130
01131 InvalidateCacheMode m_invalidateAllCaches;
01132 RenderMode m_restrictObjectRendering;
01133
01134 bool m_floatingPointFramebuffer;
01135
01136
01137 SbBool m_fsaaEnable;
01138 int m_fsaaFilterMask;
01139
01140 SoGLRenderActionImpl* m_impl;
01141 };
01142
01143
01144
01145 inline SoGLRenderActionSync* SoGLRenderAction::getSynchronizer() const
01146 {
01147 return m_synchronizer;
01148 }
01149
01150 inline SoGLRenderActionImpl* SoGLRenderAction::getImpl()
01151 {
01152 return m_impl;
01153 }
01154
01155 #ifdef _MSC_VER
01156 #pragma warning( pop )
01157 #endif
01158 #endif
01159
01160