Changeset 1170 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include
- Timestamp:
- 07/28/06 17:06:01 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h
r1165 r1170 11 11 #define _OgreKdTree_H__ 12 12 13 #define KDNODE_CAST(a) (static_cast<KdTree::Node>(a)) 14 #define KDBRANCH_CAST(a) (static_cast<KdTree::Branch>(a)) 15 #define KDLEAF_CAST(a) (static_cast<KdTree::Leaf>(a)) 16 #define KDNODEPTR_CAST(a) (static_cast<KdTree::Node *>(a)) 17 #define KDBRANCHPTR_CAST(a) (static_cast<KdTree::Branch *>(a)) 18 #define KDLEAFPTR_CAST(a) (static_cast<KdTree::Leaf *>(a)) 19 13 20 #include <OgreAxisAlignedBox.h> 14 21 #include <OgreWireBoundingBox.h> … … 20 27 #include <stack> 21 28 22 #include "OgreKdTreeHierarchyInterface.h" 29 //#include "OgreKdTreeHierarchyInterface.h" 30 23 31 24 32 namespace Ogre … … 199 207 virtual bool isLeaf() const = 0; 200 208 virtual bool isEmpty() const = 0; 209 virtual bool hasGeometry() const = 0; 201 210 202 211 // consider using typesafe callback functions … … 240 249 } 241 250 251 // functions for the CHC hierarchy interface 252 253 /** Returns last visited frame id. */ 254 unsigned int lastVisited(void) { return mLastVisited; }; 255 /** Set to current frame id. 256 @param current frame id. 257 */ 258 void setLastVisited(unsigned int frameid) { mLastVisited = frameid; }; 259 /** Makes this octree become visible / invisble. 260 @param visible Whether this node is to be made visible or invisible 261 */ 262 void setNodeVisible(bool visible) { mVisible = visible; }; 263 /** Returns true if this node is marked visible, false otherwise. 264 */ 265 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 /** Frame id when this octree was last rendered. 270 @return last rendered frame id 271 */ 272 unsigned int lastRendered(void) { return mLastRendered; }; 273 /** Sets frame id when this octree was last rendered. 274 @param last rendered frame id 275 */ 276 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. 280 */ 281 //AxisAlignedBox _getWorldAABB(void) const = 0; 282 283 242 284 Branch * mParent; 243 285 int mLevel; … … 245 287 protected: 246 288 WireBoundingBox * mWBB; 289 290 // for the CHC hierarchy interface 291 /** the real extent of the node. */ 292 //AxisAlignedBox mWorldAABB; 293 294 unsigned int mLastRendered; 295 unsigned int mLastVisited; 296 bool mVisible; 247 297 }; 248 298 … … 265 315 }; 266 316 317 // a branch is not a leaf 267 318 virtual bool isLeaf() const { return false; }; 268 319 320 // s branch is empty when it does not have children 269 321 virtual bool isEmpty() const { return (mLeft == 0 && mRight == 0); } 322 323 // a branch never has geometry 324 virtual bool hasGeometry() const { return false; }; 270 325 271 326 Node * mLeft; … … 284 339 virtual ~Leaf(); 285 340 341 // a leaf is a leaf, dammit 286 342 virtual bool isLeaf() const { return true; }; 287 343 344 // a leaf is empty when it does not posses renderables 288 345 virtual bool isEmpty() const { return mKdRenderables.empty(); }; 346 347 // a leaf has geometry when it has renderables 348 virtual bool hasGeometry() const { return !mKdRenderables.empty(); }; 289 349 290 350 virtual void remove(KdRenderable * rend) … … 337 397 }; 338 398 339 // typedef std::stack<SplitCandidate> SplitCandidatePQ;399 // typedef std::stack<SplitCandidate> SplitCandidatePQ; 340 400 typedef std::priority_queue<SplitCandidate> SplitCandidatePQ; 341 401 402 // nodestack for the stack-based rendering function 403 typedef std::stack<KdTree::Node *> NodeStack; 342 404 public: 343 friend class Ogre::KdTreeHierarchyInterface;405 friend class KdTreeHierarchyInterface; 344 406 345 407 typedef KdTree::Leaf * LeafPtr; 346 408 typedef std::set<LeafPtr> LeafSet; 409 410 enum RenderMethod 411 { 412 KDRM_RECURSE, 413 KDRM_STACK, 414 KDRM_SAW, 415 KDRM_CHC 416 }; 347 417 348 418 enum BuildMethod … … 356 426 357 427 // DEBUG 358 void KdTree::dump();359 void KdTree::calcCost();428 void dump(); 429 void calcCost(); 360 430 361 431 // insert a new scene node into an existing kd-tree … … 367 437 368 438 // test visibility of objects and add to render queue 369 void queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes = false); 439 void queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters, 440 RenderMethod renderMethod, bool showBoxes = false); 370 441 371 442 // self-explanatory ... … … 396 467 397 468 // recursive rendering function 398 void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 469 void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, 470 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 471 // stack based rendering function 472 void stackQueueVisibleObjects(KdTree::Node * root, unsigned long currentFrame, 473 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 399 474 400 475 // the root node of the kdtree -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeHierarchyInterface.h
r1165 r1170 11 11 #define _OgreKdTreeHierarchyInterface_H_ 12 12 13 #include "Ogre SceneNodeHierarchyInterface.h"13 #include "OgrePlatformHierarchyInterface.h" 14 14 15 15 namespace Ogre … … 18 18 class KdTreeSceneManager; 19 19 20 class KdTreeHierarchyInterface : public SceneNodeHierarchyInterface20 class KdTreeHierarchyInterface : public PlatformHierarchyInterface 21 21 { 22 22 public: 23 23 KdTreeHierarchyInterface(KdTreeSceneManager *sm, RenderSystem *rsys); 24 24 25 virtual ~KdTreeHierarchyInterface() {}; 25 26 26 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; 27 /** Returns true if current node is leaf of the hierarchy. 28 @param node hierarchy node 29 @returns true if node is leaf 30 */ 31 virtual bool IsLeaf(GtpVisibility::HierarchyNode *node) const; 32 /** Traverses and renders the hierarchy from the given node. 33 @param node the hierarchy node 34 */ 35 virtual void TraverseNode(GtpVisibility::HierarchyNode *node); 36 /** Renders the given hierarchy node. 37 @param node current hierarchy node to be rendered 38 */ 39 virtual void RenderNode(GtpVisibility::HierarchyNode *node); 40 /** Pulls up the visibility from the current node recursively to the parent nodes. 41 @param node the current node 42 */ 43 virtual void PullUpVisibility(GtpVisibility::HierarchyNode *node) const; 44 45 /** Returns distance of the node to the view plane. 46 @param node the hierarchy node 47 */ 48 virtual float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const; 49 /** Returns pointer to bounding box of node. 50 @param node current hierarchy node 51 @returns bounding box of current node 52 */ 53 virtual AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node); 54 /** Returns true if there is renderable geometry attached to this node 55 @param node the current node 56 @returns if the node has renderable geometry 57 */ 58 virtual bool HasGeometry(GtpVisibility::HierarchyNode *node) const; 59 /** Sets the visible flag for this node. 60 @param node the current node 61 @param visible the visible flag 62 */ 63 virtual void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const; 64 /** Returns true if node has the visible flag set. See set 65 */ 66 virtual bool IsNodeVisible(GtpVisibility::HierarchyNode *node) const; 67 /** Sets the last visited frame id for this node. 68 @param node the current node 69 @param frameId the current frame id 70 */ 71 virtual void SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const; 72 /** Returns frame id when this node was last visited by the traverser. See set 73 */ 74 virtual unsigned int LastVisited(GtpVisibility::HierarchyNode *node) const; 75 76 77 /** Visualization of a culled node, dependent on the culling type. 78 @param node the hierarchy node to be visualized 79 @param type can be one of FRUSTUM_CULLED, QUERY_CULLED 80 */ 81 virtual void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 82 GtpVisibility::CullingType type) const; 83 84 85 /** Returns the geometry of a given hierarchy node. 86 @param node the hierarchy node containing the geometry 87 @param geometryList geometry is returned in this list 88 @param includeChildren if the geometry of the children should be taken into account 89 */ 90 virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 91 GtpVisibility::GeometryVector *geometryList, 92 bool includeChildren); 93 94 27 95 }; 28 96 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h
r1165 r1170 70 70 bool mShowBoxes; 71 71 72 KdTree::RenderMethod mRenderMethod; 73 72 74 KdTree::BuildMethod mBuildMethod; 73 75 #ifdef KDTREE_DEBUG
Note: See TracChangeset
for help on using the changeset viewer.