Changeset 1768


Ignore:
Timestamp:
11/20/06 09:15:28 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh

    r1727 r1768  
    7878 
    7979############################################################################ 
    80 OBJ_SPLITS=700 
     80OBJ_SPLITS=100 
    8181 
    8282  METHOD=sequential-$OBJ_SPLITS 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r1715 r1768  
    17191719         
    17201720        Vector3 vtx; 
     1721         
     1722        ////////////// 
    17211723        //-- compute classification of vertices 
     1724 
    17221725        for (int i = 0; i < 8; ++i) 
    17231726        { 
     
    17321735        } 
    17331736 
     1737        /////////// 
    17341738        //-- find intersections 
     1739 
    17351740        if (onFrontSide && onBackSide) 
    17361741        { 
     
    17561761        { 
    17571762                Vector3 centerOfMass(0); 
     1763 
    17581764                int i; 
    17591765                // compute center of mass 
     
    17641770 
    17651771                vector<VertexData> vertexData; 
    1766                  
    17671772                Vector3 refVec = Normalize(centerOfMass - planePoly->mVertices[0]); 
    17681773 
    17691774                // compute angle to reference point 
    17701775                for (i = 1; i < (int)planePoly->mVertices.size(); ++ i) 
    1771                   { 
     1776                { 
    17721777                    float angle =  
    17731778                      Angle(refVec, centerOfMass - planePoly->mVertices[i], plane.mNormal); 
    17741779                     
    17751780                    vertexData.push_back(VertexData(planePoly->mVertices[i], angle)); 
    1776                   } 
     1781                } 
    17771782                 
    17781783                std::stable_sort(vertexData.begin(), vertexData.end()); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r1715 r1768  
    356356  /** Splits the box into two separate boxes with respect to the split plane 
    357357  */ 
    358   void Split(const int axis, const float value, AxisAlignedBox3 &left, AxisAlignedBox3 &right) const; 
     358  void Split(const int axis,  
     359                         const float value,  
     360                         AxisAlignedBox3 &left,  
     361                         AxisAlignedBox3 &right) const; 
    359362 
    360363#define __EXTENT_HACK 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1767 r1768  
    9393        mBoundingBox.GetEdge(idx, &a, &b); 
    9494         
    95         const float factor = RandomValue(0.0f, 1.0f); 
    96  
    97         point = a * factor + b * (1 - factor); 
    98         //normal = mBoundingBox.GetNormal(); 
     95        const float w = RandomValue(0.0f, 1.0f); 
     96 
     97        point = a * w + b * (1.0f - w); 
     98 
     99        // TODO 
     100        normal = Vector3(0); 
    99101 
    100102        return idx; 
     
    564566        float priority; 
    565567 
    566         // surface area heuristics is used when there is no view space subdivision available.  
    567         // In order to have some prioritized traversal, use this formula instead 
     568        // surface area heuristics is used when there is  
     569        // no view space subdivision available.  
     570        // In order to have some prioritized traversal,  
     571        // we use this formula instead 
    568572        if (mHierarchyManager->GetViewSpaceSubdivisionType() ==  
    569573                HierarchyManager::NO_VIEWSPACE_SUBDIV) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r1763 r1768  
    6363         
    6464        int GetRandomEdgePoint(Vector3 &point, Vector3 &normal); 
     65 
     66 
    6567protected: 
    6668         
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1763 r1768  
    797797int MeshInstance::GetRandomEdgePoint(Vector3 &point, Vector3 &normal) 
    798798{ 
    799         // TODO 
    800         return mMesh->GetRandomSurfacePoint(point, normal); 
     799        // get random face 
     800        const int faceIdx = (int)RandomValue(0.0f, (float)mMesh->mFaces.size() - 0.5f); 
     801        Face *face = mMesh->mFaces[faceIdx]; 
     802 
     803        // get random edge of face (hack: this is not uniform in the edges! 
     804        const int edgeIdx = (int)RandomValue(0.0f, face->mVertexIndices.size() - 0.5f); 
     805 
     806        const int vertexIdxA = face->mVertexIndices[edgeIdx]; 
     807        const int vertexIdxB = face->mVertexIndices[(edgeIdx + 1) % (int)face->mVertexIndices.size()]; 
     808 
     809        const Vector3 a = mMesh->mVertices[vertexIdxA]; 
     810        const Vector3 b = mMesh->mVertices[vertexIdxB]; 
     811 
     812        const float w = RandomValue(0.0f, 1.0f); 
     813 
     814        // get random point on edge 
     815        point = a * w + b * (1.0f - w); 
     816 
     817        // hack: set normal of face as normal 
     818        normal = mMesh->GetFacePlane(faceIdx).mNormal; 
     819 
     820    return 1; 
    801821} 
    802822 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1765 r1768  
    689689        //////// 
    690690        //-- evaluation of render cost heuristics 
     691 
    691692        float objRenderCost = 0, vcOverhead = 0, moveSpeed = 0; 
    692693 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1765 r1768  
    214214        const float c = Magnitude(direction); 
    215215 
    216         if (c <= Limits::Small)  
    217                 return false; 
     216        if ((c <= Limits::Small) || (DotProd(direction, normal) < 0)) 
     217        { 
     218                return false; 
     219        } 
    218220 
    219221        // $$ jb the pdf is yet not correct for all sampling methods! 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1765 r1768  
    309309 
    310310int ViewCellsManager::CastPassSamples(const int samplesPerPass,  
    311                                                                           const int sampleType,  
    312                                                                           VssRayContainer &passSamples) const 
     311                                                                          const vector<int> &strategies, 
     312                                                                          VssRayContainer &passSamples 
     313                                                                          ) const 
    313314{ 
    314315        SimpleRayContainer simpleRays; 
     
    318319        int castRays = 0; 
    319320         
    320         vector<int> strategies; 
    321           
    322         strategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
    323         strategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
    324         strategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
    325  
    326321        const int numRaysPerPass = samplesPerPass / (int)strategies.size(); 
    327322 
     
    397392        cout << "view cell construction: casting " << mInitialSamples << " initial samples ... " << endl; 
    398393 
     394        // mix of sampling strategies 
     395        vector<int> strategies; 
     396        strategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
     397        strategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     398        strategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
     399 
    399400        // cast initial samples 
    400         CastPassSamples(mInitialSamples, mSamplingType, initialSamples); 
     401        CastPassSamples(mInitialSamples, strategies, initialSamples); 
    401402 
    402403        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    460461        startTime = GetTime(); 
    461462        const int n = mConstructionSamples; //+initialSamples; 
    462         // should we use directional samples? 
    463         bool dirSamples = (mSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 
    464463 
    465464        while (numSamples < n) 
     
    470469                VssRayContainer constructionSamples; 
    471470 
    472                 const int samplingType = mSamplingType; 
    473                         //dirSamples ? Preprocessor::DIRECTION_BASED_DISTRIBUTION :     Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 
    474  
    475                 if (0) dirSamples = !dirSamples; // toggle sampling method 
    476  
    477471                // cast new samples 
    478472                numSamples += CastPassSamples(mSamplesPerPass,  
    479                                                                           samplingType, 
     473                                                                          strategies, 
    480474                                                                          constructionSamples); 
    481475 
     
    519513        cout << "casting " << mPostProcessSamples << " post processing samples ... "; 
    520514         
    521         CastPassSamples(mPostProcessSamples, mSamplingType, postProcessSamples); 
     515        CastPassSamples(mPostProcessSamples, strategies, postProcessSamples); 
    522516 
    523517        cout << "finished" << endl; 
     
    566560                VssRayContainer visSamples; 
    567561                int numSamples = CastPassSamples(mVisualizationSamples, 
    568                                                                                  mSamplingType,  
     562                                                                                 strategies,  
    569563                                                                                 visSamples); 
    570564 
     
    948942        Debug << "view cell stats prefix: " << statsPrefix << endl; 
    949943 
    950         // should directional sampling be used? 
    951         bool dirSamples =  
    952                 (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 
    953  
    954944        cout << "reseting pvs ... "; 
    955945                 
     
    972962        } 
    973963 
     964        // mix of sampling strategies 
     965        vector<int> strategies; 
     966        strategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
     967        strategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     968        strategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
     969 
    974970        cout << "finished" << endl; 
    975971    cout << "Evaluating view cell partition ... " << endl; 
     
    988984                Debug << "casting " << samplesPerPass << " samples ... "; 
    989985 
    990                 CastPassSamples(samplesPerPass, samplingType, evaluationSamples); 
     986                CastPassSamples(samplesPerPass, strategies, evaluationSamples); 
    991987                 
    992988                castSamples += samplesPerPass; 
     
    16321628        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    16331629 
    1634         // volume and area of the view cells are recomputed and a view cell mesh is created 
     1630        // volume and area of the view cells are recomputed  
     1631        // a view cell mesh is created 
    16351632        for (it = mViewCells.begin(); it != it_end; ++ it) 
    16361633        { 
     
    41344131        {       //////// 
    41354132                //-- real meshes are contructed at this stage 
     4133 
    41364134                cout << "finalizing view cells ... "; 
    41374135                FinalizeViewCells(true); 
     
    43344332        Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 
    43354333 
    4336         // should maybe be done here to allow merge working  
    4337         // with area or volume and to correct the rendering statistics 
    4338         if (0) FinalizeViewCells(false); 
    4339                  
    43404334        ////////// 
    4341         //-- merge the individual view cells 
     4335        //-- merge neighbouring view cells 
    43424336        MergeViewCells(postProcessRays, objects); 
    43434337         
     
    43584352        //////////// 
    43594353        //-- compression 
    4360 //#if HAS_TO_BE_REDONE 
     4354 
    43614355        if (ViewCellsTreeConstructed() && mCompressViewCells) 
    43624356        { 
     
    43694363                Debug << "number of entries after compress: " << pvsEntries << endl; 
    43704364        } 
    4371 //#endif 
    43724365 
    43734366        // collapse sibling leaves that share the same view cell 
     
    59345927        int splitsStepSize; 
    59355928 
    5936  
    59375929        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 
    59385930        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesForStats", samplesForStats); 
     
    59465938        Debug << "view cell stats prefix: " << statsPrefix << endl; 
    59475939 
    5948         // should directional sampling be used? 
    5949         bool dirSamples =  
    5950                 (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 
     5940    // mix of sampling strategies 
     5941        vector<int> strategies; 
     5942        strategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
     5943        strategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     5944        strategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
    59515945 
    59525946        cout << "reseting pvs ... "; 
     
    59715965                Debug << "casting " << samplesPerPass << " samples ... "; 
    59725966 
    5973                 CastPassSamples(samplesPerPass, samplingType, evaluationSamples); 
     5967                CastPassSamples(samplesPerPass, strategies, evaluationSamples); 
    59745968                 
    59755969                castSamples += samplesPerPass; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1764 r1768  
    567567        */ 
    568568        int CastPassSamples(const int samplesPerPass,  
    569                                                 const int sampleType,  
     569                                                const vector<int> &strategies, 
    570570                                                VssRayContainer &vssRays) const; 
    571571 
Note: See TracChangeset for help on using the changeset viewer.