Ignore:
Timestamp:
09/29/05 01:48:20 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
3 edited

Legend:

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

    r298 r301  
    1515#       viewcells ../data/atlanta/atlanta_viewcells_large.x3d 
    1616#       viewcells ../data/atlanta/atlanta_viewcells_large2.x3d 
    17         viewcells ../data/vienna/viewcells-25-sel.x3d 
    18 #       viewcells ../data/vienna/viewcells-25.x3d 
     17#       viewcells ../data/vienna/viewcells-25-sel.x3d 
     18        viewcells ../data/vienna/viewcells-25.x3d 
    1919#       viewcells ../data/vienna/viewcells-large-sel.x3d 
    2020} 
     
    7575        # least splits + balanced polygons 
    7676        #splitPlaneStrategy 12 
    77         # axis aligned + vertical axis 
     77        #axis aligned + vertical axis 
    7878        #splitPlaneStrategy 66 
    7979        # axis aligned + balanced view cells 
    80         #splitPlaneStrategy 18 
     80        splitPlaneStrategy 18 
    8181        # largest polygon area 
    82         splitPlaneStrategy 32 
     82        #splitPlaneStrategy 32 
    8383        # axus aligned + balanced polygons 
    8484        #splitPlaneStrategy 72 
     
    8989        maxViewCells 999999 
    9090        Termination { 
    91                 maxPolysForAxisAligned 50 
     91                maxPolysForAxisAligned 20 
    9292                maxPolygons 0 
    9393                maxDepth 100 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r300 r301  
    122122        for (it = mVertices.begin(); it != it_end; ++it) 
    123123                vtx.push_back(rot * (*it)); 
    124          
    125         Vector3 cur = vtx.back(); 
     124 
     125        //-- compute area 
     126        Vector3 last = vtx.back(); 
    126127 
    127128        float area = 0.0f; 
    128129        for (it = vtx.begin(); it != vtx.end(); ++it) 
    129130        { 
    130                 area += cur.y * (*it).x - cur.x * (*it).y; 
    131  
    132                 cur = *it; 
    133         } 
    134  
     131                area += last.y * (*it).x - last.x * (*it).y; 
     132 
     133                last = *it; 
     134        } 
     135        //Debug << "area: " << area * 0.5 << endl; 
    135136        return area * 0.5f; 
    136137} 
     
    219220        // check if area exceeds certain size 
    220221        if (AREA_LIMIT > GetArea()) 
     222        { 
     223                //Debug << "area too small: " << GetArea() << endl; 
    221224                return false; 
     225        } 
    222226#else 
    223227        Vector3 vtx = mVertices.back(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r299 r301  
    457457 
    458458                if (!poly->Valid()) 
    459                         Debug << "Input polygon not valid: " << *poly << endl; 
    460  
     459                        Debug << "Input polygon not valid: " << *poly  
     460                                  << endl << "Area: " << poly->GetArea() << endl; 
     461                 
    461462                ++ polysNum; 
    462463        } 
     
    580581        if ((tData.mPolygons->size() <= sTermMaxPolygons) || (tData.mDepth >= sTermMaxDepth)) 
    581582        { 
    582 //#ifdef _DEBUG 
     583#ifdef _DEBUG 
    583584                Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 
    584 //#endif 
     585#endif 
    585586 
    586587                EvaluateLeafStats(tData); 
     
    735736                Polygon3::IncludeInBox(polys, box); 
    736737         
    737                 int axis = box.Size().DrivingAxis(); 
     738                int objectsBack = 0, objectsFront = 0; 
     739                int axis = 0; 
     740                float costRatio = MAX_FLOAT; 
     741                Vector3 position; 
     742 
     743                for (int i=0; i < 3; i++)  
     744                { 
     745                        float p = 0; 
     746                        float r = 0;/*BestCostRatio(leaf, 
     747                                                                        box, 
     748                                                                        i, 
     749                                                                        p, 
     750                                                                        objectsBack, 
     751                                                                        objectsFront);*/ 
     752                        if (r < costRatio) 
     753                        { 
     754                                costRatio = r; 
     755                                axis = i; 
     756                                position = p; 
     757                        } 
     758                } 
     759                 
     760                //if (costRatio > mMaxCostRatio) axis = -1; 
     761                Vector3 norm(0,0,0); norm[axis] = 1.0f; 
     762                return Plane3(norm, position); 
     763 
     764                /*int axis = box.Size().DrivingAxis(); 
    738765                Vector3 norm(0,0,0); norm[axis] = 1; 
    739  
    740                 Vector3 pt = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 
    741  
    742                 return Plane3(norm, pt); 
     766                Vector3 pt = (box.Min()[axis] + box.Max()[axis]) * 0.5f;*/ 
     767                //Debug << "splitting axis aligned" << endl; 
     768                //return Plane3(norm, pt); 
    743769        } 
    744770 
     
    786812                } 
    787813        } 
    788         Debug << "Plane lowest cost: " << lowestCost << endl; 
     814        //Debug << "Plane lowest cost: " << lowestCost << endl; 
    789815         
    790816        return polys[bestPlaneIdx]->GetSupportingPlane(); 
     
    798824float BspTree::EvalSplitPlane(const PolygonContainer &polys, const Plane3 &candidatePlane) const 
    799825{ 
    800         float sumBalancedPolys = 0; 
    801         float sumBalancedViewCells = 0; 
    802         float sumSplits = 0; 
    803         float sumPolyArea = 0; 
    804         float verticalAxis = 0; 
     826        float val = 0; 
    805827         
    806828        if (sSplitPlaneStrategy & VERTICAL_AXIS) 
     
    809831                // want to put a penalty on the dot product between the "tiny" vertical axis 
    810832                // and the split plane axis 
    811                 verticalAxis = fabs(DotProd(candidatePlane.mNormal, tinyAxis)) * (float)polys.size(); 
     833                val += sVerticalSplitsFactor *  
     834                           fabs(DotProd(candidatePlane.mNormal, tinyAxis)) * (float)polys.size(); 
    812835        } 
    813836        //-- strategies where the effect of the split plane on the polygons is tested 
    814         if ((sSplitPlaneStrategy & BALANCED_POLYS)      ||  
    815                 (sSplitPlaneStrategy & LEAST_SPLITS)        || 
     837        if ((sSplitPlaneStrategy & BALANCED_POLYS)     ||  
     838                (sSplitPlaneStrategy & LEAST_SPLITS)       || 
    816839                (sSplitPlaneStrategy & LARGEST_POLY_AREA)) 
    817840        { 
    818841                PolygonContainer::const_iterator it, it_end = polys.end(); 
    819                  
     842                float sumBalancedPolys = 0; 
     843                float sumSplits = 0; 
     844 
    820845                for (it = polys.begin(); it != it_end; ++ it) 
    821846                { 
     
    830855                        if (sSplitPlaneStrategy & LARGEST_POLY_AREA) 
    831856                        { 
    832                                 Debug << "polygon area: " << (*it)->GetArea() << " "; 
    833                                 sumPolyArea += (*it)->GetArea(); 
     857                                if (classification == Polygon3::COINCIDENT) 
     858                                {        
     859                                        float area = (*it)->GetArea(); 
     860                                        //Debug << "polygon area: " << area << " "; 
     861                                        if (area) val += 100.0f/area; 
     862                                } 
    834863                        } 
    835                 }Debug << "\n"; 
     864                } 
     865                val += sBalancedPolysFactor * fabs(sumBalancedPolys) +  
     866                           sLeastSplitsFactor * sumSplits; 
    836867        } 
    837868         
     
    841872                ObjectContainer frontViewCells; 
    842873                ObjectContainer backViewCells; 
     874 
     875                float sumBalancedViewCells = 0; 
    843876 
    844877                PolygonContainer::const_iterator it, it_end = polys.end(); 
     
    868901                        { 
    869902                                intersect = *frontIt; 
    870                                 sumBalancedViewCells += 1; 
     903                                sumBalancedViewCells += 1.0f; 
    871904                        } 
    872905                } 
     
    883916                        } 
    884917                } 
     918 
     919                 val += sBalancedViewCellsFactor * fabs(sumBalancedViewCells); 
    885920        } 
    886921 
    887922        // return linear combination of the sums 
    888         return sBalancedPolysFactor * fabs(sumBalancedPolys) +  
    889                    sBalancedViewCellsFactor * fabs(sumBalancedViewCells) + 
    890                    sLeastSplitsFactor * sumSplits +  
    891                    sVerticalSplitsFactor * verticalAxis + 
    892                    sumPolyArea; 
     923        return val; 
    893924} 
    894925 
Note: See TracChangeset for help on using the changeset viewer.