Changeset 1824


Ignore:
Timestamp:
11/28/06 19:46:36 (17 years ago)
Author:
bittner
Message:

global lines support

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r1772 r1824  
    23102310} 
    23112311 
    2312  
    2313 } 
    2314  
     2312Vector3 
     2313AxisAlignedBox3::GetUniformRandomSurfacePoint() const 
     2314{ 
     2315        // get face based on its surface area 
     2316        float pdf[7]; 
     2317        pdf[0] = 0.0f; 
     2318        int i; 
     2319        for (i=0; i < 6; i++) { 
     2320                pdf[i+1] = pdf[i] + GetFace(i).GetArea(); 
     2321        } 
     2322         
     2323        float x = RandomValue(0, pdf[6]); 
     2324        for (i=0; i < 6; i++) { 
     2325                if (x < pdf[i]) 
     2326                        break; 
     2327        } 
     2328 
     2329        const int idx = i-1; 
     2330         
     2331        const Rectangle3 face = GetFace(idx); 
     2332         
     2333        Vector3 point = Vector3(0,0,0); 
     2334        float sum = 0.0f; 
     2335 
     2336        for (i = 0; i < 4; ++ i)  
     2337        { 
     2338                const float r = RandomValue(0, 1); 
     2339                sum += r; 
     2340                point += face.mVertices[i] * r; 
     2341        } 
     2342 
     2343        point *= 1.0f / sum; 
     2344 
     2345        //normal = face.GetNormal(); 
     2346 
     2347        return point; 
     2348} 
     2349 
     2350 
     2351} 
     2352 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r1772 r1824  
    183183  Vector3 GetRandomPoint() const; 
    184184  Vector3 GetRandomSurfacePoint() const; 
     185        Vector3 GetUniformRandomSurfacePoint() const; 
    185186 
    186187  Vector3 GetPoint(const Vector3 &p) const { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r1785 r1824  
    5656}; 
    5757 
     58        struct PvsCache { 
     59                PvsCache():mViewCell(NULL) {} 
     60                void Reset() { mViewCell = NULL; mPvs.Clear(); filteredBoxes.clear(); } 
     61                ViewCell *mViewCell; 
     62                ObjectPvs mPvs; 
     63                vector<AxisAlignedBox3> filteredBoxes; 
     64        }; 
     65 
     66 
    5867struct RenderCostSample { 
    5968 
     
    147156protected: 
    148157 
     158        PvsCache mPvsCache; 
    149159 
    150160  vector<OcclusionQuery *> mOcclusionQueries; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1584 r1824  
    2222 
    2323int InternalRayCaster::CastRay(const SimpleRay &simpleRay, 
    24                                                            VssRayContainer &vssRays, 
    25                                                            const AxisAlignedBox3 &box, 
    26                                                            const bool castDoubleRay, 
    27                                                            const bool pruneInvalidRays 
    28                                                            ) 
    29 { 
    30   //cout << "internal ray" << endl; 
     24                                                                                                                         VssRayContainer &vssRays, 
     25                                                                                                                         const AxisAlignedBox3 &box, 
     26                                                                                                                         const bool castDoubleRay, 
     27                                                                                                                         const bool pruneInvalidRays 
     28                                                                                                                         ) 
     29{ 
     30        if (simpleRay.mType == Ray::GLOBAL_RAY) 
     31                return CastGlobalRay(simpleRay, vssRays, box, pruneInvalidRays); 
     32         
     33        //cout << "internal ray" << endl; 
    3134  static Ray ray; 
    3235  int hits = 0; 
     
    5356        } 
    5457   
    55   mPreprocessor.SetupRay(ray, simpleRay.mOrigin, -simpleRay.mDirection); 
    56   ray.mFlags &= ~Ray::CULL_BACKFACES; 
    5758   
    5859  if (castDoubleRay && mKdTree->CastRay(ray))  
    59         { 
    60           hitB.mObject = ray.intersections[0].mObject; 
    61           hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 
    62           hitB.mNormal = ray.intersections[0].mNormal; 
     60                { 
     61                        mPreprocessor.SetupRay(ray, simpleRay.mOrigin, -simpleRay.mDirection); 
     62                        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     63                        hitB.mObject = ray.intersections[0].mObject; 
     64                        hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 
     65                        hitB.mNormal = ray.intersections[0].mNormal; 
     66                } 
     67   
     68  return ProcessRay( 
     69                                                                                simpleRay, 
     70                                                                                hitA, 
     71                                                                                hitB, 
     72                                                                                vssRays, 
     73                                                                                box, 
     74                                                                                castDoubleRay, 
     75                                                                                pruneInvalidRays 
     76                                                                                ); 
     77} 
     78 
     79 
     80int 
     81InternalRayCaster::CastGlobalRay(const SimpleRay &simpleRay, 
     82                                                                                                                                 VssRayContainer &vssRays, 
     83                                                                                                                                 const AxisAlignedBox3 &box, 
     84                                                                                                                                 const bool pruneInvalidRays 
     85                                                                                                                                 ) 
     86{ 
     87  static Ray ray; 
     88  int hits = 0; 
     89        mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 
     90 
     91        float tmin, tmax; 
     92        if (!(box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax))) 
     93                return 0; 
     94 
     95        // shift the ray origin to tmin 
     96        //      Vector3 origin = ray.Extrap(tmin); 
     97        //      mPreprocessor.SetupRay(ray, origin, simpleRay.mDirection); 
     98        ray.SetType(Ray::GLOBAL_RAY); 
     99        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     100 
     101 
     102        VssRay *vssRay; 
     103         
     104  if (mKdTree->CastRay(ray)) { 
     105                // sort intersections 
     106                ray.SortIntersections(); 
     107                //cout<<"I="<<ray.intersections.size()<<endl; 
     108 
     109                 
     110                Ray::Intersection &hit = ray.intersections[0]; 
     111 
     112                if (DotProd(hit.mNormal, ray.GetDir()) < 0) { 
     113                        // insert intial segment 
     114                        vssRay = new VssRay( 
     115                                                                                                        ray.Extrap(tmin), 
     116                                                                                                        ray.Extrap(hit.mT), 
     117                                                                                                        NULL, 
     118                                                                                                        hit.mObject, 
     119                                                                                                        mPreprocessor.mPass, 
     120                                                                                                        simpleRay.mPdf 
     121                                                                                                        ); 
     122                        vssRay->mFlags |= VssRay::Valid; 
     123                        vssRays.push_back(vssRay); 
     124                        ++hits; 
     125                } 
     126                                 
     127                hit = ray.intersections[ray.intersections.size()-1]; 
     128                if (DotProd(hit.mNormal, ray.GetDir()) > 0) { 
     129                         
     130                        // insert termination segment 
     131                        vssRay = new VssRay( 
     132                                                                                                        ray.Extrap(tmax), 
     133                                                                                                        ray.Extrap(hit.mT), 
     134                                                                                                        NULL, 
     135                                                                                                        hit.mObject, 
     136                                                                                                        mPreprocessor.mPass, 
     137                                                                                                        simpleRay.mPdf 
     138                                                                                                        ); 
     139                        vssRay->mFlags |= VssRay::Valid; 
     140                        vssRays.push_back(vssRay); 
     141                        ++hits; 
     142                } 
     143                 
     144                // insert the rest of segments 
     145                for (int i=0; i < ray.intersections.size() - 1; i++) { 
     146                        Ray::Intersection &hitA = ray.intersections[i]; 
     147                        Ray::Intersection &hitB = ray.intersections[i + 1]; 
     148                        if (DotProd(hitA.mNormal, ray.GetDir()) > 0 && 
     149                                        DotProd(hitB.mNormal, ray.GetDir()) < 0 
     150                                        ) { 
     151                                 
     152                                vssRay = new VssRay( 
     153                                                                                                                ray.Extrap(hitA.mT), 
     154                                                                                                                ray.Extrap(hitB.mT), 
     155                                                                                                                hitA.mObject, 
     156                                                                                                                hitB.mObject, 
     157                                                                                                                mPreprocessor.mPass, 
     158                                                                                                                simpleRay.mPdf 
     159                                                                                                                ); 
     160                                vssRay->mFlags |= VssRay::Valid; 
     161                                vssRays.push_back(vssRay); 
     162                                ++hits; 
     163                                 
     164                                vssRay = new VssRay( 
     165                                                                                                                ray.Extrap(hitB.mT), 
     166                                                                                                                ray.Extrap(hitA.mT), 
     167                                                                                                                hitB.mObject, 
     168                                                                                                                hitA.mObject, 
     169                                                                                                                mPreprocessor.mPass, 
     170                                                                                                                simpleRay.mPdf 
     171                                                                                                                ); 
     172                                 
     173                                vssRay->mFlags |= VssRay::Valid; 
     174                                vssRays.push_back(vssRay); 
     175                                ++hits; 
     176                        } 
     177                } 
    63178        } 
    64    
    65   return ProcessRay( 
    66                                         simpleRay, 
    67                                         hitA, 
    68                                         hitB, 
    69                                         vssRays, 
    70                                         box, 
    71                                         castDoubleRay, 
    72                                         pruneInvalidRays 
    73                                         ); 
    74 } 
    75  
     179         
     180        return hits; 
     181} 
    76182 
    77183void InternalRayCaster::CastRays16(const int index, 
    78                                                                   SimpleRayContainer &rays,  
    79                                                                   VssRayContainer &vssRays, 
    80                                                                   const AxisAlignedBox3 &sbox, 
    81                                                                   const bool castDoubleRays, 
    82                                                                   const bool pruneInvalidRays) 
     184                                                                                                                                        SimpleRayContainer &rays,  
     185                                                                                                                                        VssRayContainer &vssRays, 
     186                                                                                                                                        const AxisAlignedBox3 &sbox, 
     187                                                                                                                                        const bool castDoubleRays, 
     188                                                                                                                                        const bool pruneInvalidRays) 
    83189{ 
    84190        const int num = 16; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h

    r1528 r1824  
    5252                 ); 
    5353 
     54        virtual int 
     55        CastGlobalRay(const SimpleRay &simpleRay, 
     56                                                                VssRayContainer &vssRays, 
     57                                                                const AxisAlignedBox3 &box, 
     58                                                                const bool pruneInvalidRays 
     59                                                                ); 
     60 
    5461protected: 
    5562 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp

    r1786 r1824  
    2323        if (ray.GetType() == Ray::LOCAL_RAY && !ray.intersections.empty()) 
    2424                nearestT = ray.intersections[0].mT; 
    25  
     25         
    2626        const int hitCode = mItem.CastRay(ray, t, nearestT, nearestNormal); 
    2727 
    2828        nearestT = t; 
    2929 
    30         if ((hitCode == Ray::INTERSECTION) && (ray.GetType() == Ray::LOCAL_RAY)) 
    31         { 
    32                 if (!ray.intersections.empty()) 
    33                 { 
    34                         ray.intersections[0] = Ray::Intersection(nearestT, nearestNormal, this, 0); 
     30        if (hitCode == Ray::INTERSECTION) { 
     31                if (ray.GetType() == Ray::LOCAL_RAY && !ray.intersections.empty()) { 
     32                        ray.intersections[0] = Ray::Intersection(nearestT, 
     33                                                                                                                                                                                         nearestNormal, 
     34                                                                                                                                                                                         this, 
     35                                                                                                                                                                                         0); 
    3536                } 
    36                 else 
    37                 { 
    38                         ray.intersections.push_back(Ray::Intersection(nearestT, nearestNormal, this, 0)); 
     37                else { 
     38                        ray.intersections.push_back(Ray::Intersection(nearestT, 
     39                                                                                                                                                                                                                nearestNormal, 
     40                                                                                                                                                                                                                this, 
     41                                                                                                                                                                                                                0)); 
    3942                } 
    4043                 
    4144                return 1; 
    4245        } 
    43  
     46         
    4447        return 0; 
    4548} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1761 r1824  
    677677          ObjectContainer::const_iterator mi; 
    678678          for ( mi = leaf->mObjects.begin(); 
    679                         mi != leaf->mObjects.end(); 
    680                         mi++) { 
    681                 Intersectable *object = *mi; 
    682                 if (!object->Mailed() ) { 
    683                   object->Mail(); 
    684                   if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 
    685                         ray.testedObjects.push_back(object); 
    686  
    687                   static int oi=1; 
    688                   if (MeshDebug)  
    689                         cout<<"Object "<<oi++; 
    690                    
    691                   hits += object->CastRay(ray); 
    692  
    693                   if (MeshDebug) { 
    694                         if (!ray.intersections.empty())  
    695                         cout<<"nearest t="<<ray.intersections[0].mT<<endl; 
    696                   else 
    697                         cout<<"nearest t=-INF"<<endl; 
    698                   }        
    699                 } 
     679                                        mi != leaf->mObjects.end(); 
     680                                        mi++) { 
     681                        Intersectable *object = *mi; 
     682                        if (!object->Mailed() ) { 
     683                                object->Mail(); 
     684                                if (ray.mFlags & Ray::STORE_TESTED_OBJECTS) 
     685                                        ray.testedObjects.push_back(object); 
     686                                 
     687                                static int oi=1; 
     688                                if (MeshDebug)  
     689                                        cout<<"Object "<<oi++; 
     690                                 
     691                                hits += object->CastRay(ray); 
     692                                 
     693                                if (MeshDebug) { 
     694                                        if (!ray.intersections.empty())  
     695                                                cout<<"nearest t="<<ray.intersections[0].mT<<endl; 
     696                                        else 
     697                                                cout<<"nearest t=-INF"<<endl; 
     698                                }          
     699                        } 
    700700          } 
    701701           
    702702          if (hits && ray.GetType() == Ray::LOCAL_RAY) 
    703                 if (ray.intersections[0].mT <= maxt) 
    704                   break; 
     703                        if (ray.intersections[0].mT <= maxt) 
     704                                break; 
    705705           
    706706          // get the next node from the stack 
    707707          if (tStack.empty()) 
    708                 break; 
     708                        break; 
    709709           
    710710          entp = extp; 
    711711          mint = maxt; 
    712712          if (ray.GetType() == Ray::LINE_SEGMENT && mint > 1.0f) 
    713                 break; 
     713                        break; 
    714714           
    715715          RayTraversalData &s  = tStack.top(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1785 r1824  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 23. XI 14:54:07 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: út 28. XI 19:46:06 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1772 r1824  
    219219                faceIndex < mFaces.size(); 
    220220                faceIndex++) { 
    221     hits += CastRayToFace(faceIndex, ray, nearestT, nearestNormal, nearestFace, instance); 
     221    hits += CastRayToFace(faceIndex, 
     222                                                                                                        ray, 
     223                                                                                                        nearestT, 
     224                                                                                                        nearestNormal, 
     225                                                                                                        nearestFace, 
     226                                                                                                        instance); 
    222227    if (mIsConvex && nearestFace != -1) 
    223228      break; 
     
    226231  if ( hits && ray.GetType() == Ray::LOCAL_RAY ) { 
    227232    if (ray.intersections.size()) 
    228       ray.intersections[0] = Ray::Intersection(nearestT, nearestNormal, instance, nearestFace); 
     233      ray.intersections[0] = Ray::Intersection(nearestT, 
     234                                                                                                                                                                                         nearestNormal, 
     235                                                                                                                                                                                         instance, 
     236                                                                                                                                                                                         nearestFace); 
    229237    else 
    230       ray.intersections.push_back(Ray::Intersection(nearestT, nearestNormal, instance, nearestFace)); 
     238      ray.intersections.push_back(Ray::Intersection(nearestT, 
     239                                                                                                                                                                                                                nearestNormal, 
     240                                                                                                                                                                                                                instance, 
     241                                                                                                                                                                                                                nearestFace)); 
    231242  } 
    232243   
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1786 r1824  
    983983int 
    984984Preprocessor::GenerateRays(const int number, 
    985                                                   const SamplingStrategy &strategy, 
    986                                                   SimpleRayContainer &rays) 
     985                                                                                                        const SamplingStrategy &strategy, 
     986                                                                                                        SimpleRayContainer &rays) 
    987987{ 
    988988        return strategy.GenerateSamples(number, rays); 
     
    991991int 
    992992Preprocessor::GenerateRays(const int number, 
    993                                                   const int sampleType, 
    994                                                   SimpleRayContainer &rays) 
     993                                                                                                        const int sampleType, 
     994                                                                                                        SimpleRayContainer &rays) 
    995995{ 
    996996        const int startSize = (int)rays.size(); 
     
    10371037        case SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION: 
    10381038                return new ReverseViewSpaceBorderBasedDistribution(*this); 
    1039         //case OBJECTS_INTERIOR_DISTRIBUTION: 
    1040         //      return new ObjectsInteriorDistribution(*this); 
     1039        case SamplingStrategy::GLOBAL_LINES_DISTRIBUTION: 
     1040                return new GlobalLinesDistribution(*this); 
     1041                 
     1042                //case OBJECTS_INTERIOR_DISTRIBUTION: 
     1043                //      return new ObjectsInteriorDistribution(*this); 
    10411044        default: // no valid strategy 
    10421045                Debug << "warning: no valid sampling strategy" << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1785 r1824  
    148148         
    149149  if (viewcell) { 
    150         mViewCellsManager->ApplyFilter2(viewcell, 
    151                                                                         false, 
    152                                                                         1.0f, 
    153                                                                         pvs); 
    154          
    155         pvsSize = 0; 
    156         SetupCamera(); 
    157         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    158         glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); 
    159          
     150                mViewCellsManager->ApplyFilter2(viewcell, 
     151                                                                                                                                                false, 
     152                                                                                                                                                1.0f, 
     153                                                                                                                                                pvs); 
     154                 
     155                pvsSize = 0; 
     156                SetupCamera(); 
     157                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     158                glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); 
     159                 
    160160           
    161         //      // Render PVS 
    162         ObjectPvsIterator it = pvs.GetIterator(); 
    163          
    164         pvsSize = pvs.GetSize(); 
    165         Intersectable::NewMail(); 
     161                //      // Render PVS 
     162                ObjectPvsIterator it = pvs.GetIterator(); 
     163                 
     164                pvsSize = pvs.GetSize(); 
     165                Intersectable::NewMail(); 
    166166        for (; it.HasMoreEntries(); ) { 
    167167          ObjectPvsEntry entry = it.Next(); 
     
    364364           
    365365          if (mUseSpatialFilter) { 
    366                 // 9.11. 2006 -> experiment with new spatial filter 
     366                        // 9.11. 2006 -> experiment with new spatial filter 
    367367#if 0 
    368                 mViewCellsManager->ApplySpatialFilter(mKdTree, 
    369                                                                                           mSpatialFilterSize* 
    370                                                                                           Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
    371                                                                                           pvs); 
     368                        mViewCellsManager->ApplySpatialFilter(mKdTree, 
     369                                                                                                                                                                                mSpatialFilterSize* 
     370                                                                                                                                                                                Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
     371                                                                                                                                                                                pvs); 
    372372#else 
    373                 // mSpatialFilter size is in range 0.001 - 0.1 
    374                 mViewCellsManager->ApplyFilter2(viewcell, 
    375                                                                                 mUseFilter, 
    376                                                                                 100*mSpatialFilterSize, 
    377                                                                                 pvs); 
     373                        // mSpatialFilter size is in range 0.001 - 0.1 
     374                        mViewCellsManager->ApplyFilter2(viewcell, 
     375                                                                                                                                                        mUseFilter, 
     376                                                                                                                                                        100*mSpatialFilterSize, 
     377                                                                                                                                                        pvs, 
     378                                                                                                                                                        &mPvsCache.filteredBoxes 
     379                                                                                                                                                        ); 
    378380#endif 
    379381          } else 
    380                 pvs = viewcell->GetPvs(); 
     382                        pvs = viewcell->GetPvs(); 
    381383        } 
    382384 
    383385        // Render PVS 
    384         ObjectPvsIterator it = pvs.GetIterator(); 
    385          
    386         mPvsSize = pvs.GetSize(); 
    387          
    388         for (; it.HasMoreEntries(); ) { 
    389           ObjectPvsEntry entry = it.Next(); 
    390           Intersectable *object = entry.mObject; 
    391            
    392           if (mRenderVisibilityEstimates) { 
     386        if (mUseSpatialFilter && mRenderBoxes) { 
     387                for (int i=0; i < mPvsCache.filteredBoxes.size(); i++) 
     388                        RenderBox(mPvsCache.filteredBoxes[i]); 
     389        } else { 
     390                ObjectPvsIterator it = pvs.GetIterator(); 
    393391                 
    394                 float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
    395                 glColor3f(visibility, 0.0f, 0.0f); 
    396                 mUseForcedColors = true; 
    397                 RenderIntersectable(object); 
    398                 mUseForcedColors = false; 
    399           } else { 
    400                 mUseForcedColors = false; 
    401                 RenderIntersectable(object); 
    402           } 
     392                mPvsSize = pvs.GetSize(); 
     393                for (; it.HasMoreEntries(); ) { 
     394                        ObjectPvsEntry entry = it.Next(); 
     395                        Intersectable *object = entry.mObject; 
     396                         
     397                        if (mRenderVisibilityEstimates) { 
     398                                 
     399                                float visibility = mTransferFunction*log10(entry.mData.mSumPdf + 1); // /5.0f 
     400                                glColor3f(visibility, 0.0f, 0.0f); 
     401                                mUseForcedColors = true; 
     402                                RenderIntersectable(object); 
     403                                mUseForcedColors = false; 
     404                        } else { 
     405                                mUseForcedColors = false; 
     406                                RenderIntersectable(object); 
     407                        } 
     408                } 
    403409        } 
    404410 
     
    412418          glColor3f(1.0f, 0.0f, 0.0f); 
    413419          gluSphere((::GLUquadric *)mSphere, 
    414                                 1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
     420                                                        1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
    415421          glPopAttrib(); 
    416422          glPopMatrix(); 
     
    422428 
    423429  } else { 
    424         ObjectContainer::const_iterator oi = mObjects.begin(); 
    425         for (; oi != mObjects.end(); oi++) 
    426           RenderIntersectable(*oi); 
     430                ObjectContainer::const_iterator oi = mObjects.begin(); 
     431                for (; oi != mObjects.end(); oi++) 
     432                        RenderIntersectable(*oi); 
    427433  } 
    428434} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.h

    r1785 r1824  
    116116 
    117117 
    118 struct PvsCache { 
    119   PvsCache():mViewCell(NULL) {} 
    120   void Reset() { mViewCell = NULL; mPvs.Clear(); } 
    121   ViewCell *mViewCell; 
    122   ObjectPvs mPvs; 
    123 }; 
    124  
    125118class QtGlRendererWidget : public QGLWidget, public GlRendererWidget 
    126119{ 
     
    156149  float mManipulatorLastQuat[4]; 
    157150  float mManipulatorScale; 
    158   PvsCache mPvsCache; 
    159151   
    160152  QtRendererControlWidget *mControlWidget; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h

    r1594 r1824  
    33 
    44#include <vector> 
     5#include <algorithm> 
    56#include "Matrix4x4.h" 
    67#include "Vector3.h" 
     
    4647          Intersectable *mObject; 
    4748 
    48         /// the face of the intersectable 
     49                /// the face of the intersectable 
    4950          int mFace; 
    5051 
    5152          Intersection(const float t, 
    52                                   const Vector3 &normal, 
    53                                   Intersectable *object, 
    54                                   const int face):  
    55           mT(t), mNormal(normal), mObject(object), mFace(face)  
     53                                                                const Vector3 &normal, 
     54                                                                Intersectable *object, 
     55                                                                const int face):  
     56                        mT(t), mNormal(normal), mObject(object), mFace(face)  
    5657          {} 
    57  
     58                 
    5859          Intersection(): mT(0), mNormal(0,0,0), mObject(NULL), mFace(0)  
    5960          {} 
    60  
     61                 
    6162          bool operator<(const Intersection &b) const  
    6263          { 
     
    113114  void Init(const VssRay &vssRay); 
    114115 
     116        void SortIntersections() { 
     117                sort(intersections.begin(), intersections.end()); 
     118        } 
     119         
    115120  Intersectable *GetIntersectionObject(const int i) const { 
    116121    return intersections[i].mObject; 
     
    215220 
    216221  int GetType() const { return mType; } 
     222  void SetType(const int t) { mType = t; } 
    217223   
    218224  // make such operation to slightly change the ray direction 
     
    313319  Vector3 mDirection; 
    314320  float mPdf; 
    315  
    316   SimpleRay() {} 
     321        int mType; 
     322         
     323  SimpleRay(): mType(Ray::LOCAL_RAY) {} 
    317324  SimpleRay(const Vector3 &o, const Vector3 &d, const float p=1.0f): 
    318         mOrigin(o), mDirection(d), mPdf(p) {} 
    319  
     325                mOrigin(o), mDirection(d), mPdf(p), mType(Ray::LOCAL_RAY) {} 
     326         
    320327  Vector3 Extrap(const float t) const { 
    321328        return mOrigin + mDirection * t; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1771 r1824  
    150150                { 
    151151                  VssRay *vssRay = new VssRay( 
    152                                                                           hitA.mPoint, 
    153                                                                           hitB.mPoint, 
    154                                                                           hitA.mObject, 
    155                                                                           hitB.mObject, 
    156                                                                           mPreprocessor.mPass, 
    157                                                                           simpleRay.mPdf 
    158                                                                           ); 
     152                                                                                                                                        hitA.mPoint, 
     153                                                                                                                                        hitB.mPoint, 
     154                                                                                                                                        hitA.mObject, 
     155                                                                                                                                        hitB.mObject, 
     156                                                                                                                                        mPreprocessor.mPass, 
     157                                                                                                                                        simpleRay.mPdf 
     158                                                                                                                                        ); 
    159159                  if (validB) 
    160                         vssRay->mFlags |= VssRay::Valid; 
     160                                vssRay->mFlags |= VssRay::Valid; 
    161161                   
    162162                  vssRays.push_back(vssRay); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r1545 r1824  
    7474 
    7575                Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f): 
    76                 mPoint(p), mNormal(n), mObject(o), mFaceId(f) 
     76                        mPoint(p), mNormal(n), mObject(o), mFaceId(f) 
    7777                {} 
    7878 
     
    8484                int mFaceId; 
    8585        }; 
     86 
    8687 
    8788        int ProcessRay( 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1785 r1824  
    7373  case SamplingStrategy::RSS_BASED_DISTRIBUTION: 
    7474  case SamplingStrategy::RSS_SILHOUETTE_BASED_DISTRIBUTION: 
    75         if (mRssTree) { 
    76           result = GenerateImportanceRays(mRssTree, number, rays); 
    77         } 
    78         break; 
    79          
     75                if (mRssTree) { 
     76                        result = GenerateImportanceRays(mRssTree, number, rays); 
     77                } 
     78                break; 
     79                 
    8080  default: 
    81         result = Preprocessor::GenerateRays(number, sampleType, rays); 
     81                result = Preprocessor::GenerateRays(number, sampleType, rays); 
    8282  } 
    8383 
     
    465465 
    466466  if (mUseRssTree) 
    467         mDistributions.push_back(new RssBasedDistribution(*this)); 
    468  
    469   //  mDistributions.push_back(new SpatialBoxBasedDistribution(*this)); 
    470   //  mDistributions.push_back(new DirectionBasedDistribution(*this)); 
    471   mDistributions.push_back(new ObjectDirectionBasedDistribution(*this)); 
    472   //  mDistributions.push_back(new ReverseObjectBasedDistribution(*this)); 
    473   mDistributions.push_back(new ObjectBasedDistribution(*this)); 
    474   mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(*this)); 
     467                mDistributions.push_back(new RssBasedDistribution(*this)); 
     468 
     469 
     470        if (1) { 
     471                //  mDistributions.push_back(new SpatialBoxBasedDistribution(*this)); 
     472                //  mDistributions.push_back(new DirectionBasedDistribution(*this)); 
     473                mDistributions.push_back(new ObjectDirectionBasedDistribution(*this)); 
     474                //  mDistributions.push_back(new ReverseObjectBasedDistribution(*this)); 
     475                mDistributions.push_back(new ObjectBasedDistribution(*this)); 
     476                mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(*this)); 
     477        } else { 
     478                mDistributions.push_back(new GlobalLinesDistribution(*this)); 
     479        } 
    475480   
    476481  if (mLoadInitialSamples) { 
     
    495500                if (mDistributions[i]->mType != SamplingStrategy::RSS_BASED_DISTRIBUTION) 
    496501                  GenerateRays(mInitialSamples/count, 
    497                                            mDistributions[i]->mType, rays); 
     502                                                                         mDistributions[i]->mType, 
     503                                                                         rays); 
    498504 
    499505        } else { 
     
    582588   
    583589  rssPass++; 
    584    
     590 
     591        //      mDistributions.resize(1); 
     592 
    585593  mRssTree = new RssTree; 
    586594  mRssTree->SetPass(mPass); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1785 r1824  
    336336          leaf->dirBBox.Initialize(); 
    337337          leaf->dirBBox.SetMin(2, 0.0f); 
    338           leaf->dirBBox.SetMax(2, 1.0f); 
     338          leaf->dirBBox.SetMax(2, 0.0f); 
    339339          mRoots[i] = leaf; 
    340340        } 
     
    391391  // make the z axis (unused) a unit size 
    392392  // important for volume computation 
    393  
    394393   
    395394  //  if ( forcedBoundingBox )  
     
    22302229        dirVector = dirBox.GetPoint(dVector); 
    22312230         
    2232         direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 
    2233          
    2234          
    2235         // shift the origin a little bit 
    2236         direction.Normalize(); 
     2231        direction = VssRay::GetInvDirParam(dirVector.x, dirVector.y); 
    22372232         
    22382233        //      float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
     
    22432238#if 1 
    22442239        if (box.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 
    2245           dist = maxT; 
     2240          dist = (maxT + 1e-2*boxSize); 
    22462241#else 
    22472242        dist = 0.5f*boxSize; 
     
    23732368                w1*leaf->rays[r1].GetDir() + 
    23742369                w2*leaf->rays[r2].GetDir(); 
     2370 
     2371          // shift the origin a little bit 
     2372          direction.Normalize(); 
     2373           
    23752374        } else { 
    23762375          Vector3 dirVector; 
     
    24052404          dirVector = dirBox.GetPoint(dVector); 
    24062405 
    2407           direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 
    2408         } 
    2409  
    2410         // shift the origin a little bit 
    2411         direction.Normalize(); 
     2406          direction = VssRay::GetInvDirParam(dirVector.x,dirVector.y); 
     2407        } 
     2408         
    24122409         
    24132410        //      float dist = Min(avgLength*0.5f, Magnitude(GetBBox(leaf).Size())); 
     
    26282625          if (node->IsLeaf()) { 
    26292626                RssTreeLeaf *leaf = (RssTreeLeaf *)node; 
    2630                 // prunned += PruneRaysRandom(leaf, ratio); 
     2627                //              prunned += PruneRaysRandom(leaf, ratio); 
    26312628                prunned += PruneRaysContribution(leaf, ratio); 
    26322629          } else { 
     
    27592756// if small very high importance of the last sample 
    27602757// if 1.0f then weighs = 1 1/2 1/3 1/4 
     2758//float passSampleWeightDecay = 1.0f; 
    27612759float passSampleWeightDecay = 1.0f; 
    2762 //float passSampleWeightDecay = 0.0001f; 
    27632760 
    27642761float 
     
    27682765  float weight; 
    27692766  if (1)  
    2770         weight = 1.0f/sqr(passDiff + passSampleWeightDecay); 
     2767                weight = 1.0f/(passDiff + passSampleWeightDecay); 
    27712768  else  
    2772         switch (passDiff) { 
     2769                switch (passDiff) { 
    27732770          case 0: 
    2774           //      weight = 1.0f; 
    2775           //      break; 
    2776         default: 
    2777           weight = 1.0f; 
    2778           break; 
     2771                        //        weight = 1.0f; 
     2772                        //        break; 
     2773                default: 
     2774                        weight = 1.0f; 
     2775                        break; 
    27792776          //    case 1: 
    27802777//        weight = 0.5f; 
     
    28232820        float sumRelContributions = 0.0f; 
    28242821        float sumWeights = 0.0f; 
     2822        float maxContribution = 0.0f; 
     2823        float maxRelContribution = 0.0f; 
     2824        float sumLength = 0; 
     2825         
    28252826        for (; it != it_end; ++it) { 
    28262827          VssRay *ray = (*it).mRay; 
     2828          float sumLength = ray->Length(); 
     2829 
    28272830          float weight = GetSampleWeight(ray->mPass); 
    28282831           
    2829           sumContributions += weight*ray->mPvsContribution; 
    2830           //$$ 20.7. changed to sqr to pronouce higher contribution so that they do not get smoothed!! 
     2832          float c1 = weight*ray->mPvsContribution; 
     2833          float c2 = weight*ray->mRelativePvsContribution; 
     2834          sumContributions += c1; 
     2835          if (c1 > maxContribution) 
     2836                maxContribution = c1; 
     2837           
     2838          //$$ 20.7. changed to sqr to pronouce higher contribution so that 
     2839          // they do not get smoothed!! 
    28312840          //sumRelContributions += weight*ray->mRelativePvsContribution; 
    2832  
    2833           sumRelContributions += sqr(weight*ray->mRelativePvsContribution); 
    2834            
     2841           
     2842          sumRelContributions += c2; 
     2843          if (c2 > maxRelContribution) 
     2844                maxRelContribution = c2; 
     2845 
    28352846          //sumWeights += weight; 
    28362847          sumWeights += 1.0f; 
    28372848        } 
     2849 
     2850        float distImportance = 0.0f; 
     2851 
     2852        if (leaf->rays.size()) { 
     2853          // compute average length of the ray  
     2854          float avgLength = sumLength/leaf->rays.size(); 
     2855          // compute estimated area of the visible surface corresponding to these rays 
     2856          float ss = GetBBox(leaf).SurfaceArea()/2.0f; 
     2857          float sd = GetDirBBox(leaf).SurfaceArea(); 
     2858          float s = ss + avgLength*(2*sqrt(ss*sd) + avgLength*sd); 
     2859           
     2860          distImportance = s/leaf->rays.size(); 
     2861        } 
     2862         
    28382863        // $$  
    28392864        // sumWeights = leaf->mTotalRays; 
    2840            
    2841         if (sumWeights != 0.0f)  
     2865 
     2866        if (sumWeights != 0.0f) { 
    28422867          leaf->mImportance = 
    2843                 (weightAbsContributions*sumContributions + 
    2844                  (1.0f - weightAbsContributions)*sumRelContributions)/sumWeights; 
    2845         else 
     2868                        sqr(((weightAbsContributions*sumContributions + 
     2869                                                (1.0f - weightAbsContributions)*sumRelContributions)/sumWeights)); 
     2870           
     2871          //      leaf->mImportance = 
     2872          //            (weightAbsContributions*maxContribution + 
     2873          //             (1.0f - weightAbsContributions)*maxRelContribution)/sumWeights; 
     2874           
     2875        } else 
    28462876          leaf->mImportance = 0.0f; 
    28472877         
     
    28562886RssTreeLeaf::GetImportance()  const 
    28572887{ 
    2858   //return sqr(mImportance); 
     2888  //  return sqr(mImportance); 
    28592889  return mImportance; 
    28602890} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1785 r1824  
    386386} 
    387387 
    388 } 
    389  
    390  
     388 
     389bool 
     390GlobalLinesDistribution::GenerateSample(SimpleRay &ray) const 
     391{ 
     392        Vector3 origin, termination, direction;  
     393         
     394        origin = mPreprocessor.mViewCellsManager->GetViewSpaceBox().GetRandomSurfacePoint(); 
     395 
     396        termination = mPreprocessor.mViewCellsManager->GetViewSpaceBox().GetRandomSurfacePoint(); 
     397         
     398        direction = termination - origin; 
     399        //direction = UniformRandomVector(); 
     400 
     401 
     402        // $$ jb the pdf is yet not correct for all sampling methods! 
     403        const float c = Magnitude(direction); 
     404        if (c <= Limits::Small)  
     405                return false; 
     406         
     407         
     408        direction *= 1.0f / c; 
     409         
     410        // a little offset 
     411        //      origin += direction * 0.001f; 
     412         
     413        // $$ jb the pdf is yet not correct for all sampling methods! 
     414        const float pdf = 1.0f; 
     415 
     416        ray = SimpleRay(origin, direction, pdf); 
     417        ray.mType = Ray::GLOBAL_RAY; 
     418        return true; 
     419} 
     420 
     421} 
     422 
     423 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h

    r1772 r1824  
    3232                VIEWCELL_BORDER_BASED_DISTRIBUTION, 
    3333                VIEWSPACE_BORDER_BASED_DISTRIBUTION, 
    34                 REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION 
     34                REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION, 
     35                GLOBAL_LINES_DISTRIBUTION 
    3536        }; 
    3637 
     
    199200}; 
    200201 
     202class GlobalLinesDistribution: public SamplingStrategy 
     203{ 
     204public: 
     205  GlobalLinesDistribution(const Preprocessor &preprocessor): 
     206                SamplingStrategy(preprocessor) { 
     207                mType = GLOBAL_LINES_DISTRIBUTION; 
     208        } 
     209   
     210  virtual bool GenerateSample(SimpleRay &ray) const; 
     211}; 
     212 
    201213 
    202214/** This strategy generates samples inside of the objects, e.g., 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1816 r1824  
    3232 
    3333// $$JB HACK 
    34 #define USE_KD_PVS 0 
     34#define USE_KD_PVS 1 
    3535#define KD_PVS_AREA (1e-5f) 
    3636 
     
    856856        viewCells = mViewCells; 
    857857#endif 
    858         ViewCellContainer::iterator it = viewCells.begin(), it_end = viewCells.end();            
     858        ViewCellContainer::iterator it = viewCells.begin(), 
     859          it_end = viewCells.end();              
    859860        for (; it != it_end; ++it) { 
    860861          //(*it)->UpdatePvsCost(); 
     
    872873        // hack: normalize pvs size 
    873874        int histoMaxVal; 
    874         Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 
     875        Environment::GetSingleton()->GetIntValue( 
     876                                                                                         "Preprocessor.histogram.maxValue", histoMaxVal); 
    875877        maxVal = max((float)histoMaxVal, maxPvs); 
    876878                 
     
    18311833                if (evaluateFilter) { 
    18321834                  ObjectPvs filteredPvs = viewcell->GetPvs(); 
    1833                   PvsFilterStatistics fstat = ApplyFilter2(viewcell, false, 
    1834                                                                                                    1.0f, filteredPvs); 
     1835                  PvsFilterStatistics fstat = ApplyFilter2(viewcell, 
     1836                                                                                                                                                                                         false, 
     1837                                                                                                                                                                                         2.0f, 
     1838                                                                                                                                                                                         filteredPvs); 
    18351839                   
    18361840                  float filteredCost = filteredPvs.EvalPvsCost(); 
     
    19701974 
    19711975float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 
    1972                                                                                                   const bool addRays, 
    1973                                                                                                   const bool storeViewCells) 
     1976                                                                                                                                                                                                        const bool addRays, 
     1977                                                                                                                                                                                                        const bool storeViewCells) 
    19741978{ 
    19751979        ViewCellContainer viewcells; 
     
    20262030                                        ++ ray.mPvsContribution; 
    20272031                                        ray.mRelativePvsContribution += contribution; 
     2032                                        // $$ test of different contribution measure 
     2033                                        //                                      ray.mRelativePvsContribution += 1.0f/(viewcell->GetPvs().GetSize() + 10.0f); 
     2034 
    20282035                                } 
    20292036                        } 
     
    20372044                        if (ray.mOriginObject &&  
    20382045                                viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 
    2039                                                                                                                 ray.mPdf, 
    2040                                                                                                                 contribution)) 
    2041                         { 
    2042                                 ++ ray.mPvsContribution; 
    2043                                 ray.mRelativePvsContribution += contribution; 
    2044                         } 
     2046                                                                                                                                                                                                ray.mPdf, 
     2047                                                                                                                                                                                                contribution)) 
     2048                                { 
     2049                                        ++ ray.mPvsContribution; 
     2050                                        ray.mRelativePvsContribution += contribution; 
     2051                                } 
    20452052#endif 
    20462053                } 
     
    25822589PvsFilterStatistics 
    25832590ViewCellsManager::ApplyFilter2(ViewCell *viewCell, 
    2584                                                            const bool useViewSpaceFilter, 
    2585                                                            const float filterSize, 
    2586                                                            ObjectPvs &pvs 
    2587                                                            ) 
    2588 { 
    2589         cout<<"y"; 
     2591                                                                                                                         const bool useViewSpaceFilter, 
     2592                                                                                                                         const float filterSize, 
     2593                                                                                                                         ObjectPvs &pvs, 
     2594                                                                                                                         vector<AxisAlignedBox3> *filteredBoxes 
     2595                                                                                                                         ) 
     2596{ 
     2597        //cout<<"y"; 
    25902598  PvsFilterStatistics stats; 
    25912599 
     
    26012609  // first mark all object from this pvs 
    26022610  while (pit.HasMoreEntries()) {                 
    2603         ObjectPvsEntry entry = pit.Next(); 
    2604          
    2605         Intersectable *object = entry.mObject; 
    2606         object->Mail(); 
     2611                ObjectPvsEntry entry = pit.Next(); 
     2612                 
     2613                Intersectable *object = entry.mObject; 
     2614                object->Mail(); 
    26072615  } 
    26082616#endif 
     
    26252633   // and gobal estimate for the view cell 
    26262634   // (total #rays intersecting the viewcell) 
    2627 #define MIN_LOCAL_SAMPLES 5 
    2628  
     2635  int minLocalSamples = 2; 
     2636   
    26292637  float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
    26302638   
     
    26322640   
    26332641  if (useViewSpaceFilter) { 
    2634         //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
    2635         float radius = viewCellRadius/100.0f; 
    2636         vbox.Enlarge(radius); 
    2637         cout<<"vbox = "<<vbox<<endl; 
    2638         ViewCellContainer viewCells; 
    2639         ComputeBoxIntersections(vbox, viewCells); 
    2640          
    2641         ViewCellContainer::const_iterator it = viewCells.begin(), 
    2642           it_end = viewCells.end(); 
    2643         int i = 0; 
    2644         for (i=0; it != it_end; ++ it, ++ i) 
    2645           if ((*it) != viewCell) { 
    2646                 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
    2647                 basePvs.MergeInPlace((*it)->GetPvs()); 
    2648           } 
    2649          
    2650         // update samples and globalC 
    2651         samples = (float)pvs.GetSamples(); 
    2652         //      cout<<"neighboring viewcells = "<<i-1<<endl; 
    2653         //      cout<<"Samples' = "<<samples<<endl; 
     2642                //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
     2643                float radius = viewCellRadius/100.0f; 
     2644                vbox.Enlarge(radius); 
     2645                cout<<"vbox = "<<vbox<<endl; 
     2646                ViewCellContainer viewCells; 
     2647                ComputeBoxIntersections(vbox, viewCells); 
     2648                 
     2649                ViewCellContainer::const_iterator it = viewCells.begin(), 
     2650                        it_end = viewCells.end(); 
     2651                int i = 0; 
     2652                for (i=0; it != it_end; ++ it, ++ i) 
     2653                        if ((*it) != viewCell) { 
     2654                                //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
     2655                                basePvs.MergeInPlace((*it)->GetPvs()); 
     2656                        } 
     2657                 
     2658                // update samples and globalC 
     2659                samples = (float)pvs.GetSamples(); 
     2660                //      cout<<"neighboring viewcells = "<<i-1<<endl; 
     2661                //      cout<<"Samples' = "<<samples<<endl; 
    26542662  } 
    2655  
     2663         
    26562664  // Minimal number of samples so that filtering takes place 
    2657 #define MIN_SAMPLES  100 
     2665#define MIN_SAMPLES  50 
     2666 
    26582667  if (samples > MIN_SAMPLES) { 
    2659         float globalC = 2.0f*filterSize/sqrt(samples); 
    2660          
    2661         pit = basePvs.GetIterator(); 
    2662          
    2663         ObjectContainer objects; 
    2664          
    2665         while (pit.HasMoreEntries()) 
    2666           {              
    2667                 ObjectPvsEntry entry = pit.Next(); 
    2668                  
    2669                 Intersectable *object = entry.mObject; 
    2670                 // compute filter size based on the distance and the numebr of samples 
    2671                 AxisAlignedBox3 box = object->GetBox(); 
    2672                  
    2673                 float distance = Distance(center, box.Center()); 
    2674                 float globalRadius = distance*globalC; 
    2675                  
    2676                 int objectSamples = (int)entry.mData.mSumPdf; 
    2677                 float localRadius = MAX_FLOAT; 
    2678                 if (objectSamples > MIN_LOCAL_SAMPLES) 
    2679                   localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
    2680                         sqrt((float)objectSamples); 
    2681                  
    2682                 //      cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
    2683                  
    2684                 // now compute the filter size 
    2685                 float radius; 
    2686  
    2687                 if (localRadius < globalRadius) { 
    2688                   radius = localRadius; 
    2689                   stats.mLocalFilterCount++; 
    2690                 } else { 
    2691                   radius = globalRadius; 
    2692                   stats.mGlobalFilterCount++; 
    2693                 } 
    2694  
    2695                 stats.mAvgFilterRadius += radius; 
    2696                  
    2697                 // cout<<"box = "<<box<<endl; 
    2698                 //      cout<<"distance = "<<distance<<endl; 
    2699                 //      cout<<"radiues = "<<radius<<endl; 
    2700                  
    2701                 box.Enlarge(Vector3(radius)); 
    2702                  
    2703                 objects.clear(); 
    2704                 // $$ warning collect objects takes only unmailed ones! 
    2705                 CollectObjects(box, objects); 
    2706                 //      cout<<"collected objects="<<objects.size()<<endl; 
    2707                 ObjectContainer::const_iterator noi = objects.begin(); 
    2708                 for (; noi != objects.end(); ++ noi) { 
    2709                   Intersectable *o = *noi; 
    2710                   // $$ JB warning: pdfs are not correct at this point!    
    2711                   pvs.AddSampleDirty(o, Limits::Small); 
    2712                 } 
    2713           } 
    2714         stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
     2668                float globalC = 2.0f*filterSize/sqrt(samples); 
     2669                 
     2670                pit = basePvs.GetIterator(); 
     2671                 
     2672                ObjectContainer objects; 
     2673                 
     2674                while (pit.HasMoreEntries()) 
     2675                        {                
     2676                                ObjectPvsEntry entry = pit.Next(); 
     2677                                 
     2678                                Intersectable *object = entry.mObject; 
     2679                                // compute filter size based on the distance and the numebr of samples 
     2680                                AxisAlignedBox3 box = object->GetBox(); 
     2681                                 
     2682                                float distance = Distance(center, box.Center()); 
     2683                                float globalRadius = distance*globalC; 
     2684                                 
     2685                                int objectSamples = (int)entry.mData.mSumPdf; 
     2686                                float localRadius = MAX_FLOAT; 
     2687                                 
     2688                                localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
     2689                                        sqrt((float)objectSamples); 
     2690                                 
     2691                                //      cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
     2692                                 
     2693                                // now compute the filter size 
     2694                                float radius; 
     2695 
     2696#if 0 
     2697                                if (objectSamples <= 1) { 
     2698                                        if (localRadius > globalRadius) { 
     2699                                                radius = 0.5flRadius; 
     2700                                                stats.mLocalFilterCount++; 
     2701                                        } else { 
     2702                                                radius = globalRadius; 
     2703                                                stats.mGlobalFilterCount++; 
     2704                                        } 
     2705                                } else { 
     2706                                        radius = localRadius; 
     2707                                        stats.mLocalFilterCount++; 
     2708                                } 
     2709#else 
     2710                                radius = 0.5f*globalRadius + 0.5f*localRadius; 
     2711                                stats.mLocalFilterCount++; 
     2712                                stats.mGlobalFilterCount++; 
     2713#endif 
     2714                                 
     2715                                stats.mAvgFilterRadius += radius; 
     2716                                 
     2717                                // cout<<"box = "<<box<<endl; 
     2718                                //      cout<<"distance = "<<distance<<endl; 
     2719                                //      cout<<"radiues = "<<radius<<endl; 
     2720                                 
     2721                                box.Enlarge(Vector3(radius)); 
     2722                                if (filteredBoxes) 
     2723                                        filteredBoxes->push_back(box); 
     2724                                objects.clear(); 
     2725                                // $$ warning collect objects takes only unmailed ones! 
     2726                                CollectObjects(box, objects); 
     2727                                //      cout<<"collected objects="<<objects.size()<<endl; 
     2728                                ObjectContainer::const_iterator noi = objects.begin(); 
     2729                                for (; noi != objects.end(); ++ noi) { 
     2730                                        Intersectable *o = *noi; 
     2731                                        // $$ JB warning: pdfs are not correct at this point!      
     2732                                        pvs.AddSampleDirty(o, Limits::Small); 
     2733                                } 
     2734                        } 
     2735                stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
    27152736  } 
    27162737   
     
    27212742  pit = basePvs.GetIterator(); 
    27222743  while (pit.HasMoreEntries()) {                 
    2723         ObjectPvsEntry entry = pit.Next(); 
    2724         pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
     2744                ObjectPvsEntry entry = pit.Next(); 
     2745                pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
    27252746  } 
    27262747#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1789 r1824  
    500500  PvsFilterStatistics  
    501501  ApplyFilter2(ViewCell *viewCell, 
    502                            const bool useViewSpaceFilter, 
    503                            const float filterSize, 
    504                            ObjectPvs &pvs 
    505                            ); 
     502                                                         const bool useViewSpaceFilter, 
     503                                                         const float filterSize, 
     504                                                         ObjectPvs &pvs, 
     505                                                         vector<AxisAlignedBox3> *filteredBoxes = NULL 
     506                                                         ); 
    506507 
    507508        void ApplySpatialFilter(KdTree *kdTree, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp

    r1580 r1824  
    88VssRay::mailID = 0; 
    99 
     10#define OLD_PARAM 0 
    1011 
    1112VssRay::VssRay( 
     
    230231VssRay::GetDirParam(const int axis, const Vector3 dir) 
    231232{ 
     233  Vector3 d = Normalize(dir); 
     234#if OLD_PARAM 
    232235  return (axis == 0) ? atan2(dir.x, dir.z) : asin(dir.y); 
     236#else 
     237  //  x = cos(p0)sin(p1) 
     238  //  y = cos(p1) 
     239  //  z = sin(p0)sin(p1) 
     240  return (axis == 0) ? atan2(dir.z, dir.x) : acos(dir.y); 
     241#endif 
     242} 
     243 
     244Vector3 VssRay::GetInvDirParam(const float alpha, const float beta) 
     245{ 
     246#if OLD_PARAM 
     247  return Normalize(Vector3(sin(alpha), sin(beta), cos(alpha))); 
     248 
     249#else 
     250  return Normalize(Vector3(cos(alpha)*sin(beta), 
     251                                                   cos(beta), 
     252                                                   sin(alpha)*sin(beta))); 
     253#endif 
    233254} 
    234255 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h

    r1785 r1824  
    1414class KdNode; 
    1515 
    16 #define ABS_CONTRIBUTION_WEIGHT 0.8f 
     16#define ABS_CONTRIBUTION_WEIGHT 0.5f 
    1717 
    1818class VssRay { 
     
    137137 
    138138  static float VssRay::GetDirParam(const int axis, const Vector3 dir); 
     139  static Vector3 VssRay::GetInvDirParam(const float alpha, const float beta); 
    139140 
    140141  float GetSize() const { return  1.0f/mInvSize; } 
     
    203204  static Vector3 
    204205  GetDirection(const float a, const float b) { 
    205         return Vector3(sin(a), sin(b), cos(a)); 
     206        return GetInvDirParam(a, b); 
     207        //return Vector3(sin(a), sin(b), cos(a)); 
    206208  } 
    207209 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp

    r1359 r1824  
    17511751          origin = GetBBox(leaf).GetRandomPoint(); 
    17521752          Vector3 dirVector = GetDirBBox(leaf).GetRandomPoint(); 
    1753           direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 
     1753          direction = VssRay::GetInvDirParam(dirVector.x,dirVector.y); 
    17541754        } 
    17551755        //cout<<"dir vector.x="<<dirVector.x<<"direction'.x="<<atan2(direction.x, direction.y)<<endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1785 r1824  
    77 
    88#filename ../data/Arena/arena-low-lods.obj 
    9  filename ../data/Arena/arena-high-lods.obj 
     9#filename ../data/Arena/arena-high-lods.obj 
    1010# filename ../data/City4M/City4M.obj 
    1111# filename ../data/CityModel/CityModel.obj 
     
    8484 
    8585SamplingPreprocessor { 
    86         totalSamples 50000000 
     86        totalSamples 100000000 
    8787        samplesPerPass 5000000 
    8888} 
     
    9191        samplesPerPass 1000 
    9292        initialSamples 3000000 
    93         vssSamples 50000000 
     93        vssSamples 100000000 
    9494        vssSamplesPerPass 5000000 
    9595        useImportanceSampling true 
     
    101101                pvs false 
    102102                rssTree false 
    103                 rays false 
    104                 numRays 2000 
     103                rays true 
     104                numRays 10000 
    105105        } 
    106106 
     
    110110        storeInitialSamples false 
    111111 
    112         useRssTree false 
     112        useRssTree true 
    113113} 
    114114 
     
    124124#       splitType heuristic 
    125125 
    126         minRays         100 
     126        minRays         200 
    127127        minSize         0.001 
    128128        maxCostRatio 1.0 
    129129        maxRayContribution 1.0 
    130         maxRays         3000000 
    131         maxTotalMemory  200 
    132         maxStaticMemory 100 
     130        maxRays         10000000 
     131        maxTotalMemory  400 
     132        maxStaticMemory 200 
    133133 
    134134#       splitType regular 
     
    206206        #type vspKdTree 
    207207        #type bspTree 
    208         #type vspBspTree 
    209         type vspOspTree 
     208        type vspBspTree 
     209        #type vspOspTree 
    210210        #type sceneDependent 
    211211         
     
    264264 
    265265#       filename ../data/Arena/viewcells-5000.xml 
    266 #       filename ../data/Arena/viewcells-20000.xml 
     266filename ../data/Arena/viewcells-20000.xml 
    267267 
    268268#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
     
    278278#       filename ../data/test1/test-viewcells.xml 
    279279 
    280 #       filename ../data/soda/soda5-viewcell-single.xm 
    281 #       filename ../data/soda/soda-viewcells-1000.xml.zip 
    282 #       filename ../data/soda/soda-viewcells-vsposp.xml 
     280#       filename ../data/soda/soda-viewcells-1000.xml.gz 
    283281 
    284282 
  • GTP/trunk/Lib/Vis/Preprocessing/src/run_test2

    r1785 r1824  
    2929VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
    3030 
    31 PREFIX=../work/plots/osp-rss-1e5-n 
     31PREFIX=../work/plots/osp-rss-1e5 
    3232 
    3333#SCENE=../data/atlanta/atlanta2.x3d 
     
    4242$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    4343 -rss_use_importance+ -rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 
    44  -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-update-ccb12.log \ 
    45 -preprocessor_histogram_file=$PREFIX-i-combined-update-ccb12.hlog 
     44 -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-update-ccb12-n.log \ 
     45-preprocessor_histogram_file=$PREFIX-i-combined-update-ccb12-n.hlog 
    4646 
    4747 
     
    6060 
    6161 
    62 $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    63  -rss_use_importance+ -rss_use_rss_tree- -view_cells_filter_max_size=1 \ 
    64  -preprocessor_stats=$PREFIX-i-mixed-b1.log \ 
    65  -preprocessor_histogram_file=$PREFIX-i-mixed-b1.hlog 
     62# $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     63# -rss_use_importance+ -rss_use_rss_tree- -view_cells_filter_max_size=1 \ 
     64# -preprocessor_stats=$PREFIX-i-mixed-b1.log \ 
     65# -preprocessor_histogram_file=$PREFIX-i-mixed-b1.hlog 
    6666 
     67 
     68# $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     69#  -rss_use_importance+ -rss_use_rss_tree- -view_cells_filter_max_size=1 \ 
     70#  -rss_initial_samples=500000 -rss_vss_samples_per_pass=500000 -preprocessor_ray_cast_method=0 \ 
     71#   -preprocessor_stats=$PREFIX-i-global-b1.log \ 
     72#  -preprocessor_histogram_file=$PREFIX-i-global-b1.hlog 
     73 
Note: See TracChangeset for help on using the changeset viewer.