Changeset 29
- Timestamp:
- 03/24/05 12:15:20 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCulling.vcproj
r23 r29 41 41 ProgramDatabaseFile="$(OutDir)/TestCulling.pdb" 42 42 SubSystem="2" 43 ImportLibrary="" 43 44 TargetMachine="1"/> 44 45 <Tool -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
r28 r29 6 6 */ 7 7 8 #pragma warning (push)9 #pragma warning( disable : 4267 )8 //#pragma warning (push) 9 //#pragma warning( disable : 4267 ) 10 10 11 11 #include <OgreNoMemoryMacros.h> … … 15 15 #include <../CEGUIRenderer/include/OgreCEGUITexture.h> 16 16 #include <OgreMemoryMacros.h> 17 #pragma warning (pop)17 //#pragma warning (pop) 18 18 /* 19 19 #include <CEGUI/CEGUIImageset.h> … … 39 39 #include "windows.h" 40 40 41 /***********************************************/ 42 /* TestCullingApplication implementation */ 43 /***********************************************/ 44 45 46 //----------------------------------------------------------------------- 41 47 void TestCullingApplication::createScene(void) 42 48 { … … 67 73 mGUISystem->setGUISheet(sheet);*/ 68 74 } 69 70 71 /* MouseMotionListener callbacks */ 75 //----------------------------------------------------------------------- 76 void TestCullingApplication::createFrameListener(void) 77 { 78 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer, mShipNode); 79 mFrameListener->showDebugOverlay(true); 80 mRoot->addFrameListener(mFrameListener); 81 } 82 //----------------------------------------------------------------------- 83 void TestCullingApplication::chooseSceneManager(void) 84 { 85 mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 86 } 87 88 /***********************************************/ 89 /* MouseQueryListener implementation */ 90 /***********************************************/ 91 92 //----------------------------------------------------------------------- 93 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, 94 SceneNode* shipNode) 95 : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode)//, mShutdownRequested(false) 96 { 97 98 // Setup default variables 99 mCurrentObject = NULL; 100 mLMouseDown = false; 101 mRMouseDown = false; 102 mSceneMgr = sceneManager; 103 104 // Reduce move speed 105 mMoveSpeed = 50; 106 mRotateSpeed *= 2; 107 108 mCurrentAlgorithm = OcclusionCullingSceneManager::RENDER_COHERENT; 109 110 // Register this so that we get mouse events. 111 mEventProcessor->addMouseListener(this); 112 mEventProcessor->addMouseMotionListener(this); 113 mEventProcessor->addKeyListener(this); 114 115 // show overlay 116 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionDemoOverlay"); 117 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/OcclusionTechniqueInfo"); 118 //mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo"); 119 //mInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/Info"); 120 121 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 122 //mMaterialInfo->setCaption(": " + mAtheneMaterials[mCurrentAtheneMaterial]); 123 pOver->show(); 124 } // MouseQueryListener 125 //----------------------------------------------------------------------- 72 126 void MouseQueryListener::mouseMoved (MouseEvent *e) 73 127 { … … 75 129 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 76 130 } 77 78 131 //----------------------------------------------------------------------- 79 132 void MouseQueryListener::mousePressed(MouseEvent* e) 80 133 { … … 93 146 } // mousePressed 94 147 95 148 //----------------------------------------------------------------------- 96 149 void MouseQueryListener::mouseReleased(MouseEvent* e) 97 150 { … … 109 162 } // else if 110 163 } // mouseReleased 111 112 113 // This is when the mouse is clicked, held and dragged. 164 //----------------------------------------------------------------------- 114 165 void MouseQueryListener::mouseDragged (MouseEvent *e) 115 166 { … … 127 178 } // else if 128 179 } // mouseDragged 129 180 //----------------------------------------------------------------------- 181 bool MouseQueryListener::frameEnded(const FrameEvent& evt) 182 { 183 if (timeDelay >= 0) 184 timeDelay -= evt.timeSinceLastFrame; 185 186 KEY_PRESSED(KC_O, 1, changeAlgorithm()); 187 188 return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt); 189 } 190 //----------------------------------------------------------------------- 191 void MouseQueryListener::changeAlgorithm() 192 { 193 mCurrentAlgorithm = ++mCurrentAlgorithm % OcclusionCullingSceneManager::NUM_RENDERMODES; 194 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 195 196 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 197 } 130 198 131 199 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
r28 r29 17 17 } 18 18 19 String m AlgorithmTypeCaptions[OcclusionCullingSceneManager::NUM_RENDERMODES] =19 String mCurrentAlgorithmCaptions[OcclusionCullingSceneManager::NUM_RENDERMODES] = 20 20 { 21 21 "Cull Frustum", … … 29 29 30 30 MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, 31 SceneNode* shipNode) 32 : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode)//, mShutdownRequested(false) 33 { 31 SceneNode* shipNode); 34 32 35 // Setup default variables36 mCurrentObject = NULL;37 mLMouseDown = false;38 mRMouseDown = false;39 mSceneMgr = sceneManager;40 41 // Reduce move speed42 mMoveSpeed = 50;43 mRotateSpeed *= 2;44 45 mAlgorithmType = OcclusionCullingSceneManager::RENDER_COHERENT;46 47 // Register this so that we get mouse events.48 mEventProcessor->addMouseListener(this);49 mEventProcessor->addMouseMotionListener(this);50 mEventProcessor->addKeyListener(this);51 52 // show overlay53 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/ShadowsOverlay");54 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/ShadowTechniqueInfo");55 //mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo");56 //mInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/Info");57 58 mAlgorithmInfo->setCaption("Algorithm: " + mAlgorithmTypeCaptions[mAlgorithmType]);59 //mMaterialInfo->setCaption("Current: " + mAtheneMaterials[mCurrentAtheneMaterial]);60 pOver->show();61 } // MouseQueryListener62 33 63 34 ~MouseQueryListener( ) … … 65 36 } 66 37 67 bool frameEnded(const FrameEvent& evt) 68 { 69 if (timeDelay >= 0) 70 timeDelay -= evt.timeSinceLastFrame; 71 72 KEY_PRESSED(KC_O, 1, changeAlgorithm()); 73 74 return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt); 75 } 76 38 bool frameEnded(const FrameEvent& evt); 77 39 /* MouseListener callbacks. */ 78 40 virtual void mouseClicked(MouseEvent* e) { } … … 125 87 } 126 88 */ 127 void changeAlgorithm() 128 { 129 mAlgorithmType = ++mAlgorithmType % OcclusionCullingSceneManager::NUM_RENDERMODES; 130 mAlgorithmInfo->setCaption("Algorithm: " + mAlgorithmTypeCaptions[mAlgorithmType]); 131 } 89 void changeAlgorithm(); 132 90 133 91 … … 139 97 SceneNode* mShipNode; 140 98 // bool mShutdownRequested; 141 int m AlgorithmType;99 int mCurrentAlgorithm; 142 100 OverlayElement *mAlgorithmInfo; 143 101 }; … … 154 112 protected: 155 113 void createScene(void); 156 157 void createFrameListener(void) 158 { 159 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer, mShipNode); 160 mFrameListener->showDebugOverlay(true); 161 mRoot->addFrameListener(mFrameListener); 162 } 114 void createFrameListener(void); 163 115 164 116 CEGUI::OgreCEGUIRenderer *mGUIRenderer; … … 166 118 167 119 private: 120 void chooseSceneManager(void); 121 168 122 Entity* mShip; 169 123 SceneNode* mShipNode; … … 189 143 }*/ 190 144 // Override scene manager (use indoor instead of generic) 191 void chooseSceneManager(void) 192 { 193 mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 194 } 145 146 195 147 196 148 }; -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
r28 r29 53 53 void _updateSceneGraph(Camera* cam); 54 54 55 /** Sets the given option for the SceneManager 56 @remarks 57 Options are: 58 "Algorithm", int *; 59 */ 60 virtual bool setOption( const String &, const void * ); 61 /** Gets the given option for the Scene Manager. 62 @remarks 63 See setOption 64 */ 65 virtual bool getOption( const String &, void * ); 66 67 bool getOptionValues( const String & key, StringVector &refValueList ); 68 bool getOptionKeys( StringVector &refKeys ); 69 55 70 protected: 56 71 enum {MODE_QUERY, MODE_RENDER}; … … 85 100 */ 86 101 SolidHalfBoundingBox *getSolidHalfBoundingBox(int half); 87 /** sets the type of the algorithm 88 @param algorithm type 89 */ 90 void setAlgorithmType(int type); 91 92 int getAlgorithmType(); 102 93 103 94 104 // we use a priority queue rather than a renderstack … … 104 114 // two halfes of a aabb 105 115 SolidHalfBoundingBox *mHalfBoundingBox[2]; 106 int m AlgorithmType;116 int mCurrentAlgorithm; 107 117 }; 108 118 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
r28 r29 15 15 OcclusionCullingSceneManager::OcclusionCullingSceneManager(): 16 16 mFrameId(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0), 17 mQueryMode(MODE_RENDER), mNumSceneNodes(0), m AlgorithmType(RENDER_COHERENT)17 mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT) 18 18 { 19 19 mHalfBoundingBox[0] = mHalfBoundingBox[1] = 0; … … 44 44 //renderZPass(); 45 45 46 switch(m AlgorithmType)46 switch(mCurrentAlgorithm) 47 47 { 48 48 case RENDER_CULL_FRUSTUM: … … 346 346 } 347 347 //----------------------------------------------------------------------- 348 void OcclusionCullingSceneManager::setAlgorithmType(int type) 349 { 350 mAlgorithmType = type; 351 } 352 //----------------------------------------------------------------------- 353 int OcclusionCullingSceneManager::getAlgorithmType() 354 { 355 return mAlgorithmType; 348 bool OcclusionCullingSceneManager::setOption( const String & key, const void * val ) 349 { 350 if ( key == "Algorithm" ) 351 { 352 mCurrentAlgorithm = * static_cast < const int * > ( val ); 353 return true; 354 } 355 356 return SceneManager::setOption( key, val ); 357 } 358 //----------------------------------------------------------------------- 359 bool OcclusionCullingSceneManager::getOption( const String & key, void *val ) 360 { 361 if ( key == "Algorithm" ) 362 { 363 * static_cast < int * > ( val ) = mCurrentAlgorithm; 364 return true; 365 } 366 367 return SceneManager::getOption( key, val ); 368 } 369 //----------------------------------------------------------------------- 370 bool OcclusionCullingSceneManager::getOptionValues( const String & key, StringVector &refValueList ) 371 { 372 return SceneManager::getOptionValues( key, refValueList ); 373 } 374 //----------------------------------------------------------------------- 375 bool OcclusionCullingSceneManager::getOptionKeys( StringVector & refKeys ) 376 { 377 SceneManager::getOptionKeys( refKeys ); 378 refKeys.push_back( "Algorithm" ); 379 380 return true; 356 381 } 357 382 }
Note: See TracChangeset
for help on using the changeset viewer.