Changeset 2292 for GTP/trunk/Lib/Vis
- Timestamp:
- 03/26/07 18:49:17 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h
r2280 r2292 95 95 96 96 void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {} 97 void TraverseNode2(GtpVisibility::HierarchyNode *node) {}97 98 98 bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;} 99 99 100 GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *root) { return NULL;} 101 102 void CollectLeaves(GtpVisibility::HierarchyNode *root, 103 GtpVisibility::HierarchyNodeContainer &nodes) {}; 104 105 void RenderNodeRecursive(GtpVisibility::HierarchyNode *node) {}; 100 106 }; 101 107 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneNode.h
r2280 r2292 23 23 SceneNode(creator) {}; 24 24 25 BvHierarchySceneNode(SceneManager *creator, const String& name):25 BvHierarchySceneNode(SceneManager *creator, const String& name): 26 26 SceneNode(creator, name) {}; 27 27 28 ~BvHierarchySceneNode() {};28 ~BvHierarchySceneNode() {}; 29 29 30 // gather info for kd-tree creation 31 virtual void computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren = true); 30 // gather info for kd-tree creation 31 virtual void computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb, 32 int& nObjects, 33 bool includeChildren = true); 32 34 33 // add all contained objects to render queue34 virtual void queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters);35 // add all contained objects to render queue 36 virtual void queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters); 35 37 36 // place all entities in geometry queue (for CHC)37 virtual void getGeometryList(GeometryVector *geometryList);38 // place all entities in geometry queue (for CHC) 39 virtual void getGeometryList(GeometryVector *geometryList); 38 40 39 // return a bounding box enclosing all objects40 virtual AxisAlignedBox getBoundingBox(void) const;41 // return a bounding box enclosing all objects 42 virtual AxisAlignedBox getBoundingBox(void) const; 41 43 42 // DEBUG 43 String dumpToString(void); 44 // DEBUG 45 String dumpToString(void); 46 44 47 protected: 45 48 virtual void _updateBounds(void); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeHierarchyInterface.h
r2280 r2292 96 96 void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {} 97 97 98 void TraverseNode2(GtpVisibility::HierarchyNode *node) {}99 100 98 GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *root) { return NULL;} 101 99 102 100 bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;} 103 101 102 void CollectLeaves(GtpVisibility::HierarchyNode *root, 103 GtpVisibility::HierarchyNodeContainer &nodes) {}; 104 105 void RenderNodeRecursive(GtpVisibility::HierarchyNode *node) {}; 104 106 }; 105 107 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h
r2280 r2292 54 54 void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const; 55 55 56 void TraverseNode2(GtpVisibility::HierarchyNode *node);57 58 56 GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *node); 59 57 … … 62 60 void RenderNodeRecursive(GtpVisibility::HierarchyNode *node); 63 61 62 void CollectLeaves(GtpVisibility::HierarchyNode *root, 63 GtpVisibility::HierarchyNodeContainer &nodes); 64 64 65 65 protected: -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreSceneNodeHierarchyInterface.h
r2280 r2292 47 47 48 48 void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {} 49 void TraverseNode2(GtpVisibility::HierarchyNode *node) {} 49 50 50 GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *root) { return NULL;} 51 51 52 bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;} 52 53 54 void CollectLeaves(GtpVisibility::HierarchyNode *root, GtpVisibility::HierarchyNodeContainer &nodes) {}; 53 55 }; 54 56 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
r2287 r2292 1 1 #include "OgreOctreeHierarchyInterface.h" 2 //#include "OgreVisibilityOctreeSceneManager.h"3 2 #include <OgreOctree.h> 4 3 #include <OgreLogManager.h> … … 70 69 int z = i & 1; 71 70 72 //std::stringstream d; d << x << " " << y << " " << z;73 //Ogre::LogManager::getSingleton().logMessage(d.str());74 75 71 if ((child = octree->mChildren[x][y][z]) != NULL) 76 72 { … … 78 74 } 79 75 } 80 81 //std::stringstream str; str << "nodes: " << nodes.size();82 //Ogre::LogManager::getSingleton().logMessage(str.str());83 76 84 77 if (nodes.empty()) … … 87 80 int r = (int)(((float)rand() / RAND_MAX) * ((float)nodes.size() - 0.5f)); 88 81 89 //std::stringstream str2;90 //str2 << "rand: " << r;91 //Ogre::LogManager::getSingleton().logMessage(str2.str());92 93 82 return GetRandomLeaf(nodes[r]); 94 // assume that at least one child is not NULL ...95 /*while (!child)96 {97 int mask = (int) (rand() * 8.0f);98 child = octree->mChildren[(mask & 4) / 4][(mask & 2) / 2][mask & 1];99 }100 101 return GetRandomLeaf(child);*/102 }103 //-----------------------------------------------------------------------104 void OctreeHierarchyInterface::TraverseNode2(GtpVisibility::HierarchyNode *node)105 {106 ++ mNumTraversedNodes;107 108 Octree *octree = static_cast<Octree *>(node);109 110 // if we come across some renderable geometry => render it111 //if (!octree->mNodes.empty())112 //{113 RenderNodeRecursive(node);114 //}115 116 /*117 // render everything from here118 if (octree->isOctreeFullyVisible())119 {120 RenderNodeRecursive(node);121 return;122 }123 124 RenderNode(node);125 }126 127 // if not all subtrees are empty128 if (!IsLeaf(node))129 {130 Octree *nextChild;131 132 if ((nextChild = octree->mChildren[0][0][0]) != NULL)133 mDistanceQueue->push(nextChild);134 if ((nextChild = octree->mChildren[0][0][1]) != NULL)135 mDistanceQueue->push(nextChild);136 if ((nextChild = octree->mChildren[0][1][0]) != NULL)137 mDistanceQueue->push(nextChild);138 if ((nextChild = octree->mChildren[0][1][1]) != NULL)139 mDistanceQueue->push(nextChild);140 if ((nextChild = octree->mChildren[1][0][0]) != NULL)141 mDistanceQueue->push(nextChild);142 if ((nextChild = octree->mChildren[1][0][1]) != NULL)143 mDistanceQueue->push(nextChild);144 if ((nextChild = octree->mChildren[1][1][0]) != NULL)145 mDistanceQueue->push(nextChild);146 if ((nextChild = octree->mChildren[1][1][1]) != NULL)147 mDistanceQueue->push(nextChild);148 }149 */150 83 } 151 84 //----------------------------------------------------------------------- … … 168 101 const Vector3 bmax = static_cast<Octree *>(node)->mBox.getMaximum(); 169 102 170 const Vector3 pos = (bmax - bmin) * 0.5 + bmin; 171 172 /* std::stringstream d; 173 d << "a: " << (mCameraPosition - pos).squaredLength() 174 << " b: " << (mCullCamera->getDerivedPosition() - pos).squaredLength(); 175 LogManager::getSingleton().logMessage(d.str());*/ 103 const Vector3 pos = (bmax - bmin) * 0.5f + bmin; 104 176 105 return (mCameraPosition - pos).squaredLength(); 177 106 } … … 206 135 } 207 136 //----------------------------------------------------------------------- 208 void OctreeHierarchyInterface::DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const137 /*void OctreeHierarchyInterface::PullUpFullVisibility(GtpVisibility::HierarchyNode *node) const 209 138 { 210 Octree *octant = static_cast<Octree *>(node); 211 212 // leaf node: terminate recursion 213 if (IsLeaf(node)) 214 { 215 octant->setOctreeFullyVisible(octant->isOctreeVisible()); 216 217 return; 218 } 219 220 octant->setOctreeFullyVisible(true); 221 222 Octree *nextChild; 223 139 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 140 Octree *octant = static_cast<Octree *>(node); 141 224 142 for (int i = 0; i < 8; ++ i) 225 143 { … … 228 146 int z = i & 1; 229 147 230 148 if ((nextChild = octant->mChildren[x][y][z]) != NULL) 231 149 { 232 150 DetermineFullVisibility(nextChild); … … 236 154 } 237 155 } 156 157 while (octant && !octant->isOctreeVisible()) 158 { 159 octant->setOctreeVisible(true); 160 octant = octant->getParent(); 161 } 162 #endif 163 }*/ 164 //----------------------------------------------------------------------- 165 void OctreeHierarchyInterface::DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const 166 { 167 Octree *octant = static_cast<Octree *>(node); 168 169 // leaf node: terminate recursion 170 if (IsLeaf(node)) 171 { 172 octant->setOctreeFullyVisible(octant->isOctreeVisible()); 173 return; 174 } 175 176 octant->setOctreeFullyVisible(true); 177 178 Octree *nextChild; 179 180 for (int i = 0; i < 8; ++ i) 181 { 182 int x = (i & 4) / 4; 183 int y = (i & 2) / 2; 184 int z = i & 1; 185 186 if ((nextChild = octant->mChildren[x][y][z]) != NULL) 187 { 188 DetermineFullVisibility(nextChild); 189 // this leaf is not fully visible => break 190 if (!nextChild->isOctreeFullyVisible()) 191 octant->setOctreeFullyVisible(false); 192 } 193 } 238 194 } 239 195 //----------------------------------------------------------------------- … … 264 220 Octree *octant = static_cast<Octree *>(node); 265 221 266 if ( 1)//octant->lastRendered() != mFrameId)222 if (octant->lastRendered() != mFrameId) 267 223 { 268 224 octant->setLastRendered(mFrameId); … … 351 307 } 352 308 } 309 //----------------------------------------------------------------------- 310 void OctreeHierarchyInterface::CollectLeaves(GtpVisibility::HierarchyNode *root, 311 GtpVisibility::HierarchyNodeContainer &nodes) 312 { 313 std::stack<GtpVisibility::HierarchyNode *> tStack; 314 tStack.push(root); 315 316 Octree *child; 317 318 while (!tStack.empty()) 319 { 320 GtpVisibility::HierarchyNode *node = tStack.top(); 321 tStack.pop(); 322 323 if (IsLeaf(node)) 324 { 325 nodes.push_back(node); 326 } 327 else 328 { 329 Octree *octree = static_cast<Octree *>(node); 330 331 for (int i = 0; i < 8; ++ i) 332 { 333 int x = (i & 4) / 4; 334 int y = (i & 2) / 2; 335 int z = i & 1; 336 337 if ((child = octree->mChildren[x][y][z]) != NULL) 338 { 339 tStack.push(child); 340 } 341 } 342 } 343 } 344 } 353 345 354 346 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
r2280 r2292 322 322 AdditionalLibraryDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\Release";"$(OGRE_PATH)\OgreMain\lib\Release";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;"$(OGRE_PATH)\Dependencies\lib\Release";..\..\..\Preprocessing\lib\Release;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;"$(CG_LIB_PATH)";..\..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\Lib\Vis\Preprocessing\MultiLevelRayTracing\RTWorld\Release;..\..\..\..\..\Lib\Vis\Preprocessing\MultiLevelRayTracing\RTScene\Release;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\Release;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\lib\Release" 323 323 ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def" 324 GenerateDebugInformation=" FALSE"324 GenerateDebugInformation="TRUE" 325 325 SubSystem="2" 326 326 OptimizeReferences="2" -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h
r2280 r2292 19 19 typedef std::queue<PendingQuery> PendingQueue; 20 20 21 typedef std::vector<HierarchyNode *> HierarchyNodeContainer; 21 22 22 /** Class which implements a hierarchy interface for a scene hierarchy. It has to be implemented 23 for any rendering engine to use the CHC algorithm. 23 24 /** Class which implements an interface for the operations on a hierarchy 25 of a scene. 26 It has to be implemented for any rendering engine to use the CHC algorithm. 24 27 */ 25 28 class HierarchyInterface … … 153 156 virtual void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const = 0; 154 157 155 virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) = 0;156 157 158 virtual HierarchyNode *GetRandomLeaf(HierarchyNode *root) = 0; 158 159 virtual bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const = 0; 160 161 virtual void CollectLeaves(HierarchyNode *root, HierarchyNodeContainer &nodes) = 0; 162 163 virtual void RenderNodeRecursive(HierarchyNode *node) = 0; 159 164 160 165 protected: -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp
r2289 r2292 11 11 SetAssumedVisibility(0); 12 12 // initialise random generator in case we use assumed visibility 13 srand(time(NULL));13 //srand(time(NULL)); 14 14 } 15 15 //----------------------------------------------------------------------- … … 19 19 SetAssumedVisibility(assumedVisibility); 20 20 // initialise random generator in case we use assumed visibility 21 srand(time(NULL));21 //srand(time(NULL)); 22 22 } 23 23 //----------------------------------------------------------------------- 24 24 void CoherentHierarchicalCullingManager::RenderScene() 25 25 { 26 CullingLogManager::GetSingleton()->LogMessage("chc");26 if (0) CullingLogManager::GetSingleton()->LogMessage("chc"); 27 27 QueryQueue queryQueue; 28 28 unsigned int visiblePixels = 0; … … 158 158 inline void CoherentHierarchicalCullingManager::SkipQuery(HierarchyNode *node) const 159 159 { 160 // 160 //-- set node to be visible in this frame, then traverse it 161 161 mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 162 162 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp
r2289 r2292 8 8 void FrustumCullingManager::RenderScene() 9 9 { 10 CullingLogManager::GetSingleton()->LogMessage("vfc");10 if (0) CullingLogManager::GetSingleton()->LogMessage("vfc"); 11 11 12 12 while (!mHierarchyInterface->GetQueue()->empty()) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp
r2289 r2292 2 2 #include <time.h> 3 3 #include "CullingLogManager.h" 4 #include <vector> 5 //#include <iostream> 6 #include <sstream> 7 8 9 using namespace std; 4 10 5 11 … … 12 18 SetAssumedVisibility(0); 13 19 // initialise random generator in case we use assumed visibility 14 srand(time(NULL));20 //srand(time(NULL)); 15 21 16 22 mRandomCandidates = R_CANDIDATES; … … 22 28 SetAssumedVisibility(assumedVisibility); 23 29 // initialise random generator in case we use assumed visibility 24 srand(time(NULL));30 //srand(time(NULL)); 25 31 26 32 mRandomCandidates = R_CANDIDATES; … … 29 35 void RandomUpdateCullingManager::RenderScene() 30 36 { 31 CullingLogManager::GetSingleton()->LogMessage("ruc");37 if (0) CullingLogManager::GetSingleton()->LogMessage("ruc"); 32 38 33 39 QueryQueue queryQueue; … … 37 43 //-- PART 1: process finished occlusion queries 38 44 39 // update the fully visible classifications40 mHierarchyInterface->DetermineFullVisibility(mHierarchyInterface->GetHierarchyRoot());41 42 //mHierarchyInterface->TraverseNode2(mHierarchyInterface->GetHierarchyRoot());43 44 #if 145 45 while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) 46 46 { … … 121 121 if (mHierarchyInterface->IsNodeFullyVisible(node)) 122 122 { 123 #if 1 123 124 // node fully visible => test only random leaves 124 125 for (int i = 0; i < mRandomCandidates; ++ i) … … 138 139 mHierarchyInterface->IssueNodeOcclusionQuery(node))); 139 140 } 140 141 mHierarchyInterface->TraverseNode2(node); 141 #else 142 // test all leaves for visibility changes 143 HierarchyNodeContainer mynodes; 144 mHierarchyInterface->CollectLeaves(node, mynodes); 145 146 HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 147 148 for (nit = mynodes.begin(); nit != nit_end; ++ nit) 149 { 150 HierarchyNode *leaf = *nit; 151 mHierarchyInterface->SetNodeVisible(leaf, false); 152 153 // update node's visited flag 154 mHierarchyInterface->SetLastVisited(leaf, mHierarchyInterface->GetFrameId()); 155 156 queryQueue.push(QueryPair(leaf, 157 mHierarchyInterface->IssueNodeOcclusionQuery(node))); 158 } 159 #endif 160 mHierarchyInterface->RenderNodeRecursive(node); 142 161 143 162 continue; … … 173 192 } 174 193 } 175 #endif 194 176 195 //while (!mHierarchyInterface->GetQueue()->empty()) 177 196 // mHierarchyInterface->GetQueue()->pop(); 178 197 198 // update the fully visible classifications 199 // TODO: this should be done during traversal! 200 mHierarchyInterface->DetermineFullVisibility(mHierarchyInterface->GetHierarchyRoot()); 179 201 } 180 202 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/StopAndWaitCullingManager.cpp
r2289 r2292 7 7 void StopAndWaitCullingManager::RenderScene() 8 8 { 9 CullingLogManager::GetSingleton()->LogMessage("swc");9 if (0) CullingLogManager::GetSingleton()->LogMessage("swc"); 10 10 11 11 while (!mHierarchyInterface->GetQueue()->empty())
Note: See TracChangeset
for help on using the changeset viewer.