Changeset 2720


Ignore:
Timestamp:
05/27/08 21:24:34 (16 years ago)
Author:
mattausch
Message:

dynamic objects problem!!

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

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

    r2718 r2720  
    4242-gvs_initial_samples=16 \ 
    4343-gvs_max_viewcells=5000 \ 
    44 -gvs_min_contribution=500 \ 
     44-gvs_min_contribution=2000 \ 
    4545-gvs_per_viewcell=true \ 
    4646-preprocessor_detect_empty_viewspace+ \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r2691 r2720  
    88#include "Triangle3.h" 
    99#include "VssRay.h" 
    10  
     10#include "IntersectableWrapper.h" 
    1111 
    1212 
     
    21352135    face6->mVertices.push_back(Vector3(mMax.x, mMax.y, mMax.z)); 
    21362136    face6->mVertices.push_back(Vector3(mMin.x, mMax.y, mMax.z)); 
    2137  
     2137} 
     2138 /*  
     2139   xxxxxx 
     2140  x    xx 
     2141 x    x x 
     2142xxxxxx  x          
     2143x    x x  
     2144x    xx 
     2145xxxxxx 
     2146   */ 
     2147 
     2148void AxisAlignedBox3::Triangulate(ObjectContainer &triangles) const 
     2149{ 
     2150        /*PolygonContainer polys; 
     2151        TriangleContainer tris; 
     2152 
     2153        ExtractPolys(polys); 
     2154 
     2155        for (size_t i = 0; i < polys.size(); ++ i) 
     2156        { 
     2157                Triangle tri; 
     2158                polys[i].Trianulage(tris); 
     2159        }*/ 
     2160 
     2161        TriangleIntersectable *triObj; 
     2162        Triangle3 tri; 
     2163 
     2164        tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z); 
     2165        tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z); 
     2166        tri.mVertices[2] = Vector3(mMin.x, mMax.y ,mMin.z); 
     2167 
     2168        triObj = new TriangleIntersectable(tri); 
     2169        triangles.push_back(triObj); 
     2170 
     2171        tri.mVertices[0] = Vector3(mMin.x, mMax.y ,mMin.z); 
     2172        tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z); 
     2173    tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z); 
     2174 
     2175        triObj = new TriangleIntersectable(tri); 
     2176        triangles.push_back(triObj); 
     2177 
     2178        tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z); 
     2179    tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z); 
     2180    tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z); 
     2181 
     2182        triObj = new TriangleIntersectable(tri); 
     2183        triangles.push_back(triObj); 
     2184 
     2185    tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z); 
     2186        tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z); 
     2187        tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z); 
     2188 
     2189        triObj = new TriangleIntersectable(tri); 
     2190        triangles.push_back(triObj); 
     2191 
     2192    tri.mVertices[0] = Vector3(mMax.x, mMin.y ,mMin.z); 
     2193        tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z); 
     2194        tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z); 
     2195 
     2196        triObj = new TriangleIntersectable(tri); 
     2197        triangles.push_back(triObj); 
     2198 
     2199        tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z);      
     2200        tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z); 
     2201    tri.mVertices[2] = Vector3(mMax.x, mMin.y ,mMin.z); 
     2202 
     2203 
     2204        triObj = new TriangleIntersectable(tri); 
     2205        triangles.push_back(triObj); 
     2206 
     2207        tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z); 
     2208        tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z); 
     2209        tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z); 
     2210 
     2211        triObj = new TriangleIntersectable(tri); 
     2212        triangles.push_back(triObj); 
     2213 
     2214        tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z); 
     2215        tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z); 
     2216        tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z); 
     2217     
     2218        triObj = new TriangleIntersectable(tri); 
     2219        triangles.push_back(triObj); 
     2220 
     2221        tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z); 
     2222        tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z); 
     2223    tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z); 
     2224 
     2225            
     2226        triObj = new TriangleIntersectable(tri); 
     2227        triangles.push_back(triObj); 
     2228 
     2229    tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z); 
     2230        tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z); 
     2231        tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z); 
     2232            
     2233        triObj = new TriangleIntersectable(tri); 
     2234        triangles.push_back(triObj); 
     2235 
     2236    tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z); 
     2237        tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z); 
     2238    tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z); 
     2239 
     2240            
     2241        triObj = new TriangleIntersectable(tri); 
     2242        triangles.push_back(triObj); 
     2243 
     2244    tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z); 
     2245    tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z); 
     2246    tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z); 
     2247            
     2248        triObj = new TriangleIntersectable(tri); 
     2249        triangles.push_back(triObj); 
    21382250} 
    21392251 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r2691 r2720  
    165165  void 
    166166  GetSqrDistances(const Vector3 &point, 
    167                   float &minDistance, 
    168                   float &maxDistance 
    169                   ) const; 
     167                                  float &minDistance, 
     168                                  float &maxDistance) const; 
    170169 
    171170  // returns true, when the sphere specified by the origin and radius 
     
    377376  */ 
    378377  void ExtractPolys(PolygonContainer &polys) const; 
    379  
     378  /** Triangulate the box. 
     379  */ 
     380  void Triangulate(ObjectContainer &triangles) const; 
    380381  /** Returns true if the mesh intersects the bounding box. 
    381382  */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GtpVisibility05.vcproj

    r2709 r2720  
    529529                        > 
    530530                        <File 
     531                                RelativePath=".\AxisAlignedBox3.cpp" 
     532                                > 
     533                        </File> 
     534                        <File 
    531535                                RelativePath=".\AxisAlignedBox3.h" 
    532536                                > 
     
    952956                                > 
    953957                                <File 
    954                                         RelativePath=".\AxisAlignedBox3.cpp" 
    955                                         > 
    956                                 </File> 
    957                                 <File 
    958958                                        RelativePath=".\Beam.cpp" 
    959959                                        > 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h

    r2176 r2720  
    105105        */ 
    106106        void Triangulate(vector<Triangle3> &triangles) const; 
    107  
    108         /**  
    109                 Triangle strip indices are created from this polgon. 
     107        /** Triangle strip indices are created from this polgon. 
    110108        */ 
    111109        void Triangulate(VertexIndexContainer &indices) const; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2716 r2720  
    16081608 
    16091609 
     1610SceneGraphLeaf *Preprocessor::GenerateBoxGeometry(const AxisAlignedBox3 &box) 
     1611{ 
     1612        float offs = box.Min().y; 
     1613        AxisAlignedBox3 newBox = box; 
     1614        newBox.Translate(Vector3(0.0f, -offs, 0.0f)); 
     1615 
     1616        const bool dynamic = true; 
     1617        SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic); 
     1618        newBox.Triangulate(leaf->mGeometry); 
     1619 
     1620        leaf->UpdateBox(); 
     1621 
     1622        return leaf; 
     1623} 
     1624 
     1625 
    16101626SceneGraphLeaf *Preprocessor::LoadDynamicGeometry(const string &filename) 
    16111627{ 
     
    16781694        return NULL; 
    16791695} 
     1696 
     1697 
     1698float Preprocessor::_HackComputeRenderCost(ViewCell *vc) 
     1699{ 
     1700        ObjectPvs basePvs; 
     1701         
     1702        basePvs = vc->CopyPvs(); 
     1703        ObjectPvsIterator pit = basePvs.GetIterator(); 
     1704 
     1705        float renderCost = 0; 
     1706 
     1707        // first mark all objects from this pvs 
     1708        while (pit.HasMoreEntries())     
     1709        { 
     1710                Intersectable *obj = pit.Next(); 
     1711 
     1712                if (obj->Type() == Intersectable::KD_INTERSECTABLE) 
     1713                { 
     1714                        KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 
     1715 
     1716                        /*if (mShowDistanceWeightedPvs) 
     1717                        { 
     1718                        const AxisAlignedBox3 box = kdObj->GetBox(); 
     1719 
     1720                        const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
     1721                        renderCost += 1.0f / dist; 
     1722                        } 
     1723                        else if (mShowDistanceWeightedTriangles) 
     1724                        { 
     1725                        const AxisAlignedBox3 box = kdObj->GetBox(); 
     1726 
     1727                        const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
     1728                        renderCost += kdObj->ComputeNumTriangles() / dist; 
     1729                        } 
     1730                        else //if (mShowWeightedTriangles) 
     1731                        { 
     1732                        */ 
     1733                        renderCost += kdObj->ComputeNumTriangles(); 
     1734                        //} 
     1735                } 
     1736        } 
     1737 
     1738        return renderCost; 
     1739} 
     1740 
     1741 
    16801742 
    16811743 
     
    16961758  // now search for pvss which contained any mailed node 
    16971759  for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) { 
    1698         ObjectPvs &pvs = (*vit)->GetPvs(); 
    1699         if (Overlap(box, (*vit)->GetBox())) { 
    1700           pvs.Clear(); 
    1701           removedEntries += pvs.GetSize(); 
    1702         } else { 
    1703           //    cout<<(*vit)->GetBox()<<" "<<box<<endl; 
    1704           shadowVolume.Init((*vit)->GetBox(), box); 
    1705           if (shadowVolume.CntPlanes() > maxPlanes) 
    1706                 maxPlanes = shadowVolume.CntPlanes(); 
    1707            
    1708           int j = 0; 
    1709           for (int i=0; i < pvs.mEntries.size(); i++) { 
    1710                 allEntries++; 
    1711                 Intersectable *o = pvs.mEntries[i].mObject; 
    1712                 if (o == inter) { 
    1713                   removedSelfEntries++; 
    1714                 } else { 
    1715                   if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 
    1716                         if (j != i) 
    1717                           pvs.mEntries[j] = pvs.mEntries[i]; 
    1718                         j++; 
    1719                   } else { 
    1720                         removedEntries++; 
     1760          ObjectPvs &pvs = (*vit)->GetPvs(); 
     1761          if (Overlap(box, (*vit)->GetBox())) { 
     1762                  pvs.Clear(); 
     1763                  removedEntries += pvs.GetSize(); 
     1764          } else { 
     1765                  //    cout<<(*vit)->GetBox()<<" "<<box<<endl; 
     1766                  shadowVolume.Init((*vit)->GetBox(), box); 
     1767                  if (shadowVolume.CntPlanes() > maxPlanes) 
     1768                          maxPlanes = shadowVolume.CntPlanes(); 
     1769 
     1770                  int j = 0; 
     1771                  for (int i=0; i < pvs.mEntries.size(); i++) { 
     1772                          allEntries++; 
     1773                          Intersectable *o = pvs.mEntries[i].mObject; 
     1774                          if (o == inter) { 
     1775                                  removedSelfEntries++; 
     1776                          } else { 
     1777                                  if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 
     1778                                          if (j != i) 
     1779                                                  pvs.mEntries[j] = pvs.mEntries[i]; 
     1780                                          j++; 
     1781                                  } else { 
     1782                                          removedEntries++; 
     1783                                  } 
     1784                          } 
    17211785                  } 
    1722                 } 
     1786                  // now the pvs has to be resorted 
     1787                  pvs.mLastSorted = 0; 
     1788                  if (j==0) 
     1789                          pvs.mEntries.clear(); 
     1790                  else { 
     1791                          pvs.mEntries.resize(j); 
     1792                          if (j>1) 
     1793                                  pvs.SimpleSort(); 
     1794                  } 
    17231795          } 
    1724           // now the pvs has to be resorted 
    1725           pvs.mLastSorted = 0; 
    1726           if (j==0) 
    1727                 pvs.mEntries.clear(); 
    1728           else { 
    1729                 pvs.mEntries.resize(j); 
    1730                 if (j>1) 
    1731                   pvs.SimpleSort(); 
    1732           } 
    1733         } 
     1796 
     1797          ViewCell *vc = *vit; 
     1798 
     1799          // recompute render cost 
     1800          float renderCost = _HackComputeRenderCost(vc); 
     1801          vc->GetPvs().mStats.mWeightedTriangles = renderCost; 
    17341802  } 
    17351803   
     
    17541822        if (mUpdateDynamicObjects)  
    17551823        { 
    1756  
    17571824                // delete ALL dynamic stuff and rebuild using the new trafos 
    17581825                preprocessor->mRayCaster->DeleteDynamicObjects(); 
    17591826 
    1760 #define MULTIPLE_OBJECTS 1 
     1827#define MULTIPLE_OBJECTS 0 
    17611828 
    17621829#if MULTIPLE_OBJECTS  
    17631830                static ObjectContainer objects; 
    1764  
    17651831                CLEAR_CONTAINER(objects); 
    17661832 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2715 r2720  
    208208        virtual void ObjectRemoved(SceneGraphLeaf *object); 
    209209 
    210  
     210        SceneGraphLeaf *GenerateBoxGeometry(const AxisAlignedBox3 &box); 
     211 
     212        float _HackComputeRenderCost(ViewCell *vc); 
    211213 
    212214        ///////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp

    r2710 r2720  
    6363        AxisAlignedBox3 box = leaf->GetBox(); 
    6464 
    65         Vector3 p = box.Center() - pt;; 
     65        Vector3 p = box.Center() - pt; 
    6666 
    6767        // set pivot to ground of object 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2719 r2720  
    589589 
    590590        //cout << "dynamic objects in pvs " << mDynamicPvsObjects.size() << endl;; 
    591  
     591#if 0 
    592592        for (dit = mDynamicPvsObjects.begin(); dit != dit_end; ++ dit) 
    593593        { 
    594594                _RenderDynamicObject(*dit); 
    595595        } 
    596  
    597         glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
     596#endif 
     597        //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
    598598 
    599599        // show placed dynamic objects as wireframe 
     
    789789 
    790790        int pixelCount = query->GetQueryResult(); 
    791         pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     791        pErrorPixels = (float)pixelCount / (GetWidth() * GetHeight()); 
    792792         
    793793        if (0) cout << "error pixels=" << pixelCount << endl; 
     
    13471347void QtGlRendererWidget::LoadObjects() 
    13481348{ 
     1349        AxisAlignedBox3 sceneBox = mViewCellsManager->GetViewSpaceBox(); 
     1350         
     1351        float x = 1.0f; 
     1352        float y = 20.0f; 
     1353        float z = 80.0f; 
     1354 
     1355        AxisAlignedBox3 box(Vector3(0.5f * x, 0, -0.5f * z), Vector3(-0.5f * x, y, 0.5f * z)); 
     1356 
     1357//      box.Scale(Vector3(0.02f, 0.1f, 0.1f)); 
     1358 
     1359        box.Translate(-box.Min()); 
     1360 
     1361        SceneGraphLeaf *leaf = GetPreprocessor()->GenerateBoxGeometry(box); 
     1362        mPlacer->AddObject(leaf); 
     1363         
    13491364        LoadObject("../data/teapot.bn"); 
    13501365        LoadObject("../data/bunny.bn"); 
     
    16251640} 
    16261641 
    1627 #if 0 
    1628 float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc) 
    1629 { 
    1630         ObjectPvs basePvs; 
    1631          
    1632         basePvs = vc->CopyPvs(); 
    1633         ObjectPvsIterator pit = basePvs.GetIterator(); 
    1634  
    1635         float renderCost = 0; 
    1636  
    1637         //cout << "cost vis: " << mShowDistanceWeightedPvs << " " << " " << mShowDistanceWeightedTriangles << " " << mShowWeightedTriangles << endl; 
    1638          
    1639         // first mark all objects from this pvs 
    1640         while (pit.HasMoreEntries())     
    1641         { 
    1642                 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 
    1643  
    1644                 if (mShowDistanceWeightedPvs) 
    1645                 { 
    1646                         const AxisAlignedBox3 box = kdObj->GetBox(); 
    1647  
    1648                         const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
    1649                         renderCost += 1.0f / dist; 
    1650                 } 
    1651                 else if (mShowDistanceWeightedTriangles) 
    1652                 { 
    1653                         const AxisAlignedBox3 box = kdObj->GetBox(); 
    1654  
    1655                         const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 
    1656                         renderCost += kdObj->ComputeNumTriangles() / dist; 
    1657                 } 
    1658                 else //if (mShowWeightedTriangles) 
    1659                 { 
    1660                         renderCost += kdObj->ComputeNumTriangles(); 
    1661                 } 
    1662                 //if (pit.Next()->Mail(); 
    1663         } 
    1664  
    1665         return renderCost; 
    1666 } 
    1667 #else 
    16681642 
    16691643float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc) 
     
    16881662#endif 
    16891663} 
    1690 #endif 
    1691  
    16921664 
    16931665 
     
    19461918                if (0 && (i < 20)) 
    19471919                { 
    1948                         cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " << compareInfo[i].mPvsSize << " importance: " << importance << endl; 
     1920                        cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: "  
     1921                                 << compareInfo[i].mPvsSize << " importance: " << importance << endl; 
    19491922                } 
    19501923 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2710 r2720  
    368368                                                                                                  const bool isTermination) const 
    369369{ 
     370        //if (!ray.mTerminationObject) return NULL; 
     371         
    370372        // dynamic objects are scene graph leaves 
    371373        const int index = ray.mTerminationObject->GetId(); 
     374 
    372375        if (index >= mPreprocessor->mObjects.size()) 
    373376        { 
     377                // Do nothing 
     378                return NULL; 
    374379                for (size_t i = 0; i < mPreprocessor->mDynamicObjects.size(); ++ i) 
    375380                { 
Note: See TracChangeset for help on using the changeset viewer.