Changeset 85 for trunk/VUT/work
- Timestamp:
- 05/04/05 17:58:13 (20 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 8 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); -
trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp
r84 r85 53 53 { 54 54 mMinPos = Vector3(0.0f, 5000.0f, 0.0f); 55 mMaxPos = Vector3( 1000.0f, 5000.0f, 1000.0f);55 mMaxPos = Vector3(3000.0f, 5000.0f, 3000.0f); 56 56 57 57 mMinAngle = Vector3(0.0f, 0.0f, 0.0f); … … 87 87 mMaxHeight = maxHeight; 88 88 } 89 //-----------------------------------------------------------------------90 int TerrainContentGenerator::GetObjectCount()91 {92 return mCount;93 }94 89 95 90 } // namespace Ogre -
trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h
r84 r85 34 34 35 35 void SetMaxHeight(Real maxHeight); 36 int GetObjectCount(); 37 36 38 37 protected: 39 38 RayQueryExecutor *mRayQueryExecutor; -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r84 r85 86 86 87 87 // Set a nice viewpoint 88 mCamera->setPosition(707, 2500,528);88 mCamera->setPosition(707, 2500, 528); 89 89 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 90 90 … … 96 96 97 97 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 98 mTerrainContentGenerator->GenerateScene( 300, "robot.mesh");98 mTerrainContentGenerator->GenerateScene(500, "robot.mesh"); 99 99 // no limitations needed anymore: the user can set 100 100 // objects also on peaks of terrain … … 151 151 mRotateSpeed *= 2; 152 152 153 mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING ,154 m Threshold = 0;153 mCurrentAlgorithm = GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 154 mVisibilityThreshold = 0; 155 155 156 156 // Register this so that we get mouse events. … … 182 182 mRenderedNodesInfo->setCaption(": 0"); 183 183 mNumObjectsInfo->setCaption(": 0"); 184 185 setAlgorithm(mCurrentAlgorithm); 184 186 185 187 pOver->show(); … … 287 289 timeDelay -= evt.timeSinceLastFrame; 288 290 289 KEY_PRESSED(KC_SPACE, 0.3, changeAlgorithm());291 KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 290 292 291 293 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); … … 300 302 void MouseQueryListener::changeThreshold(int incr) 301 303 { 302 mThreshold += incr; if(mThreshold < 0) mThreshold = 0; 303 304 char str[100]; sprintf(str,": %d", mThreshold); 305 306 mSceneMgr->setOption("Threshold", &mThreshold); 304 mVisibilityThreshold += incr; 305 if(mVisibilityThreshold < 0) mVisibilityThreshold = 0; 306 307 char str[100]; sprintf(str,": %d", mVisibilityThreshold); 308 309 mSceneMgr->setOption("Threshold", &mVisibilityThreshold); 307 310 mThresholdInfo->setCaption(str); 308 311 } 309 312 //----------------------------------------------------------------------- 310 void MouseQueryListener:: changeAlgorithm()313 void MouseQueryListener::nextAlgorithm() 311 314 { 312 315 mCurrentAlgorithm = ++mCurrentAlgorithm % 313 316 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS, 314 317 318 setAlgorithm(mCurrentAlgorithm); 319 } 320 //----------------------------------------------------------------------- 321 void MouseQueryListener::setAlgorithm(int algorithm) 322 { 315 323 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 316 324 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r84 r85 59 59 void keyClicked(KeyEvent* e); 60 60 61 void changeAlgorithm(); 61 void nextAlgorithm(); 62 void setAlgorithm(int algorithm); 62 63 void changeThreshold(int incr); 63 64 void changeStats(); … … 71 72 bool mShutdownRequested; 72 73 int mCurrentAlgorithm; 73 int m Threshold;74 int mVisibilityThreshold; 74 75 75 76 OverlayElement *mAlgorithmInfo; … … 97 98 98 99 protected: 99 void createScene( void);100 void createFrameListener( void);101 void setupGui( void);102 virtual void createCamera( void);100 void createScene(); 101 void createFrameListener(); 102 void setupGui(); 103 virtual void createCamera(); 103 104 104 105 CEGUI::OgreCEGUIRenderer *mGUIRenderer;
Note: See TracChangeset
for help on using the changeset viewer.