- Timestamp:
- 05/12/05 18:55:25 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r87 r94 1 1 #include "CoherentHierarchicalCullingManager.h" 2 #include < windows.h>2 #include <OgreLogManager.h> 3 3 4 4 namespace GtpVisibility { … … 8 8 { 9 9 InitFrame(); 10 Ogre::LogManager::getSingleton().logMessage("**** CHCULL ****\n"); 10 11 11 12 QueryQueue queryQueue; … … 20 21 mHierarchyInterface->GetQueue()->empty())) 21 22 { 22 //if (mHierarchyInterface->GetQueue()->empty())OutputDebugString("empty\n"); 23 24 HierarchyNode *node = queryQueue.front().first; 23 HierarchyNode *node = queryQueue.front().first; 25 24 26 25 queryQueue.pop(); -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r87 r94 1 1 #include "FrustumCullingManager.h" 2 #include < windows.h>2 #include <OgreLogManager.h> 3 3 4 4 namespace GtpVisibility { … … 8 8 { 9 9 InitFrame(); 10 10 Ogre::LogManager::getSingleton().logMessage("**** Frustum Culling ****\n"); 11 11 while (!mHierarchyInterface->GetQueue()->empty()) 12 12 { -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r92 r94 1 1 #include "StopAndWaitCullingManager.h" 2 #include <windows.h> 2 #include <OgreLogManager.h> 3 3 4 4 5 namespace GtpVisibility { … … 8 9 { 9 10 InitFrame(); 10 11 Ogre::LogManager::getSingleton().logMessage("*** STOP AND WAIT CULL ****\n"); 12 11 13 while (!mHierarchyInterface->GetQueue()->empty()) 12 14 { -
trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
r92 r94 9 9 //----------------------------------------------------------------------- 10 10 VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment): 11 mVisibilityThreshold(0) 11 mVisibilityThreshold(0), mCullingManager(NULL) 12 12 { 13 13 mVisibilityEnvironment = visEnvironment; 14 14 15 mCullingManagerType = VisibilityEnvironment::STOP_AND_WAIT_CULLING;16 mCullingManager = new StopAndWaitCullingManager();15 SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING); 16 //SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING); 17 17 18 18 mQueryManager = new DummyQueryManager(0); … … 28 28 VisibilityEnvironment::CullingManagerType ocmType) 29 29 { 30 if (mCullingManagerType != ocmType) 30 // change only if necessary 31 if (!mCullingManager || (mCullingManagerType != ocmType)) 31 32 { 32 33 // delete old culling manager 33 delete mCullingManager; 34 if(mCullingManager) 35 delete mCullingManager; 34 36 35 37 mCullingManagerType = ocmType; -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r92 r94 34 34 GtpVisibility::OcclusionQuery *GetNextOcclusionQuery(); 35 35 36 /** Sets the current camera .36 /** Sets the current camera used for the rendering. 37 37 @param cam the current camera 38 38 */ 39 39 void SetCamera(Camera *cam); 40 40 /** Sets the current camera used for culling. 41 @param cam the current camera 42 @remark the default is the camera used for rendering 43 */ 44 void SetCullCamera(Camera *cullCam); 41 45 /** Initialises this scene traverser for the current frame. 42 46 @param root root of the hierarchy 43 47 @param cam current camera 48 @param cullCam the camera used for culling. If null, the current camera is used 44 49 @remark convenience method wich calls VisibilitySceneTraverser::initFrame, 45 50 sets the current camera, and initialises the distance queue. 46 51 */ 47 void InitFrame(GtpVisibility::HierarchyNode *root, Ogre::Camera *cam);52 void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL); 48 53 /** Checks if the node is visible from the current view frustum. 49 54 @param node the current node … … 95 100 96 101 Camera *mCamera; 102 Camera *mCullCamera; 103 97 104 AxisAlignedBox mBox; 98 105 -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r93 r94 2 2 #include "OgreVisibilityOctreeSceneManager.h" 3 3 #include <OgreOctree.h> 4 #include <OgreLogManager.h> 5 4 6 #include <windows.h> 5 7 6 8 namespace Ogre { 7 //namespace GtpVisibility { 9 8 10 //----------------------------------------------------------------------- 9 11 OctreeHierarchyInterface::OctreeHierarchyInterface(SceneManager *sm, RenderSystem *rsys): … … 25 27 26 28 // if not all subtrees are empty 27 if (octree->numNodes() > (int)octree->mNodes.size()) 29 //if (octree->numNodes() > (int)octree->mNodes.size()) 30 if (!IsLeaf(node)) 28 31 { 29 32 for(int i=0; i<8; ++i) … … 42 45 bool OctreeHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const 43 46 { 44 Octree *octant = static_cast<Octree *>(node); 45 46 for(int i=0; i<8; i++) 47 { 48 if (octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]) 49 return false; 50 } 51 52 return true; 47 Octree *octree = static_cast<Octree *>(node); 48 // HACK: if there are subtrees, they are empty => we are not interested in them 49 return octree->numNodes() == (int)octree->mNodes.size(); 53 50 } 54 51 //----------------------------------------------------------------------- … … 68 65 Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 69 66 70 return (mC amera->getDerivedPosition() - mid).squaredLength();67 return (mCullCamera->getDerivedPosition() - mid).squaredLength(); 71 68 } 72 69 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r93 r94 1 1 #include <OgreCamera.h> 2 2 #include <OgreLogManager.h> 3 3 //#include "OgreSolidHalfBoundingBox.h" 4 4 #include "OgreSolidBoundingBox.h" … … 11 11 //----------------------------------------------------------------------- 12 12 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 13 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL)/*, mSolidHalfBoundingBox(NULL)*/ 13 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), 14 mCamera(NULL), mCullCamera(NULL) 14 15 { 15 16 } … … 64 65 } 65 66 //----------------------------------------------------------------------- 67 void PlatformHierarchyInterface::SetCullCamera(Ogre::Camera *cullCam) 68 { 69 mCullCamera = cullCam; 70 } 71 //----------------------------------------------------------------------- 66 72 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::GetNextOcclusionQuery() 67 73 { … … 74 80 } 75 81 //----------------------------------------------------------------------- 76 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam )82 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam) 77 83 { 78 84 GtpVisibility::HierarchyInterface::InitFrame(root); … … 80 86 81 87 SetCamera(cam); 88 89 if(cullCam) 90 SetCullCamera(cullCam); 91 else 92 SetCullCamera(cam); 82 93 } 83 94 //----------------------------------------------------------------------- … … 96 107 { 97 108 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 98 return mC amera->isVisible(*GetBoundingBox(node), intersects);109 return mCullCamera->isVisible(*GetBoundingBox(node), intersects); 99 110 #else 100 111 return true; … … 113 124 // if node is leaf and was visible => will be rendered anyway. 114 125 // In this case we can also test with the real geometry. 115 if(mUseOptimization && wasVisible && IsLeaf(node)) 126 // if camera for culling is different from camera for rendering => cannot optimize 127 if (mUseOptimization && wasVisible && IsLeaf(node) && (mCamera == mCullCamera)) 116 128 { 129 //LogManager::getSingleton().logMessage("render node\n"); 117 130 RenderNode(node); 118 131 } 119 132 else 120 133 { 134 //LogManager::getSingleton().logMessage("render box\n"); 121 135 RenderBoundingBox(GetBoundingBox(node)); 122 136 } -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r87 r94 3 3 #include <OgreCamera.h> 4 4 #include <OgreSceneNode.h> 5 6 //#include <windows.h>7 5 8 6 namespace Ogre { -
trunk/VUT/Ogre/src/OgreSolidBoundingBox.cpp
r92 r94 6 6 #include "OgreCamera.h" 7 7 #include "OgreMaterialManager.h" 8 //#include <windows.h> 8 9 9 10 10 namespace Ogre { -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r93 r94 6 6 #include <OgreCamera.h> 7 7 #include <OgreLogManager.h> 8 9 #include <windows.h>10 8 11 9 namespace Ogre { … … 18 16 mHierarchyInterface = 19 17 new OctreeHierarchyInterface(this, mDestRenderSystem); 20 //visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING); 21 18 22 19 //mDisplayNodes = true; 23 20 //mShowBoundingBoxes = true; … … 34 31 void VisibilityOctreeSceneManager::_renderVisibleObjects() 35 32 { 36 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 33 Camera *cullCam = NULL; 34 35 if(mCullCamera) cullCam = getCamera("CullCamera"); 36 37 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, cullCam); 37 38 mVisibilityManager->GetCullingManager()->InitFrame(); 38 39 -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r87 r94 7 7 #include "OgreVisibilityOptionsManager.h" 8 8 9 //#include <windows.h>10 9 11 10 namespace Ogre { -
trunk/VUT/Ogre/src/OgreVisibilitySceneManagerDll.cpp
r74 r94 34 34 #include <OgreRoot.h> 35 35 36 //#include <windows.h>37 36 GtpVisibility::VisibilityEnvironment *visEnv; 38 37 GtpVisibility::VisibilityManager *visManager; -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r93 r94 32 32 void VisibilityTerrainSceneManager::_renderVisibleObjects() 33 33 { 34 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 34 Camera *cullCam = NULL; 35 36 // if two cameras (one for culling, one for visualization) 37 if(mCullCamera) 38 cullCam = getCamera("CullCamera"); 39 40 if(cullCam && (mCameraInProgress != cullCam)) 41 OutputDebugString("using cullcam\n"); 42 else 43 OutputDebugString("not using cullcam\n"); 44 45 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, cullCam); 35 46 mVisibilityManager->GetCullingManager()->InitFrame(); 36 47 -
trunk/VUT/work/TestCulling/SceneContentGenerator.cpp
r87 r94 6 6 */ 7 7 #include "SceneContentGenerator.h" 8 #include <windows.h>9 8 10 9 namespace Ogre { -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r93 r94 17 17 18 18 #define WIN32_LEAN_AND_MEAN 19 #include "windows.h"19 #include <windows.h> 20 20 21 21 … … 28 28 { 29 29 // Create the camera 30 mCamera = mSceneMgr->createCamera(" PlayerCam");30 mCamera = mSceneMgr->createCamera("CullCamera"); 31 31 32 32 // Position it at 500 in Z direction … … 112 112 mShowOctree(false), 113 113 mUseCulling(true), 114 mUseOptimization( false),114 mUseOptimization(true), 115 115 mUseCullCamera(false) 116 116 { -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r93 r94 97 97 bool mUseCullCamera; 98 98 99 Camera *m CullCamera;99 Camera *mVisualizationCamera; 100 100 }; 101 101 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r93 r94 17 17 18 18 #define WIN32_LEAN_AND_MEAN 19 #include "windows.h"19 #include <windows.h> 20 20 21 21 … … 27 27 if(mTerrainContentGenerator) 28 28 delete mTerrainContentGenerator; 29 //if(m CullCamera) delete mCullCamera;29 //if(mVisualizationCamera) delete mVisualizationCamera; 30 30 } 31 31 //----------------------------------------------------------------------- … … 33 33 { 34 34 // Create the camera 35 mCamera = mSceneMgr->createCamera(" PlayerCam");35 mCamera = mSceneMgr->createCamera("CullCamera"); 36 36 37 37 // Set a nice viewpoint … … 40 40 41 41 //--create cull camera 42 m CullCamera = mSceneMgr->createCamera("CullCamera");43 m CullCamera->setPosition(707, 2500, 528);44 m CullCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));45 46 m CullCamera->setNearClipDistance(1);42 mVisualizationCamera = mSceneMgr->createCamera("VisualizationCamera"); 43 mVisualizationCamera->setPosition(707, 2500, 528); 44 mVisualizationCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 45 46 mVisualizationCamera->setNearClipDistance(1); 47 47 mCamera->setNearClipDistance(1); 48 48 … … 50 50 if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 51 51 { 52 m CullCamera->setFarClipDistance(0);52 mVisualizationCamera->setFarClipDistance(0); 53 53 mCamera->setFarClipDistance(0); 54 54 } 55 55 else 56 56 { 57 m CullCamera->setFarClipDistance(1000);57 mVisualizationCamera->setFarClipDistance(1000); 58 58 mCamera->setFarClipDistance(1000); 59 59 } … … 79 79 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 80 80 //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 81 mWindow->addViewport(mCullCamera, 10, 0.5, 0.5, 1, 1); 82 81 83 82 // Create a skybox 84 83 mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 5000, false); … … 133 132 { 134 133 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, 135 mGUIRenderer, mTerrainContentGenerator, m CullCamera);134 mGUIRenderer, mTerrainContentGenerator, mVisualizationCamera); 136 135 mFrameListener->showDebugOverlay(true); 137 136 mRoot->addFrameListener(mFrameListener); … … 150 149 CEGUI::Renderer *renderer, 151 150 TerrainContentGenerator *sceneGenerator, 152 Camera * cullCamera):151 Camera *vizCamera): 153 152 ExampleFrameListener(win, cam, false, true), 154 153 mGUIRenderer(renderer), … … 163 162 mShowOctree(false), 164 163 mUseCulling(true), 165 mUseOptimization( false),164 mUseOptimization(true), 166 165 mUseCullCamera(false), 167 m CullCamera(cullCamera)166 mVisualizationCamera(vizCamera) 168 167 { 169 168 // Reduce move speed … … 293 292 bool MouseQueryListener::frameStarted(const FrameEvent &evt) 294 293 { 294 clamp2Terrain(mCamera); 295 clamp2Terrain(mVisualizationCamera); 296 297 return ExampleFrameListener::frameStarted(evt); 298 } 299 void MouseQueryListener::clamp2Terrain(Camera *cam) 300 { 295 301 // clamp to terrain 296 Vector3 camPos = mCamera->getPosition();302 Vector3 camPos = cam->getPosition(); 297 303 Vector3 queryResult; 298 304 299 300 Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y))305 if(mRayQueryExecutor->executeRayQuery(&queryResult, 306 Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y)) 301 307 { 302 mCamera->setPosition(mCamera->getPosition().x, queryResult.y + 10,303 mCamera->getPosition().z);308 cam->setPosition(cam->getPosition().x, queryResult.y + 10, 309 cam->getPosition().z); 304 310 } 305 306 camPos = mCullCamera->getPosition();307 308 if(mRayQueryExecutor->executeRayQuery(&queryResult,309 Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y))310 {311 mCullCamera->setPosition(mCullCamera->getPosition().x, queryResult.y + 10,312 mCullCamera->getPosition().z);313 }314 315 return ExampleFrameListener::frameStarted(evt);316 311 } 317 312 //----------------------------------------------------------------------- … … 332 327 KEY_PRESSED(KC_C, 0.3, toggleUseCulling()); 333 328 KEY_PRESSED(KC_V, 0.3, toggleCullCamera()); 334 KEY_PRESSED(KC_X, 0.3, fixCullCamera());329 KEY_PRESSED(KC_X, 0.3, FixVizCamera()); 335 330 336 331 updateStats(); 332 //if(mWindow->getViewport(1)) mWindow->getViewport(1)->update(); 337 333 338 334 return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt); … … 420 416 { 421 417 mUseCullCamera = !mUseCullCamera; 418 419 if(mUseCullCamera) 420 { 421 mWindow->addViewport(mVisualizationCamera, 10, 0.5, 0.5, 1, 1); 422 mWindow->getViewport(1)->setClearEveryFrame(true); 423 } 424 else 425 mWindow->removeViewport(10); 426 422 427 mSceneMgr->setOption("CullCamera", &mUseCullCamera); 423 428 } 424 429 //----------------------------------------------------------------------- 425 void MouseQueryListener::fixCullCamera() 426 { 427 mCullCamera->setPosition(mCamera->getPosition()); 428 mCullCamera->setOrientation(mCamera->getOrientation()); 430 void MouseQueryListener::FixVizCamera() 431 { 432 mVisualizationCamera->setPosition(mCamera->getPosition()); 433 mVisualizationCamera->setOrientation(mCamera->getOrientation()); 434 clamp2Terrain(mVisualizationCamera); 429 435 } 430 436 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r93 r94 30 30 31 31 MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 32 CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera * cullCamera);32 CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera); 33 33 34 34 ~MouseQueryListener(); … … 67 67 void toggleUseCulling(); 68 68 void toggleCullCamera(); 69 void fixCullCamera();69 void FixVizCamera(); 70 70 71 71 protected: 72 void clamp2Terrain(Camera *cam); 73 72 74 bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down 73 75 SceneManager *mSceneMgr; // A pointer to the scene manager … … 101 103 bool mUseCullCamera; 102 104 103 Camera *m CullCamera;105 Camera *mVisualizationCamera; 104 106 }; 105 107 … … 127 129 TerrainContentGenerator *mTerrainContentGenerator; 128 130 129 Camera *m CullCamera;131 Camera *mVisualizationCamera; 130 132 131 133 private:
Note: See TracChangeset
for help on using the changeset viewer.