Changeset 598


Ignore:
Timestamp:
02/05/06 11:03:17 (18 years ago)
Author:
mattausch
Message:

added cutting plane and enlarging view space

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r597 r598  
    3636        loadInitialSamples  false 
    3737        storeInitialSamples false 
    38         useViewSpaceBox false 
     38        useViewSpaceBox true 
    3939#       testBeamSampling true 
    4040} 
     
    213213                useRaysForMerge false 
    214214                refine false 
    215                 compress true 
     215                compress false 
    216216                merge false 
    217217        } 
     
    322322        Termination { 
    323323                # parameters used for autopartition 
    324                 minRays                 150 
     324                minRays                 -150 
    325325                minPolygons             -1 
    326326                maxDepth                30 
    327                 minPvs                  10 
     327                minPvs                  -10 
    328328                #minProbability         0.0001 
    329329                minProbability          -1 
    330                 maxRayContribution      0.3 
    331                 maxCostRatio            0.9 
     330#               maxRayContribution      0.3 
     331                maxRayContribution      2.3 
     332#               maxCostRatio            0.9 
     333                maxCostRatio            3.9 
    332334                missTolerance           3 
    333                 #maxAccRayLength        100 
     335 
    334336                 
    335337                maxViewCells            512 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r597 r598  
    8585{ 
    8686        DEL_PTR(mRenderer); 
    87         //CLEAR_CONTAINER(mViewCells); 
    88         DEL_PTR(mViewCellsTree); 
     87 
     88        if (!ViewCellsTreeConstructed()) 
     89                CLEAR_CONTAINER(mViewCells); 
     90        else 
     91                DEL_PTR(mViewCellsTree); 
    8992 
    9093        CLEAR_CONTAINER(mMeshContainer); 
     
    689692        int axis = 0; 
    690693 
    691         Vector3 point = mViewSpaceBox.Center(); 
     694        const float factor = 0.55; 
     695        Vector3 point = mViewSpaceBox.Min() +  mViewSpaceBox.Size() * factor; 
    692696 
    693697        if (mUseCuttingPlaneForViz) 
     
    12771281        if (exporter) 
    12781282        { 
     1283                //exporter->SetFilled(); 
     1284 
     1285                if (mExportGeometry) 
     1286                        exporter->ExportGeometry(objects); 
     1287 
    12791288                Material m; 
    12801289                m.mDiffuseColor = RgbColor(1, 0, 0); 
     
    12881297                exporter->SetForcedMaterial(m); 
    12891298                //exporter->ResetForcedMaterial(); 
    1290  
    1291                 exporter->SetFilled(); 
    1292  
    1293                 if (mExportGeometry) 
    1294                         exporter->ExportGeometry(objects); 
    12951299 
    12961300                delete exporter; 
     
    14021406                                                                          ViewCell *vc) const 
    14031407{ 
    1404         if (mColorCode == 0) // Random color 
    1405         { 
    1406                 exporter->ResetForcedMaterial(); 
    1407                 return; 
    1408         } 
     1408                const bool vcValid = CheckValidity(vc, mMinPvsSize, mMaxPvsSize); 
    14091409 
    14101410        float importance = 0; 
     1411        static Material m; 
    14111412 
    14121413        switch (mColorCode) 
    14131414        { 
     1415        case 0: // Random 
     1416                { 
     1417                        if (vcValid) 
     1418                        { 
     1419                                m.mDiffuseColor.r = 0.5f + RandomValue(0.0f, 0.5f); 
     1420                                m.mDiffuseColor.g = 0.5f + RandomValue(0.0f, 0.5f); 
     1421                                m.mDiffuseColor.b = 0.5f + RandomValue(0.f, 0.5f); 
     1422                        } 
     1423                        else 
     1424                        { 
     1425                                m.mDiffuseColor.r = 0.0f; 
     1426                                m.mDiffuseColor.g = 1.0f; 
     1427                                m.mDiffuseColor.b = 0.0f; 
     1428                        } 
     1429 
     1430                        exporter->SetForcedMaterial(m); 
     1431                        return; 
     1432                } 
     1433                 
    14141434        case 1: // pvs 
    14151435                { 
    14161436                        importance = (float)vc->GetPvs().GetSize() / 
    14171437                                (float)mViewCellsStats.maxPvs; 
     1438 
    14181439                } 
    14191440                break; 
    14201441        case 2: // merges 
    14211442                { 
    1422                         importance = (float)mViewCellsTree->GetSize(vc) / 
    1423                                 (float)mViewCellsStats.maxLeaves; 
    1424                 } 
    1425                 break; 
     1443            int lSize = mViewCellsTree->GetSize(vc); 
     1444         
     1445                        importance = (float)lSize / (float)mViewCellsStats.maxLeaves; 
     1446                } 
     1447                //break; 
    14261448        case 3: // merge tree differene 
    14271449                { 
    14281450                        // TODO 
     1451                        //importance = (float)GetMaxTreeDiff(vc) / 
     1452                        //      (float)(mVspBspTree->GetStatistics().maxDepth * 2); 
     1453 
    14291454                } 
    14301455                break; 
     
    14331458        } 
    14341459 
    1435         Material m; 
    1436         m.mDiffuseColor.b = 1.0f; 
     1460        // special color code for invalid view cells 
    14371461        m.mDiffuseColor.r = importance; 
    14381462        m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r; 
    1439  
     1463        m.mDiffuseColor.b = vcValid ? 1.0f : 0.0f; 
     1464 
     1465        //Debug << "importance: " << importance << endl; 
    14401466        exporter->SetForcedMaterial(m); 
    14411467} 
     
    14661492                                                   *cuttingPlane, 
    14671493                                                   mViewSpaceBox,  
    1468                                                    0.005); 
     1494                                                   0.0001); 
    14691495 
    14701496                exporter->ExportPolygons(back.mPolys); 
     
    20492075                return; 
    20502076 
     2077        if (mExportGeometry) 
     2078                exporter->ExportGeometry(objects); 
     2079         
    20512080        //exporter->SetWireframe(); 
    20522081        //exporter->ExportVspKdTree(*mVspKdTree, mVspKdTree->GetStatistics().maxPvsSize); 
    20532082        exporter->ExportVspKdTree(*mVspKdTree); 
    2054  
    2055         if (mExportGeometry) 
    2056                 exporter->ExportGeometry(objects); 
    20572083 
    20582084        if (mExportRays) 
     
    24162442                if (exporter) 
    24172443                { 
     2444                        if (0 && mExportRays) 
     2445                                exporter->ExportRays(rays, RgbColor(1, 1, 1)); 
     2446 
     2447                        if (mExportGeometry) 
     2448                                exporter->ExportGeometry(objects); 
     2449 
    24182450                        //exporter->SetWireframe(); 
    24192451                        exporter->SetFilled(); 
    24202452                        ExportViewCellsForViz(exporter); 
    2421  
    2422                         if (0 && mExportRays) 
    2423                                 exporter->ExportRays(rays, RgbColor(1, 1, 1)); 
    2424  
    2425                         if (mExportGeometry) 
    2426                                 exporter->ExportGeometry(objects); 
    24272453 
    24282454                        delete exporter; 
     
    24972523                if (exporter) 
    24982524                { 
    2499                         if (0) 
    2500                                 exporter->SetWireframe(); 
    2501                         else 
    2502                                 exporter->SetFilled(); 
    2503                         ExportViewCellsForViz(exporter); 
    2504  
    25052525                        if (mExportGeometry) 
    25062526                        { 
     
    25132533                        } 
    25142534 
     2535                        if (0) 
     2536                                exporter->SetWireframe(); 
     2537                        else 
     2538                                exporter->SetFilled(); 
     2539 
     2540                        ExportViewCellsForViz(exporter); 
     2541 
    25152542                        delete exporter; 
    25162543                } 
     
    26002627                RefineViewCells(postProcessRays, objects); 
    26012628 
    2602         if (mCompressViewCells) 
     2629        //-- compression 
     2630 
     2631        if (ViewCellsTreeConstructed() && mCompressViewCells) 
    26032632        { 
    26042633                int pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 
     
    26282657 
    26292658 
    2630         //-- export shuffled view cells 
     2659        //-- export refined (shuffled) view cells 
    26312660        if (0) 
    26322661        { 
     
    27012730        // real meshes are only contructed only at this stage 
    27022731        FinalizeViewCells(true); 
    2703  
    2704         // HACK: removes view cells in bsp leaves with active ones 
    2705         if (0) 
    2706                 AddCurrentViewCellsToHierarchy(); 
    2707  
    27082732 
    27092733        // write view cells to disc 
     
    30563080                        if (vcValid) 
    30573081                        { 
    3058                                 m.mDiffuseColor.r = RandomValue(0.3f, 1.0f); 
    3059                                 m.mDiffuseColor.g = RandomValue(0.3f, 1.0f); 
    3060                                 m.mDiffuseColor.b = RandomValue(0.3f, 1.0f); 
     3082                                m.mDiffuseColor.r = 0.5f + RandomValue(0.0f, 0.5f); 
     3083                                m.mDiffuseColor.g = 0.5f + RandomValue(0.0f, 0.5f); 
     3084                                m.mDiffuseColor.b = 0.5f + RandomValue(0.f, 0.5f); 
    30613085                        } 
    30623086                        else 
     
    31403164                                                           *cuttingPlane, 
    31413165                                                           mViewSpaceBox,  
    3142                                                            0.005); 
     3166                                                           0.0001); 
    31433167 
    31443168                        exporter->ExportPolygons(back.mPolys); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r589 r598  
    22732273        } 
    22742274} 
    2275 #if 0 
    2276 void VspKdTree::CollectMergeCandidates(const vector<VspKdRay *> &rays) 
    2277 { 
    2278         VspKdMergeCandidate::sOverallCost = 0; 
    2279  
    2280         vector<VspKdIntersection>::const_iterator iit; 
    2281         map<BspLeaf *, vector<BspLeaf*> candidateMap; 
    2282  
    2283         for (int i = 0; i < (int)rays.size(); ++ i) 
    2284         {   
    2285                 //VspKdLeaf::NewMail(); 
    2286                 VspKdRay *ray = rays[i]; 
    2287            
    2288                 // traverse leaves stored in the rays and compare and merge consecutive 
    2289                 // leaves (i.e., the neighbors in the tree) 
    2290                 if (ray->intersections.size() < 2) 
    2291                         continue; 
    2292            
    2293                 iit = ray->intersections.begin(); 
    2294  
    2295                 BspLeaf *previousLeaf = (*iit).mLeaf; 
    2296          
    2297                 ++ iit; 
    2298                  
    2299                 for (; iit != ray->intersections.end(); ++ iit) 
    2300                 { 
    2301             BspLeaf *leaf = (*iit).mLeaf; 
    2302                         leaf->Mail 
    2303                         // TODO: how to sort out doubles? 
    2304                         VspKdMergeCandidate mc = VspKdMergeCandidate(leaf, previousLeaf); 
    2305                         mMergeQueue.push(mc); 
    2306  
    2307                         VspKdMergeCandidate::sOverallCost += mc.GetLeaf1Cost(); 
    2308                         VspKdMergeCandidate::sOverallCost += mc.GetLeaf2Cost(); 
    2309  
    2310                         previousLeaf = leaf; 
    2311         } 
    2312         } 
    2313 } 
    2314 #endif 
     2275 
    23152276 
    23162277int VspKdTree::MergeViewCells(const VssRayContainer &rays) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r590 r598  
    4141{ 
    4242  CLEAR_CONTAINER(mVssRays); 
     43  DEL_PTR(mViewSpaceBox); 
    4344} 
    4445 
     
    526527  if (mUseViewSpaceBox) 
    527528  { 
    528           mViewSpaceBox = box; 
     529          if (0) 
     530                mViewSpaceBox = box; 
     531          else 
     532          { 
     533                // HACK: enlarge in y directon 
     534                mViewSpaceBox = new AxisAlignedBox3(mKdTree->GetBox()); 
     535                //Vector3 pmin = mViewSpaceBox->Min(); 
     536                Vector3 size = mViewSpaceBox->Size(); 
     537                //size[1] *= 1.25; 
     538                Vector3 enlarge(size[0] * 0.1f, size[1] * 0.0f, size[2] * 0.1); 
     539 
     540                mViewSpaceBox->Enlarge(enlarge); 
     541          } 
     542 
     543          //Debug << "view space box: " << *mViewSpaceBox << endl; 
    529544  } 
    530545  else 
Note: See TracChangeset for help on using the changeset viewer.