Changeset 1486


Ignore:
Timestamp:
09/25/06 18:54:21 (18 years ago)
Author:
mattausch
Message:

worked on guided visibility sampling

Location:
GTP/trunk/Lib/Vis
Files:
2 added
26 edited

Legend:

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

    r938 r1486  
    7575{ 
    7676        ResetQueries(); 
    77  
    7877        OGRE_DELETE(mSolidBoundingBox); 
    7978} 
     
    10099        mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    101100        mSceneManager->useRenderableViewProjModeWrapper(solidBox); 
    102          
     101        // HACK! (mySetPass should be setPass) 
    103102        // set no depth write, no color, no lighting material 
    104         mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); // HACK! (mySetPass should be setPass) 
    105         //mSceneManager->_setPass(solidBox->getTechnique()->getPass(0)); // HACK! (mySetPass should be setPass) 
     103        mSceneManager->setPassWrapper(solidBox->getTechnique()->getPass(0)); 
     104        //mSceneManager->_setPass(solidBox->getTechnique()->getPass(0));  
    106105        //SetOcclusionPass(); 
    107106 
     
    130129                mOcclusionQueries.push_back(new PlatformOcclusionQuery(mRenderSystem)); 
    131130        } 
     131 
     132        std::stringstream d; 
     133        d << "resizing queries: " << (int)mOcclusionQueries.size() << endl; 
     134        LogManager::getSingleton().logMessage(d.str()); 
    132135         
    133136        return mOcclusionQueries[mCurrentTestIdx ++]; 
     
    186189        if (mTestGeometryForVisibleLeaves && (mCamera == mCullCamera) && wasVisible && IsLeaf(node))  
    187190        { 
    188                 //LogManager::getSingleton().logMessage("render node\n"); 
    189191                RenderNode(node); 
    190192        } 
     
    194196                // must be treated differently to the scene geometry during rendering 
    195197                mIsBoundingBoxQuery = true; 
    196  
    197                 //LogManager::getSingleton().logMessage("render box\n"); 
    198198                RenderBoundingBox(GetBoundingBox(node)); 
    199199 
     
    227227        // get next available test id 
    228228        GtpVisibility::OcclusionQuery *query = GetNextOcclusionQuery(); 
    229  
     229         
     230        //////// 
    230231        //-- the actual query test 
     232 
    231233        query->BeginQuery(); 
    232          
    233234        RenderGeometry(mesh); 
    234  
    235235        query->EndQuery(); 
    236236 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOptionsManager.cpp

    r1175 r1486  
    1616        { 
    1717                // delete old queries (not needed for e.g., view frustum culling) 
     18                // note cannot be deleted because of new ogre occlusion query implementation 
     19                // there we cannot just delete the queries, so they would stay! 
    1820                //mHierarchyInterface->ResetQueries(); 
    1921                mVisibilityManager->SetCullingManager(*static_cast<const  
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp

    r955 r1486  
    8383                        if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 
    8484                        { 
    85                                 ++ mNumFrustumCulledNodes; 
    86                                  
     85                                ++ mNumFrustumCulledNodes;       
    8786                                if (mVisualizeCulledNodes) 
    8887                                { 
     
    9089                                } 
    9190                        } 
    92                         // -- if node intersects near plane, skip query because wrong results possible 
     91                        //-- if node intersects near plane, skip query because wrong results possible 
    9392                        else if (intersects) 
    9493                        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r1415 r1486  
    21652165 
    21662166 
    2167 } 
     2167void AxisAlignedBox3::Initialize() { 
     2168    mMin = Vector3(MAXFLOAT); 
     2169    mMax = Vector3(-MAXFLOAT); 
     2170  } 
     2171 
     2172 
     2173Vector3 AxisAlignedBox3::Center() const  
     2174{  
     2175        return 0.5 * (mMin + mMax);  
     2176} 
     2177   
     2178Vector3 AxisAlignedBox3::Diagonal() const  
     2179{  
     2180        return (mMax -mMin);  
     2181} 
     2182 
     2183 
     2184float AxisAlignedBox3::Center(const int axis) const  
     2185{ 
     2186        return  0.5f * (mMin[axis] + mMax[axis]); 
     2187} 
     2188 
     2189 
     2190float AxisAlignedBox3::Min(const int axis) const  
     2191{ 
     2192        return mMin[axis]; 
     2193} 
     2194 
     2195float AxisAlignedBox3::Max(const int axis) const { 
     2196        return  mMax[axis]; 
     2197} 
     2198 
     2199float AxisAlignedBox3::Size(const int axis) const { 
     2200        return  Max(axis) - Min(axis); 
     2201} 
     2202 
     2203// Read-only const access tomMin and max vectors using references 
     2204const Vector3& AxisAlignedBox3::Min() const  
     2205{  
     2206        return mMin; 
     2207} 
     2208 
     2209 
     2210const Vector3& AxisAlignedBox3::Max() const  
     2211{  
     2212        return mMax; 
     2213} 
     2214 
     2215 
     2216void AxisAlignedBox3::Enlarge (const Vector3 &v)  
     2217{ 
     2218        mMax += v; 
     2219        mMin -= v; 
     2220} 
     2221 
     2222 
     2223void AxisAlignedBox3::SetMin(const Vector3 &v)  
     2224{ 
     2225        mMin = v; 
     2226} 
     2227 
     2228 
     2229void AxisAlignedBox3::SetMax(const Vector3 &v)  
     2230{ 
     2231        mMax = v; 
     2232} 
     2233 
     2234 
     2235void AxisAlignedBox3::SetMin(int axis, const float value)  
     2236{ 
     2237        mMin[axis] = value; 
     2238} 
     2239 
     2240 
     2241void AxisAlignedBox3::SetMax(int axis, const float value)  
     2242{ 
     2243        mMax[axis] = value; 
     2244} 
     2245 
     2246// Decrease box by given splitting plane 
     2247void AxisAlignedBox3::Reduce(int axis, int right, float value)  
     2248{ 
     2249        if ( (value >=mMin[axis]) && (value <= mMax[axis]) ) 
     2250                if (right) 
     2251                        mMin[axis] = value; 
     2252                else 
     2253                        mMax[axis] = value; 
     2254} 
     2255 
     2256 
     2257Vector3 AxisAlignedBox3::Size() const  
     2258{  
     2259        return mMax - mMin;  
     2260} 
     2261 
     2262} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r1415 r1486  
    3535  /** initialization to the non existing bounding box 
    3636  */ 
    37   void Initialize() { 
    38     mMin = Vector3(MAXFLOAT); 
    39     mMax = Vector3(-MAXFLOAT); 
    40   } 
     37  void Initialize(); 
    4138 
    4239  /** The center of the box 
    4340  */ 
    44   Vector3 Center() const { return 0.5 * (mMin + mMax); } 
     41  Vector3 Center() const; 
    4542   
    4643  /** The diagonal of the box 
    4744  */ 
    48   Vector3 Diagonal() const { return (mMax -mMin); } 
    49  
    50   float Center(const int axis) const { 
    51     return  0.5f * (mMin[axis] + mMax[axis]); 
    52   } 
    53  
    54   float Min(const int axis) const { 
    55     return mMin[axis]; 
    56   } 
    57  
    58   float Max(const int axis) const { 
    59     return  mMax[axis]; 
    60   } 
    61  
    62   float Size(const int axis) const { 
    63     return  Max(axis) - Min(axis); 
    64   } 
     45  Vector3 Diagonal() const; 
     46 
     47  float Center(const int axis) const; 
     48 
     49  float Min(const int axis) const; 
     50 
     51  float Max(const int axis) const; 
     52 
     53  float Size(const int axis) const; 
    6554 
    6655  // Read-only const access tomMin and max vectors using references 
    67   const Vector3& Min() const { return mMin;} 
    68   const Vector3& Max() const { return mMax;} 
    69  
    70   void Enlarge (const Vector3 &v) { 
    71     mMax += v; 
    72     mMin -= v; 
    73   } 
    74  
    75   void SetMin(const Vector3 &v) { 
    76     mMin = v; 
    77   } 
    78  
    79   void SetMax(const Vector3 &v) { 
    80     mMax = v; 
    81   } 
    82  
    83   void SetMin(int axis, const float value) { 
    84    mMin[axis] = value; 
    85   } 
    86  
    87   void SetMax(int axis, const float value) { 
    88     mMax[axis] = value; 
    89   } 
     56  const Vector3& Min() const; 
     57  const Vector3& Max() const; 
     58 
     59  void Enlarge (const Vector3 &v); 
     60 
     61  void SetMin(const Vector3 &v); 
     62 
     63  void SetMax(const Vector3 &v); 
     64 
     65  void SetMin(int axis, const float value); 
     66 
     67  void SetMax(int axis, const float value); 
    9068 
    9169  // Decrease box by given splitting plane 
    92   void Reduce(int axis, int right, float value) { 
    93     if ( (value >=mMin[axis]) && (value <= mMax[axis]) ) 
    94       if (right) 
    95                 mMin[axis] = value; 
    96       else 
    97         mMax[axis] = value; 
    98   } 
    99  
     70  void Reduce(int axis, int right, float value);  
    10071   
    10172 
    10273  // the size of the box along all the axes 
    103   Vector3 Size() const { return mMax - mMin; } 
     74  Vector3 Size() const; 
    10475 
    10576  // Return whether the box is unbounded.  Unbounded boxes appear 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1449 r1486  
    263263 
    264264 
    265 static void AssociateObjectsWithLeaf(BvhLeaf *leaf) 
     265void BvHierarchy::AssociateObjectsWithLeaf(BvhLeaf *leaf) 
    266266{ 
    267267        ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
     
    272272} 
    273273 
     274 
    274275static int CountRays(const ObjectContainer &objects) 
    275276{ 
     
    285286        return nRays; 
    286287} 
     288 
    287289 
    288290BvhInterior *BvHierarchy::SubdivideNode(const BvhSubdivisionCandidate &sc, 
     
    15351537{ 
    15361538        // search nodes 
    1537         std::map<BvhNode *, BvhIntersectable *>:: 
    1538                 const_iterator it = mBvhIntersectables.find(node); 
     1539        std::map<BvhNode *, BvhIntersectable *>::const_iterator it  
     1540                = mBvhIntersectables.find(node); 
    15391541 
    15401542        if (it != mBvhIntersectables.end())  
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1449 r1486  
    650650        void CreateRoot(const ObjectContainer &objects); 
    651651 
     652        static void AssociateObjectsWithLeaf(BvhLeaf *leaf); 
     653 
     654 
    652655        ///////////////////////////// 
    653656        // Helper functions for local cost heuristics 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1458 r1486  
    12001200   RegisterOption("VssPreprocessor.initialSamples", 
    12011201                                 optInt, 
    1202                                  "initial_samples=", 
     1202                                 "vss_initial_samples=", 
    12031203                                 "100000"); 
    12041204   
    12051205  RegisterOption("VssPreprocessor.testBeamSampling",  
    12061206                                optBool,  
    1207                                 "beam_sampling",  
     1207                                "vss_beam_sampling=",  
    12081208                                "false"); 
    12091209 
     
    12201220  RegisterOption("VssPreprocessor.samplesPerPass", 
    12211221                                 optInt, 
    1222                                  "samples_per_pass=", 
     1222                                 "vss_samples_per_pass=", 
    12231223                                 "100000"); 
    12241224 
     
    12431243          "false"); 
    12441244    
    1245  
    1246     RegisterOption("VssPreprocessor.useViewSpaceBox", 
     1245   RegisterOption("VssPreprocessor.useViewSpaceBox", 
    12471246          optBool, 
    12481247          "vss_use_viewspace_box=", 
    1249           "false"); 
     1248          "false");    
    12501249    
    12511250 
    1252   /************************************************************************************/ 
    1253   /*                         View cells related options                               */ 
    1254   /************************************************************************************/ 
     1251 
     1252   /************************************************************************************/ 
     1253   /*                         GvsPrerpocessor related options                          */ 
     1254   /************************************************************************************/ 
     1255 
     1256 
     1257   RegisterOption("GvsPreprocessor.totalSamples", 
     1258                 optInt, 
     1259                 "gvs_total_samples=", 
     1260                 "1000000"); 
     1261    
     1262   RegisterOption("GvsPreprocessor.samplesPerPass", 
     1263                 optInt, 
     1264                 "gvs_samples_per_pass=", 
     1265                 "100000"); 
     1266    
     1267   RegisterOption("GvsPreprocessor.initialSamples", 
     1268                 optInt, 
     1269                 "gvs_initial_samples=", 
     1270                 "256"); 
     1271 
     1272   RegisterOption("GvsPreprocessor.epsilon", 
     1273                 optFloat, 
     1274                 "gvs_epsilon", 
     1275                 "0.00001"); 
     1276 
     1277 
     1278  /***********************************************************************************/ 
     1279  /*                         View cells related options                              */ 
     1280  /***********************************************************************************/ 
    12551281 
    12561282 
     
    15131539 
    15141540 
    1515  
    1516         /************************************************************************************/ 
    1517         /*                         Bsp tree related options                                 */ 
    1518         /************************************************************************************/ 
     1541        /******************************************************************/ 
     1542        /*                    Bsp tree related options                    */ 
     1543        /******************************************************************/ 
    15191544 
    15201545 
     
    16651690        RegisterOption("Preprocessor.loadMeshes", 
    16661691                                        optBool, 
    1667                                         "loadMeshes=", 
     1692                                        "preprocessor_load_meshes=", 
    16681693                                        "true"); 
    16691694 
     
    17941819        RegisterOption("RssPreprocessor.initialSamples", 
    17951820                                                                        optInt, 
    1796                                                                         "initial_samples=", 
     1821                                                                        "rss_initial_samples=", 
    17971822                                                                        "100000"); 
    17981823 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1473 r1486  
    44#include "VssRay.h" 
    55#include "ViewCellsManager.h" 
     6#include "Triangle3.h" 
    67 
    78 
     
    1314GvsPreprocessor::GvsPreprocessor(): Preprocessor(), mSamplingType(0) 
    1415{ 
    15         Environment::GetSingleton()->GetIntValue("RenderSampler.samples", mSamples); 
    16         //Environment::GetSingleton()->GetIntValue("Render.samples", mTotalSamples); 
    17  
    18         cout << "number of render samples: " << mSamples << endl; 
    19 } 
    20  
    21  
    22 int GvsPreprocessor::HandleRay(VssRay &ray) 
    23 { 
    24         int sampleContributions = 0; 
    25  
    26         if (mViewCellsManager->ComputeSampleContribution(ray, true, false)) 
    27         { 
    28                 return AdaptiveBorderSampling(ray); 
     16        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); 
     17        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.initialSamples", mInitialSamples); 
     18        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.samplesPerPass", mSamplesPerPass); 
     19        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.epsilon", mEps); 
     20                 
     21 
     22        Debug << "Gvs preprocessor options" << endl; 
     23        Debug << "number of total samples: " << mTotalSamples << endl; 
     24        Debug << "number of initial samples: " << mInitialSamples << endl; 
     25        Debug << "number of samples per pass: " << mSamplesPerPass << endl; 
     26 
     27        mStats.open("gvspreprocessor.log"); 
     28} 
     29 
     30 
     31const bool GvsPreprocessor::DiscontinuityFound(const VssRay &ray) const 
     32{ 
     33        return false; 
     34} 
     35 
     36 
     37int GvsPreprocessor::HandleRay(const GvsRayInfo &gvsRay) 
     38{ 
     39        VssRay *ray = gvsRay.mRay; 
     40 
     41        if (!mViewCellsManager->ComputeSampleContribution(*ray, true, false)) 
     42                return 1; 
     43 
     44        if (gvsRay.mFoundDiscontinuity) 
     45        { 
     46                return ReverseSampling(*ray); 
    2947        } 
    3048        else 
    3149        { 
    32                 return ReverseSampling(ray); 
    33         } 
    34 } 
    35  
    36  
    37 int GvsPreprocessor::AdaptiveBorderSampling(VssRay &ray) 
    38 { 
     50                return AdaptiveBorderSampling(*ray); 
     51        } 
     52} 
     53 
     54 
     55void GvsPreprocessor::CreateNewSamples(VertexContainer &samples,  
     56                                                                           const VssRay &ray,  
     57                                                                           const Triangle3 &hitTriangle,  
     58                                                                           const int index, 
     59                                                                           const float eps) 
     60{ 
     61        const int indexU = (index + 1) % 3; 
     62        const int indexL = (index == 0) ? 2 : index - 1; 
     63 
     64        const Vector3 a = hitTriangle.mVertices[index] - ray.GetDir(); 
     65        const Vector3 b = hitTriangle.mVertices[indexU] - hitTriangle.mVertices[index]; 
     66        const Vector3 c = hitTriangle.mVertices[index] - hitTriangle.mVertices[indexL]; 
     67        const float len = Magnitude(a); 
     68 
     69        // compute the new three hit points 
     70        // pi, i + 1 
     71        const Vector3 dir1 = CrossProd(a, b); //N((pi-xp)×(pi+1- pi)); 
     72        const Vector3 pt1 = hitTriangle.mVertices[index] + eps * len * dir1; //pi+ e·|pi-xp|·di, j 
     73        samples.push_back(pt1); 
     74 
     75        // pi, i - 1 
     76    const Vector3 dir2 = CrossProd(a, c); // N((pi-xp)×(pi- pi-1)) 
     77        const Vector3 pt2 = hitTriangle.mVertices[index] + eps * len * dir2; //pi+ e·|pi-xp|·di, j 
     78        samples.push_back(pt2); 
     79 
     80        // pi, i 
     81        const Vector3 dir3 = DotProd(dir1, dir2) > 0 ?  
     82                Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir2) + CrossProd(dir1, a)); // N((pi-xp)×di,i-1+di,i+1×(pi-xp)) 
     83        const Vector3 pt3 = hitTriangle.mVertices[index] + eps * len * dir3; //pi+ e·|pi-xp|·di, j 
     84        samples.push_back(pt3); 
     85} 
     86 
     87 
     88int GvsPreprocessor::AdaptiveBorderSampling(const VssRay &ray) 
     89{ 
     90        cout << "a"; 
     91        //Intersectable *tObj = ray->GetTerminationObject; 
     92        Triangle3 hitTriangle; 
     93        vector<Vector3> samples; 
     94        samples.reserve(9); 
     95 
     96        CreateNewSamples(samples, ray, hitTriangle, 0, mEps); 
     97        CreateNewSamples(samples, ray, hitTriangle, 1, mEps); 
     98        CreateNewSamples(samples, ray, hitTriangle, 2, mEps); 
     99 
     100        VertexContainer::const_iterator vit, vit_end = samples.end(); 
     101         
     102        for (vit = samples.begin(); vit != vit_end; ++ vit) 
     103        { 
     104                VssRay *ray;// = CreateRay(*vit); 
     105 
     106                if (DiscontinuityFound(*ray)) 
     107                { 
     108                        // schedule for reverse sampling 
     109                        mRayQueue.push(GvsRayInfo(ray, true)); 
     110                } 
     111                else 
     112                { 
     113                        // schedule for adaptive border sampling 
     114                        mRayQueue.push(GvsRayInfo(ray, false)); 
     115                } 
     116        } 
     117 
    39118        // TODO 
    40         return 0; 
    41 } 
    42  
    43  
    44 int GvsPreprocessor::ReverseSampling(VssRay &ray) 
    45 { 
     119        return 1; 
     120} 
     121 
     122 
     123int GvsPreprocessor::ReverseSampling(const VssRay &ray) 
     124{ 
     125        cout << "r" << endl; 
    46126        // TODO 
    47         return 0; 
     127        return 1; 
    48128} 
    49129 
     
    58138        Debug << "generated " <<  samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    59139 
     140        // cast the rays and optain hitpoints with geometry 
    60141        VssRayContainer samples; 
    61  
    62         // cast the rays and optain hitpoints with geometry 
    63142        CastRays(simpleRays, samples); 
     143 
    64144        Debug << "cast " <<  samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    65145 
    66         // add to ray queue 
     146        // add samples to ray queue 
    67147        VssRayContainer::const_iterator vit, vit_end = samples.end(); 
    68  
    69148        for (vit = samples.begin(); vit != vit_end; ++ vit) 
    70149        { 
     
    76155 
    77156 
    78 int GvsPreprocessor::Pass(const int passSamples) 
     157int GvsPreprocessor::Pass() 
    79158{ 
    80159        int castSamples = 0; 
    81         const int uniformSamples = 1000; 
    82  
    83         while (castSamples < passSamples)  
     160         
     161        while (castSamples < mSamplesPerPass)  
    84162        { 
    85163                // Ray queue empty =>  
    86164                // cast a number of uniform samples to fill ray Queue 
    87                 CastAvsSamples(uniformSamples, mSamplingType, mRayQueue); 
    88                 castSamples += Pass(passSamples); 
     165                CastAvsSamples(mInitialSamples, mSamplingType, mRayQueue); 
     166                 
     167                const int gvsSamples = RunSampling(); 
     168                castSamples += gvsSamples; 
     169                //cout << "\ngvs samples: " << gvsSamples << endl; 
     170                //cout << "cast " << castSamples << " of " << mSamplesPerPass << endl; 
    89171        } 
    90172 
     
    116198        const long startTime = GetTime(); 
    117199         
    118         cout<<"Gvs Preprocessor started\n"<<flush; 
    119          
    120         /// construct the view cells first 
    121         ConstructViewCells(); 
    122  
    123         int samples = 0; 
    124  
    125         while (samples < mTotalSamples)  
    126         { 
    127                 samples += Pass(mSamplesPerPass); 
    128                  
    129                 cout<<"+"; 
    130                  
    131                 // mVssRays.PrintStatistics(mStats); 
     200        mViewSpaceBox = mKdTree->GetBox(); 
     201        cout << "Gvs Preprocessor started\n" << flush; 
     202         
     203        if (!mLoadViewCells) 
     204        {       /// construct the view cells from the scratch 
     205                ConstructViewCells(mViewSpaceBox); 
     206                cout << "view cells loaded" << endl; 
     207        } 
     208 
     209        int castSamples = 0; 
     210 
     211        while (castSamples < mTotalSamples)  
     212        { 
     213                const int passSamples = Pass(); 
     214                castSamples += passSamples; 
     215                cout << "+"; 
     216                cout << "\nsamples cast " << passSamples << " (=" << castSamples << " of " << mTotalSamples << ")" << endl; 
     217                //mVssRays.PrintStatistics(mStats); 
    132218                //mStats << "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl 
    133219                //         << "#TotalSamples\n" << samples << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r1473 r1486  
    1313class VssRay; 
    1414 
    15  
    16 typedef stack<VssRay *> RayQueue; 
    1715 
    1816/** Sampling based visibility preprocessing. The implementation is  
     
    3129protected: 
    3230 
     31        struct GvsRayInfo 
     32        { 
     33                VssRay *mRay; 
     34                bool mFoundDiscontinuity; 
     35        } 
     36 
     37         
     38        typedef stack<GvsRayInfo> RayQueue; 
     39 
    3340        /** Runs the adaptive sampling. The method starts with a number of random rays given 
    3441                by the queue and continues as long it finds new visible geometry (i.e., the queue is 
     
    4350                @returns the number of samples cast. 
    4451        */ 
    45         int Pass(const int passSamples); 
     52        int Pass(); 
    4653 
    4754        /** Generates the rays starting the adaptive visibility sampling process. 
     
    6168                b) if triangle was found reverse sampling 
    6269        */ 
    63         int HandleRay(VssRay &ray); 
     70        int HandleRay(const GvsRayInfo &ray); 
    6471 
    6572        /**  
    6673        */       
    67         int AdaptiveBorderSampling(VssRay &ray); 
     74        int AdaptiveBorderSampling(const VssRay &ray); 
    6875         
    69         int ReverseSampling(VssRay &ray); 
     76        int ReverseSampling(const VssRay &ray); 
    7077 
    7178        /** Cast samples according to a specific sampling strategy. 
     
    7683                VssRayContainer &passSamples) const; 
    7784 
     85        void CreateNewSamples( 
     86                VertexContainer &samples,  
     87                const VssRay &ray,  
     88                const Triangle3 &hitTriangle,  
     89                const int index, 
     90                const float eps); 
     91 
     92        const bool DiscontinuityFound(const VssRay &ray) const; 
    7893 
    7994 
     
    8196 
    8297        ofstream mStats; 
    83         int mSamples; 
     98 
    8499        int mSamplesPerPass; 
    85100        RayQueue mRayQueue;  
    86101        int mSamplingType; 
    87102        int mTotalSamples; 
     103        int mInitialSamples; 
     104        AxisAlignedBox3 mViewSpaceBox; 
     105        float mEps; 
    88106}; 
    89107 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1473 r1486  
    329329                                                                                                   const ObjectContainer &objects) 
    330330{ 
    331         cout << "starting view space hierarchy construction ... " << endl; 
     331        cout << "\nstarting view space hierarchy construction ... " << endl; 
    332332 
    333333        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
     
    604604{ 
    605605        Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 
    606         cout << "resetting bv hierarchy" << endl; 
     606        cout << "\nresetting bv hierarchy" << endl; 
    607607        mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 
    608608        mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 
     
    856856        { 
    857857        case NO_OBJ_SUBDIV: 
    858                 // potentially visible objects 
    859                 return vc->AddPvsSample(obj, pdf, contribution); 
     858                { 
     859                        // potentially visible objects 
     860                        return vc->AddPvsSample(obj, pdf, contribution); 
     861                } 
    860862        case KD_BASED_OBJ_SUBDIV: 
    861863                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/MeshKdTree.cpp

    r1233 r1486  
    463463   
    464464  return result; 
    465  
    466 } 
    467  
    468 } 
     465} 
     466 
     467 
     468AxisAlignedBox3 MeshKdTree::GetBox() const  
     469{  
     470        return mMesh->mBox;  
     471} 
     472 
     473 
     474MeshKdTree::~MeshKdTree()  
     475{ 
     476    if (mSubdivisionCandidates) 
     477                delete mSubdivisionCandidates; 
     478 
     479        if (mRoot) 
     480                delete mRoot; 
     481} 
     482   
     483 
     484MeshKdNode *MeshKdTree::GetRoot() const  
     485{ 
     486        return mRoot; 
     487} 
     488 
     489 
     490} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/MeshKdTree.h

    r1233 r1486  
    127127public: 
    128128 
    129   enum {SPLIT_OBJECT_MEDIAN, 
    130         SPLIT_SPATIAL_MEDIAN, 
    131         SPLIT_SAH}; 
     129  enum { 
     130          SPLIT_OBJECT_MEDIAN, 
     131          SPLIT_SPATIAL_MEDIAN, 
     132          SPLIT_SAH}; 
    132133   
    133134 
    134135  MeshKdTree(Mesh *mesh); 
    135   ~MeshKdTree() { 
    136     if (mSubdivisionCandidates) 
    137       delete mSubdivisionCandidates; 
    138      
    139     if (mRoot) 
    140       delete mRoot; 
    141   } 
     136  ~MeshKdTree(); 
    142137   
    143138  virtual bool Construct(); 
     
    155150  virtual MeshKdNode *Subdivide(const TraversalData &tdata); 
    156151   
    157   /** Get the root of the tree */ 
    158   MeshKdNode *GetRoot() const { 
    159     return mRoot; 
    160   } 
    161    
    162   AxisAlignedBox3 GetBox() const { return mMesh->mBox; } 
     152  /** Get the root of the tree  
     153  */ 
     154  MeshKdNode *GetRoot() const; 
     155   
     156  AxisAlignedBox3 GetBox() const; 
    163157 
    164158  int 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1421 r1486  
    327327Preprocessor::ExportPreprocessedData(const string filename) 
    328328{ 
    329    
    330   mViewCellsManager->ExportViewCells(filename, true, mObjects); 
    331    
    332   return true; 
    333 } 
     329        mViewCellsManager->ExportViewCells(filename, true, mObjects); 
     330        return true; 
     331} 
     332 
    334333 
    335334bool 
     
    352351  // export the preprocessed information to a file 
    353352  if (mExportVisibility) 
    354         ExportPreprocessedData(mVisibilityFileName); 
    355    
     353  { 
     354          ExportPreprocessedData(mVisibilityFileName); 
     355  } 
     356 
    356357  return true; 
    357358} 
     
    445446        } 
    446447         
    447         //-- parameters for render heuristics evaluation 
     448        //////// 
     449        //-- render heuristics evaluation 
    448450        float objRenderCost = 0, vcOverhead = 0, moveSpeed = 0; 
    449451 
     
    472474 
    473475   
    474 bool 
    475 Preprocessor::ConstructViewCells() 
    476 { 
    477   // if not already loaded, construct view cells from file 
    478   if (!mLoadViewCells) { 
    479         mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
     476bool Preprocessor::ConstructViewCells(const AxisAlignedBox3 &viewSpaceBox) 
     477{ 
     478        mViewCellsManager->SetViewSpaceBox(viewSpaceBox); 
    480479         
    481480        // construct view cells using it's own set of samples 
    482481        mViewCellsManager->Construct(this); 
    483          
    484         //-- several visualizations and statistics 
    485         Debug << "view cells construction finished: " << endl; 
     482 
     483        // visualizations and statistics 
     484        Debug << "finished view cells:" << endl; 
    486485        mViewCellsManager->PrintStatistics(Debug); 
    487   } 
    488   return true; 
     486             
     487        return true; 
    489488} 
    490489 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1421 r1486  
    8888  bool PrepareViewCells(); 
    8989 
    90   /** Construct viewcells (if not already loaded) */ 
    91   bool 
    92   ConstructViewCells(); 
     90  /** Construct viewcells from the scratch  
     91  */ 
     92  bool ConstructViewCells(const AxisAlignedBox3 &viewSpaceBox); 
    9393 
    9494  /** Returns the specified sample strategy, NULL if no valid strategy. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r1473 r1486  
    506506                        </File> 
    507507                        <File 
     508                                RelativePath=".\PreprocessorFactory.cpp"> 
     509                        </File> 
     510                        <File 
     511                                RelativePath=".\PreprocessorFactory.h"> 
     512                        </File> 
     513                        <File 
    508514                                RelativePath="..\src\PreprocessorThread.cpp"> 
    509515                        </File> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r1315 r1486  
    9191 
    9292                node->Mail(); 
    93  
    94                 return (int)(((BvhLeaf *)node)->mObjects.size()); 
     93                BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node); 
     94                return (int)leaf->mObjects.size(); 
    9595        }                         
    9696 
    9797        // compute leaf pvs 
    9898        int pvs = 0; 
    99  
    10099        stack<BvhNode *> tStack; 
    101  
    102100        tStack.push(bvhobj->GetItem()); 
    103101 
     
    146144        { 
    147145                Intersectable *obj = (*it).first; 
    148  
     146         
    149147                switch (obj->Type()) 
    150148                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r1292 r1486  
    124124  if (!mLoadViewCells) 
    125125  { 
    126         mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
    127  
    128         // construct view cells using it's own set of samples 
    129         mViewCellsManager->Construct(this); 
    130          
    131         //-- several visualizations and statistics 
    132         Debug << "view cells construction finished: " << endl; 
    133         mViewCellsManager->PrintStatistics(Debug); 
     126          ConstructViewCells(mKdTree->GetBox()); 
    134127  } 
    135128   
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r1379 r1486  
    175175  } 
    176176   
    177   if (currentMesh->mVertices.size()) { 
    178           if (1) 
    179                 RotateMesh(currentMesh); 
     177  if (currentMesh->mVertices.size())  
     178  { 
     179          if (ROTATE_SCENE) RotateMesh(currentMesh); 
    180180  
    181     currentMesh->Preprocess(); 
    182     MeshInstance *mi = new MeshInstance(currentMesh); 
    183     root->mGeometry.push_back(mi); 
     181          currentMesh->Preprocess(); 
     182          MeshInstance *mi = new MeshInstance(currentMesh); 
     183          root->mGeometry.push_back(mi); 
    184184  } 
    185185   
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1473 r1486  
    2727#define SAMPLE_ORIGIN_OBJECTS 0 
    2828 
     29 
     30 
     31 
    2932namespace GtpVisibilityPreprocessor { 
    3033 
     
    3235// HACK 
    3336const static bool SAMPLE_AFTER_SUBDIVISION = true; 
    34 const static bool TEST_EMPTY_VIEW_CELLS = false; 
    35  
     37const static bool CLAMP_TO_BOX = false; 
    3638 
    3739template <typename T> class myless 
     
    223225                CLEAR_CONTAINER(mViewCells); 
    224226        } 
    225         //DEL_PTR(mViewCellsTree); 
    226227} 
    227228 
     
    18721873                        if (viewcell->GetValid()) 
    18731874                        { 
    1874                                 // if ray not outside of view space 
    1875  
    1876                                 // add new object to the pvs 
     1875                                // if view point is valid, add new object to the pvs 
    18771876                                if (ray.mTerminationObject) 
    18781877                                { 
     
    27372736        if (1) FinalizeViewCells(true); 
    27382737 
    2739         // write view cells to disc (this moved to preprocessor) 
    2740         if (0 && mExportViewCells) 
     2738        // write view cells to disc 
     2739        if (1 && mExportViewCells) 
    27412740        { 
    27422741                char filename[100]; 
     
    39063905        SimulationStatistics ss; 
    39073906        dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    3908   
    3909         cout << ss << endl; 
     3907        cout << ss << endl; 
    39103908         
    39113909 
     
    39353933 
    39363934        // write view cells to disc 
    3937         if (0 && mExportViewCells) 
     3935        if (1 && mExportViewCells) 
    39383936        { 
    39393937                char filename[100]; 
     
    49034901        cout << ss << endl; 
    49044902         
     4903 
    49054904        /////////////// 
    49064905        //-- compression 
     
    49174916        } 
    49184917 
    4919         /////////////// 
    4920         //-- compute final meshes and volume / area 
     4918        ///////////// 
     4919        //-- some tasks still to do on the view cells: 
     4920        //-- Compute meshes from view cell geometry, evaluate volume and / or area 
    49214921        if (1) FinalizeViewCells(true); 
    49224922 
    49234923        // write out view cells (this moved to preprocessor) 
    4924         if (0 && mExportViewCells) 
     4924        if (1 && mExportViewCells) 
    49254925        { 
    49264926                char filename[100]; 
     
    50935093                        AxisAlignedBox3 bbox = mHierarchyManager->GetViewSpaceBox(); 
    50945094                        bbox.Scale(Vector3(0.5, 1, 0.5)); 
    5095                          
    5096                         exporter->SetWireframe();  
    5097                         exporter->ExportBox(bbox); 
    5098                         exporter->SetFilled();  
    50995095                                 
     5096                        if (CLAMP_TO_BOX) 
     5097                        {        
     5098                                exporter->SetWireframe();  
     5099                                exporter->ExportBox(bbox); 
     5100                                exporter->SetFilled();  
     5101                        } 
     5102                                 
     5103                        /////////////////// 
     5104 
    51005105                        if (0 && mExportGeometry) 
    51015106                        { 
    5102                                 exporter->ExportGeometry(objects, true, &bbox); 
     5107                                exporter->ExportGeometry(objects, true, CLAMP_TO_BOX ? &bbox : NULL); 
    51035108                        } 
    51045109 
     
    51095114                        } 
    51105115                 
    5111                         mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, &bbox, false); 
    5112                         ExportViewCellsForViz(exporter, &bbox, GetClipPlane()); 
     5116                        mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL, false); 
     5117                        ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, GetClipPlane()); 
    51135118 
    51145119                        delete exporter; 
     
    51285133                        const long starttime = GetTime(); 
    51295134                         
    5130                         // matt: hack 
     5135                        // matt: hack for making visualization smaller in size 
    51315136                        AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 
    51325137                        bbox.Scale(Vector3(0.5, 1, 0.5)); 
    51335138 
    51345139                        cout << "exporting object space hierarchy ... "; 
    5135                         mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, &bbox); 
     5140                        mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL); 
    51365141                 
    51375142                        delete exporter; 
     
    53045309 
    53055310 
    5306         ////////////////////////////////////////////////////////////// 
     5311        /////////////// 
    53075312        //-- export bounding boxes 
    53085313        //-- The bounding boxes are used to identify  
     
    54785483                                // todo: maybe not correct for kd node pvs 
    54795484                                if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
    5480                                         ray.mPdf, contribution)) 
     5485                                                                                                                         ray.mPdf, contribution)) 
    54815486                                { 
    54825487                                        ++ ray.mPvsContribution; 
     
    55415546                                                                                        float &contribution) const 
    55425547{ 
     5548        // The hierarchy manager decides about the type of sample cast 
    55435549        return mHierarchyManager->AddSampleToPvs(obj, hitPoint, vc, pdf, contribution); 
    55445550} 
     
    56095615         
    56105616        cout << "computing sample contributions of " << (int)evaluationSamples.size()  << " samples ... "; 
    5611  
     5617         
    56125618        ComputeSampleContributions(evaluationSamples, true, false); 
    5613  
     5619         
    56145620        cout << "finished" << endl; 
    56155621         
    56165622        cout << "compute new statistics ... "; 
    5617         Debug << "compute new statistics ... "; 
    5618  
     5623         
    56195624        // propagate pvs or pvs size information 
    56205625        ObjectPvs pvs; 
    56215626        UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
    56225627 
    5623         /////////////////////////////////////// 
    5624         //-- temporary matt: test render cost 
     5628 
     5629        ///////////////////// 
     5630        // $§temporary matt: test render cost 
    56255631 
    56265632        sprintf(s, "-%09d-eval.log", castSamples); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r1421 r1486  
    919919        { 
    920920                Debug << "creating view cells manager: VspBsp" << endl; 
    921  
    922921                mViewCellsManager = new VspBspViewCellsManager(mViewCellsTree, mVspBspTree); 
    923922        } 
     
    925924        { 
    926925                Debug << "creating view cells manager: VspOsp" << endl; 
    927                 // hack 
    928926                mViewCellsManager = new VspOspViewCellsManager(mViewCellsTree, mHierarchyManager); 
    929927        } 
     
    998996 
    999997                //cout << "\nsearching view cell with id " << viewCellId << endl; 
    1000  
    1001998                ViewCellContainer::iterator vit = 
    1002999                        lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 
     
    11831180 
    11841181        leaf->mObjects = objects; 
     1182        BvHierarchy::AssociateObjectsWithLeaf(leaf);     
    11851183} 
    11861184 
     
    11901188{ 
    11911189        vector<int> objIndices; 
    1192  
    11931190        char *endptr; 
    11941191                         
     
    12211218                if ((oit != mObjects->end()) && ((*oit)->GetId() == objId)) 
    12221219                { 
    1223                         objects.push_back(*oit);         
     1220                        objects.push_back(*oit); 
    12241221                } 
    12251222                else 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.h

    r1404 r1486  
    2626class Beam; 
    2727class OspTree; 
     28 
     29 
    2830 
    2931class VrmlExporter : public Exporter 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r1418 r1486  
    2424 
    2525VssPreprocessor::VssPreprocessor(): 
    26   mVssRays(), 
    27   mViewSpaceBox(NULL) 
     26  mVssRays() 
    2827{ 
    2928  // this should increase coherence of the samples 
     
    4342  useViewspacePlane = mUseViewSpaceBox; //hack 
    4443 
     44  mViewSpaceBox.Initialize(); 
    4545   
    4646  Debug << "*********** vss preprocessor options **************" << endl; 
     
    5656{ 
    5757        CLEAR_CONTAINER(mVssRays); 
    58         DEL_PTR(mViewSpaceBox); 
    59 } 
    60  
    61  
    62  
    63  
     58} 
    6459 
    6560 
     
    163158  exporter->SetWireframe(); 
    164159 
    165   if (mViewSpaceBox) { 
    166         exporter->SetForcedMaterial(RgbColor(1,0,1)); 
    167         exporter->ExportBox(*mViewSpaceBox); 
    168         exporter->ResetForcedMaterial(); 
    169   } 
     160  exporter->SetForcedMaterial(RgbColor(1,0,1)); 
     161  exporter->ExportBox(mViewSpaceBox); 
     162  exporter->ResetForcedMaterial(); 
     163 
    170164 
    171165  VssRayContainer rays; 
     
    207201  exporter->ExportKdTree(*mKdTree); 
    208202 
    209   if (mViewSpaceBox) { 
    210         exporter->SetForcedMaterial(RgbColor(1,0,0)); 
    211         exporter->ExportBox(*mViewSpaceBox); 
    212         exporter->ResetForcedMaterial(); 
    213   } 
     203  exporter->SetForcedMaterial(RgbColor(1,0,0)); 
     204  exporter->ExportBox(mViewSpaceBox); 
     205  exporter->ResetForcedMaterial(); 
    214206 
    215207  exporter->SetForcedMaterial(RgbColor(0,0,1)); 
     
    412404  if (mUseViewSpaceBox) 
    413405  { 
    414         //mViewSpaceBox = ConstructViewSpaceBox(); 
    415  
    416406          if (!mEnlargeViewSpace) 
    417407          { 
    418                   mViewSpaceBox = new AxisAlignedBox3(box); 
     408                  mViewSpaceBox = AxisAlignedBox3(box); 
    419409          } 
    420410          else 
    421411          { 
    422                   mViewSpaceBox = new AxisAlignedBox3(mKdTree->GetBox()); 
     412                  mViewSpaceBox = AxisAlignedBox3(mKdTree->GetBox()); 
    423413 
    424414                  if (0)  
    425415                  { 
    426416                          // HACK: enlarge in y directon 
    427                           Vector3 size = mViewSpaceBox->Size(); 
     417                          Vector3 size = mViewSpaceBox.Size(); 
    428418                         
    429419                          size[1] *= 1.25; 
     
    431421                          //Vector3 enlarge(size[0] * 4.0f, 0.0f, 0.0f); 
    432422 
    433                           mViewSpaceBox->Enlarge(enlarge); 
    434                           mViewSpaceBox->SetMax(mViewSpaceBox->Max() + enlarge); 
     423                          mViewSpaceBox.Enlarge(enlarge); 
     424                          mViewSpaceBox.SetMax(mViewSpaceBox.Max() + enlarge); 
    435425                  }  
    436426                  else  
    437427                  { 
    438                           AxisAlignedBox3 tbox(*mViewSpaceBox); 
    439  
    440                           Vector3 size = mViewSpaceBox->Size(); 
    441                           tbox.SetMax(0, mViewSpaceBox->Max(0) + size[0] * 0.5f); 
    442                           tbox.SetMin(0, mViewSpaceBox->Min(0) + size[0]); 
    443                           *mViewSpaceBox = tbox; 
    444  
    445                           // $$ JB temporary 
    446                           /*AxisAlignedBox3 tempbox = *mViewSpaceBox; 
    447                            
    448                           float s = tempbox.Size(0); 
    449                            
    450                           tempbox.Scale(0.8f); 
    451                           tempbox.SetMax(0, box.Max(0) + s*0.8f); 
    452                           tempbox.SetMin(0, box.Min(0) + s*0.8f); 
    453                           *mViewSpaceBox = tempbox;*/ 
     428                          AxisAlignedBox3 tbox(mViewSpaceBox); 
     429 
     430                          Vector3 size = mViewSpaceBox.Size(); 
     431                          tbox.SetMax(0, mViewSpaceBox.Max(0) + size[0] * 0.5f); 
     432                          tbox.SetMin(0, mViewSpaceBox.Min(0) + size[0]); 
     433                          mViewSpaceBox = tbox; 
    454434                  }              
    455435          } 
    456           //Debug << "view space box: " << *mViewSpaceBox << endl; 
    457436  } 
    458437  else 
    459438  { 
    460           mViewSpaceBox = NULL; 
    461   } 
    462    
    463   AxisAlignedBox3 vbox = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 
    464  
     439          mViewSpaceBox = AxisAlignedBox3(mKdTree->GetBox()); 
     440  } 
     441   
    465442  mSceneGraph->CollectObjects(&mObjects); 
    466443 
    467444  if (!mLoadViewCells) 
    468445  { 
    469           //-- generate new view cells or reconstruct them 
     446          //-- generate new view cells from the scratch 
    470447          //-- for construction the manager uses it's own set of samples 
    471           mViewCellsManager->SetViewSpaceBox(vbox); 
    472           mViewCellsManager->Construct(this); 
    473  
    474           // output visualizations and statistics 
    475           Debug << "view cells construction finished: " << endl; 
    476           mViewCellsManager->PrintStatistics(Debug); 
     448          ConstructViewCells(mViewSpaceBox); 
    477449  } 
    478450#if 0 
     
    509481 
    510482                int s = Min(mSamplesPerPass, mInitialSamples); 
    511                 for (int k=0; k < s; k++) { 
    512                         // changed by matt 
     483                for (int k=0; k < s; k++)  
     484                { 
    513485                        Vector3 viewpoint;  
    514                         //                      viewpoint = GetViewpoint(mViewSpaceBox); 
     486                 
    515487                        mViewCellsManager->GetViewPoint(viewpoint); 
    516                         Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
    517  
    518                         sampleContributions = CastRay(viewpoint, direction, 1, mVssRays, vbox); 
     488                        Vector3 direction = GetDirection(viewpoint, &mViewSpaceBox); 
     489 
     490                        sampleContributions = CastRay(viewpoint, direction, 1, mVssRays, mViewSpaceBox); 
    519491 
    520492                        if (sampleContributions) { 
     
    589561  // viewcells = Construct(mVssRays); 
    590562 
    591   vssTree->Construct(mVssRays, mViewSpaceBox); 
     563  vssTree->Construct(mVssRays, NULL); 
    592564  cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 
    593565 
     
    635607        if (!mUseImportanceSampling) { 
    636608          for (int j=0; j < num; j++) { 
    637             // changed by matt 
    638                 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 
    639                 Vector3 viewpoint;  
     609                Vector3 viewpoint;  
    640610                mViewCellsManager->GetViewPoint(viewpoint); 
    641                 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
     611                Vector3 direction = GetDirection(viewpoint, NULL); 
    642612                rays.push_back(SimpleRay(viewpoint, direction)); 
    643613          } 
     
    647617 
    648618        for (int i=0; i < rays.size(); i++) 
    649           CastRay(rays[i].mOrigin, rays[i].mDirection, 1, vssRays, vbox); 
     619          CastRay(rays[i].mOrigin, rays[i].mDirection, 1, vssRays, mViewSpaceBox); 
    650620 
    651621        vssTree->AddRays(vssRays); 
     
    698668 
    699669 
    700   ////////////////////////////////// 
    701   //-- render simulation after  
     670  //////////////////// 
     671  //-- render simulation after construction 
    702672 
    703673  mRenderSimulator->RenderScene(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.h

    r1281 r1486  
    2626  bool mUseImportanceSampling; 
    2727  bool mEnlargeViewSpace; 
    28   AxisAlignedBox3 *mViewSpaceBox; 
     28  AxisAlignedBox3 mViewSpaceBox; 
    2929 
    3030  ofstream mStats; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r1404 r1486  
    2626   
    2727} 
     28 
    2829 
    2930X3dExporter::~X3dExporter() 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1457 r1486  
    1818#include <crtdbg.h> 
    1919 
    20 #include "SamplingPreprocessor.h" 
    21 #include "VssPreprocessor.h" 
    22 #include "RssPreprocessor.h" 
    23 #include "ExactPreprocessor.h" 
     20#include "PreprocessorFactory.h" 
    2421#include "Parser.h" 
    25 #include "UnigraphicsParser.h" 
    26 #include "X3dParser.h" 
    2722#include "Environment.h" 
    28 #include "Camera.h" 
    2923#include "MeshKdTree.h" 
    30 #include "Exporter.h" 
    31 #include "ViewCell.h" 
    32 #include "SceneGraph.h" 
     24#include "Preprocessor.h" 
     25 
    3326 
    3427#include "PreprocessorThread.h" 
     
    3730#endif 
    3831 
    39 #include "RenderSampler.h" 
    4032#include "ResourceManager.h" 
    4133#include "GlRenderer.h" 
     
    115107        string preprocessorType(buff); 
    116108 
    117         if (preprocessorType == "vss") 
    118         { 
    119                 preprocessor = new VssPreprocessor(); 
    120         } 
    121         else 
    122         { 
    123                 if (preprocessorType == "rss") 
    124                 { 
    125                         preprocessor = new RssPreprocessor(); 
    126                 } 
    127                 else 
    128                 { 
    129                         if (preprocessorType == "exact") 
    130                         { 
    131                                 preprocessor = new ExactPreprocessor(); 
    132                         } 
    133                         else 
    134                         { 
    135                                 if (preprocessorType == "sampling") 
    136                                 { 
    137                                         preprocessor = new SamplingPreprocessor(); 
    138                                 } 
    139                                 else 
    140                                 {        
    141                                         if (preprocessorType == "render") 
    142                                         { 
    143                                                 preprocessor = new RenderSampler(); 
    144                                         } 
    145                                         else  
    146                                         { 
    147                                                 Environment::DelSingleton(); 
    148                                                 cerr<<"Unknown preprocessor type"<<endl; 
    149                                                 Debug<<"Unknown preprocessor type"<<endl; 
    150                                                 exit(1); 
    151                                         } 
    152                                 } 
    153                         } 
    154                 } 
     109        if (!(preprocessor = PreprocessorFactory::CreatePreprocessor(preprocessorType))) 
     110        { 
     111                Environment::DelSingleton(); 
     112                cerr << "Unknown preprocessor type" << endl; 
     113                exit(1); 
    155114        } 
    156115 
Note: See TracChangeset for help on using the changeset viewer.