Changeset 85 for trunk/VUT/work/TestCulling
- Timestamp:
- 05/04/05 17:58:13 (19 years ago)
- Location:
- trunk/VUT/work/TestCulling
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCulling/SceneContentGenerator.cpp
r82 r85 101 101 mMaxPos = maxPos; 102 102 } 103 103 //----------------------------------------------------------------------- 104 int SceneContentGenerator::GetObjectCount() 105 { 106 return mCount; 107 } 104 108 } // namespace Ogre -
trunk/VUT/work/TestCulling/SceneContentGenerator.h
r82 r85 34 34 void SetMinPos(Vector3 minPos); 35 35 void SetMaxPos(Vector3 maxPos); 36 36 int GetObjectCount(); 37 37 38 protected: 38 39 -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r84 r85 39 39 }*/ 40 40 //----------------------------------------------------------------------- 41 TestCullingApplication::~TestCullingApplication() 42 { 43 delete mSceneContentGenerator; 44 } 45 //----------------------------------------------------------------------- 41 46 void TestCullingApplication::createScene(void) 42 47 { … … 48 53 //l->setPosition(20,80,50); 49 54 50 SceneContentGenerator contentGenerator(mSceneMgr);51 contentGenerator.GenerateScene(330, "robot.mesh");55 mSceneContentGenerator = new SceneContentGenerator(mSceneMgr); 56 mSceneContentGenerator->GenerateScene(330, "robot.mesh"); 52 57 53 58 // Create a skybox … … 60 65 } 61 66 //----------------------------------------------------------------------- 62 void TestCullingApplication::setupGui( void)67 void TestCullingApplication::setupGui() 63 68 { 64 69 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); … … 74 79 } 75 80 //----------------------------------------------------------------------- 76 void TestCullingApplication::createFrameListener(void) 77 { 78 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer); 81 void TestCullingApplication::createFrameListener() 82 { 83 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, 84 mGUIRenderer, mSceneContentGenerator); 79 85 mFrameListener->showDebugOverlay(true); 80 86 mRoot->addFrameListener(mFrameListener); … … 91 97 /***********************************************/ 92 98 //----------------------------------------------------------------------- 93 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer) 99 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, 100 SceneManager *sceneManager, 101 CEGUI::Renderer *renderer, 102 SceneContentGenerator *sceneContentGenerator) 94 103 : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), 95 104 mShutdownRequested(false) … … 102 111 mSceneMgr = sceneManager; 103 112 113 mSceneContentGenerator = sceneContentGenerator; 114 104 115 // Reduce move speed 105 116 mMoveSpeed = 50; … … 107 118 108 119 mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 109 m Threshold = 0;120 mVisibilityThreshold = 0; 110 121 111 122 // Register this so that we get mouse events. … … 135 146 mRenderedNodesInfo->setCaption(": 0"); 136 147 mNumObjectsInfo->setCaption(": 0"); 148 149 setAlgorithm(mCurrentAlgorithm); 137 150 138 151 pOver->show(); … … 170 183 if (e->getButtonID() & InputEvent::BUTTON0_MASK) 171 184 { 172 CEGUI::MouseCursor::getSingleton().show( 185 CEGUI::MouseCursor::getSingleton().show(); 173 186 mLMouseDown = false; 174 187 } … … 176 189 else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 177 190 { 178 CEGUI::MouseCursor::getSingleton().show( 191 CEGUI::MouseCursor::getSingleton().show(); 179 192 mRMouseDown = false; 180 193 } … … 209 222 timeDelay -= evt.timeSinceLastFrame; 210 223 211 KEY_PRESSED(KC_SPACE, 0.3, changeAlgorithm());224 KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 212 225 213 226 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); … … 222 235 void MouseQueryListener::changeThreshold(int incr) 223 236 { 224 mThreshold += incr; if(mThreshold < 0) mThreshold = 0; 225 226 char str[100]; sprintf(str,": %d", mThreshold); 227 228 mSceneMgr->setOption("Threshold", &mThreshold); 237 mVisibilityThreshold += incr; 238 if(mVisibilityThreshold < 0) mVisibilityThreshold = 0; 239 240 char str[100]; sprintf(str,": %d", mVisibilityThreshold); 241 242 mSceneMgr->setOption("Threshold", &mVisibilityThreshold); 229 243 mThresholdInfo->setCaption(str); 230 244 } 231 245 //----------------------------------------------------------------------- 232 void MouseQueryListener::changeAlgorithm() 233 { 234 mCurrentAlgorithm = ++mCurrentAlgorithm % GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 235 246 void MouseQueryListener::nextAlgorithm() 247 { 248 mCurrentAlgorithm = ++mCurrentAlgorithm % 249 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 250 251 setAlgorithm(mCurrentAlgorithm); 252 } 253 //----------------------------------------------------------------------- 254 void MouseQueryListener::setAlgorithm(int algorithm) 255 { 236 256 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 237 257 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); … … 258 278 mRenderedNodesInfo->setCaption(str); 259 279 260 sprintf(str,": %d", m TerrainContentGenerator->GetObjectCount());280 sprintf(str,": %d", mSceneContentGenerator->GetObjectCount()); 261 281 mNumObjectsInfo->setCaption(str); 262 282 } -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r84 r85 6 6 #include "ExampleApplication.h" 7 7 #include "VisibilityEnvironment.h" 8 8 #include "SceneContentGenerator.h" 9 9 10 10 Real timeDelay = 0; … … 30 30 31 31 MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 32 CEGUI::Renderer *renderer );32 CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator); 33 33 34 34 … … 60 60 void keyClicked(KeyEvent* e); 61 61 62 void changeAlgorithm(); 62 void nextAlgorithm(); 63 void setAlgorithm(int algorithm); 63 64 void changeThreshold(int incr); 64 65 void changeStats(); … … 72 73 bool mShutdownRequested; 73 74 int mCurrentAlgorithm; 74 int m Threshold;75 int mVisibilityThreshold; 75 76 76 77 OverlayElement *mAlgorithmInfo; … … 82 83 OverlayElement *mRenderedNodesInfo; 83 84 OverlayElement *mNumObjectsInfo; 85 86 SceneContentGenerator *mSceneContentGenerator; 84 87 }; 85 88 … … 87 90 class TestCullingApplication : public ExampleApplication 88 91 { 92 public: 93 ~TestCullingApplication(); 94 89 95 protected: 90 void createScene(void); 91 void createFrameListener(void); 92 void setupGui(void); 93 /** generates a the scene hierarchy with random values 94 @param number of objects to generate 95 */ 96 void GenerateScene(int numObjects); 97 98 /** generates a new scene object 99 @param tranlationRatio ratio between minimal and maximal possible translation 100 @param rotationRatio ratio between minimal and maximal possible rotation 101 @idx the index of the new object 102 @entName the name of the object entity 103 */ 104 void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio, 105 const int idx, const String &entName); 106 96 void createScene(); 97 void createFrameListener(); 98 void setupGui(); 99 107 100 //virtual void createCamera(void); 108 101 … … 116 109 Vector3 mMaxAngle; 117 110 111 SceneContentGenerator *mSceneContentGenerator; 112 118 113 private: 119 114 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.