Changeset 158 for trunk/VUT/Ogre
- Timestamp:
- 07/06/05 11:04:25 (20 years ago)
- Location:
- trunk/VUT/Ogre
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgreBspHierarchyInterface.h
r155 r158 24 24 @remark pushes children on the distance queue 25 25 */ 26 void Traverse AndRenderNode(GtpVisibility::HierarchyNode *node);26 void TraverseNode(GtpVisibility::HierarchyNode *node); 27 27 void RenderNode(GtpVisibility::HierarchyNode *node); 28 28 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r155 r158 27 27 void PullUpVisibility(GtpVisibility::HierarchyNode *node); 28 28 29 /** Traverses given node.29 /** Traverses and renders the given node. 30 30 @param node current node 31 31 @remark pushes children on a distance queue. 32 32 */ 33 void TraverseAndRenderNode(GtpVisibility::HierarchyNode *node); 33 void TraverseNode(GtpVisibility::HierarchyNode *node); 34 /** @copydoc HierarchyInterface::RenderNode */ 34 35 void RenderNode(GtpVisibility::HierarchyNode *node); 35 36 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; … … 50 51 bool includeChildren); 51 52 52 void SetNodeId(GtpVisibility::HierarchyNode *node, int id);53 54 int GetNodeId(GtpVisibility::HierarchyNode *node);55 56 GtpVisibility::HierarchyNode *GetNextNode();57 58 53 protected: 59 54 /** Returns pointer to the bounding box of the node. … … 67 62 */ 68 63 Real GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const; 69 70 int mCurrentOctreePosition;71 64 }; 72 65 } // namespace Ogre -
trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
r155 r158 24 24 bool IsLeaf(GtpVisibility::HierarchyNode *node) const; 25 25 26 void Traverse AndRenderNode(GtpVisibility::HierarchyNode *node);26 void TraverseNode(GtpVisibility::HierarchyNode *node); 27 27 void RenderNode(GtpVisibility::HierarchyNode *node); 28 28 void PullUpVisibility(GtpVisibility::HierarchyNode *node); … … 41 41 void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 42 42 GtpVisibility::CullingType type); 43 44 /*bool FindVisibleObjects(GtpVisibility::HierarchyNode *node,45 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,46 bool includeChildren = false);*/47 43 48 44 void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, … … 50 46 bool includeChildren); 51 47 52 void SetNodeId(GtpVisibility::HierarchyNode *node, int id);53 54 int GetNodeId(GtpVisibility::HierarchyNode *node);55 56 GtpVisibility::HierarchyNode *GetNextNode();57 48 }; 58 49 -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r156 r158 11 11 #include "OgrePlatformQueryManager.h" 12 12 #include "VisibilityManager.h" 13 #include <OgreSolidBoundingBox.h>14 13 15 14 … … 97 96 */ 98 97 void PrepareVisualization(Camera *cam); 99 98 /** Initialises necessary parameters for hierarchical visibility culling. 99 */ 100 100 void InitVisibilityCulling(Camera *cam); 101 101 102 102 /// the interface to the scene hierarchy. 103 103 OctreeHierarchyInterface *mHierarchyInterface; 104 /// manages all visibility options 104 105 GtpVisibility::VisibilityManager *mVisibilityManager; 105 106 107 /// if a visualization of the hierarchical culling is shown 106 108 bool mShowVisualization; 109 110 /// if the culled nodes are indicated in the visualization 107 111 bool mVisualizeCulledNodes; 108 112 113 /// if symbols for the nodes are shown in the visualization 109 114 bool mRenderNodesForViz; 115 /// if content of the nodes is shown in the visualization 110 116 bool mRenderNodesContentForViz; 117 118 /// if we render transparents after the hierarchical traversal 111 119 bool mDelayRenderTransparents; 120 121 /// if we use a depth pass (i.e., fill only the depth buffer in the first pass) 112 122 bool mUseDepthPass; 123 /// if we currently render the depth pass 113 124 bool mRenderDepthPass; 125 126 /// if we use an item buffer for rendering (i.e., object ids as color codes 127 bool mUseItemBuffer; 128 /// if we currently render the item buffer 114 129 bool mRenderItemBuffer; 115 bool mUseItemBuffer; 130 131 /// if depth write should be enabled 116 132 bool mEnableDepthWrite; 133 /// if transparents are skipped during rendering 117 134 bool mSkipTransparents; 118 135 136 /// the depth pass (no lighting, just filling the depth buffer) 119 137 Pass *mDepthPass; 120 138 Pass *mItemBufferPass; 121 139 122 140 int mCurrentEntityId; 123 141 /// flag for passes which should not be deleted from queue during first traversal 124 142 int mLeavePassesInQueue; 125 143 ShadowTechnique mSavedShadowTechnique; 126 127 bool mRenderHierarchyNodes;128 129 std::vector<SolidBoundingBox *> mSolidBoxes;130 144 }; 131 145 -
trunk/VUT/Ogre/src/OgreBspHierarchyInterface.cpp
r155 r158 12 12 } 13 13 //----------------------------------------------------------------------- 14 void BspHierarchyInterface::Traverse AndRenderNode(GtpVisibility::HierarchyNode *node)14 void BspHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 15 15 { 16 16 } -
trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
r156 r158 77 77 } 78 78 79 delete [] buf; 80 81 // ---- render visible nodes and collect node visibility 82 bool renderBoxes = true; 83 sm->setOption("RenderHierarchyNodes", &renderBoxes); 84 85 86 // --- render item buffer for visible nodes only 87 pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false); 88 89 90 // get frame buffer for node visibility 91 buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 92 93 94 // loop through frame buffer & collect visible pixels 95 for (int idx = 0; idx < dimy * dimx * 3; idx += 3) 96 { 97 // -- decode color code to receive id 98 int id = buf[idx] << 16; 99 id += buf[idx + 1] << 8; 100 id += buf[idx + 2]; 101 102 // if valid id <= add visibility (id values start at 1 103 if ((id > 0) && (id < (int)visibleNodes->size())) 104 { 105 ((*visibleNodes)[id]).AddVisibility(1, 1); 106 } 107 } 79 //-- reset options 108 80 109 81 // don't need item buffer anymore 110 82 useItemBuffer = false; 111 //sm->setOption("UseItemBuffer", &useItemBuffer); 112 113 renderBoxes = false; 114 //sm->setOption("RenderHierarchyNodes", &renderBoxes); 115 83 sm->setOption("UseItemBuffer", &useItemBuffer); 116 84 // reset initialised - flag 117 85 mWasInitialised = false; 118 119 86 // reset old overlay status 120 87 mViewport->setOverlaysEnabled(overlayEnabled); 121 88 // reset background color 122 89 mViewport->setBackgroundColour(bg); 123 90 91 // delete array storing the frame buffer 124 92 delete [] buf; 125 93 } … … 146 114 visibleGeometry->push_back(GtpVisibility::MeshInfo(it.getNext(), 0, 0)); 147 115 } 148 149 // -- initialise hierarchy interface for simple node traversal150 mHierarchyInterface->InitTraversal(false);151 152 GtpVisibility::HierarchyNode *node = NULL;153 154 int i = 1;155 156 while (node = mHierarchyInterface->GetNextNode())157 {158 mHierarchyInterface->SetNodeId(node, i++);159 visibleNodes->push_back(GtpVisibility::NodeInfo(node, 0, 0));160 }161 116 } 162 117 -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r155 r158 10 10 //----------------------------------------------------------------------- 11 11 OctreeHierarchyInterface::OctreeHierarchyInterface(OctreeSceneManager *sm, RenderSystem *rsys): 12 SceneNodeHierarchyInterface(sm, rsys) , mCurrentOctreePosition(0)12 SceneNodeHierarchyInterface(sm, rsys) 13 13 { 14 14 } 15 15 //----------------------------------------------------------------------- 16 void OctreeHierarchyInterface::Traverse AndRenderNode(GtpVisibility::HierarchyNode *node)16 void OctreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 17 17 { 18 18 ++ mNumTraversedNodes; … … 168 168 } 169 169 } 170 //-----------------------------------------------------------------------171 void OctreeHierarchyInterface::SetNodeId(GtpVisibility::HierarchyNode *node, int id)172 {173 static_cast<Octree *>(node)->setId(id);174 }175 //-----------------------------------------------------------------------176 int OctreeHierarchyInterface::GetNodeId(GtpVisibility::HierarchyNode *node)177 {178 return static_cast<Octree *>(node)->getId();179 }180 //-----------------------------------------------------------------------181 GtpVisibility::HierarchyNode *OctreeHierarchyInterface::GetNextNode()182 {183 if (mTraversalStack->empty())184 return NULL;185 186 Octree *octree = static_cast<Octree *>(mTraversalStack->top());187 mTraversalStack->pop();188 189 for(int i=0; i<8; ++i)190 {191 Octree *nextChild =192 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];193 194 if (nextChild)195 {196 mTraversalStack->push(nextChild);197 }198 }199 200 return octree;201 }202 203 170 } // namespace Ogre -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r155 r158 130 130 } 131 131 //----------------------------------------------------------------------- 132 void PlatformHierarchyInterface::InitTraversal(Camera *cam, Camera *cullCam, int leavePassesInQueue) 132 void PlatformHierarchyInterface::InitTraversal(Camera *cam, Camera *cullCam, 133 int leavePassesInQueue) 133 134 { 134 135 GtpVisibility::HierarchyInterface::InitTraversal(); -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r155 r158 17 17 } 18 18 //----------------------------------------------------------------------- 19 void SceneNodeHierarchyInterface::Traverse AndRenderNode(GtpVisibility::HierarchyNode *node)19 void SceneNodeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 20 20 { 21 21 ++ mNumTraversedNodes; … … 157 157 } 158 158 } 159 //-----------------------------------------------------------------------160 void SceneNodeHierarchyInterface::SetNodeId(GtpVisibility::HierarchyNode *node, int id)161 {162 static_cast<SceneNode *>(node)->setId(id);163 }164 //-----------------------------------------------------------------------165 int SceneNodeHierarchyInterface::GetNodeId(GtpVisibility::HierarchyNode *node)166 {167 return static_cast<SceneNode *>(node)->getId();168 }169 //-----------------------------------------------------------------------170 GtpVisibility::HierarchyNode *SceneNodeHierarchyInterface::GetNextNode()171 {172 if (mTraversalStack->empty())173 return NULL;174 175 SceneNode *node = static_cast<SceneNode *>(mTraversalStack->top());176 mTraversalStack->pop();177 159 178 // internal node: add children to priority queue for further processing179 Node::ChildNodeIterator it = node->getChildIterator();180 181 while (it.hasMoreElements())182 {183 mTraversalStack->push(it.getNext());184 }185 186 return node;187 }188 160 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r157 r158 31 31 mEnableDepthWrite(true), 32 32 mSkipTransparents(false), 33 mSavedShadowTechnique(SHADOWTYPE_NONE), 34 mRenderHierarchyNodes(false) 35 //mRenderHierarchyNodes(true) 33 mSavedShadowTechnique(SHADOWTYPE_NONE) 36 34 { 37 35 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 210 208 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 211 209 { 212 // clear list of solid boxes (used for item buffer hierarchy node rendering)213 /*for (int i=0; i<(int)mSolidBoxes.size(); ++i)214 delete mSolidBoxes[i];215 216 mSolidBoxes.clear();*/217 218 210 //-- show visible scene nodes and octree bounding boxes from last frame 219 211 if (mShowVisualization) … … 221 213 PrepareVisualization(cam); 222 214 } 223 else if (mRenderHierarchyNodes)224 {225 AxisAlignedBox aab;226 227 228 // get rendered hierarchy nodes from last frame229 GtpVisibility::HierarchyNodeList *nodeList = mHierarchyInterface->GetRenderedNodes();230 GtpVisibility::HierarchyNodeList::iterator nodeIt, nodeIt_end = nodeList->end();231 232 for (nodeIt = nodeList->begin(); nodeIt != nodeIt_end; ++nodeIt)233 {234 SolidBoundingBox *solidBox = new SolidBoundingBox();235 solidBox->SetupBoundingBox(aab);236 237 Octree *octree = static_cast<Octree *>(*nodeIt);238 solidBox->setId(octree->getId());239 mSolidBoxes.push_back(solidBox);240 241 aab = octree->_getWorldAABB();242 std::stringstream d; d << "bounding box with id: " << octree->getId() << ", " << aab << "\n";243 LogManager::getSingleton().logMessage(d.str());244 245 getRenderQueue()->addRenderable(solidBox);246 }247 }248 215 else 249 216 { … … 273 240 ColourValue savedAmbient = mAmbientLight; 274 241 275 // --- apply standard rendering for some cases 276 // e.g., visualization, shadow pass 277 278 if (mShowVisualization || mRenderHierarchyNodes || 242 // --- apply standard rendering for some cases (e.g., visualization, shadow pass) 243 244 if (mShowVisualization || 279 245 (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 280 246 mIlluminationStage == IRS_RENDER_TO_TEXTURE)) … … 282 248 IlluminationRenderStage savedStage = mIlluminationStage; 283 249 284 if (mShowVisualization || mRenderHierarchyNodes)285 // disable illumination stage because we want noshadows250 if (mShowVisualization) 251 // disable illumination stage to prevent rendering shadows 286 252 mIlluminationStage = IRS_NONE; 287 253 … … 448 414 return true; 449 415 } 450 if (key == "RenderHierarchyNodes") 451 { 452 mRenderHierarchyNodes = (*static_cast<const bool *>(val)); 453 } 416 454 417 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 455 418 setOption(key, val) || TerrainSceneManager::setOption(key, val);
Note: See TracChangeset
for help on using the changeset viewer.