Changeset 3052 for GTP/trunk


Ignore:
Timestamp:
10/21/08 03:55:43 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3040 r3052  
    112112                                EnableFiberSafeOptimizations="true" 
    113113                                AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include;"$(CG_INC_PATH)"" 
    114                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" 
     114                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET" 
    115115                                StringPooling="true" 
    116116                                RuntimeLibrary="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r3042 r3052  
    402402void Bvh::UpdateDistance(BvhNode *node) const 
    403403{ 
     404        // use distance to center rather than the distance to the near plane because 
     405        // otherwise problems with big object penetrating the near plane  
     406        // (e.g., big objects in the distance which are then always visible) 
     407        // especially annoying is this problem when using the frustum  
     408        // fitting on the visible objects for shadow mapping 
     409 
    404410        //node->mDistance = node->GetBox()GetMinDistance(sNearPlane); 
    405411        node->mDistance = sNearPlane.Distance(node->GetBox().Center()); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp

    r3021 r3052  
    7676        BvhNode *root = LoadNextNode(stream, NULL); 
    7777 
    78 #if 1 
     78#if 0 
    7979 
    8080        bvh->mRoot = root; 
    8181 
    8282#else 
    83         // copy root and set new one for dynamic objects 
     83        // we are setting a new root node 
     84        // which adds one level of indirection to the bvh but  
     85        // allows us to use dynamic objects 
     86        // the new bvh has two main branches 
     87        // one is the static branch (the old root), 
     88        // one is the dynamic branch  
     89        // we create a 'dynamic' leaf which basically is a container 
     90        // for all dynamic objects underneath 
     91        // the bounding boxes of the dynamic tree must be updated 
     92        // once each frame in order to be able to incorporate 
     93        // the movements of the objects within 
     94 
    8495        BvhInterior *newRoot = new BvhInterior(NULL); 
    85          
     96        bvh->mRoot = newRoot; 
     97 
     98        BvhLeaf *dynamicLeaf = new BvhLeaf(newRoot); 
     99 
     100        newRoot->mFront = root; 
     101        newRoot->mBack = dynamicLeaf; 
     102        root->mParent = newRoot; 
     103 
     104        // the separation is a purely logical one 
     105        // the bounding boxes of the child nodes is the 
     106        // same as for the root node 
    86107        newRoot->mBox = root->mBox; 
     108        dynamicLeaf->mBox = root->mBox; 
     109 
     110        newRoot->mArea = newRoot->mBox.SurfaceArea(); 
     111        dynamicLeaf->mArea = dynamicLeaf->mBox.SurfaceArea(); 
     112 
    87113        newRoot->mFirst = root->mFirst; 
    88114        newRoot->mLast = root->mLast; 
    89115 
    90         // create 'dynamic' leaf which basically is a container 
    91         // for all dynamic objects 
    92         BvhLeaf *dynamicLeaf = new BvhLeaf(newRoot); 
    93         dynamicLeaf->mBox = root->mBox; 
    94  
    95         newRoot->mFront = root; 
    96         root->mParent = newRoot; 
    97  
    98         newRoot->mBack = dynamicLeaf; 
    99  
    100         bvh->mRoot = newRoot; 
     116        dynamicLeaf->mFirst = 0; 
     117        dynamicLeaf->mLast = 0; 
    101118#endif 
    102119 
    103         tQueue.push(bvh->mRoot); 
     120        tQueue.push(root); 
    104121        bvh->mNumNodes = 1; 
    105122 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h

    r3050 r3052  
    3636        */ 
    3737        RenderState(); 
    38          
    39         ~RenderState() { Reset(); }; 
    4038        /** This must be called each time before and after an occlusion test. 
    4139                Mode is one of render mode or query mode. Returns true if a state 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r3050 r3052  
    9191 
    9292 
     93void ResourceManager::DelSingleton() 
     94{ 
     95        DEL_PTR(sResourceManager); 
     96} 
     97 
     98 
    9399SceneEntity *ResourceManager::LoadSceneEntity(igzstream &str) 
    94100{        
     
    431437 
    432438 
    433  
    434439ShaderProgram *ResourceManager::CreateFragmentProgram(const std::string &filename,  
    435440                                                                                                          const std::string &funcName) 
     
    438443 
    439444        ShaderProgram *p = new ShaderProgram(sCgContext, fullName, sCgFragmentProfile, funcName); 
    440  
    441445        mShaders.push_back(p); 
    442446 
     
    465469                cerr << "Program " << funcName << " in " << fullName << " failed to load" << endl; 
    466470        } 
    467          
    468         cout << "Program " << funcName << " in " << fullName << " loaded" << endl; 
     471        else 
     472                cout << "Program " << funcName << " in " << fullName << " loaded" << endl; 
    469473 
    470474        return p; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h

    r3045 r3052  
    3232public: 
    3333 
    34         /** Returns the resource manager as a singleton. 
    35         */ 
    36         static ResourceManager *GetSingleton() 
    37         { 
    38                 if (!sResourceManager) 
    39                 { 
    40                         sResourceManager = new ResourceManager(); 
    41                 } 
    42  
    43                 return sResourceManager; 
    44         } 
    45  
    46         /** We also want full control over the delete. 
    47         */ 
    48         static void DelSingleton() 
    49         { 
    50                 DEL_PTR(sResourceManager); 
    51         } 
    52  
    5334        /** Loads a model 
    5435        */ 
    5536        bool Load(const std::string &filename, SceneEntityContainer &geometry); 
    56  
     37        /** Returns number of scene entities loaded with this manager. 
     38        */ 
    5739        int GetNumEntities() const { return (int)mSceneEntities.size(); } 
    58  
    5940        /** Creates new gpu program parameters. 
    6041        */ 
     
    7152        void DisableVertexProfile(); 
    7253 
     54        /** Returns the resource manager as a singleton. 
     55        */ 
     56        inline static ResourceManager *GetSingleton(); 
     57        /** We also want full control over the delete. 
     58        */ 
     59        static void DelSingleton(); 
    7360 
    7461protected: 
     
    11198        LODContainer mLODs; 
    11299 
    113         //////// 
    114  
    115100        /// the scene entities 
    116  
    117101        SceneEntityContainer mSceneEntities; 
    118102 
     
    132116 
    133117 
     118ResourceManager *ResourceManager::GetSingleton() 
     119{ 
     120        if (!sResourceManager) 
     121                sResourceManager = new ResourceManager(); 
     122         
     123        return sResourceManager; 
     124} 
     125 
     126 
    134127} 
    135128#endif 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3051 r3052  
    9595 
    9696int assumedVisibleFrames = 10; 
    97  
    9897int maxBatchSize = 50; 
    99  
    10098int trianglesPerVirtualLeaf = INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES; 
    101  
    10299SceneQuery *sceneQuery = NULL; 
    103100RenderQueue *renderQueue = NULL; 
    104  
    105101// traverses and renders the hierarchy 
    106102RenderTraverser *shadowTraverser = NULL; 
     
    291287int main(int argc, char* argv[]) 
    292288{ 
    293 /* 
    294289#ifdef _CRT_SET 
    295290 
     
    304299        _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);  
    305300#endif 
    306 */ 
     301 
    307302        cout << "=== reading environment file ===" << endl << endl; 
    308303 
     
    470465        { 
    471466                cerr << "loading file " << skyDomeStr << " failed" << endl; 
    472  
    473467                CleanUp(); 
    474468                exit(0); 
     
    10941088                CleanUp(); 
    10951089                exit(0); 
    1096                 break; 
    10971090        case 32: // space 
    10981091                renderMode = (renderMode + 1) % RenderTraverser::NUM_TRAVERSAL_TYPES; 
     
    16491642        DEL_PTR(shadowMap); 
    16501643        DEL_PTR(shadowTraverser); 
    1651          
     1644 
    16521645        ResourceManager::DelSingleton(); 
    16531646        loader = NULL; 
Note: See TracChangeset for help on using the changeset viewer.