Changeset 94 for trunk/VUT/Ogre


Ignore:
Timestamp:
05/12/05 18:55:25 (20 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/Ogre
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h

    r92 r94  
    3434        GtpVisibility::OcclusionQuery *GetNextOcclusionQuery(); 
    3535                 
    36         /** Sets the current camera. 
     36        /** Sets the current camera used for the rendering. 
    3737                @param cam the current camera 
    3838        */ 
    3939        void SetCamera(Camera *cam); 
    40                  
     40        /** Sets the current camera used for culling. 
     41                @param cam the current camera 
     42                @remark the default is the camera used for rendering 
     43        */ 
     44        void SetCullCamera(Camera *cullCam); 
    4145        /** Initialises this scene traverser for the current frame. 
    4246        @param root root of the hierarchy 
    4347                @param cam current camera 
     48                @param cullCam the camera used for culling. If null, the current camera is used 
    4449                @remark convenience method wich calls VisibilitySceneTraverser::initFrame, 
    4550                sets the current camera, and initialises the distance queue. 
    4651        */ 
    47         void InitFrame(GtpVisibility::HierarchyNode *root, Ogre::Camera *cam); 
     52        void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL); 
    4853        /** Checks if the node is visible from the current view frustum. 
    4954                @param node the current node 
     
    95100 
    96101        Camera *mCamera; 
     102        Camera *mCullCamera; 
     103 
    97104        AxisAlignedBox mBox; 
    98105         
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r93 r94  
    22#include "OgreVisibilityOctreeSceneManager.h" 
    33#include <OgreOctree.h> 
     4#include <OgreLogManager.h> 
     5 
    46#include <windows.h> 
    57 
    68namespace Ogre { 
    7 //namespace GtpVisibility { 
     9 
    810//----------------------------------------------------------------------- 
    911OctreeHierarchyInterface::OctreeHierarchyInterface(SceneManager *sm, RenderSystem *rsys):  
     
    2527         
    2628        // if not all subtrees are empty 
    27         if (octree->numNodes() > (int)octree->mNodes.size()) 
     29        //if (octree->numNodes() > (int)octree->mNodes.size()) 
     30        if (!IsLeaf(node)) 
    2831        { 
    2932                for(int i=0; i<8; ++i) 
     
    4245bool OctreeHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const 
    4346{ 
    44         Octree *octant = static_cast<Octree *>(node); 
    45  
    46         for(int i=0; i<8; i++) 
    47         { 
    48                 if (octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]) 
    49                         return false; 
    50         } 
    51  
    52         return true; 
     47        Octree *octree = static_cast<Octree *>(node); 
     48        // HACK: if there are subtrees, they are empty => we are not interested in them 
     49        return octree->numNodes() == (int)octree->mNodes.size(); 
    5350} 
    5451//----------------------------------------------------------------------- 
     
    6865        Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 
    6966 
    70         return (mCamera->getDerivedPosition() - mid).squaredLength(); 
     67        return (mCullCamera->getDerivedPosition() - mid).squaredLength(); 
    7168} 
    7269//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r93 r94  
    11#include <OgreCamera.h> 
    2  
     2#include <OgreLogManager.h> 
    33//#include "OgreSolidHalfBoundingBox.h" 
    44#include "OgreSolidBoundingBox.h" 
     
    1111//----------------------------------------------------------------------- 
    1212PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 
    13 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL)/*, mSolidHalfBoundingBox(NULL)*/ 
     13mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), 
     14mCamera(NULL), mCullCamera(NULL) 
    1415{ 
    1516} 
     
    6465} 
    6566//----------------------------------------------------------------------- 
     67void PlatformHierarchyInterface::SetCullCamera(Ogre::Camera *cullCam) 
     68{ 
     69        mCullCamera = cullCam; 
     70} 
     71//----------------------------------------------------------------------- 
    6672GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::GetNextOcclusionQuery() 
    6773{ 
     
    7480} 
    7581//----------------------------------------------------------------------- 
    76 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam) 
     82void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam) 
    7783{ 
    7884        GtpVisibility::HierarchyInterface::InitFrame(root); 
     
    8086 
    8187        SetCamera(cam); 
     88 
     89        if(cullCam) 
     90                SetCullCamera(cullCam); 
     91        else 
     92                SetCullCamera(cam); 
    8293} 
    8394//----------------------------------------------------------------------- 
     
    96107{ 
    97108#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    98         return mCamera->isVisible(*GetBoundingBox(node), intersects); 
     109        return mCullCamera->isVisible(*GetBoundingBox(node), intersects); 
    99110#else 
    100111        return true; 
     
    113124        // if node is leaf and was visible => will be rendered anyway. 
    114125        // In this case we can also test with the real geometry. 
    115         if(mUseOptimization && wasVisible && IsLeaf(node)) 
     126        // if camera for culling is different from camera for rendering => cannot optimize 
     127        if (mUseOptimization && wasVisible && IsLeaf(node) && (mCamera == mCullCamera)) 
    116128        { 
     129                //LogManager::getSingleton().logMessage("render node\n"); 
    117130                RenderNode(node); 
    118131        } 
    119132        else 
    120133        { 
     134                //LogManager::getSingleton().logMessage("render box\n"); 
    121135                RenderBoundingBox(GetBoundingBox(node)); 
    122136        } 
  • trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp

    r87 r94  
    33#include <OgreCamera.h> 
    44#include <OgreSceneNode.h> 
    5  
    6 //#include <windows.h> 
    75 
    86namespace Ogre { 
  • trunk/VUT/Ogre/src/OgreSolidBoundingBox.cpp

    r92 r94  
    66#include "OgreCamera.h" 
    77#include "OgreMaterialManager.h" 
    8 //#include <windows.h> 
     8 
    99 
    1010namespace Ogre { 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r93 r94  
    66#include <OgreCamera.h> 
    77#include <OgreLogManager.h> 
    8  
    9 #include <windows.h> 
    108 
    119namespace Ogre { 
     
    1816        mHierarchyInterface =  
    1917                new OctreeHierarchyInterface(this, mDestRenderSystem); 
    20         //visManager->SetCullingManager(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING); 
    21          
     18                 
    2219        //mDisplayNodes = true; 
    2320        //mShowBoundingBoxes = true; 
     
    3431void VisibilityOctreeSceneManager::_renderVisibleObjects() 
    3532{ 
    36         mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 
     33        Camera *cullCam = NULL; 
     34 
     35        if(mCullCamera) cullCam = getCamera("CullCamera"); 
     36         
     37        mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, cullCam); 
    3738        mVisibilityManager->GetCullingManager()->InitFrame(); 
    3839 
  • trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp

    r87 r94  
    77#include "OgreVisibilityOptionsManager.h" 
    88 
    9 //#include <windows.h> 
    109 
    1110namespace Ogre { 
  • trunk/VUT/Ogre/src/OgreVisibilitySceneManagerDll.cpp

    r74 r94  
    3434#include <OgreRoot.h> 
    3535 
    36 //#include <windows.h> 
    3736GtpVisibility::VisibilityEnvironment *visEnv; 
    3837GtpVisibility::VisibilityManager *visManager; 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r93 r94  
    3232void VisibilityTerrainSceneManager::_renderVisibleObjects() 
    3333{ 
    34         mHierarchyInterface->InitFrame(mOctree, mCameraInProgress); 
     34        Camera *cullCam = NULL; 
     35 
     36        // if two cameras (one for culling, one for visualization) 
     37        if(mCullCamera) 
     38                cullCam = getCamera("CullCamera"); 
     39         
     40        if(cullCam && (mCameraInProgress != cullCam)) 
     41                OutputDebugString("using cullcam\n"); 
     42        else 
     43                OutputDebugString("not using cullcam\n"); 
     44 
     45        mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, cullCam); 
    3546        mVisibilityManager->GetCullingManager()->InitFrame(); 
    3647 
Note: See TracChangeset for help on using the changeset viewer.