Changeset 2340


Ignore:
Timestamp:
04/24/07 18:09:37 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/include/CausticTest.h

    r2319 r2340  
    3131float cauintens = 40; 
    3232 
     33class RaytraceDemoApplication; 
     34 
    3335// Listener class for frame updates 
    3436class RaytraceDemoListener : public ExampleFrameListener 
     
    4042        SceneNode* sphereNode; 
    4143        unsigned long framecount; 
     44        RaytraceDemoApplication* app; 
    4245         
    4346public: 
    44     RaytraceDemoListener(RenderWindow* window, Camera* maincam,SceneNode* lightNode, SceneNode* sphereNode, Light* l) 
     47    RaytraceDemoListener(RenderWindow* window, Camera* maincam,SceneNode* lightNode, SceneNode* sphereNode, Light* l, RaytraceDemoApplication* app) 
    4548        :ExampleFrameListener(window, maincam)  
    4649                                  
     
    5053                this->lightNode = lightNode; 
    5154                light = l; 
     55                this->app = app; 
    5256    } 
    5357        bool processUnbufferedKeyInput(const FrameEvent& evt) 
     
    120124                return ExampleFrameListener::processUnbufferedKeyInput(evt); 
    121125        } 
    122     bool frameStarted(const FrameEvent& evt) 
    123     { 
    124                 static bool first = true; 
    125          
    126  
    127         //      lightNode->setPosition( 100.0 * Vector3(cos(-(float)framecount/500.0),2.0,sin(-(float)framecount/500.0))); 
    128                  
    129                  
    130                 bool result = ExampleFrameListener::frameStarted(evt); 
    131        framecount++; 
    132  
    133            if (framecount == 60) 
    134                    OgreIlluminationManager::getSingleton().freeAllResources(); 
    135       return result;      
    136     } 
    137  
     126     
     127        bool frameStarted(const FrameEvent& evt); 
    138128         
    139129 
     
    145135 
    146136public: 
    147  
    148 protected: 
    149         SceneNode* mainLightNode; 
    150         SceneNode* sphereNode; 
    151          
    152         void chooseSceneManager() 
    153         { 
    154                 //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager"); 
    155                 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 
    156         } 
    157  
    158         void loadResources(void) 
    159         { 
    160                  
    161                 // Initialise, parse scripts etc 
    162                 ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap"); 
    163                 ResourceGroupManager::getSingleton().initialiseResourceGroup("General"); 
    164                 ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic"); 
    165                 ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc"); 
    166                 ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap"); 
    167                 ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic"); 
    168         } 
    169  
    170         void createPostproc() 
    171         {                
    172                 CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), 
    173                                                                                                                 "GTP/PostProc/Glow"); 
    174                 CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), 
    175                                                                                                                 "GTP/PostProc/Glow", true); 
    176  
    177                 CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), 
    178                                                                                                                 "GTP/PostProc/ToneMap"); 
    179                 CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), 
    180                                                                                                                 "GTP/PostProc/ToneMap", true);           
    181         } 
    182      
    183         Light* light; 
    184         void createScene(void) 
    185     { 
    186                 std::string occlusion_cfg("OcclusionCulling.cfg"); 
    187                 mSceneMgr->setWorldGeometry(occlusion_cfg); 
    188  
    189                 //createPostproc(); 
    190                 OgreIlluminationManager::getSingleton().setBlurShadowMap(true); 
    191                 OgreIlluminationManager::getSingleton().setUseLISPSM(false); 
    192  
    193                 OgreIlluminationManager::getSingleton().setMainCamera(mCamera); 
    194                 OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0)); 
    195                  
    196                 OgreIlluminationManager::getSingleton().setMaxJoinRadius(420);           
    197  
    198                 Root::getSingleton()._setCurrentSceneManager(mSceneMgr); 
    199  
    200                 mCamera->setPosition(0,100,240); 
    201                 mCamera->setFOVy(Radian(Degree(80))); 
    202                 //mCamera->setFarClipDistance(1000); 
    203                 // Set ambient light 
    204         mSceneMgr->setAmbientLight(ColourValue(1, 1, 1)); 
    205  
     137        void LoadRes() 
     138        { 
     139                loadResources(); 
     140        } 
     141        void setupScene() 
     142        { 
    206143                // Skybox 
    207144        mSceneMgr->setSkyBox(true, "Examples/EveningSkyBox"); 
     
    249186                //createPlane("ground", "TestPlane", Vector3(0,0,0), Vector2(500,500)); 
    250187                OgreIlluminationManager::getSingleton().initTechniques(); 
     188 
     189                OgreIlluminationManager::getSingleton().setPriority(2); 
     190        mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());               
     191        } 
     192 
     193protected: 
     194        SceneNode* mainLightNode; 
     195        SceneNode* sphereNode; 
     196         
     197        void chooseSceneManager() 
     198        { 
     199                //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager"); 
     200                mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 
     201        } 
     202 
     203        void loadResources(void) 
     204        { 
     205                 
     206                // Initialise, parse scripts etc 
     207                ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap"); 
     208                ResourceGroupManager::getSingleton().initialiseResourceGroup("General"); 
     209                ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic"); 
     210                ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc"); 
     211                ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap"); 
     212                ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic"); 
     213        } 
     214 
     215        void createPostproc() 
     216        {                
     217                CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), 
     218                                                                                                                "GTP/PostProc/Glow"); 
     219                CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), 
     220                                                                                                                "GTP/PostProc/Glow", true); 
     221 
     222                CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), 
     223                                                                                                                "GTP/PostProc/ToneMap"); 
     224                CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), 
     225                                                                                                                "GTP/PostProc/ToneMap", true);           
     226        } 
     227     
     228        Light* light; 
     229        void createScene(void) 
     230    { 
     231                std::string occlusion_cfg("OcclusionCulling.cfg"); 
     232                mSceneMgr->setWorldGeometry(occlusion_cfg); 
     233 
     234                //createPostproc(); 
     235                OgreIlluminationManager::getSingleton().setBlurShadowMap(true); 
     236                OgreIlluminationManager::getSingleton().setUseLISPSM(false); 
     237 
     238                OgreIlluminationManager::getSingleton().setMainCamera(mCamera); 
     239                OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0)); 
     240                 
     241                OgreIlluminationManager::getSingleton().setMaxJoinRadius(420);           
     242 
     243                Root::getSingleton()._setCurrentSceneManager(mSceneMgr); 
     244 
     245                mCamera->setPosition(0,100,240); 
     246                mCamera->setFOVy(Radian(Degree(80))); 
     247                //mCamera->setFarClipDistance(1000); 
     248                // Set ambient light 
     249        mSceneMgr->setAmbientLight(ColourValue(1, 1, 1)); 
     250 
     251                setupScene(); 
    251252         } 
     253 
     254         
    252255   void createPlane(Ogre::String _name, Ogre::String _material, Ogre::Vector3 _pos, Ogre::Vector2 _size, Ogre::Vector2 _subdivisions = Ogre::Vector2(1,1)) { 
    253256                 
     
    278281                                                                                        mainLightNode, 
    279282                                                                                        sphereNode, 
    280                                                                                         light 
     283                                                                                        light,  
     284                                                                                        this 
    281285                                                                                        ); 
    282286                mFrameListener->setPriority(1); 
    283                 OgreIlluminationManager::getSingleton().setPriority(2); 
    284         mRoot->addFrameListener(&OgreIlluminationManager::getSingleton()); 
    285287                mRoot->addFrameListener(mFrameListener); 
    286288         
     
    289291}; 
    290292 
     293 
     294 
     295 
     296 
     297 
  • GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/src/CausticTest.cpp

    r1450 r2340  
    3333#endif 
    3434 
     35bool RaytraceDemoListener::frameStarted(const FrameEvent& evt) 
     36    { 
     37                static bool first = true; 
     38         
    3539 
     40        //      lightNode->setPosition( 100.0 * Vector3(cos(-(float)framecount/500.0),2.0,sin(-(float)framecount/500.0))); 
     41                 
     42                 
     43                bool result = ExampleFrameListener::frameStarted(evt); 
     44       framecount++; 
     45 
     46           if (framecount == 60) 
     47           { 
     48                   OgreIlluminationManager::getSingleton().freeAllResources(); 
     49                   Root::getSingleton().removeFrameListener(&OgreIlluminationManager::getSingleton()); 
     50                   Root::getSingleton()._getCurrentSceneManager()->clearScene(); 
     51                   TextureManager::getSingleton().removeAll(); 
     52                   MeshManager::getSingleton().removeAll(); 
     53                   MaterialManager::getSingleton().removeAll(); 
     54           //} 
     55           //if (framecount == 120) 
     56           //{ 
     57                   app->LoadRes(); 
     58                   app->setupScene(); 
     59           } 
     60      return result;      
     61    } 
    3662 
    3763#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
     
    6187} 
    6288#endif 
     89 
     90 
     91 
Note: See TracChangeset for help on using the changeset viewer.