Ignore:
Timestamp:
03/26/07 18:49:17 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp

    r2287 r2292  
    11#include "OgreOctreeHierarchyInterface.h" 
    2 //#include "OgreVisibilityOctreeSceneManager.h" 
    32#include <OgreOctree.h> 
    43#include <OgreLogManager.h> 
     
    7069                int z = i & 1; 
    7170         
    72                 //std::stringstream d; d << x << " " << y << " " << z; 
    73                 //Ogre::LogManager::getSingleton().logMessage(d.str()); 
    74  
    7571                if ((child = octree->mChildren[x][y][z]) != NULL) 
    7672                { 
     
    7874                } 
    7975        } 
    80  
    81         //std::stringstream str; str << "nodes: " << nodes.size(); 
    82         //Ogre::LogManager::getSingleton().logMessage(str.str()); 
    8376 
    8477        if (nodes.empty()) 
     
    8780        int r = (int)(((float)rand() / RAND_MAX) * ((float)nodes.size() - 0.5f)); 
    8881 
    89         //std::stringstream str2; 
    90         //str2 << "rand: " << r; 
    91         //Ogre::LogManager::getSingleton().logMessage(str2.str()); 
    92  
    9382        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 it 
    111         //if (!octree->mNodes.empty()) 
    112         //{ 
    113                 RenderNodeRecursive(node); 
    114         //} 
    115  
    116 /* 
    117                 // render everything from here 
    118                 if (octree->isOctreeFullyVisible()) 
    119                 {                
    120                         RenderNodeRecursive(node); 
    121                         return; 
    122                 } 
    123  
    124                 RenderNode(node); 
    125         } 
    126                  
    127         // if not all subtrees are empty 
    128         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         */ 
    15083} 
    15184//----------------------------------------------------------------------- 
     
    168101        const Vector3 bmax = static_cast<Octree *>(node)->mBox.getMaximum(); 
    169102 
    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         
    176105        return (mCameraPosition - pos).squaredLength(); 
    177106} 
     
    206135} 
    207136//----------------------------------------------------------------------- 
    208 void OctreeHierarchyInterface::DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const 
     137/*void OctreeHierarchyInterface::PullUpFullVisibility(GtpVisibility::HierarchyNode *node) const 
    209138{                
    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 
    224142        for (int i = 0; i < 8; ++ i) 
    225143        { 
     
    228146                int z = i & 1; 
    229147                 
    230                         if ((nextChild = octant->mChildren[x][y][z]) != NULL) 
     148                if ((nextChild = octant->mChildren[x][y][z]) != NULL) 
    231149                { 
    232150                        DetermineFullVisibility(nextChild); 
     
    236154                } 
    237155        } 
     156 
     157        while (octant && !octant->isOctreeVisible()) 
     158        { 
     159                octant->setOctreeVisible(true); 
     160                octant = octant->getParent(); 
     161        } 
     162#endif 
     163}*/ 
     164//----------------------------------------------------------------------- 
     165void 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        } 
    238194} 
    239195//----------------------------------------------------------------------- 
     
    264220        Octree *octant = static_cast<Octree *>(node); 
    265221 
    266         if (1)//octant->lastRendered() != mFrameId) 
     222        if (octant->lastRendered() != mFrameId) 
    267223        { 
    268224                octant->setLastRendered(mFrameId); 
     
    351307        } 
    352308} 
     309//----------------------------------------------------------------------- 
     310void 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} 
    353345 
    354346 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj

    r2280 r2292  
    322322                                AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\Release&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\Release&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;&quot;$(OGRE_PATH)\Dependencies\lib\Release&quot;;..\..\..\Preprocessing\lib\Release;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;&quot;$(CG_LIB_PATH)&quot;;..\..\..\..\..\..\..\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" 
    323323                                ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def" 
    324                                 GenerateDebugInformation="FALSE" 
     324                                GenerateDebugInformation="TRUE" 
    325325                                SubSystem="2" 
    326326                                OptimizeReferences="2" 
Note: See TracChangeset for help on using the changeset viewer.