Changeset 1173 for GTP/trunk/Lib/Vis
- Timestamp:
- 07/31/06 17:34:56 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdRenderable.h
r1163 r1173 12 12 13 13 #include "OgreKdTree.h" 14 #include "HierarchyInterface.h" 14 15 15 16 namespace Ogre … … 33 34 // put all objects this element holds in the renedering queue 34 35 virtual void queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters) = 0; 36 37 // place all entities in geometry queue (for CHC) 38 virtual void getGeometryList(GtpVisibility::GeometryVector *geometryList) = 0; 35 39 36 40 // return a bounding box enclosing all objects -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h
r1170 r1173 27 27 #include <stack> 28 28 29 //#include "OgreKdTreeHierarchyInterface.h"30 29 31 30 … … 264 263 */ 265 264 bool isNodeVisible(void) { return mVisible; }; 266 /** Gets this node's parent (NULL if this is the root).267 */268 KdTree::Node *getParent(void) { return mParent; };269 265 /** Frame id when this octree was last rendered. 270 266 @return last rendered frame id … … 275 271 */ 276 272 void setLastRendered(unsigned int frameid) { mLastRendered = frameid; }; 277 278 /* do we need this? */ 279 /** Returns real extent of the octree, i.e., the merged extent of the bounding boxes. 273 /** Gets this node's parent (NULL if this is the root). 274 */ 275 KdTree::Branch *getParent(void) { return mParent; }; 276 /** Returns real extent of the kdtree, i.e., the merged extent of the bounding boxes. 280 277 */ 281 //AxisAlignedBox _getWorldAABB(void) const = 0; 278 AxisAlignedBox _getWorldAABB(void) const { return mWorldAABB; }; 279 /** Updates bound of the real aabb of kdtree 280 */ 281 virtual void _updateBounds() = 0; 282 282 283 283 … … 290 290 // for the CHC hierarchy interface 291 291 /** the real extent of the node. */ 292 //AxisAlignedBox mWorldAABB;293 292 AxisAlignedBox mWorldAABB; 293 294 294 unsigned int mLastRendered; 295 295 unsigned int mLastVisited; … … 323 323 // a branch never has geometry 324 324 virtual bool hasGeometry() const { return false; }; 325 326 // branches do not posses geometry => just merge child aabbs 327 virtual void _updateBounds() 328 { 329 // reset box 330 mWorldAABB.setNull(); 331 332 if (mLeft) 333 mWorldAABB.merge(mLeft->_getWorldAABB()); 334 if (mRight) 335 mWorldAABB.merge(mRight->_getWorldAABB()); 336 337 // update parent recursively 338 if (mParent) 339 mParent->_updateBounds(); 340 } 325 341 326 342 Node * mLeft; … … 347 363 // a leaf has geometry when it has renderables 348 364 virtual bool hasGeometry() const { return !mKdRenderables.empty(); }; 365 366 // update the world aabb based on the contained geometry 367 virtual void _updateBounds(); 349 368 350 369 virtual void remove(KdRenderable * rend) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h
r1170 r1173 28 28 public: 29 29 KdTreeSceneManager(const String& name, GtpVisibility::VisibilityManager *vm); 30 //KdTreeSceneManager(const String& name, int maxdepth);31 30 ~KdTreeSceneManager(void); 32 31 … … 34 33 virtual SceneNode* createSceneNode(void); 35 34 virtual SceneNode* createSceneNode(const String& name); 36 void init( int maxdepth );37 void walkTree(KdTree * node, Camera *cam);38 35 39 36 virtual void _findVisibleObjects(Camera *cam, bool onlyShadowCasters); 37 38 virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam, 39 bool onlyShadowCasters, int leavePassesInQueue); 40 40 41 41 virtual void setShowBoxes(bool showboxes); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneNode.h
r1163 r1173 37 37 virtual void queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters); 38 38 39 // place all entities in geometry queue (for CHC) 40 virtual void getGeometryList(GtpVisibility::GeometryVector *geometryList); 41 39 42 // return a bounding box enclosing all objects 40 43 virtual AxisAlignedBox getBoundingBox() const; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
r1170 r1173 1496 1496 mKdRenderables.clear(); 1497 1497 } 1498 } 1498 1499 // update the world aabb based on the contained geometry 1500 void KdTree::Leaf::_updateBounds() 1501 { 1502 // reset box 1503 mWorldAABB.setNull(); 1504 1505 // merge boxes from attached geometry 1506 KdRenderableList::iterator it = mKdRenderables.begin(); 1507 KdRenderableList::iterator end = mKdRenderables.end(); 1508 while (it != end) 1509 { 1510 mWorldAABB.merge((*it)->getBoundingBox()); 1511 it++; 1512 } 1513 1514 // update parent recursively 1515 if (mParent) 1516 mParent->_updateBounds(); 1517 } 1518 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeHierarchyInterface.cpp
r1170 r1173 8 8 */ 9 9 10 #include "OgreKdRenderable.h" 10 11 #include "OgreKdTreeSceneManager.h" 11 12 #include "OgreKdTreeHierarchyInterface.h" … … 51 52 void KdTreeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node) 52 53 { 53 /*** TODO ***/ 54 KdTree::Node * kdnode = KDNODEPTR_CAST(node); 55 if (kdnode->lastRendered() != mFrameId) 56 { 57 kdnode->setLastRendered(mFrameId); 58 KdTreeSceneManager * ksm = static_cast<KdTreeSceneManager *>(mSceneManager); 59 60 // render only if the node is a leaf 61 if (kdnode->isLeaf()) 62 { 63 ksm->_renderNodes(KDLEAFPTR_CAST(node)->mKdRenderables, mCamera, 64 mOnlyShadowCasters, mLeavePassesInQueue); 65 } 66 67 mVisibleNodes.push_back(node); 68 } 54 69 } 55 70 56 71 void KdTreeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 57 72 { 58 /*** TODO ***/ 73 KdTree::Node * kdnode = KDNODEPTR_CAST(node); 74 75 while (kdnode && !kdnode->isNodeVisible()) 76 { 77 kdnode->setNodeVisible(true); 78 kdnode = kdnode->getParent(); 79 } 59 80 } 60 81 61 82 float KdTreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 62 83 { 63 /*** TODO ***/64 return 0.0;84 const Vector3 pos = KDNODEPTR_CAST(node)->mAABB.getCenter(); 85 return (mCameraPosition - pos).squaredLength(); 65 86 } 66 87 67 88 AxisAlignedBox * KdTreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 68 89 { 69 /*** TODO ***/ 70 return new AxisAlignedBox(); 90 // reuse box if node is the same 91 // only create renderable bounding box for new node 92 if (node != mSavedNode) 93 { 94 mSavedNode = node; 95 mBox = KDNODEPTR_CAST(node)->_getWorldAABB(); 96 } 97 98 return &mBox; 71 99 } 72 100 … … 78 106 void KdTreeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const 79 107 { 80 /*** TODO ***/108 KDNODEPTR_CAST(node)->setNodeVisible(visible); 81 109 } 82 110 83 111 bool KdTreeHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node) const 84 112 { 85 /*** TODO ***/ 86 return true; 113 return KDNODEPTR_CAST(node)->isNodeVisible(); 87 114 } 88 115 89 116 void KdTreeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const 90 117 { 91 /*** TODO ***/118 KDNODEPTR_CAST(node)->setLastVisited(frameId); 92 119 } 93 120 94 121 unsigned int KdTreeHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const 95 122 { 96 /*** TODO ***/ 97 return 0; 123 return KDNODEPTR_CAST(node)->lastVisited(); 98 124 } 99 125 … … 101 127 GtpVisibility::CullingType type) const 102 128 { 103 /*** TODO ***/ 129 WireBoundingBox *box = KDNODEPTR_CAST(node)->getWireBoundingBox(); 130 131 if (type == GtpVisibility::FRUSTUM_CULLED) 132 { 133 box->setMaterial("FrustumCulledNodesMaterial"); 134 } 135 else // type == GtpVisibility::QUERY_CULLED 136 { 137 box->setMaterial("QueryCulledNodesMaterial"); 138 } 139 140 // TODO: maybe boxlist? 141 dynamic_cast<KdTreeSceneManager *>(mSceneManager)->getRenderQueue()->addRenderable(box); 104 142 } 105 143 … … 108 146 bool includeChildren) 109 147 { 110 /*** TODO ***/ 148 KdTree::Node * kdnode = KDNODEPTR_CAST(node); 149 if (kdnode->isLeaf()) 150 { 151 KdTree::Leaf * kdleaf = KDLEAFPTR_CAST(node); 152 KdRenderableList::iterator it = kdleaf->mKdRenderables.begin(); 153 KdRenderableList::iterator end = kdleaf->mKdRenderables.end(); 154 while (it != end) 155 { 156 (*it)->getGeometryList(geometryList); 157 it++; 158 } 159 } 111 160 } 112 161 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1170 r1173 347 347 } 348 348 349 // TODO: looks too easy, verify if it works 350 void KdTreeSceneManager::_renderNodes(const KdRenderableList& nodelist, Camera * cam, 351 bool onlyShadowCasters, int leavePassesInQueue) 352 { 353 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 354 _deleteRenderedQueueGroups(leavePassesInQueue); //try avoiding modified ogre code 355 #else 356 getRenderQueue()->clear(); 357 #endif 358 KdRenderableList::const_iterator it = nodelist.begin(); 359 KdRenderableList::const_iterator end = nodelist.end(); 360 while (it != end) 361 { 362 (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 363 it++; 364 } 365 366 SceneManager::_renderVisibleObjects(); 367 368 } 369 349 370 //----------------------------------------------------------------------- 350 371 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneNode.cpp
r1163 r1173 140 140 } 141 141 142 void KdTreeSceneNode::getGeometryList(GtpVisibility::GeometryVector *geometryList) 143 { 144 SceneNode::ObjectIterator objIt = getAttachedObjectIterator(); 145 146 while (objIt.hasMoreElements()) 147 { 148 MovableObject *movable = objIt.getNext(); 149 150 // we are interested only in the entities, i.e., instances of geometry 151 if (movable->getMovableType() == "Entity") 152 { 153 Entity *ent = static_cast<Entity *>(movable); 154 //std::stringstream d; d << "ent " << ent->getName(); 155 //LogManager::getSingleton().logMessage(d.str()); 156 geometryList->push_back(ent); 157 } 158 } 159 } 160 142 161 AxisAlignedBox KdTreeSceneNode::getBoundingBox() const 143 162 {
Note: See TracChangeset
for help on using the changeset viewer.