Changeset 135 for trunk/VUT/work
- Timestamp:
- 06/16/05 18:13:33 (20 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r133 r135 16 16 17 17 18 String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =19 { 20 18 String currentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] = 19 { 20 "View Frustum Culling", 21 21 "Stop and Wait Culling", 22 22 "Coherent Hierarchical Culling" 23 23 }; 24 24 25 String queryTypeCaptions[4] = 26 { 27 "from camera, visible pixels", 28 "from viewpoint, visible pixels", 29 "from camera, relative visibility", 30 "from viewpoint, relative visibility" 31 }; 25 32 26 33 //----------------------------------------------------------------------- … … 73 80 mVisualizeCulledNodes(false), 74 81 mSunLight(sunLight), 75 mShiftPressed(false) 82 mShiftPressed(false), 83 mShowQueryStats(false) 76 84 { 77 85 //mInputDevice = PlatformManager::getSingleton().createInputReader(); 78 79 86 //mInputDevice->initialise(win, true, true); 87 80 88 mEventProcessor = new EventProcessor(); 81 89 … … 94 102 mHelpOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/HelpOverlay"); 95 103 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 96 104 mQueryOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/QueryOverlay"); 97 105 98 106 //-- visibility culling stats overlay … … 112 120 mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo"); 113 121 114 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);122 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]); 115 123 mThresholdInfo->setCaption(": 0"); 116 124 mFrustumCulledNodesInfo->setCaption(": 0"); … … 124 132 mQueriesIssuedInfo->setCaption(": 0"); 125 133 134 135 //-- visibility query stats overlay 136 mQueryTypeInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/QueryTypeInfo"); 137 mQueryVisibleNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleNodesInfo"); 138 mQueryVisibleGeometryInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleGeometryInfo"); 139 mQueryNodeVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/NodeVisibilityInfo"); 140 mQueryGeometryVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/GeometryVisibilityInfo"); 141 126 142 // show stats overlays 127 143 showStats(true); … … 145 161 mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 146 162 147 // TODO: change this 163 // TODO: change this (does not work with other scene manager plugins) 148 164 mVisibilityManager = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)-> 149 165 GetVisibilityManager(); … … 155 171 TerrainFrameListener::~TerrainFrameListener() 156 172 { 157 //PlatformManager::getSingleton().destroyInputReader(mInputDevice);158 159 173 delete mRayQueryExecutor; 160 174 delete mEventProcessor; … … 182 196 // Get results, create a node/entity on the position 183 197 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 184 mouseRay.getOrigin(), Vector3::ZERO, "robot" , false);198 mouseRay.getOrigin(), Vector3::ZERO, "robot"); 185 199 186 200 mLMouseDown = true; … … 341 355 if (fromPoint) 342 356 { 357 Vector3 point; 358 mVisibilityManager->GetQueryManager()-> 359 ComputeFromPointVisibility(point, &visibleNodes, &visibleGeometry, relativeVisibility); 343 360 } 344 361 else … … 348 365 } 349 366 367 float averageNodeVis = 0; 368 float averageGeometryVis = 0; 369 350 370 for (int i=0; i < visibleGeometry.size(); ++i) 351 371 { 352 std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibiliy(); 372 averageGeometryVis += visibleGeometry[i].GetVisibility(); 373 374 std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibility(); 353 375 LogManager::getSingleton().logMessage(d.str()); 354 376 } 355 377 for (int i=0; i < visibleNodes.size(); ++i) 356 378 { 357 std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibiliy(); 379 averageNodeVis += visibleNodes[i].GetVisibility(); 380 381 std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibility(); 358 382 LogManager::getSingleton().logMessage(d.str()); 359 383 } 360 384 385 averageNodeVis /= (float)visibleNodes.size(); 386 averageGeometryVis /= (float)visibleGeometry.size(); 387 388 char str[100]; 389 390 //-- update visibility queries stats 391 try 392 { 393 //-- visibility queries stats 394 int idx = fromPoint ? 1 : 0; 395 idx += relativeVisibility ? 2 : 0; 396 397 sprintf(str, ": %s", queryTypeCaptions[idx].c_str()); 398 mQueryTypeInfo->setCaption(str); 399 400 sprintf(str, ": %d", (int)visibleNodes.size()); 401 mQueryVisibleNodesInfo->setCaption(str); 402 403 sprintf(str,": %d", (int)visibleGeometry.size()); 404 mQueryVisibleGeometryInfo->setCaption(str); 405 406 sprintf(str,": %3.3f", averageNodeVis); 407 mQueryNodeVisibilityInfo->setCaption(str); 408 409 sprintf(str,": %3.3f", averageGeometryVis); 410 mQueryGeometryVisibilityInfo->setCaption(str); 411 } 412 catch (...) 413 { 414 // ignore 415 } 416 417 // show the results 418 if (!mShowQueryStats) 419 { 420 mQueryOverlay->show(); 421 mShowQueryStats = true; 422 } 361 423 } 362 424 //----------------------------------------------------------------------- … … 399 461 400 462 it_end = mFrameInfo.end(); 401 for (it = mFrameInfo.begin(); it < it_end; ++it)463 for (it = mFrameInfo.begin(); it < it_end; ++it) 402 464 { 403 465 ofstr << StringConverter::toString((*it).position) << " " … … 422 484 ifstr.getline(line, 256); 423 485 sscanf(line, "%f %f %f %f %f %f %f %f", &info.position.x, &info.position.y, &info.position.z, 424 425 486 &info.orientation.w, &info.orientation.x, &info.orientation.y, &info.orientation.z, 487 &info.timeElapsed); 426 488 427 489 mFrameInfo.push_back(info); … … 447 509 //-- write out stats for recorded walkthrough 448 510 std::stringstream d; 449 d << "Algorithm: " << mCurrentAlgorithmCaptions[mCurrentAlgorithm] << "\n"511 d << "Algorithm: " << currentAlgorithmCaptions[mCurrentAlgorithm] << "\n" 450 512 << "avg. FPS: " << mWindow->getAverageFPS() << "\n" 451 513 << "best FPS: " << mWindow->getBestFPS() << "\n" … … 532 594 void TerrainFrameListener::setAlgorithm(int algorithm) 533 595 { 534 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);596 mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]); 535 597 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 536 598 } … … 548 610 549 611 // update stats when necessary 550 try { 612 try 613 { 551 614 OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps"); 552 615 OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps"); … … 591 654 mObjectsInfo->setCaption(str); 592 655 } 593 catch (...)594 { 595 656 catch (...) 657 { 658 // ignore 596 659 } 597 660 } … … 787 850 788 851 case KC_LSHIFT: 789 mShiftPressed = !mShiftPressed;852 mShiftPressed = true; 790 853 break; 791 854 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); … … 798 861 { 799 862 // Print camera details 800 mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + " " +801 863 mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + 864 " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation())); 802 865 } 803 866 … … 809 872 void TerrainFrameListener::keyReleased(KeyEvent* e) 810 873 { 874 if (e->getKey() == KC_LSHIFT) 875 { 876 mShiftPressed = false; 877 } 878 811 879 CEGUI::System::getSingleton().injectKeyUp(e->getKey()); 812 880 e->consume(); … … 867 935 bool TerrainFrameListener::processUnbufferedKeyInput(const FrameEvent& evt) 868 936 { 869 /*if (mInputDevice->isKeyDown(KC_ESCAPE)) 870 { 871 return false; 872 }*/ 873 937 bool cursorPressed = false; 938 874 939 /* Move camera forward by keypress. */ 875 940 if (mInputDevice->isKeyDown(KC_UP)) 876 941 { 877 942 mTranslateVector.z = -mMoveScale; 878 }879 943 cursorPressed = true; 944 } 880 945 /* Move camera backward by keypress. */ 881 946 if (mInputDevice->isKeyDown(KC_DOWN)) 882 947 { 883 948 mTranslateVector.z = mMoveScale; 949 cursorPressed = true; 884 950 } 885 951 … … 887 953 { 888 954 mCamNode->yaw(-mRotScale); 955 cursorPressed = true; 889 956 } 890 957 … … 892 959 { 893 960 mCamNode->yaw(mRotScale); 961 cursorPressed = true; 894 962 } 895 963 // visualization camera … … 903 971 } 904 972 973 // show the results 974 if (cursorPressed && mShowQueryStats) 975 { 976 mQueryOverlay->hide(); 977 mShowQueryStats = false; 978 } 905 979 906 980 // Return true to continue rendering -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r133 r135 121 121 */ 122 122 void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility); 123 124 void toggleShowQueryStats(); 123 125 124 126 protected: … … 156 158 OverlayElement *mObjectsInfo; 157 159 OverlayElement *mQueriesIssuedInfo; 160 161 OverlayElement *mQueryTypeInfo; 162 OverlayElement *mQueryVisibleNodesInfo; 163 OverlayElement *mQueryVisibleGeometryInfo; 164 OverlayElement *mQueryVisiblityInfo; 165 OverlayElement *mQueryNodeVisibilityInfo; 166 OverlayElement *mQueryGeometryVisibilityInfo; 158 167 159 168 RayQueryExecutor *mRayQueryExecutor; … … 173 182 bool mShutdownRequested; 174 183 bool mDisplayCameraDetails; 175 184 176 185 Real mVizCameraHeight; 177 186 … … 208 217 Overlay* mHelpOverlay; 209 218 Overlay* mCullStatsOverlay; 219 Overlay* mQueryOverlay; 210 220 211 221 Light *mSunLight; … … 214 224 215 225 bool mShiftPressed; 226 bool mShowQueryStats; 227 216 228 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 217 229 }; -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r133 r135 162 162 if (!mTerrainContentGenerator->LoadObjects("objects.out")) 163 163 { 164 // height is restricted to 50, so no objects appear on peaks165 // => there is much occlusion164 // to provide much occlusion, 165 // height is restricted to 50, so no objects appear on peaks 166 166 mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 50.0f, 3000.0f)); 167 167 mTerrainContentGenerator->SetOffset(0); -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneManager.cpp
r131 r135 779 779 void SceneManager::_renderScene(Camera* camera, Viewport* vp, bool includeOverlays) 780 780 { 781 LogManager::getSingleton().logMessage("***********RENDER SCENE************"); 782 Root::getSingleton()._setCurrentSceneManager(this); 781 Root::getSingleton()._setCurrentSceneManager(this); 783 782 // Prep Pass for use in debug shadows 784 783 initShadowVolumeMaterials(); … … 4200 4199 void SceneManager::_renderSceneNode(Camera *cam, SceneNode *node, bool leaveTransparentsInQueue) 4201 4200 { 4201 // delete previously rendered objects from renderqueue 4202 _deleteRenderedQueueGroups(leaveTransparentsInQueue); 4203 4202 4204 node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false); 4203 4205 SceneManager::_renderVisibleObjects(); 4204 4205 // delete all rendered objects from renderqueue4206 _deleteRenderedQueueGroups(leaveTransparentsInQueue);4207 4206 } 4208 4207 //----------------------------------------------------------------------- … … 4248 4247 void SceneManager::_renderMovableObject(MovableObject *mov, const bool leaveTransparentsInQueue) 4249 4248 { 4249 // delete previously rendered objects from renderqueue 4250 _deleteRenderedQueueGroups(leaveTransparentsInQueue); 4251 4250 4252 mov->_updateRenderQueue(getRenderQueue()); 4251 4253 SceneManager::_renderVisibleObjects(); 4252 4253 // delete rendered objects from renderqueue4254 //TODO: should be first4255 _deleteRenderedQueueGroups(leaveTransparentsInQueue);4256 4254 } 4257 4255 #endif //GTP_VISIBILITY_MODIFIED_OGRE -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctree.h
r104 r135 157 157 158 158 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 159 public: 160 /** Returns last visited frame id. */ 161 int lastVisited(void); 162 /** Set to current frame id. 163 @param current frame id. 164 */ 165 void setLastVisited(int frameid); 166 /** Makes this octree become visible / invisble. 167 @param visible Whether this node is to be made visible or invisible 168 */ 169 void setOctreeVisible(bool visible); 170 /** Returns true if this node is marked visible, false otherwise. 171 */ 172 bool isOctreeVisible(void); 173 /** Gets this node's parent (NULL if this is the root). 174 */ 175 Octree *getParent(); 176 /** Frame id when this octree was last rendered. 177 @return last rendered frame id 178 */ 179 int lastRendered(void); 180 /** Sets frame id when this octree was last rendered. 181 @param last rendered frame id 182 */ 183 void setLastRendered(int frameid); 184 /** Returns current depth of octree 185 @return current depth 186 */ 187 int getDepth(); 188 189 protected: 190 191 int mLastRendered; 192 int mLastVisited; 193 bool mVisible; 194 int mDepth; 159 public: 160 /** Returns last visited frame id. */ 161 int lastVisited(void); 162 /** Set to current frame id. 163 @param current frame id. 164 */ 165 void setLastVisited(int frameid); 166 /** Makes this octree become visible / invisble. 167 @param visible Whether this node is to be made visible or invisible 168 */ 169 void setOctreeVisible(bool visible); 170 /** Returns true if this node is marked visible, false otherwise. 171 */ 172 bool isOctreeVisible(void); 173 /** Gets this node's parent (NULL if this is the root). 174 */ 175 Octree *getParent(); 176 /** Frame id when this octree was last rendered. 177 @return last rendered frame id 178 */ 179 int lastRendered(void); 180 /** Sets frame id when this octree was last rendered. 181 @param last rendered frame id 182 */ 183 void setLastRendered(int frameid); 184 /** Returns current depth of octree 185 @return current depth 186 */ 187 int getDepth(); 188 /** Returns real extent of the octree, i.e., the merged extent of the bounding boxes. */ 189 AxisAlignedBox _getWorldAABB(void) const; 190 191 /** Updates bounds of real aabb of octree. */ 192 void _updateBounds(); 193 194 protected: 195 196 /** the real extent of the octree. */ 197 AxisAlignedBox mWorldAABB; 198 199 int mLastRendered; 200 int mLastVisited; 201 bool mVisible; 202 int mDepth; 195 203 196 204 #endif // GTP_VISIBILITY_MODIFIED_OGRE -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
r115 r135 142 142 _ref(); 143 143 144 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 145 _updateBounds(); 146 #endif 147 144 148 } 145 149 … … 151 155 //update total counts. 152 156 _unref(); 157 158 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 159 _updateBounds(); 160 #endif 153 161 } 154 162 … … 165 173 mWireBoundingBox = new WireBoundingBox(); 166 174 167 mWireBoundingBox->setupBoundingBox(mBox); 175 //mWireBoundingBox->setupBoundingBox(mBox); 176 mWireBoundingBox->setupBoundingBox(mWorldAABB); 168 177 return mWireBoundingBox; 169 178 } … … 171 180 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 172 181 //----------------------------------------------------------------------- 173 int Octree::lastVisited( void)182 int Octree::lastVisited() 174 183 { 175 184 return mLastVisited; … … 181 190 } 182 191 //----------------------------------------------------------------------- 183 int Octree::lastRendered( void)192 int Octree::lastRendered() 184 193 { 185 194 return mLastRendered; … … 196 205 } 197 206 //----------------------------------------------------------------------- 198 bool Octree::isOctreeVisible( void)207 bool Octree::isOctreeVisible() 199 208 { 200 209 return mVisible; … … 210 219 return mDepth; 211 220 } 221 //----------------------------------------------------------------------- 222 AxisAlignedBox Octree::_getWorldAABB(void) const 223 { 224 return mWorldAABB; 225 } 226 //----------------------------------------------------------------------- 227 void Octree::_updateBounds() 228 { 229 // Reset bounds first 230 mWorldAABB.setNull(); 231 232 // Update bounds from own attached objects 233 NodeList::iterator it, it_end; 234 it_end = mNodes.end(); 235 236 for (it = mNodes.begin(); it != it_end; ++it) 237 { 238 // Merge world bounds of each object 239 mWorldAABB.merge((*it)->_getWorldAABB()); 240 } 241 242 // Merge with children 243 for (int i = 0; i < 2; ++i) 244 { 245 for (int j = 0; j < 2; ++j) 246 { 247 for (int k = 0; k < 2; ++k) 248 { 249 if (mChildren[i][j][k] != 0) 250 { 251 mWorldAABB.merge(mChildren[i][j][k]->_getWorldAABB()); 252 } 253 } 254 } 255 } 256 // recursively update parent bounds 257 if (mParent) 258 { 259 mParent->_updateBounds(); 260 } 261 } 212 262 #endif //GTP_VISIBILITY_MODIFIED_OGRE 213 263 } -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
r115 r135 428 428 _addOctreeNode( onode, mOctree ); 429 429 } 430 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 431 else // still update because bounding box may be different 432 { 433 onode -> getOctant() -> _updateBounds(); 434 } 435 #endif // GTP_VISIBILITY_MODIFIED_OGRE 430 436 } 431 437 … … 1172 1178 bool leaveTransparentsInQueue)//, bool useZPassQueue) 1173 1179 { 1180 // delete previously rendered objects from the render queue 1181 _deleteRenderedQueueGroups(leaveTransparentsInQueue); 1182 1174 1183 //Add stuff to be rendered; 1175 1184 NodeList::iterator it = octant->mNodes.begin(); … … 1211 1220 //-- the actual rendering 1212 1221 SceneManager::_renderVisibleObjects(); 1213 // delete all rendered objects from the render queue1214 _deleteRenderedQueueGroups(leaveTransparentsInQueue);1215 1222 } 1216 1223 #endif // GTP_VISIBILITY_MODIFIED_OGRE
Note: See TracChangeset
for help on using the changeset viewer.