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 #ifndef _SO_DIRECTVIZ_MANAGER_
00026 #define _SO_DIRECTVIZ_MANAGER_
00027
00028 #include <SoVersion.h>
00029
00030
00031
00032
00033
00034 #ifdef _WIN32
00035 # if defined(_DEBUG)
00036 # define __DIRECTVIZDLL "DirectVizD.dll"
00037 # define __DIRECTVIZLIB "DirectVizD.lib"
00038 # else
00039 # define __DIRECTVIZDLL "DirectViz.dll"
00040 # define __DIRECTVIZLIB "DirectViz.lib"
00041 # endif
00042 # ifndef DirectViz_EXPORTS
00043 # ifndef OIV_DISABLE_AUTOLINK
00044 # pragma comment(lib,__DIRECTVIZLIB)
00045 # endif
00046 # endif
00047 #else
00048 # define __DIRECTVIZDLL "libDirectViz"
00049 #endif
00050
00051 #include <Inventor/SbLinear.h>
00052 #include <Inventor/SbString.h>
00053 #include <Inventor/actions/SoGLRenderAction.h>
00054 #include <Inventor/nodes/SoNode.h>
00055 #include <Inventor/fields/SoSFInt32.h>
00056 #include <Inventor/fields/SoMFInt32.h>
00057 #include <Inventor/fields/SoSFBool.h>
00058 #include <Inventor/fields/SoSFFloat.h>
00059 #include <Inventor/fields/SoSFFieldContainer.h>
00060 #include <Inventor/fields/SoMFBool.h>
00061 #include <Inventor/fields/SoSFEnum.h>
00062
00063 class SoSceneManager;
00064 class SoCamera;
00065 class SoNode;
00066 class SoFieldContainer;
00067 class SoFieldSensor;
00068 class SoSensor;
00069 class SoDirectVizShader;
00070 class SoDirectVizRenderAction;
00071 class SoDirectVizRenderManager;
00072 class SoDirectVizCacheManager;
00073 class SoDirectVizOpenRTManager;
00074 class SoDirectVizDialog;
00075 class SoDirectVizAction;
00076
00077 #include <Inventor/SoModule.h>
00078 SO_MODULE_HEADER( SoDirectViz, __DIRECTVIZDLL )
00079
00080
00081
00082
00083
00084
00085
00086
00088 class SoDEPRECATED SoDirectVizManager : public SoNode{
00138
00139 SO_NODE_HEADER(SoDirectVizManager);
00140
00141 public:
00142
00146 ~SoDirectVizManager();
00147
00151 enum CacheMode
00152 {
00154 READ_WRITE_MODE,
00156 READ_MODE,
00158 WRITE_MODE
00159 };
00160
00164 enum EnvLights
00165 {
00167 ENV_LIGHTS_0,
00169 ENV_LIGHTS_2,
00171 ENV_LIGHTS_4,
00173 ENV_LIGHTS_8,
00175 ENV_LIGHTS_16,
00177 ENV_LIGHTS_32,
00179 ENV_LIGHTS_64,
00181 ENV_LIGHTS_128,
00183 ENV_LIGHTS_256
00184 };
00185
00200 SoSFBool accumulation;
00201
00209 SoSFInt32 maxAccumulationValue;
00210
00222 SoSFBool subSampling;
00223
00230 SoSFFloat subSamplingFactor;
00231
00243 SoSFInt32 recursionLimit;
00244
00255 SoSFBool subRecursion;
00256
00267 SoSFBool progressiveRendering;
00268
00277 SoSFInt32 numProgressiveRenderingSteps;
00278
00284 SoSFBool rendering;
00285
00294 SoSFBool globalShadowing;
00295
00305 SoSFBool adaptiveOversampling;
00306
00315 SoSFBool softShadows;
00316
00325 SoSFBool fuzzyLights;
00326
00335 SoSFBool glossySurfaces;
00336
00351 SoSFEnum numEnvLights;
00352
00361 SoSFFloat envLightIntensityScale;
00362
00384 SoSFBool fileCaching;
00385
00396 SoSFBool controlDialog;
00397
00405 static void init();
00406
00417 static void finish();
00418
00423 static bool isInitialized();
00424
00436 static SoDirectVizManager *getInstance(SoSceneManager *mgr);
00437
00441 int getCurrentAccumValue() const;
00442
00446 void getRenderedImageSize(SbVec2s &size) const;
00447
00451 double getLastRenderTime() const;
00452
00458 void setCacheDirectory(SbString directory);
00459
00467 void setCacheFile(SbString file,CacheMode mode = READ_WRITE_MODE);
00468
00472 int getNumEnvironmentLights();
00473
00481 void setCamera(SoCamera *camera);
00482
00483
00484 private:
00485
00489 typedef enum{
00490 FORCE_RENDER = 0,
00491 CHECK_STILL_TIME,
00492 GENERATING,
00493 SIZE_CHANGED,
00494 STILL,
00495 ASK_REDRAW,
00496 FORCE_REDRAW,
00497 CLEAR_ACCUM_BUFFER,
00498 FIRST_RENDER,
00499 SUBSAMPLED,
00500 FORCE_CAMERA_SETUP,
00501 FORCE_ACCUMULATION,
00502 DISABLE_SUBSAMPLING_CHECK,
00503 PRIVATE_BOOL_STATES
00504 } privateBoolStates;
00505
00509 typedef enum{
00510 CURRENT_ACCUM_VALUE = 0,
00511 CURRENT_PROGRESSIVE_RENDER,
00512 PRIVATE_INT_STATES
00513 } privateIntStates;
00514
00515 private:
00516
00520 SoDirectVizManager();
00521
00522
00523 void stopFrame();
00524
00529 void setManageRenderingProperties( bool manage );
00530
00534 bool manageRenderingProperties();
00535
00539 void forceCameraSetup();
00540
00546 void setAccuId( unsigned int accuId );
00547
00551 void forceAccumulation( bool forceAccum );
00552
00556 void disableSubSamplingCheck( bool disableCheck );
00557
00558
00559 int getEnvLightsEnumValue( int numLights );
00560
00561
00562 int getNumEnvironmentLights( int enumValue );
00563
00564 static SoDirectVizManager * getInstance();
00565
00569 typedef enum{
00570 ACTIVE=0,
00571 BUILT
00572 } DirectVizObjectState;
00573
00577 typedef enum{
00578 SEPARATOR=0,
00579 SHADER,
00580 ENVIRONMENT,
00581 TEXTURE,
00582 LIGHT,
00583 SHAPE,
00584 CAMERA,
00585 NUMVECTORS,
00586 OBJECT
00587 } DirectVizObjectType;
00588
00589 static void initClass();
00590
00591 static void exitClass();
00592
00593 static void setViewer(void *viewer){_viewer = viewer;}
00594
00595 static void *getViewer(){return _viewer;}
00596
00600 int getNumRTObjects(DirectVizObjectType t,DirectVizObjectState s) const;
00601
00605 int getNumRTObjects(DirectVizObjectType t) const;
00606
00610 void setRecursionLimit(int limit,SbBool forceRedraw = true);
00611
00615 static SoDirectVizManager *instance();
00616
00620 SoDirectVizCacheManager *getCacheMgr();
00621
00625 SoDirectVizOpenRTManager *getOpenRTMgr(){
00626 return _openRTMgr;
00627 }
00628
00632 void generatePixMap();
00633
00634 void internalEnable(SbBool enable);
00635
00639 void render(bool forceRender = true);
00640
00644 void checkCache(bool startTraversal);
00645
00649 SoSceneManager *getSceneManager() const;
00650
00654 void setSceneManager(SoSceneManager *sceneManager);
00655
00659 void setSceneRoot(SoNode *sceneRoot);
00660
00664 unsigned int getShaderClass(SoNode *node);
00665
00669 unsigned int getShaderClass(SoDirectVizShader *shader);
00670
00674 int getShaderClassType(SoNode *node);
00675
00679 void setSceneGraph(SoNode *node);
00680
00681 void setMsg(SbString msg);
00682
00683 void setDialog(SoDirectVizDialog *dialog){_dialog = dialog;}
00684
00688 SoDirectVizRenderManager *_renderMgr;
00689
00693 static SoDirectVizManager *_directVizManager;
00694
00698 SoDirectVizDialog *_dialog;
00699
00700 SbBool getInitialisationState(){return _openRTInitialized;}
00701
00705 void setQuality(int quality);
00706
00710 bool initRendering();
00711
00715 void redraw();
00716
00720 void internalRedraw(SbBool fromOffscreen = FALSE);
00721
00725 void initialize();
00726
00730 void readConfigFile();
00731
00735 void clear();
00736
00740 SoDirectVizRenderAction *getRenderAction() const;
00741
00745 SoDirectVizAction *_directVizAction;
00746
00750 SoNode *getSceneGraph() const;
00751
00755 SbVec2s _size,_lastSize;
00756
00760 void storeRenderingState();
00761
00765 void restoreRenderingState();
00766
00767 private:
00768
00769
00770 bool m_storedBoolRenderingState[PRIVATE_BOOL_STATES];
00771
00772
00773 int m_storedIntRenderingState[PRIVATE_INT_STATES];
00774
00775
00776 SbVec2s m_storedSize;
00777
00783 bool m_manageRenderingProperties;
00784
00785 private :
00786
00787 static int s_initRefCount;
00788
00789 static const char *s_versionString;
00790
00794 void notify(SoNotList *list);
00795
00796
00800 void setupCamera();
00801
00805 SoSFFieldContainer m_sceneManager;
00806
00810 SoSFFieldContainer m_sceneGraph;
00811
00815 SoGLRenderAction *_oldAction;
00816
00820 SoSceneManager *_sceneManager;
00821
00825 SoSFFieldContainer m_camera;
00826 SoCamera * getCamera() const;
00827
00831 SoDirectVizRenderAction *_renderAction;
00832
00836 SoCamera *_camera;
00837
00841 int _oldLimit;
00842
00846 SoMFBool _privateBoolState;
00847
00851 SoMFInt32 _privateIntState;
00852
00856 SbBool m_clusterMode;
00857
00858 static SbBool _openRTInitialized;
00859
00863 double _lastRenderTime;
00864
00868 SoDirectVizCacheManager *_cacheMgr;
00869
00873 SoDirectVizOpenRTManager *_openRTMgr;
00874
00875 static void *_viewer;
00876
00877 friend class SoDirectVizCacheManager;
00878 friend class SoDirectVizRenderAction;
00879 friend class SoDirectVizRenderManager;
00880
00882 static bool isGuiBase(const SoFieldContainer *fc);
00883 };
00884
00885 class SoGuiBase;
00886 class SoSceneManager;
00887 class SoCamera;
00888
00889 extern "C" {
00890 void directviz_init();
00891 void directviz_finish();
00892 bool directviz_check();
00893 int32_t directviz_getShortcutValue();
00894 bool directviz_isLoadedGui( bool );
00895 void* directviz_getViewer();
00896 void directviz_setViewer(void*);
00897 void directviz_showDialog( bool, SoNode*, SoGuiBase* );
00898 void directviz_hideDialog( bool );
00899 void directviz_deleteDialog();
00900 SoNode* directviz_getInstance( SoSceneManager* );
00901 void directviz_internalEnable( SbBool, SoSceneManager*, SoCamera*, SoNode*, SoGuiBase*);
00902 void directviz_setCamera( SoSceneManager*, SoCamera*, SoNode* );
00903 };
00904
00905 #endif
00906
00907