- Timestamp:
- 07/31/06 17:34:56 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.