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/actions/SoSubAction.h>
00054 #include <Inventor/elements/SoShapeStyleElement.h>
00055 #include <Inventor/elements/SoDecimationTypeElement.h>
00056 #include <Inventor/lists/SoPathList.h>
00057 #include <Inventor/lists/SoSensorList.h>
00058
00059 #ifdef _MSC_VER
00060 #pragma warning( push )
00061 #pragma warning(disable:4251)
00062 #endif
00063
00064 class SbBox3f;
00065 class SoGetBoundingBoxAction;
00066 class SoGLDepthPeeling;
00067 class SoCamera;
00068 class SoSeparator;
00069 class SoGLRenderActionSync;
00070 class SoGLRenderActionImpl;
00071 class SoAccumulatedTextPolygon;
00072 class SoAccumulatedTextTextured;
00073
00074
00079 typedef void SoGLRenderPassCB(void *userData);
00080
00082
00083
00084
00085
00086
00088
00202 class SoGLRenderAction : public SoAction {
00203
00204 SO_ACTION_HEADER(SoGLRenderAction);
00205
00206 public:
00207
00212 enum TransparencyType {
00213
00223 SCREEN_DOOR,
00224
00228 ADD,
00229
00236 DELAYED_ADD,
00237
00241 BLEND,
00242
00250 DELAYED_BLEND,
00251
00256 SORTED_OBJECT_ADD,
00257
00262 SORTED_OBJECT_BLEND,
00263 SoDEPRECATED
00268 SORTED_LAYERS_BLEND,
00269
00317 SORTED_PIXELS_BLEND = SORTED_LAYERS_BLEND,
00318 SoDEPRECATED
00323 DELAYED_SORTED_LAYERS_BLEND,
00324
00329 DELAYED_SORTED_PIXELS_BLEND = DELAYED_SORTED_LAYERS_BLEND,
00330
00336 SORTED_TRIANGLES_ADD,
00337
00341 SORTED_TRIANGLES_BLEND,
00342
00348 SORTED_OBJECT_TRIANGLES_ADD,
00349
00353 SORTED_OBJECT_TRIANGLES_BLEND,
00354
00358 NO_TRANSPARENCY
00359
00360 };
00361
00383 enum FastEditSavePolicy {
00390 DISABLE,
00391
00408 EACH_FRAME,
00409
00423 WHEN_NEEDED
00424 };
00425
00427 enum AbortCode {
00431 CONTINUE,
00432
00436 ABORT,
00437
00441 PRUNE,
00442
00446 DELAY
00447 };
00448
00454 typedef AbortCode SoGLRenderAbortCB(void *userData);
00455
00457 enum InvalidateCacheMode {
00461 OFF,
00462
00468 ONCE,
00469
00474 ALWAYS
00475 };
00476
00481 SoGLRenderAction(const SbViewportRegion &viewportRegion);
00482
00483 #ifndef HIDDEN_FROM_DOC
00484
00485 virtual ~SoGLRenderAction();
00486 #endif // HIDDEN_FROM_DOC
00487
00491 void setViewportRegion(const SbViewportRegion &newRegion);
00492
00496 const SbViewportRegion &getViewportRegion() const { return vpRegion; }
00497
00502 void setLogicalViewportRegion(const SbViewportRegion &newLogicalRegion);
00503
00507 const SbViewportRegion &getLogicalViewportRegion() const { return vpLogicalRegion; }
00508
00517 void setUpdateArea(const SbVec2f &origin, const SbVec2f &size);
00518
00522 void getUpdateArea(SbVec2f &origin, SbVec2f &size) const;
00523
00532 void setAbortCallback(SoGLRenderAbortCB *func, void *userData)
00533 { abortCB = func; abortData = userData; }
00534
00576 void setTransparencyType(TransparencyType type);
00577
00582 TransparencyType getTransparencyType() const { return transpType; }
00583
00599 void setFastEditSavePolicy(FastEditSavePolicy policy, SbBool fastEditDelayedObjects = FALSE);
00600
00604 FastEditSavePolicy getFastEditSavePolicy() const { return fastEditPolicy; }
00605
00606
00617 void setSmoothing(SbBool smooth);
00618
00622 SbBool isSmoothing() const { return doSmooth; }
00623
00639 void setNumPasses(int num);
00640
00644 int getNumPasses() const { return numPasses; }
00645
00650 void setPassUpdate(SbBool flag) { passUpdate = flag; }
00651
00659 SbBool isPassUpdate() const { return passUpdate; }
00660
00666 void setPassCallback(SoGLRenderPassCB *func, void *userData)
00667 { passCB = func; passData = userData; }
00668
00677 void setCacheContext(uint32_t context);
00678
00682 uint32_t getCacheContext() const;
00683
00688 static uint32_t generateCacheContext();
00689
00693 static bool isUsedCacheContext( uint32_t context );
00694
00721 void setSortedLayersNumPasses(int num)
00722 { m_sortedLayersNumPasses = num; }
00723
00724
00730 int getSortedLayersNumPasses() const
00731 { return m_sortedLayersNumPasses ; }
00732
00738 static SbBool isSortedLayersSupported(SoState* state=NULL) ;
00739
00756 void setAlphaTest( SbBool flag );
00757
00761 SbBool isAlphaTest() const
00762 { return m_alphaTest; }
00763
00764
00773 void setRenderingIsRemote(SbBool flag);
00778 SbBool getRenderingIsRemote() const;
00779
00783 virtual void invalidateState();
00784
00790 void setDecimationValue(SoDecimationTypeElement::Type type,
00791 float percentage = 1.0);
00792
00796 SoDecimationTypeElement::Type getDecimationType() { return decType; };
00797
00802 float getDecimationPercentage() { return decPercent; };
00803
00837 void setSortedTrianglesSortFrequency(int angle);
00838
00843 int getSortedTrianglesSortFrequency();
00844
00857 void setSortedTrianglesNumCaches(int numCaches);
00858
00862 int getSortedTrianglesNumCaches();
00863
00879 void setInvalidateCacheMode(InvalidateCacheMode icm);
00880
00884 InvalidateCacheMode getInvalidateCacheMode();
00885
00893 uint32_t getFrameCounter() const { return m_frameCounter; }
00894
00899 void resetFrameCounter( uint32_t count = 0 ) { m_frameCounter = count; }
00900
00909 enum AutoCacheMode
00910 {
00911 DO_AUTO_CACHE = 1,
00912 DONT_AUTO_CACHE = 2
00913 };
00914
00920 void shouldAutoCache( AutoCacheMode mode );
00921
00922 private:
00924 inline bool isDoingDepthPeeling() const { return m_isDoingDepthPeeling; }
00925
00929 int getDepthPeelingPass();
00930
00935 void enableDepthPeeling3D(bool flag) const;
00936
00937 SoGLDepthPeeling* getDepthPeelingInterface() const;
00938
00939 SoAccumulatedTextPolygon* getAccumulatedTextPolygon();
00940 SoAccumulatedTextTextured* getAccumulatedTextTextured();
00941
00942
00943 int getCurPass() const { return curPass; }
00944
00945
00946 SbBool abortNow()
00947 { return (hasTerminated() || (abortCB != NULL && checkAbort())); }
00948
00949
00950
00951
00952
00953
00954
00955
00956 virtual SbBool handleTransparency(SbBool isTransparent = FALSE, SbBool isLinesOrPoints = FALSE);
00957
00959 virtual void setUpState();
00960
00965 void setDelayedObjDepthWrite( SbBool flag ) { m_delayedObjDepthWrite = flag; }
00966
00971 SbBool getDelayedObjDepthWrite() const { return m_delayedObjDepthWrite; }
00972
00979 virtual bool preDelayedTraversal();
00980
00987 virtual void postDelayedTraversal();
00988
00989 private:
00990 static void initClass();
00991 static void exitClass();
00992
00993 virtual void apply(SoNode* node);
00994 virtual void apply(SoPath* path) { SoAction::apply(path); }
00995 virtual void apply(const SoPathList &pathList, SbBool obeysRules = FALSE) { SoAction::apply(pathList, obeysRules); }
00996
00998 inline bool isFloatingPointFramebuffer() const { return m_floatingPointFramebuffer; }
00999 inline void setFloatingPointFramebuffer(bool flag) { m_floatingPointFramebuffer = flag; }
01000
01001
01002 SbBool isDelaying() const { return delayObjs; }
01003
01004
01005 void removeAllDelayedPath();
01006
01007 bool isTraversalPassTransparent();
01008 bool isTraversalPassTransparentSortedTriangles();
01009
01010 bool handleFastEdit(SoSeparator* sep);
01011
01012 int getCullTestResults() { return cullBits; }
01013 void setCullTestResults(int b) { cullBits = b; }
01014
01015
01016 void setBackFaceCullingIgnored(SbBool flag) { m_isBackFaceCullingIgnored = flag; }
01017 SbBool isBackFaceCullingIgnored() const { return m_isBackFaceCullingIgnored; }
01018
01019 SbBool isLogicalRegionSet() const;
01020
01021
01022
01023 void setDoubleBuffer(SbBool db);
01024
01025 void setForceRender();
01026
01027 void setViewing(SbBool viewing);
01028
01029 SbBool hasDelayedNodesToRender() const;
01030
01031 void setFirstStereoPass(SbBool first);
01032
01033 SoPathList transpPaths;
01034
01035 void setRenderingFromOffscreen(SbBool renderFromOffscreen)
01036 { m_renderingFromOffscreen = renderFromOffscreen; }
01037
01038 SbBool getRenderingFromOffscreen() const
01039 { return m_renderingFromOffscreen; }
01040
01041
01042
01043 SbBool hasDrawnTransparentObjs() const
01044 { return m_hasDrawnTransparentObjs; }
01045
01046
01047 void setFullSceneAntialiasingElement( SbBool enable, int filterMask );
01048
01050 enum RenderMode {
01054 ALL_OBJECTS,
01058 OPAQUE_OBJECTS,
01062 DELAYED_OBJECTS
01063 };
01064
01065
01066
01067
01068
01069 void setRestrictObjectRenderingMode( const RenderMode mode = ALL_OBJECTS )
01070 { m_restrictObjectRendering = mode; };
01071
01072 int getRestrictObjectRenderingMode() const
01073 { return m_restrictObjectRendering; };
01074
01075 SoGLRenderActionSync* getSynchronizer();
01076 void setSynchronizer( SoGLRenderActionSync* );
01077
01078 virtual void updateParametersFrom( SoGLRenderAction* );
01079 SoGLRenderPassCB* getPassCallback( void*& data )
01080 {
01081 data = passData;
01082 return passCB;
01083 }
01084
01085 SoGLRenderActionImpl* getImpl();
01086
01087
01088
01089 SoGLDepthPeeling* setDepthPeelingInterface(SoGLDepthPeeling*);
01090
01091 bool isFastEditManipulating();
01092
01093 SoPathList delayedPaths;
01094
01095 #if 1
01097 // Adds to the list of paths to render after all other stuff
01098
01099
01100
01102 void addDelayedPath(SoPath *path);
01103
01104
01105
01106
01108 void removeDelayedTranspPath(SoNode *node) ;
01109
01110
01111
01112
01114 void addOpaqueDelayedPath(SoPath *path);
01115
01116
01117
01118
01120 void removeOpaqueDelayedPath(SoPath *path);
01121
01122
01123
01125 void removePathFromAllPass(SoPath *path);
01126
01127
01128
01130 bool isRenderingDelayed() const;
01131
01132
01133
01135 SbBool isRenderingDelayedPaths() const;
01136
01137
01138
01140 SbBool isRenderingOpaqueDelayedPaths() const;
01141
01142
01143
01145 SbBool isRenderingTranspObjs() const;
01146
01147
01148
01150 const SoPathList &getDelayedPaths() const;
01151
01152
01153
01155 SbBool isRenderingTranspPaths() const;
01156
01157
01158
01159
01160
01161
01162
01163
01165 void updateTranspList(SoSensor* sensor, SbBool forceRebuilding=FALSE, SoNode *nodeKitToRemove = NULL);
01166
01167
01169 SoPathList& getTranspPathsList();
01170
01171 #endif
01173 private:
01174
01175 virtual void beginTraversal(SoNode *node);
01176
01177 virtual void endTraversal(SoNode *node);
01178
01179 SoGLRenderActionSync* m_synchronizer;
01180
01181 SoINTERNAL private:
01182 FastEditSavePolicy fastEditPolicy;
01183 TransparencyType transpType;
01184
01185 private:
01189 void removeInvalidPaths();
01190
01192 bool m_isDoingDepthPeeling;
01193
01194 SbBool m_hasDrawnTransparentObjs;
01195 SbBool m_isViewing;
01196 SoNode* m_appliedNode;
01197 SbBool m_isFirstApply;
01198 SbBool m_firstStereoPass;
01199 int m_lastStereoMode;
01200
01201 int m_useCacheOpt;
01202 int m_useCompactPaths;
01203
01204 SbViewportRegion vpRegion;
01205
01206 SbViewportRegion vpLogicalRegion;
01207 int logicalRegionIsSet;
01208
01209 SbVec2f updateOrigin;
01210 SbVec2f updateSize;
01211
01212
01213
01214 SoGLRenderAbortCB *abortCB;
01215 void *abortData;
01216
01217
01218 SbBool doSmooth;
01219 int numPasses;
01220 int curPass;
01221 SbBool passUpdate;
01222 SoGLRenderPassCB *passCB;
01223 void *passData;
01224
01225
01226 SbBool delayObjs;
01227 SbBool fastEditObjs;
01228
01229 SbBool m_shouldSortOpaquePaths ;
01230 SbBool m_shouldSortTranspPaths ;
01231 SbBool sortObjs;
01232
01233 SbBool remoteRendering;
01234
01235
01236 SoDecimationTypeElement::Type decType;
01237 float decPercent;
01238
01239
01240
01241
01242 enum flags {
01243 TRANSPARENCY_TYPE = 0x01,
01244 SMOOTHING = 0x02,
01245 ALPHA_TEST = 0x04,
01246 FASTEDIT_SAVE_POLICY = 0x08,
01247 SCENE_GRAPH = 0x10,
01248 ANTIALIASING = 0x20,
01249 ALL = 0x3F
01250 };
01251 uint32_t whatChanged;
01252
01253
01254 void enableBlending(SbBool enable);
01255
01256
01257 void enableSmoothing(SbBool enable);
01258
01259
01260 SbBool checkAbort();
01261
01262
01263
01264 int cullBits;
01265
01266
01267 SbBool m_isBackFaceCullingIgnored;
01268
01269 SbBool m_delayedObjDepthWrite;
01270
01271
01272 SbBool m_renderingFromOffscreen;
01273
01274 SbBool m_alphaTest;
01275
01276
01277 uint32_t m_frameCounter;
01278
01279
01280
01281 int m_sortedLayersNumPasses ;
01282
01283
01284 void renderSortedLayers(SoNode *node) ;
01285 void initDepthPeeling(SoNode *node);
01286
01287
01288 static void renderSortedLayersCB(void *userData, SoGLDepthPeeling *mgr) ;
01289
01290 SoGLDepthPeeling *m_glDepthPeeling ;
01291
01292 static void cameraPostCB( SoCamera *camera, SoGLRenderAction* renderAction );
01293 bool m_ignoreCameraPostCB;
01294
01295
01296
01297 InvalidateCacheMode m_invalidateAllCaches;
01298 RenderMode m_restrictObjectRendering;
01299
01300 static char s_separateSpecularMode;
01301
01302 bool m_floatingPointFramebuffer;
01303
01304
01305 SbBool m_fsaaEnable;
01306 int m_fsaaFilterMask;
01307
01311 bool m_synchronizeStillFrame;
01312
01313 SoGLRenderActionImpl* m_impl;
01314 };
01315
01316
01317
01318 inline SoGLRenderActionSync* SoGLRenderAction::getSynchronizer()
01319 {
01320 return m_synchronizer;
01321 }
01322
01323 inline SoGLRenderActionImpl* SoGLRenderAction::getImpl()
01324 {
01325 return m_impl;
01326 }
01327
01328 #ifdef _MSC_VER
01329 #pragma warning( pop )
01330 #endif
01331 #endif
01332
01333