- Timestamp:
- 07/04/05 17:57:51 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 6 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r130 r154 144 144 145 145 146 /** Renders geometry.146 /** Renders the given geometry. 147 147 */ 148 148 virtual void RenderGeometry(GtpVisibility::Mesh *geom) = 0; 149 149 150 /** Sets node id to specified value. 151 */ 152 virtual void SetNodeId(HierarchyNode *node, int id) = 0; 153 /** Returns id of given node. 154 */ 155 virtual int GetNodeId(HierarchyNode *node) = 0; 150 156 protected: 151 157 -
trunk/VUT/Ogre/include/OgreBspHierarchyInterface.h
r87 r154 43 43 */ 44 44 AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node); 45 46 unsigned int mNumOctreeNodes;47 45 }; 48 46 } // namespace Ogre -
trunk/VUT/Ogre/include/OgreItemBufferQueryManager.h
r153 r154 22 22 bool relativeVisibility = false); 23 23 24 /**25 Uses the specified point to execute the visibility query in all directions.26 @sa ComputeCameraVisibility()27 */28 void ComputeFromPointVisibility(const Vector3 &point,29 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,30 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,31 bool relativeVisibility = false);32 33 24 bool ShootRay(const Ray &ray, std::vector<Mesh *> *visibleMeshes, bool isGlobalLine = false); 34 25 … … 36 27 void InitItemBuffer( InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 37 28 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry); 38 bool mWasInitialised;29 39 30 }; 40 31 -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r130 r154 25 25 See setOption 26 26 */ 27 //bool getOption( const String &, void * );28 //bool getOptionKeys( StringVector &refKeys );29 27 void PullUpVisibility(GtpVisibility::HierarchyNode *node); 28 30 29 /** Traverses given node. 31 30 @param node current node … … 50 49 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 51 50 bool includeChildren = false);*/ 51 52 52 void GetGeometry(GtpVisibility::HierarchyNode *node, 53 53 GtpVisibility::GeometryList *geometryList, 54 54 bool includeChildren); 55 56 void SetNodeId(GtpVisibility::HierarchyNode *node, int id); 57 58 int GetNodeId(GtpVisibility::HierarchyNode *node); 55 59 56 60 protected: … … 65 69 */ 66 70 Real GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const; 67 /** number of octree hierarchy nodes */68 unsigned int mNumOctreeNodes;69 71 }; 70 72 } // namespace Ogre -
trunk/VUT/Ogre/include/OgrePlatformQueryManager.h
r144 r154 20 20 21 21 /** 22 Computes restricted visibility from point by using an explicit camera to execute23 the visibility query.24 @param camera The camera to be used25 26 @param visibleNodes Pointer to the container where visible nodes should be added.27 This set is formed of visible leafs or fully visible interior nodes.28 If NULL no visible nodes are not evaluated.29 30 @param visibleGeometry Pointer to the container where visible meshes should be added.31 If NULL no visible meshes are not evaluated.32 33 @param projectedPixels If true the visibility member for34 NodeInfo and MeshInfo represent relative visibility; i.e. the number of visible35 pixels divided by the the number of projected pixels.36 37 @return true if the corresponding PVS exists.38 */39 virtual void40 ComputeCameraVisibility(const Camera &camera,41 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,42 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,43 bool relativeVisibility = false44 );45 46 /**47 22 Uses the specified point to execute the visibility query in all directions. 48 23 @sa ComputeCameraVisibility() 49 24 */ 50 virtual void 51 ComputeFromPointVisibility(const Vector3 &point, 25 void ComputeFromPointVisibility(const Vector3 &point, 52 26 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 53 27 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 54 bool relativeVisibility = false 55 ); 28 bool relativeVisibility = false); 56 29 57 30 /** … … 79 52 protected: 80 53 Viewport *mViewport; 54 bool mWasInitialised; 81 55 }; 82 56 -
trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
r130 r154 49 49 GtpVisibility::GeometryList *geometryList, 50 50 bool includeChildren); 51 52 void SetNodeId(GtpVisibility::HierarchyNode *node, int id); 53 54 int GetNodeId(GtpVisibility::HierarchyNode *node); 51 55 }; 52 56 -
trunk/VUT/Ogre/scripts/Plugin_VisibilitySceneManager.vcproj
r150 r154 195 195 </File> 196 196 <File 197 RelativePath="..\include\OgreOcclusionQueriesQueryManager.h"> 198 </File> 199 <File 197 200 RelativePath="..\include\OgrePlatformHierarchyInterface.h"> 198 201 </File> … … 227 230 <File 228 231 RelativePath="..\src\OgreItemBufferQueryManager.cpp"> 232 </File> 233 <File 234 RelativePath="..\src\OgreOcclusionQueriesQueryManager.cpp"> 229 235 </File> 230 236 <File -
trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
r153 r154 8 8 //----------------------------------------------------------------------- 9 9 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp): 10 PlatformQueryManager(hierarchyInterface, vp) , mWasInitialised(false)10 PlatformQueryManager(hierarchyInterface, vp) 11 11 { 12 12 } … … 23 23 bool relativeVisibility) 24 24 { 25 // initialise item buffer if necessary25 // initialise item buffer (if not already initialised) 26 26 InitItemBuffer(visibleNodes, visibleGeometry); 27 27 … … 45 45 sm->setOption("UseItemBuffer", &useItemBuffer); 46 46 47 // clear background with black 47 // clear background with black (i.e., not a valid item id) 48 48 ColourValue bg = mViewport->getBackgroundColour(); 49 49 mViewport->setBackgroundColour(ColourValue(0, 0, 0, 0)); … … 70 70 uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 71 71 72 72 73 // loop through frame buffer & collect visible pixels 73 74 for (int idx = 0; idx < dimy * dimx * 3; idx += 3) 74 75 { 76 // -- decode color code to receive id 75 77 int id = buf[idx] << 16; 76 78 id += buf[idx + 1] << 8; 77 79 id += buf[idx + 2]; 78 80 79 // if valid id <= add visibility 80 if ((id > =0) && (id < (int)visibleGeometry->size()))81 // if valid id <= add visibility (id values start at 1 82 if ((id > 0) && (id < (int)visibleGeometry->size())) 81 83 { 82 84 ((*visibleGeometry)[id]).AddVisibility(1, 1); 83 85 } 84 /* else 85 { 86 std::stringstream d; 87 d << "id: " << id << ", buf 1: " << (int)buf[idx] << ", buf 2: " << (int)buf[idx + 1] << ", buf 3: " << (int)buf[idx + 2]; 88 LogManager::getSingleton().logMessage(d.str()); 89 }*/ 86 /*else { std::stringstream d; 87 d << "adding pixel to geometry with id: " << id << ", buf 1: " << (int)buf[idx] << ", buf 2: " << (int)buf[idx + 1] << ", buf 3: " << (int)buf[idx + 2]; 88 LogManager::getSingleton().logMessage(d.str()); }*/ 90 89 } 91 90 … … 104 103 mWasInitialised = true; 105 104 106 SceneManager::EntityIterator it = dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)-> 105 SceneManager::EntityIterator it = 106 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)-> 107 107 GetSceneManager()->getEntityIterator(); 108 108 109 109 // TODO: make this more efficient 110 110 visibleGeometry->clear(); 111 visibleNodes->clear(); 111 112 112 113 while (it.hasMoreElements()) … … 115 116 } 116 117 } 117 //-----------------------------------------------------------------------118 void ItemBufferQueryManager::ComputeFromPointVisibility(const Vector3 &point,119 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,120 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,121 bool relativeVisibility)122 {123 SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *>124 (mHierarchyInterface)->GetSceneManager();125 126 Camera *cam = sm->createCamera("PointQueryCam");127 128 //save old camera129 Camera *savedCam = mViewport->getCamera();130 131 // --- initialise new camera132 mViewport->setCamera(cam);133 cam->setPosition(point);134 135 cam->setNearClipDistance(savedCam->getNearClipDistance());136 cam->setFarClipDistance(savedCam->getFarClipDistance());137 138 // set frustum to 45 degrees so all the scene can be captured with 6 shots139 cam->setAspectRatio(1.0);140 cam->setFOVy(Radian(Math::HALF_PI));141 142 int sign = -1;143 144 // ---- capture visibility from all 6 directions145 for (int i=0; i < 6; i++)146 {147 sign *= -1;148 149 // Print camera details150 std::stringstream d;151 d << "Point query camera: " + StringConverter::toString(cam->getDerivedPosition()) +152 " " + "O: " + StringConverter::toString(cam->getDerivedOrientation());153 LogManager::getSingleton().logMessage(d.str());154 155 // prevent from initialising array again156 if (i > 0)157 mWasInitialised = true;158 159 // compute camera visibility for this direction160 ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility);161 162 //mViewport->getTarget()->update(); for(int j=0; j<10000000; j++) printf("wait"); // HACK: DISPLAY CAMERA VIEW163 164 // --- permute directions165 Vector3 dir(0,0,0);166 dir[i/2] = sign;167 168 cam->setDirection(dir);169 }170 171 // reset camera172 mViewport->setCamera(savedCam);173 }174 175 118 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r139 r154 55 55 } 56 56 //----------------------------------------------------------------------- 57 void OctreeHierarchyInterface::SetNumOctreeNodes(unsigned int num)58 {59 mNumOctreeNodes = num;60 }61 //-----------------------------------------------------------------------62 57 float OctreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 63 58 { … … 173 168 SceneNodeHierarchyInterface::GetGeometry(*nodeIt, geometryList, includeChildren); 174 169 } 170 } 171 //----------------------------------------------------------------------- 172 void OctreeHierarchyInterface::SetNodeId(GtpVisibility::HierarchyNode *node, int id) 173 { 174 static_cast<Octree *>(node)->setId(id); 175 } 176 //----------------------------------------------------------------------- 177 int OctreeHierarchyInterface::GetNodeId(GtpVisibility::HierarchyNode *node) 178 { 179 return static_cast<Octree *>(node)->getId(); 175 180 } 176 181 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
r153 r154 10 10 //----------------------------------------------------------------------- 11 11 PlatformQueryManager::PlatformQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp): 12 QueryManager(hierarchyInterface), mViewport(vp) 12 QueryManager(hierarchyInterface), mViewport(vp), mWasInitialised(false) 13 13 { 14 14 } … … 18 18 // run OGRE ray shooting query 19 19 return false; 20 }21 //-----------------------------------------------------------------------22 void PlatformQueryManager::ComputeCameraVisibility(const Camera &camera,23 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes,24 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,25 bool relativeVisibility)26 {27 // we need access to the scene manager and the rendersystem28 PlatformHierarchyInterface *pfHierarchyInterface =29 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface);30 31 //-- Render scene to get conservative visibility and fill depth buffer32 33 // const_cast allowed because camera is not changed in renderScene34 Camera *pCam = const_cast<Camera *>(&camera);35 36 // disable overlays, reset them later37 bool overlayEnabled = mViewport->getOverlaysEnabled();38 mViewport->setOverlaysEnabled(false);39 40 //-- render the scene once to update depth buffer41 pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false);42 43 /*44 Two query lists for projected pixels and for visibile pixels:45 We test queries after a rendering pass46 to get exact visibility with regard to the current camera.47 We issue all queries at once to avoid starvation & stalls.48 */49 GtpVisibility::QueryList queryList[2];50 51 // get rendered hierarchy nodes52 GtpVisibility::HierarchyNodeList *nodeList = mHierarchyInterface->GetRenderedNodes();53 // vector for storing entities of meshes54 GtpVisibility::GeometryList geometryList;55 56 GtpVisibility::HierarchyNodeList::iterator nodeIt, nodeIt_end = nodeList->end();57 // geometry list has still do be built58 GtpVisibility::GeometryList::iterator geometryIt, geometryIt_end;59 60 // to obtain the correct number of projected pixels, depth write must be disabled61 bool enableDepthWrite = false;62 63 // this option must be provided by the scene manager64 pfHierarchyInterface->GetSceneManager()->setOption("DepthWrite", &enableDepthWrite);65 66 /* relative visiblity:67 1) get visible pixels count of objects68 2) clear frame buffer69 3) get projected visible pixels count:70 test all objects again without depth write (set as option in scene manager)71 4) calculate ratio between visible vs. projected pixels72 */73 // for relative visibility we need 2 rendering passes74 int n = relativeVisibility ? 2 : 1;75 76 for (int i=0; i<n; ++i)77 {78 //-- queries for hierarchy nodes79 for (nodeIt = nodeList->begin(); nodeIt != nodeIt_end; ++nodeIt)80 {81 // TODO: DELETE QUERIES FROM PREVIOUS RENDER82 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(*nodeIt, false));83 84 // store geometry of the hierarchy node in a geometry list (only once!)85 if (i == 0)86 {87 mHierarchyInterface->GetGeometry(*nodeIt, &geometryList, false);88 }89 }90 91 geometryIt_end = geometryList.end();92 93 //-- add queries for geometry94 for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt)95 {96 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(*geometryIt));97 }98 99 100 pfHierarchyInterface->GetRenderSystem()->clearFrameBuffer(FBT_DEPTH);101 }102 103 enableDepthWrite = true;104 // this option must be provided by the scene manager105 pfHierarchyInterface->GetSceneManager()->setOption("DepthWrite", &enableDepthWrite);106 // reset old overlay status107 mViewport->setOverlaysEnabled(overlayEnabled);108 109 //---- collect results110 GtpVisibility::QueryList::iterator visQueryIt, projQueryIt;111 112 visQueryIt = queryList[0].begin();113 projQueryIt = queryList[1].begin();114 115 116 for (nodeIt = nodeList->begin(); nodeIt != nodeIt_end; ++nodeIt)117 {118 unsigned int visiblePixels = 0;119 (*visQueryIt)->GetQueryResult(visiblePixels, true);120 121 unsigned int projectedPixels = 0;122 123 if (relativeVisibility)124 {125 (*projQueryIt)->GetQueryResult(projectedPixels, true);126 127 ++projQueryIt;128 }129 130 ++visQueryIt;131 132 // node with visibilty 0 in queue (e.g., if node is intersected by near plane)133 if (visiblePixels > 0)134 {135 visibleNodes->push_back(GtpVisibility::NodeInfo(*nodeIt, visiblePixels, projectedPixels));136 }137 }138 139 //---- queries for geometry140 geometryIt_end = geometryList.end();141 142 for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt)143 {144 unsigned int visiblePixels = 0;145 (*visQueryIt)->GetQueryResult(visiblePixels, true);146 147 unsigned int projectedPixels = 0;148 149 if (relativeVisibility)150 {151 (*projQueryIt)->GetQueryResult(projectedPixels, true);152 153 ++projQueryIt;154 }155 156 ++visQueryIt;157 158 // approximate depth ordering during rendering =>159 // geometry maybe occluded160 if (visiblePixels > 0)161 {162 visibleGeometry->push_back(GtpVisibility::MeshInfo(*geometryIt, visiblePixels,163 projectedPixels));164 }165 }166 167 }168 //-----------------------------------------------------------------------169 inline bool nodeinfo_eq(const GtpVisibility::NodeInfo &info1, const GtpVisibility::NodeInfo &info2)170 {171 return info1.GetNode() == info2.GetNode();172 }173 //-----------------------------------------------------------------------174 inline bool meshinfo_eq(const GtpVisibility::MeshInfo &info1, const GtpVisibility::MeshInfo &info2)175 {176 return info1.GetMesh() == info2.GetMesh();177 }178 //-----------------------------------------------------------------------179 inline bool nodeinfo_lower(const GtpVisibility::NodeInfo &info1, const GtpVisibility::NodeInfo &info2)180 {181 return info1.GetNode() < info2.GetNode();182 }183 //-----------------------------------------------------------------------184 inline bool meshinfo_lower(const GtpVisibility::MeshInfo &info1, const GtpVisibility::MeshInfo &info2)185 {186 return info1.GetMesh() < info2.GetMesh();187 20 } 188 21 //----------------------------------------------------------------------- … … 222 55 LogManager::getSingleton().logMessage(d.str()); 223 56 57 // prevent from initialising geometry / node array again 58 if (i > 0) 59 mWasInitialised = true; 60 224 61 ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility); 225 62 … … 235 72 // reset camera 236 73 mViewport->setCamera(savedCam); 237 238 // --- remove duplicates (duplicates occur if an object is on the edge of the viewport)239 240 // before duplicates can be deleted we have to add up their visibility241 242 // --- visible nodes243 sort(visibleNodes->begin(), visibleNodes->end(), nodeinfo_lower);244 InfoContainer<GtpVisibility::NodeInfo>::iterator visibleNodesIt,245 visibleNodesIt_end = visibleNodes->end();246 247 GtpVisibility::NodeInfo *nodeInfo = NULL;248 249 for (visibleNodesIt = visibleNodes->begin(); visibleNodesIt != visibleNodesIt_end;250 ++visibleNodesIt)251 {252 if (!nodeInfo || (nodeInfo->GetNode() != (*visibleNodesIt).GetNode()))253 {254 nodeInfo = &(*visibleNodesIt);255 }256 else // add visibility257 {258 nodeInfo->AddVisibility(*visibleNodesIt);259 }260 261 }262 263 // physically delete duplicates264 visibleNodes->erase( std::unique(visibleNodes->begin(),265 visibleNodes->end(), nodeinfo_eq), visibleNodes->end());266 267 // --- visible geometry268 sort(visibleGeometry->begin(), visibleGeometry->end(), meshinfo_lower);269 InfoContainer<GtpVisibility::MeshInfo>::iterator visibleGeomIt,270 visibleGeomIt_end = visibleGeometry->end();271 272 GtpVisibility::MeshInfo *geomInfo = NULL;273 274 int i=0;275 for (visibleGeomIt = visibleGeometry->begin(); visibleGeomIt != visibleGeomIt_end;276 ++visibleGeomIt)277 {278 if (!geomInfo || (geomInfo->GetMesh() != (*visibleGeomIt).GetMesh()))279 {280 geomInfo = &(*visibleGeomIt);281 }282 else // info points to same mesh, just add visibility283 {284 geomInfo->AddVisibility(*visibleGeomIt);285 }286 }287 288 // physically delete duplicates289 visibleGeometry->erase(std::unique(visibleGeometry->begin(), visibleGeometry->end(),290 meshinfo_eq), visibleGeometry->end());291 292 74 } 293 75 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r139 r154 147 147 MovableObject *movable = objIt.getNext(); 148 148 149 // we are interested only in the entities, i.e., in tances of geometry149 // we are interested only in the entities, i.e., instances of geometry 150 150 if (movable->getMovableType() == "Entity") 151 151 { … … 156 156 } 157 157 } 158 //----------------------------------------------------------------------- 159 void SceneNodeHierarchyInterface::SetNodeId(GtpVisibility::HierarchyNode *node, int id) 160 { 161 static_cast<SceneNode *>(node)->setId(id); 162 } 163 //----------------------------------------------------------------------- 164 int SceneNodeHierarchyInterface::GetNodeId(GtpVisibility::HierarchyNode *node) 165 { 166 return static_cast<SceneNode *>(node)->getId(); 167 } 158 168 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r139 r154 259 259 mHierarchyInterface->SetRenderSystem(mDestRenderSystem); 260 260 261 #ifdef GTP_VISIBILITY_MODIFIED_OGRE262 mHierarchyInterface->SetNumOctreeNodes(mNumOctreeNodes);263 #endif264 261 OctreeSceneManager::_updateSceneGraph(cam); 265 262 } -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r153 r154 24 24 mUseDepthPass(false), 25 25 mRenderDepthPass(false), 26 //mUseItemBuffer(false),27 mUseItemBuffer(true),26 mUseItemBuffer(false), 27 //mUseItemBuffer(true), 28 28 mRenderItemBuffer(false), 29 mCurrentEntityId( 0),29 mCurrentEntityId(1), 30 30 mEnableDepthWrite(true), 31 31 mSkipTransparents(false), … … 327 327 328 328 // set the new render level index afterwards => new level in the next frame 329 int levelIdx = (TerrainRenderable::getCurrentRenderLevelIndex() + 1) % 10;329 int levelIdx = TerrainRenderable::getCurrentRenderLevelIndex() + 1; 330 330 TerrainRenderable::setCurrentRenderLevelIndex(levelIdx); 331 331 … … 343 343 mHierarchyInterface->SetRenderSystem(mDestRenderSystem); 344 344 345 #ifdef GTP_VISIBILITY_MODIFIED_OGRE346 mHierarchyInterface->SetNumOctreeNodes(mNumOctreeNodes);347 #endif348 345 TerrainSceneManager::_updateSceneGraph(cam); 349 346 } … … 567 564 int col[4]; 568 565 566 // -- create color code out of object id 569 567 col[0] = (rend->getId() >> 16) & 255; 570 568 col[1] = (rend->getId() >> 8) & 255; … … 599 597 600 598 Pass *usedPass = setPass(mItemBufferPass); 601 //Pass *usedPass = setPass(pass); 602 603 if (rend->getId() > 0) 599 600 /*if (rend->getId() > 0) 604 601 { 605 602 std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col[0] << 606 603 " " << col[1] << " " << col[2] << " " << col[3]; 607 604 LogManager::getSingleton().logMessage(d.str()); 608 } 605 }*/ 609 606 610 607 // Render a single object, this will set up auto params if required 611 608 renderSingleObject(rend, usedPass, false, &nullLightList); 612 613 // reset colour614 //mDestRenderSystem->setColour(255, 255, 255, 255);615 609 } 616 610 //----------------------------------------------------------------------- … … 630 624 } 631 625 626 // increase counter of entity id values 632 627 ++ mCurrentEntityId; 633 628 -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r153 r154 9 9 #include "OgreVisibilityTerrainSceneManager.h" 10 10 #include "VisibilityInfo.h" 11 #include "OgreItemBufferQueryManager.h"; 11 #include "OgreItemBufferQueryManager.h" 12 #include "OgreOcclusionQueriesQueryManager.h" 13 14 15 16 12 17 // output file for frame info 13 18 const char* frames_out_filename = "frame.out"; … … 16 21 17 22 23 // --- captions for overlays 24 18 25 String currentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] = 19 26 { … … 23 30 }; 24 31 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" 32 String queryTypeCaptions[] = 33 { 34 "from camera", 35 "from viewpoint" 36 }; 37 38 String queryRelativeVisCaptions[] = 39 { 40 "visible pixels", 41 "relative visibility" 42 }; 43 44 String queryMethodCaptions[] = 45 { 46 "occlusion queries", 47 "item buffer" 31 48 }; 32 49 … … 360 377 } 361 378 //----------------------------------------------------------------------- 362 void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility) 379 void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility, 380 bool useItemBuffer) 363 381 { 364 382 // TODO: change this (does not work with other scene manager plugins) 365 VisibilityTerrainSceneManager *sm = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr); 366 367 mQueryManager = new ItemBufferQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0)); 368 //mQueryManager = new PlatformQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0)); 383 VisibilityTerrainSceneManager *sm = 384 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr); 385 386 if (useItemBuffer) 387 { 388 mQueryManager = new ItemBufferQueryManager(sm->GetHierarchyInterface(), 389 mWindow->getViewport(0)); 390 } 391 else 392 { 393 mQueryManager = new OcclusionQueriesQueryManager(sm->GetHierarchyInterface(), 394 mWindow->getViewport(0)); 395 } 369 396 370 397 sm->GetVisibilityManager()->SetQueryManager(mQueryManager); … … 403 430 ++geomSize; 404 431 405 std::stringstream d; d << "Geometry visibility: " << vis;432 std::stringstream d; d << "Geometry " << geomSize << " visibility: " << vis; 406 433 LogManager::getSingleton().logMessage(d.str()); 407 434 } … … 431 458 averageGeometryVis /= (float)geomSize; 432 459 433 char str[100];434 435 460 //-- update visibility queries stats 436 461 try 437 462 { 438 //-- visibility queries stats 439 int idx = fromPoint ? 1 : 0; 440 idx += relativeVisibility ? 2 : 0; 441 442 sprintf(str, ": %s", queryTypeCaptions[idx].c_str()); 463 char str[100]; 464 465 sprintf(str, ": %s, %s, %s", 466 queryTypeCaptions[fromPoint ? 1 : 0].c_str(), 467 queryRelativeVisCaptions[relativeVisibility ? 1 : 0].c_str(), 468 queryMethodCaptions[useItemBuffer ? 1 : 0].c_str()); 469 443 470 mQueryTypeInfo->setCaption(str); 444 471 … … 912 939 break; 913 940 case KC_F5: 914 ApplyVisibilityQuery(false, mShiftPressed );941 ApplyVisibilityQuery(false, mShiftPressed, false); 915 942 break; 916 943 case KC_F6: 917 ApplyVisibilityQuery(true, mShiftPressed); 918 break; 919 944 ApplyVisibilityQuery(true, mShiftPressed, false); 945 break; 946 case KC_F7: 947 ApplyVisibilityQuery(false, mShiftPressed, true); 948 break; 949 case KC_F8: 950 ApplyVisibilityQuery(true, mShiftPressed, true); 951 break; 920 952 case KC_F11: 921 953 takeScreenShot(); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r151 r154 117 117 /** Applies visibility query. Collects the visible objects 118 118 and their visibility information. 119 @param fromnPoint if query should be from point or from camera 120 @param projectedPixels if query should return number of visible pixels or the ratio 121 visible pixels / projected pixels. 119 @param fromPoint if query should be from point or from camera 120 @param relativeVisibility if query should return number of visible pixels or 121 the ratio visible / projected pixels. 122 @param useItemBuffer if item buffer should be used or occlusion queries 122 123 */ 123 void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility );124 void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility, bool useItemBuffer); 124 125 125 126 void toggleShowQueryStats(); -
trunk/VUT/work/ogre_changes/OgreMain/include/OgreSceneNode.h
r61 r154 444 444 void setLastRendered(int frameid); 445 445 446 /** Sets scene node id 447 @param the id 448 */ 449 void setId(int id); 450 /** see set */ 451 int getId(void); 452 446 453 protected: 447 454 int mLastVisited; 448 455 bool mVisible; 449 456 int mLastRendered; 450 457 int mId; 451 458 #endif //GTP_VISIBILITY_MODIFIED_OGRE 452 459 -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneNode.cpp
r61 r154 42 42 mYawFixed(false), mAutoTrackTarget(0), mIsInSceneGraph(false) 43 43 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 44 , mLastVisited(0), mVisible(false), mLastRendered(-1) 44 , mLastVisited(0), mVisible(false), mLastRendered(-1), mId(-1) 45 45 #endif //GTP_VISIBILITY_MODIFIED_OGRE 46 46 { … … 53 53 mAutoTrackTarget(0), mIsInSceneGraph(false) 54 54 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 55 , mLastVisited(0), mVisible(false) 55 , mLastVisited(0), mVisible(false), mId(-1) 56 56 #endif //GTP_VISIBILITY_MODIFIED_OGRE 57 57 { … … 641 641 mLastRendered = frameid; 642 642 } 643 //----------------------------------------------------------------------- 644 void SceneNode::setId(int id) 645 { 646 mId = id; 647 } 648 //----------------------------------------------------------------------- 649 int SceneNode::getId(void) 650 { 651 return mId; 652 } 643 653 #endif //GTP_VISIBILITY_MODIFIED_OGRE 644 654 } -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctree.h
r135 r154 192 192 void _updateBounds(); 193 193 194 /** Sets scene node id 195 @param the id 196 */ 197 void setId(int id); 198 199 /** see set */ 200 int getId(void); 201 194 202 protected: 195 203 … … 201 209 bool mVisible; 202 210 int mDepth; 211 int mId; 203 212 204 213 #endif // GTP_VISIBILITY_MODIFIED_OGRE -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h
r131 r154 47 47 48 48 #define MORPH_CUSTOM_PARAM_ID 77 49 50 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 51 #define MAX_RENDERLEVEL_INDEX 15 52 #endif // GTP_VISIBILITY_MODIFIED_OGRE 49 53 50 54 namespace Ogre … … 293 297 /// Get the static list of indexes cached (internal use only) 294 298 static TerrainBufferCache& _getIndexCache(void) {return msIndexCache;} 295 // index of renderlevel of current pass 296 static int getCurrentRenderLevelIndex() {return msCurrentRenderLevelIndex;} 297 static void setCurrentRenderLevelIndex(int index) {msCurrentRenderLevelIndex = index;} 299 300 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 301 // index of renderlevel used for current pass 302 static int getCurrentRenderLevelIndex(); 303 // returns index of renderlevel 304 static void setCurrentRenderLevelIndex(int index); 305 #endif // GTP_VISIBILITY_MODIFIED_OGRE 306 298 307 protected: 299 308 // index of renderlevel of current pass … … 355 364 VertexData* mTerrain; 356 365 357 /// The current LOD level: for multiple passes, up to 10 renderlevels can be saved 358 int mRenderLevel[10]; 366 /// The current LOD level 367 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 368 int mRenderLevel[MAX_RENDERLEVEL_INDEX]; 369 #else 370 int mRenderLevel; 371 #endif // GTP_VISIBILITY_MODIFIED_OGRE 372 359 373 /// The previous 'next' LOD level down, for frame coherency 360 374 int mLastNextLevel; -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
r139 r154 88 88 mHalfSize( 0, 0, 0 ) 89 89 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 90 , mLastVisited(0), mVisible(false), mLastRendered(-1) 90 , mLastVisited(0), mVisible(false), mLastRendered(-1), mId(-1) 91 91 #endif //GTP_VISIBILITY_MODIFIED_OGRE 92 92 { … … 271 271 } 272 272 } 273 //----------------------------------------------------------------------- 274 void Octree::setId(int id) 275 { 276 mId = id; 277 } 278 //----------------------------------------------------------------------- 279 int Octree::getId() 280 { 281 return mId; 282 } 273 283 #endif //GTP_VISIBILITY_MODIFIED_OGRE 274 284 } -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
r139 r154 318 318 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 319 319 mNumOctreeNodes = 1; 320 mOctree->setId(mNumOctreeNodes); 320 321 #endif // GTP_VISIBILITY_MODIFIED_OGRE 321 322 mMaxDepth = depth; … … 468 469 octant -> mChildren[ x ][ y ][ z ] = new Octree( octant ); 469 470 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 470 m NumOctreeNodes ++;471 mOctree->setId(++ mNumOctreeNodes); 471 472 #endif // GTP_VISIBILITY_MODIFIED_OGRE 472 473 … … 1032 1033 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 1033 1034 mNumOctreeNodes = 1; 1035 mOctree->setId(mNumOctreeNodes); 1034 1036 #endif // GTP_VISIBILITY_MODIFIED_OGRE 1035 1037 mOctree->mBox = box; -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp
r139 r154 58 58 bool TerrainRenderable::mLevelInit = false; 59 59 const TerrainOptions* TerrainRenderable::msOptions = 0; 60 61 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 60 62 int TerrainRenderable::msCurrentRenderLevelIndex = 0; 63 #endif // GTP_VISIBILITY_MODIFIED_OGRE 61 64 //----------------------------------------------------------------------- 62 65 //----------------------------------------------------------------------- … … 177 180 mInit = true; 178 181 179 //#ifdef GTP_VISIBILITY_MODIFIED_OGRE 180 // for up to 10 passes 181 for (int i = 0; i < 10; ++i) 182 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 183 for (int i = 0; i < MAX_RENDERLEVEL_INDEX; ++i) 182 184 { 183 185 mRenderLevel[i] = 1; 184 186 } 187 #else 188 mRenderLevel = 1; 189 #endif // GTP_VISIBILITY_MODIFIED_OGRE 185 190 186 191 mMinLevelDistSqr = new Real[ msOptions->maxGeoMipMapLevel ]; … … 330 335 if ( mForcedRenderLevel >= 0 ) 331 336 { 337 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 332 338 mRenderLevel[msCurrentRenderLevelIndex] = mForcedRenderLevel; 339 #else 340 mRenderLevel = mForcedRenderLevel; 341 #endif // GTP_VISIBILITY_MODIFIED_OGRE 333 342 return ; 334 343 } … … 339 348 Real L = diff.squaredLength(); 340 349 341 mRenderLevel[msCurrentRenderLevelIndex] = -1; 350 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 351 mRenderLevel[msCurrentRenderLevelIndex] = -1;; 352 #else 353 mRenderLevel = -1; 354 #endif // GTP_VISIBILITY_MODIFIED_OGRE 342 355 343 356 for ( int i = 0; i < msOptions->maxGeoMipMapLevel; i++ ) … … 345 358 if ( mMinLevelDistSqr[ i ] > L ) 346 359 { 360 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 347 361 mRenderLevel[msCurrentRenderLevelIndex] = i - 1; 362 #else 363 mRenderLevel = i - 1; 364 #endif // GTP_VISIBILITY_MODIFIED_OGRE 348 365 break; 349 366 } 350 367 } 351 368 369 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 352 370 if ( getRenderLevel() < 0 ) 353 371 mRenderLevel[msCurrentRenderLevelIndex] = msOptions->maxGeoMipMapLevel - 1; 372 #else 373 if ( mRenderLevel < 0 ) 374 mRenderLevel = msOptions->maxGeoMipMapLevel - 1; 375 #endif // GTP_VISIBILITY_MODIFIED_OGRE 354 376 355 377 if (msOptions->lodMorph) 356 378 { 357 379 // Get the next LOD level down 380 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 358 381 int nextLevel = mNextLevelDown[getRenderLevel()]; 382 #else 383 int nextLevel = mNextLevelDown; 384 #endif // GTP_VISIBILITY_MODIFIED_OGRE 385 359 386 if (nextLevel == 0) 360 387 { … … 668 695 void TerrainRenderable::_adjustRenderLevel( int i ) 669 696 { 670 697 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 671 698 mRenderLevel[msCurrentRenderLevelIndex] = i; 699 #else 700 mRenderLevel = i; 701 #endif // GTP_VISIBILITY_MODIFIED_OGRE 672 702 } 673 703 //----------------------------------------------------------------------- … … 1469 1499 1470 1500 } 1471 1501 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 1502 //----------------------------------------------------------------------- 1503 int TerrainRenderable::getCurrentRenderLevelIndex() 1504 { 1505 return msCurrentRenderLevelIndex; 1506 } 1507 //----------------------------------------------------------------------- 1508 void TerrainRenderable::setCurrentRenderLevelIndex(int index) 1509 { 1510 if (index > MAX_RENDERLEVEL_INDEX) 1511 index = 0; 1512 1513 msCurrentRenderLevelIndex = index; 1514 } 1515 #endif // GTP_VISIBILITY_MODIFIED_OGRE 1472 1516 1473 1517 } //namespace -
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h
r153 r154 311 311 312 312 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 313 uchar *getBufferContents(int &dimx, int &dimy) { return NULL; };313 uchar *getBufferContents(int &dimx, int &dimy) { dimx = dimy = 0; return NULL; }; 314 314 #endif // GTP_VISIBILITY_MODIFIED_OGRE 315 315
Note: See TracChangeset
for help on using the changeset viewer.