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
00257 SORTED_OBJECT_ADD,
00258
00264 SORTED_OBJECT_BLEND,
00265 SoDEPRECATED
00270 SORTED_LAYERS_BLEND,
00271
00322 SORTED_PIXELS_BLEND = SORTED_LAYERS_BLEND,
00323 SoDEPRECATED
00328 DELAYED_SORTED_LAYERS_BLEND,
00329
00334 DELAYED_SORTED_PIXELS_BLEND = DELAYED_SORTED_LAYERS_BLEND,
00335
00341 SORTED_TRIANGLES_ADD,
00342
00346 SORTED_TRIANGLES_BLEND,
00347
00353 SORTED_OBJECT_TRIANGLES_ADD,
00354
00358 SORTED_OBJECT_TRIANGLES_BLEND,
00359
00363 NO_TRANSPARENCY
00364
00365 };
00366
00388 enum FastEditSavePolicy {
00395 DISABLE,
00396
00413 EACH_FRAME,
00414
00428 WHEN_NEEDED
00429 };
00430
00432 enum AbortCode {
00436 CONTINUE,
00437
00441 ABORT,
00442
00446 PRUNE,
00447
00451 DELAY
00452 };
00453
00459 typedef AbortCode SoGLRenderAbortCB(void *userData);
00460
00462 enum InvalidateCacheMode {
00466 OFF,
00467
00473 ONCE,
00474
00479 ALWAYS
00480 };
00481
00486 SoGLRenderAction(const SbViewportRegion &viewportRegion);
00487
00488 #ifndef HIDDEN_FROM_DOC
00489
00490 virtual ~SoGLRenderAction();
00491 #endif // HIDDEN_FROM_DOC
00492
00496 void setViewportRegion(const SbViewportRegion &newRegion);
00497
00501 const SbViewportRegion &getViewportRegion() const { return vpRegion; }
00502
00507 void setLogicalViewportRegion(const SbViewportRegion &newLogicalRegion);
00508
00512 const SbViewportRegion &getLogicalViewportRegion() const { return vpLogicalRegion; }
00513
00522 void setUpdateArea(const SbVec2f &origin, const SbVec2f &size);
00523
00527 void getUpdateArea(SbVec2f &origin, SbVec2f &size) const;
00528
00537 void setAbortCallback(SoGLRenderAbortCB *func, void *userData)
00538 { abortCB = func; abortData = userData; }
00539
00581 void setTransparencyType(TransparencyType type);
00582
00587 TransparencyType getTransparencyType() const { return transpType; }
00588
00604 void setFastEditSavePolicy(FastEditSavePolicy policy, SbBool fastEditDelayedObjects = FALSE);
00605
00609 FastEditSavePolicy getFastEditSavePolicy() const { return fastEditPolicy; }
00610
00611
00622 void setSmoothing(SbBool smooth);
00623
00627 SbBool isSmoothing() const { return doSmooth; }
00628
00644 void setNumPasses(int num);
00645
00649 int getNumPasses() const { return numPasses; }
00650
00655 void setPassUpdate(SbBool flag) { passUpdate = flag; }
00656
00664 SbBool isPassUpdate() const { return passUpdate; }
00665
00671 void setPassCallback(SoGLRenderPassCB *func, void *userData)
00672 { passCB = func; passData = userData; }
00673
00682 void setCacheContext(uint32_t context);
00683
00687 uint32_t getCacheContext() const;
00688
00693 static uint32_t generateCacheContext();
00694
00698 static bool isUsedCacheContext( uint32_t context );
00699
00726 void setSortedLayersNumPasses(int num)
00727 { m_sortedLayersNumPasses = num; }
00728
00729
00735 int getSortedLayersNumPasses() const
00736 { return m_sortedLayersNumPasses ; }
00737
00743 static SbBool isSortedLayersSupported(SoState* state=NULL) ;
00744
00761 void setAlphaTest( SbBool flag );
00762
00766 SbBool isAlphaTest() const
00767 { return m_alphaTest; }
00768
00769
00778 void setRenderingIsRemote(SbBool flag);
00783 SbBool getRenderingIsRemote() const;
00784
00788 virtual void invalidateState();
00789
00795 void setDecimationValue(SoDecimationTypeElement::Type type,
00796 float percentage = 1.0);
00797
00801 SoDecimationTypeElement::Type getDecimationType() { return decType; };
00802
00807 float getDecimationPercentage() { return decPercent; };
00808
00842 void setSortedTrianglesSortFrequency(int angle);
00843
00848 int getSortedTrianglesSortFrequency();
00849
00862 void setSortedTrianglesNumCaches(int numCaches);
00863
00867 int getSortedTrianglesNumCaches();
00868
00884 void setInvalidateCacheMode(InvalidateCacheMode icm);
00885
00889 InvalidateCacheMode getInvalidateCacheMode();
00890
00898 uint32_t getFrameCounter() const { return m_frameCounter; }
00899
00904 void resetFrameCounter( uint32_t count = 0 ) { m_frameCounter = count; }
00905
00914 enum AutoCacheMode
00915 {
00916 DO_AUTO_CACHE = 1,
00917 DONT_AUTO_CACHE = 2
00918 };
00919
00925 void shouldAutoCache( AutoCacheMode mode );
00926
00927 private:
00929 inline bool isDoingDepthPeeling() const { return m_isDoingDepthPeeling; }
00930
00934 int getDepthPeelingPass();
00935
00940 void enableDepthPeeling3D(bool flag) const;
00941
00942 SoGLDepthPeeling* getDepthPeelingInterface() const;
00943
00944 SoAccumulatedTextPolygon* getAccumulatedTextPolygon();
00945 SoAccumulatedTextTextured* getAccumulatedTextTextured();
00946
00947
00948 int getCurPass() const { return curPass; }
00949
00950
00951 SbBool abortNow()
00952 { return (hasTerminated() || (abortCB != NULL && checkAbort())); }
00953
00954
00955
00956
00957
00958
00959
00960
00961 virtual SbBool handleTransparency(SbBool isTransparent = FALSE, SbBool isLinesOrPoints = FALSE);
00962
00964 virtual void setUpState();
00965
00970 void setDelayedObjDepthWrite( SbBool flag ) { m_delayedObjDepthWrite = flag; }
00971
00976 SbBool getDelayedObjDepthWrite() const { return m_delayedObjDepthWrite; }
00977
00984 virtual bool preDelayedTraversal();
00985
00992 virtual void postDelayedTraversal();
00993
00994 private:
00995 static void initClass();
00996 static void exitClass();
00997
00998 virtual void apply(SoNode* node);
00999 virtual void apply(SoPath* path) { SoAction::apply(path); }
01000 virtual void apply(const SoPathList &pathList, SbBool obeysRules = FALSE) { SoAction::apply(pathList, obeysRules); }
01001
01003 inline bool isFloatingPointFramebuffer() const { return m_floatingPointFramebuffer; }
01004 inline void setFloatingPointFramebuffer(bool flag) { m_floatingPointFramebuffer = flag; }
01005
01006
01007 SbBool isDelaying() const { return delayObjs; }
01008
01009
01010 void removeAllDelayedPath();
01011
01012 bool isTraversalPassTransparent() const;
01013 bool isTraversalPassTransparentSortedTriangles() const;
01014
01015 bool handleFastEdit(SoSeparator* sep);
01016
01017 int getCullTestResults() { return cullBits; }
01018 void setCullTestResults(int b) { cullBits = b; }
01019
01020
01021 void setBackFaceCullingIgnored(SbBool flag) { m_isBackFaceCullingIgnored = flag; }
01022 SbBool isBackFaceCullingIgnored() const { return m_isBackFaceCullingIgnored; }
01023
01024 SbBool isLogicalRegionSet() const;
01025
01026
01027
01028 void setDoubleBuffer(SbBool db);
01029
01030 void setForceRender();
01031
01032 void setViewing(SbBool viewing);
01033
01034 SbBool hasDelayedNodesToRender() const;
01035
01036 void setFirstStereoPass(SbBool first);
01037
01038 SoPathList transpPaths;
01039
01040 void setRenderingFromOffscreen(SbBool renderFromOffscreen)
01041 { m_renderingFromOffscreen = renderFromOffscreen; }
01042
01043 SbBool getRenderingFromOffscreen() const
01044 { return m_renderingFromOffscreen; }
01045
01046
01047
01048 SbBool hasDrawnTransparentObjs() const
01049 { return m_hasDrawnTransparentObjs; }
01050
01051
01052 void setFullSceneAntialiasingElement( SbBool enable, int filterMask );
01053
01055 enum RenderMode {
01059 ALL_OBJECTS,
01063 OPAQUE_OBJECTS,
01067 DELAYED_OBJECTS
01068 };
01069
01070
01071
01072
01073
01074 void setRestrictObjectRenderingMode( const RenderMode mode = ALL_OBJECTS )
01075 { m_restrictObjectRendering = mode; };
01076
01077 int getRestrictObjectRenderingMode() const
01078 { return m_restrictObjectRendering; };
01079
01080 SoGLRenderActionSync* getSynchronizer();
01081 void setSynchronizer( SoGLRenderActionSync* );
01082
01083 virtual void updateParametersFrom( SoGLRenderAction* );
01084 SoGLRenderPassCB* getPassCallback( void*& data )
01085 {
01086 data = passData;
01087 return passCB;
01088 }
01089
01090 SoGLRenderActionImpl* getImpl();
01091
01092
01093
01094 SoGLDepthPeeling* setDepthPeelingInterface(SoGLDepthPeeling*);
01095
01096 bool isFastEditManipulating();
01097
01098 SoPathList delayedPaths;
01099
01100 #if 1
01102 // Adds to the list of paths to render after all other stuff
01103
01104
01105
01107 void addDelayedPath(SoPath *path);
01108
01109
01110
01111
01113 void removeDelayedTranspPath(SoNode *node) ;
01114
01115
01116
01117
01119 void addOpaqueDelayedPath(SoPath *path);
01120
01121
01122
01123
01125 void removeOpaqueDelayedPath(SoPath *path);
01126
01127
01128
01130 void removePathFromAllPass(SoPath *path);
01131
01132
01133
01135 bool isRenderingDelayed() const;
01136
01137
01138
01140 SbBool isRenderingDelayedPaths() const;
01141
01142
01143
01145 SbBool isRenderingOpaqueDelayedPaths() const;
01146
01147
01148
01150 SbBool isRenderingTranspObjs() const;
01151
01152
01153
01155 const SoPathList &getDelayedPaths() const;
01156
01157
01158
01160 SbBool isRenderingTranspPaths() const;
01161
01162
01163
01164
01165
01166
01167
01168
01170 void updateTranspList(SoSensor* sensor, SbBool forceRebuilding=FALSE, SoNode *nodeKitToRemove = NULL);
01171
01172
01174 SoPathList& getTranspPathsList();
01175
01176 #endif
01178 private:
01179
01180 virtual void beginTraversal(SoNode *node);
01181
01182 virtual void endTraversal(SoNode *node);
01183
01184 SoGLRenderActionSync* m_synchronizer;
01185
01186 SoINTERNAL private:
01187 FastEditSavePolicy fastEditPolicy;
01188 TransparencyType transpType;
01189
01190 private:
01194 void removeInvalidPaths();
01195
01197 bool m_isDoingDepthPeeling;
01198
01199 SbBool m_hasDrawnTransparentObjs;
01200 SbBool m_isViewing;
01201 SoNode* m_appliedNode;
01202 SbBool m_isFirstApply;
01203 SbBool m_firstStereoPass;
01204 int m_lastStereoMode;
01205
01206 int m_useCacheOpt;
01207 int m_useCompactPaths;
01208
01209 SbViewportRegion vpRegion;
01210
01211 SbViewportRegion vpLogicalRegion;
01212 int logicalRegionIsSet;
01213
01214 SbVec2f updateOrigin;
01215 SbVec2f updateSize;
01216
01217
01218
01219 SoGLRenderAbortCB *abortCB;
01220 void *abortData;
01221
01222
01223 SbBool doSmooth;
01224 int numPasses;
01225 int curPass;
01226 SbBool passUpdate;
01227 SoGLRenderPassCB *passCB;
01228 void *passData;
01229
01230
01231 SbBool delayObjs;
01232 SbBool fastEditObjs;
01233
01234 SbBool m_shouldSortOpaquePaths ;
01235 SbBool m_shouldSortTranspPaths ;
01236 SbBool sortObjs;
01237
01238 SbBool remoteRendering;
01239
01240
01241 SoDecimationTypeElement::Type decType;
01242 float decPercent;
01243
01244
01245
01246
01247 enum flags {
01248 TRANSPARENCY_TYPE = 0x01,
01249 SMOOTHING = 0x02,
01250 ALPHA_TEST = 0x04,
01251 FASTEDIT_SAVE_POLICY = 0x08,
01252 SCENE_GRAPH = 0x10,
01253 ANTIALIASING = 0x20,
01254 ALL = 0x3F
01255 };
01256 uint32_t whatChanged;
01257
01258
01259 void enableBlending(SbBool enable);
01260
01261
01262 void enableSmoothing(SbBool enable);
01263
01264
01265 SbBool checkAbort();
01266
01267
01268
01269 int cullBits;
01270
01271
01272 SbBool m_isBackFaceCullingIgnored;
01273
01274 SbBool m_delayedObjDepthWrite;
01275
01276
01277 SbBool m_renderingFromOffscreen;
01278
01279 SbBool m_alphaTest;
01280
01281
01282 uint32_t m_frameCounter;
01283
01284
01285
01286 int m_sortedLayersNumPasses ;
01287
01288
01289 void renderSortedLayers(SoNode *node) ;
01290 void initDepthPeeling(SoNode *node);
01291
01292
01293 static void renderSortedLayersCB(void *userData, SoGLDepthPeeling *mgr) ;
01294
01295 SoGLDepthPeeling *m_glDepthPeeling ;
01296
01297 static void cameraPostCB( SoCamera *camera, SoGLRenderAction* renderAction );
01298 bool m_ignoreCameraPostCB;
01299
01300
01301
01302 InvalidateCacheMode m_invalidateAllCaches;
01303 RenderMode m_restrictObjectRendering;
01304
01305 static char s_separateSpecularMode;
01306
01307 bool m_floatingPointFramebuffer;
01308
01309
01310 SbBool m_fsaaEnable;
01311 int m_fsaaFilterMask;
01312
01316 bool m_synchronizeStillFrame;
01317
01318 SoGLRenderActionImpl* m_impl;
01319 };
01320
01321
01322
01323 inline SoGLRenderActionSync* SoGLRenderAction::getSynchronizer()
01324 {
01325 return m_synchronizer;
01326 }
01327
01328 inline SoGLRenderActionImpl* SoGLRenderAction::getImpl()
01329 {
01330 return m_impl;
01331 }
01332
01333 #ifdef _MSC_VER
01334 #pragma warning( pop )
01335 #endif
01336 #endif
01337
01338